Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
dist/
build/
node_modules/
Debug/
Release/
*.lock
*.log
npm-debug.log*

.idea/
.vscode/
.DS_Store

*/*.bin
prebuilds/
package-lock.json
6 changes: 6 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
},
}],
],
'msvs_settings': {
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
'VCLinkerTool':{
'DelayLoadDLLs':['wpcap.dll']
}
}
}, {
# POSIX
'link_settings': {
Expand Down
27 changes: 22 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ "name": "cap",
{
"name": "cap",
"version": "0.2.1",
"author": "Brian White <mscdex@mscdex.net>",
"description": "A cross-platform binding for performing packet capturing with node.js",
Expand All @@ -10,8 +11,24 @@
"install": "node-gyp rebuild",
"test": "node test/test.js"
},
"engines": { "node": ">=4.0.0" },
"keywords": [ "pcap", "packet", "capture", "libpcap", "winpcap" ],
"licenses": [ { "type": "MIT", "url": "http://github.com/mscdex/cap/raw/master/LICENSE" } ],
"repository" : { "type": "git", "url": "http://github.com/mscdex/cap.git" }
"engines": {
"node": ">=4.0.0"
},
"keywords": [
"pcap",
"packet",
"capture",
"libpcap",
"winpcap"
],
"licenses": [
{
"type": "MIT",
"url": "http://github.com/mscdex/cap/raw/master/LICENSE"
}
],
"repository": {
"type": "git",
"url": "http://github.com/mscdex/cap.git"
}
}
26 changes: 26 additions & 0 deletions src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@
(set_immediate_fn)(dlsym(_pcap_lib_handle, "pcap_set_immediate_mode"));
#endif

#ifdef _WIN32
#include <tchar.h>
BOOL LoadNpcapDlls()
{
_TCHAR npcap_dir[512];
UINT len;
len = GetSystemDirectory(npcap_dir, 480);
if (!len) {
return FALSE;
}
_tcscat_s(npcap_dir, 512, _T("\\Npcap"));
if (SetDllDirectory(npcap_dir) == 0) {
return FALSE;
}
return TRUE;
}
#endif

using namespace node;
using namespace v8;

Expand Down Expand Up @@ -617,6 +635,14 @@ static NAN_METHOD(FindDevice) {

extern "C" {
void init(Local<Object> target) {
#ifdef _WIN32
/* Load Npcap and its functions. */
if (!LoadNpcapDlls())
{
exit(1);
}
#endif

Nan::HandleScope scope;
Pcap::Initialize(target);
Nan::Set(target,
Expand Down