Skip to content

speed server example is not working, and crashing  #272

Open

Description

@sanehab

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

Activity

  1. TankNee commented on May 30, 2021

    @TankNee

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions