Skip to content

Wrapper around the "cap" module that listens for packages on network interfaces

Notifications You must be signed in to change notification settings

onomondo/raw-network-listener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Wrapper around the "cap" module that listens for packages on network interfaces

Resources

Stars

Watchers

Forks

Packages

No packages published