Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: device must be a string #40

Closed
nikhiljha opened this issue Jul 16, 2016 · 6 comments
Closed

TypeError: device must be a string #40

nikhiljha opened this issue Jul 16, 2016 · 6 comments

Comments

@nikhiljha
Copy link

I just copy-pasted code from the example and I get that error. Why though? I can ping it just fine.

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

var c = new Cap(),
    device = Cap.findDevice('192.168.1.131'),
    filter = 'tcp and dst port 80',
    bufSize = 10 * 1024 * 1024,
    buffer = new Buffer(65535);

var linkType = c.open(device, filter, bufSize, buffer);

c.setMinBytes && c.setMinBytes(0);

c.on('packet', function(nbytes, trunc) {
  console.log('Potential Dash Button Press?!?!?!');
});
@mscdex
Copy link
Owner

mscdex commented Jul 17, 2016

Did you check console.dir(device)? If it's not a non-empty string, you might try doing console.dir(Cap.deviceList()) to check what network interfaces and addresses are available.

@nikhiljha
Copy link
Author

console.dir(device) is undefined, so that's a problem

console.dir(Cap.deviceList()) gives a few interfaces

@mscdex
Copy link
Owner

mscdex commented Jul 17, 2016

Ok, but none of the interfaces shown include the interface with the IP address you're trying? If that is true, then you may need to find out what is unique about the missing interface.

If you execute node -e "console.dir(require('os').networkInterfaces())", do you see the IP address?

Lastly, what OS and OS version are you trying this on?

@nikhiljha
Copy link
Author

Is that supposed to be my own address?

What if I'm trying to monitor arp packets from everywhere?

(It does work if I change the device = Cap.findDevice('192.168.1.131'), to my ip, but that does something else).


I see my own address with node -e "console.dir(require('os').networkInterfaces())" and loopback.


Win10

@nikhiljha
Copy link
Author

nikhiljha commented Jul 17, 2016

Yup, figured it out.

I just used this library (which builds off of cap) - so if anyone reads this in the future is trying to work with dash buttons - read this:

I needed to put my own IP, which wasn't very idiot friendly, but it doesn't need to be.

var nodeis = require('win-node-dash-button');
var svr = new nodeis.Server(),
    tide   = new nodeis.DashButton("MAC ADDRESS OF BUTTON - WIRESHARK IT (Filter: ARP)", function () { console.log("Button pressed"); });

svr.register(tide)
   .start("YOUR LOCAL IP (like 192.168.1.111)");

@JaLe29
Copy link

JaLe29 commented Feb 27, 2018

Not working for me, still I am getting undefined on line device = Cap.findDevice('192.168.1.131')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants