Permalink
Browse files

Theoretical Linux support

  • Loading branch information...
1 parent 5a35e9d commit 5d9f09c5a4f1ac7e315cb132ad06ed166b87c8b8 @raphaelr committed Mar 9, 2012
Showing with 22 additions and 3 deletions.
  1. +20 −2 lib/platform.js
  2. +2 −1 package.json
View
22 lib/platform.js
@@ -1,4 +1,7 @@
-var os = require('os');
+var _ = require('underscore'),
+ os = require('os'),
+ path = require('path'),
+ glob = require('glob');
var platform = module.exports = { };
@@ -10,6 +13,21 @@ case 'win32':
};
break;
default:
- platform.PCAP_LIBRARY = 'libpcap';
+ var libpcap = process.env.LIBPCAP_PATH;
+ if(!libpcap) {
+ var matches = glob.sync('{/lib/,/usr/lib/,/usr/local/lib/}libpcap.so*');
+ if(!matches.length) {
+ throw new Error('libpcap was not found on your system. If you have libpcap installed' +
+ 'on your system, set the "LIBPCAP_PATH" environment variable to point to your' +
+ 'libpcap.so');
+ }
+ matches = _.collect(matches, function(fullpath) {
+ return [path.basename(fullpath), fullpath];
+ }).sort(function(a, b) {
+ return a[0].localeCompare(b[0]);
+ }).reverse();
+ libpcap = matches[0][1].replace(/\.so$/, '');
+ }
+ platform.PCAP_LIBRARY = libpcap;
platform.pcapName = function(systemName) { return systemName; };
}
View
3 package.json
@@ -8,7 +8,8 @@
"dependencies": {
"node-ffi": "~0.5",
- "underscore": "~1.3"
+ "underscore": "~1.3",
+ "glob": "~3.1"
},
"devDependencies": {

0 comments on commit 5d9f09c

Please sign in to comment.