1.0.11 • Published 8 months ago

ace-pcap v1.0.11

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

Node Aceinna PCap

This is a node-addon-api native addon to capture packet from a specifed network. Some code is referenced from https://github.com/mscdex/cap.git

You need to have Node 10.5.0 or later installed.

How to use

Install

npm install ace-pcap

Sample Code

Basic

import { EthernetPacketCapture, GetNetworkInterface } from 'ace-pcap'
const ip = '192.168.22.140'; // IP Address of network for capture packet
const iface = GetNetworkInterface(ip);
const instance = new EthernetPacketCapture({ iface });

instance.on('data', (data) => {
    console.log(data);
})

instance.start();

Filter

import { EthernetPacketCapture, GetNetworkInterface } from 'ace-pcap'
const ip = '192.168.22.140'; // IP Address of network for capture packet
const filter = `ether src 88:e9:fe:52:68:56`;
const iface = GetNetworkInterface(ip);
const instance = new EthernetPacketCapture({ iface, filter });

instance.on('data', (data) => {
  console.log(data);
})

instance.start();

// update filter while capturing
setTimeout(()=>{
  instance.setFilter('ether src 98:5f:d3:3c:ab:fd');
},5000)

Send packet to network

import { EthernetPacketCapture, GetNetworkInterface } from 'ace-pcap'
const ip = '192.168.22.140'; // IP Address of network for capture packet
const iface = GetNetworkInterface(ip);
const instance = new EthernetPacketCapture({ iface });

instance.start();

// update filter while capturing
setTimeout(()=>{
  instance.send(Buffer.from('data to send'))
},5000)
1.0.9

8 months ago

1.0.11

8 months ago

1.0.10

8 months ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago