Wrapper around cap that listens for packets on network interfaces.
Uses pcap filters.
$ npm install raw-network-listener
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'))
})
From cap.decoders
From cap.Cap.findDevice
From cap.Cap.deviceList
Create listener on the interface
(e.g. lo0
or eth0
) with the filter. Filters are based on pcap filters.
Is emitted when a new packet is registered on the interface. packet
is a buffer.
The link type of the interface
From cap.Cap().send
From cap.Cap().close