Permalink
Browse files

Initial commit.

  • Loading branch information...
1 parent 2ee9fed commit 60ef921ff1931ee3426720413007aafbb7b0f1d5 @mranney mranney committed Aug 24, 2010
Showing with 15 additions and 0 deletions.
  1. +15 −0 examples/network_grep.js
View
@@ -0,0 +1,15 @@
+var pcap = require("pcap"),
+ pcap_session = pcap.createSession("", "tcp"),
+ matcher = /safari/i;
+
+console.log("Listening on " + pcap_session.device_name);
+
+pcap_session.on('packet', function (raw_packet) {
+ var packet = pcap.decode.packet(raw_packet),
+ data = packet.link.ip.tcp.data;
+
+ if (data && matcher.test(data.toString())) {
+ console.log(pcap.print.packet(packet));
+ console.log(data.toString());
+ }
+});

0 comments on commit 60ef921

Please sign in to comment.