1.0.3 • Published 6 years ago

osi2-stream v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

osi2-stream

npmVersion npmdw openIssues license

Installation

npm install iso2-stream --save

Example

const {Pcap, findalldevs} = require('iso2-stream');
var devs = findalldevs(); //find all netdevs from pc
var netDev = new Pcap(devs[0].name); //create new netDev by devs[0].name
netDev.listen("arp");         //listen devs[0] and filter arp
netDev.on("data", (data) => {
    console.log(data);
    netDev.send("10:12:13:14:15:16", "02:03:04:05:06:07", Buffer.from(sendData));  //send packet from 02:03:04:05:06:07 => 10:12:13:14:15:16
    netDev.end();  //close the netDev
})

API

(method) findalldevs: Dev

find all netdevs from pc

Dev.name: String

Device name

Dev.description: String

Device description

Dev.mac: String

Device MAC Address

Dev.address: Address

Device all IP Address

Address.ipaddr: String

IPv4 or APv6 Address

Address.netmask: String

IPv4 Netmask

Address.broadaddr: String

Broadaddr

Pcap

The Pcap extends Duplex

constructor Pcap(devName:String, option?:any): Pcap

create new netDev by devName

var netDev = new Pcap(devName);

(method) Pcap.listen(filter?:String, cb?:Function): void

listen netDev

filter: see tcpdump

cb: call in listen is ready

(method) send(dmac:String, smac:String, data:string|Array|arrayBuffer|Buffer, vlans?:Array): void

send packet

dmac: Destination MAC address

smac: Source MAC address

data: The data to be sent. string|Array|arrayBuffer|Buffer

vlans: null or number or number.

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago