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

speed server example is not working, and crashing #272

Open
sanehab opened this issue Sep 29, 2020 · 1 comment
Open

speed server example is not working, and crashing #272

sanehab opened this issue Sep 29, 2020 · 1 comment

Comments

@sanehab
Copy link

sanehab commented Sep 29, 2020

Hey,

While trying to browse through the examples i have found that the speed_server example is not working, due to the following code, findalldevs is undefined and not a function:

const pcap_session = pcap.createSession(process.argv[2], {
  filter: process.argv[3],
})

// Print all devices, currently listening device prefixed with an asterisk
console.log("All devices:")
console.log(pcap_session)
pcap_session.findalldevs().forEach(function (dev) {
    if (pcap_session.device_name === dev.name) {
        console.log("* ");
    }
    console.log(dev.name + " ");
    if (dev.addresses.length > 0) {
        dev.addresses.forEach(function (address) {
            console.log(address.addr + "/" + address.netmask);
        });
        console.log("\n");
    } else {
        console.log("no address\n");
    }
});

also note that the following code is not doing anything since the tcp_tracker does not emit any event called http request, this event was emitted however in previous versions

tcp_tracker.on("http request", function (session, http) {
  var matches = /send_file\?id=(\d+)/.exec(http.request.url)
  if (matches && matches[1]) {
    session.track_id = matches[1]
    console.log("Added tracking for " + matches[1])
  } else {
    console.log("Didn't add tracking for " + http.request.url)
  }
})

Thanks

@TankNee
Copy link

TankNee commented May 30, 2021

Hey, when I looked through the pcap.js file, I found that the findalldevs function was defined to an isolate function and it had been exported independently! So, I reckoned that you'd replace the pcap_session.findalldevs with pcap.findalldevs!
It works on my device: Windows WSL Ubuntu 20.

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

2 participants