Socket
Socket
Sign inDemoInstall

pcap

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pcap - npm Package Compare versions

Comparing version 0.4.1 to 1.0.0

examples/multiple_interfaces

10

changelog.md
Changelog
=========
## v0.3.3 - April 21, 2012
## v1.0.0 - August 28, 2013
Support for multiple sessions is introduced. Pcap is officially out of beta.
## v0.3.3 - April 21, 2013
Resolved "Symbol pcap_binding_module not found" by adding NODE_MODULE directive.
## v0.3.2 - April 9, 2012
## v0.3.2 - April 9, 2013
Bumped version to test npm install

@@ -9,0 +15,0 @@

2

package.json
{
"name" : "pcap",
"version" : "0.4.1",
"version" : "1.0.0",
"description" : "raw packet capture, decoding, and analysis",

@@ -5,0 +5,0 @@ "author": "Matt Ranney <mjr@ranney.com>",

@@ -29,23 +29,10 @@ /*global process require exports console */

if (typeof buffer_size === 'number' && !isNaN(buffer_size)) {
this.buffer_size = Math.round(buffer_size);
me.buffer_size = Math.round(buffer_size);
} else {
this.buffer_size = 10 * 1024 * 1024; // Default buffer size is 10MB
me.buffer_size = 10 * 1024 * 1024; // Default buffer size is 10MB
}
this.live = live;
me.live = live;
me.session = new binding.PcapSession();
if (live) {
this.device_name = device || binding.default_device();
this.link_type = binding.open_live(this.device_name, filter || "", this.buffer_size, pcap_output_filename || "");
} else {
this.device_name = device;
this.link_type = binding.open_offline(this.device_name, filter || "", this.buffer_size, pcap_output_filename || "");
}
this.fd = binding.fileno();
this.opened = true;
this.readWatcher = new SocketWatcher();
this.empty_reads = 0;
this.buf = new Buffer(65535);
// called for each packet read by pcap

@@ -59,5 +46,19 @@ function packet_ready(header) {

if (live) {
me.device_name = device || binding.default_device();
me.link_type = me.session.open_live(me.device_name, filter || "", me.buffer_size, pcap_output_filename || "", packet_ready);
} else {
me.device_name = device;
me.link_type = me.session.open_offline(me.device_name, filter || "", me.buffer_size, pcap_output_filename || "", packet_ready);
}
me.fd = me.session.fileno();
me.opened = true;
me.readWatcher = new SocketWatcher();
me.empty_reads = 0;
me.buf = new Buffer(65535);
// readWatcher gets a callback when pcap has data to read. multiple packets may be readable.
this.readWatcher.callback = function pcap_read_callback() {
var packets_read = binding.dispatch(me.buf, packet_ready);
me.readWatcher.callback = function pcap_read_callback() {
var packets_read = me.session.dispatch(me.buf);
if (packets_read < 1) {

@@ -69,3 +70,3 @@ // according to pcap_dispatch documentation if 0 is returned when reading

// with events.
if(!me.live) {
if (!me.live) {
me.readWatcher.stop();

@@ -79,4 +80,4 @@ me.emit('complete');

};
this.readWatcher.set(this.fd, true, false);
this.readWatcher.start();
me.readWatcher.set(me.fd, true, false);
me.readWatcher.start();
};

@@ -86,3 +87,3 @@

this.opened = false;
binding.close();
this.session.close();
// TODO - remove listeners so program will exit I guess?

@@ -92,3 +93,3 @@ };

Pcap.prototype.stats = function () {
return binding.stats();
return this.session.stats();
};

@@ -95,0 +96,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc