raw-network-listener

1.0.1 • Public • Published

raw-network-listener

Wrapper around cap that listens for packets on network interfaces.

Uses pcap filters.

$ npm install raw-network-listener

Usage

const rnl = require('raw-network-listener')
 
const loopback = rnl({
  interface: 'lo0',
  filter: '(icmp) and (src net 9.8.7.6)' // https://www.tcpdump.org/manpages/pcap-filter.7.html
})
 
console.log('Link type:', loopback.linkType)
 
loopback.on('packet', packet => {
  console.log('New packet received:', packet.toString('hex'))
})

API

.decoders

From cap.decoders

.findDevice()

From cap.Cap.findDevice

.deviceList()

From cap.Cap.deviceList

({ interface, filter })

Create listener on the interface (e.g. lo0 or eth0) with the filter. Filters are based on pcap filters.

.on('packet', packet => ...)

Is emitted when a new packet is registered on the interface. packet is a buffer.

.linkType

The link type of the interface

.send()

From cap.Cap().send

.close()

From cap.Cap().close

.setMinBytes()

From cap.Cap().setMinBytes

Readme

Keywords

none

Package Sidebar

Install

npm i raw-network-listener

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

4.17 kB

Total Files

4

Last publish

Collaborators

  • freeall