p-by-p

0.1.0 • Public • Published

p-by-p

Packet-By-Packet, a pcap reader inspired by line-by-line and pcap-reader

Installation

npm install p-by-p

Usage

const PacketByPacket = require('p-by-p')
const readline = require('readline')
 
const pbyp = PacketByPacket('/path/to/file.pcap')
// setup event handler
pbyp.on('globalHeader', gh => {
  // process pcap file global header
})
pbyp.on('packet', p => {
  // process your packet data
 
  // you can also stop/resume the reader
  pbyp.pause()
  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  })
  rl.question(`Do you want to resume?`, (answer) => {
    pbyp.resume()
    rl.close()
  })
})
pbyp.on('end', () => {
  // no more data
})
pbyp.on('error', err => {})
// start it
pbyp.resume()

Readme

Keywords

Package Sidebar

Install

npm i p-by-p

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

8.37 kB

Total Files

4

Last publish

Collaborators

  • txchen