mscdex / cap

A cross-platform binding for performing packet capturing with node.js
MIT License
361 stars 45 forks source link

Does not find Pcap Library #94

Closed g407 closed 4 years ago

g407 commented 4 years ago

Hi,

on Windows10, I can only use "cap" after I install _Wincap (4.1.3)_ manually, i.e. after

npm i cap

builds successfully and I run my node.js script, the js call sequence

var Caplib = require('cap'); var Cap = Caplib.Cap; var decoders = Caplib.decoders; var PROTOCOL = decoders.PROTOCOL;

var c = new Cap(); var device = Cap.findDevice("192.168.0.158");

results in 'device==undefined'. After I install winpcap manually, the device is initialized correctly.

I see the 'deps' directory contains the required libs, but for some reason they are never used.

My binding.gyp says:

{ 'targets': [ { 'target_name': 'cap', 'sources': [ 'src/binding.cc', ], 'include_dirs': [ "<!(node -e \"require('nan')\")", ], 'conditions': [ [ 'OS=="win"', { 'include_dirs': [ 'deps/winpcap/Include', ], 'defines': [ 'WPCAP', ], 'conditions': [ [ 'target_arch=="ia32"', { 'link_settings': { 'libraries': ['ws2_32.lib', '<(PRODUCT_DIR)/../../deps/winpcap/Lib/wpcap.lib'], }, }, { 'link_settings': { 'libraries': ['ws2_32.lib', '<(PRODUCT_DIR)/../../deps/winpcap/Lib/x64/wpcap.lib'], }, }], ], }, {

POSIX

      'link_settings': {
        'libraries': ['-lpcap'],
      },
    }],
  ],
},

], }

Do you have a clue how I can debug this?

Thank you.

mscdex commented 4 years ago

The readme clearly states that you need to install npcap as a requirement. The Windows files bundled with this addon are not sufficient to support packet capturing. They are part of the SDK needed to link with the necessary DLLs installed by the actual packet capturing software (npcap).