-1

I'd like make cordova app in javascript with traceroute to another ip/domain. I can detect my IP in device with server side script in PHP which gives me back my IP address to my javascript app script. But is it possible to trace my server or another ip from javascript in device app?

I found this traceroute cordova plugin, but there is no information how can I use it.

https://github.com/navidmalekan/cordova-plugin-traceroute

Anybody with same problem? Thanks a lot for help

buffy.cz
  • 66
  • 5

1 Answers1

0

Unfortunately a proper traceroute command requires the use of ICMP. JavaScript does not even have the ability to create raw TCP or UDP sockets (instead it creates WebSockets and WebRTC connections which abstract these two with some added security around establishing the socket), and it certainly doesn't have the ability to send ICMP messages.

That isn't to say that all hope is lost, but you won't get a perfectly accurate traceroute with 100% accuracy. If your goal is to find the route taken from a JavaScript client to your own server, you can instead have your server initiate the traceroute to the client and assume that they use the same path in reverse to reach you. This isn't always true, but it's usually fairly close.

If your goal is to find the route taken between two JavaScript clients, then this requires even more guesswork. Your server can initiate a traceroute to each client, then figure out what the common path is. For instance:

Server -> ClientA

192.168.1.1
100.100.100.100
200.200.200.200
123.123.123.123
75.75.75.75

Server -> ClientB

192.168.1.1
100.100.100.100
200.200.200.200
180.180.180.180
150.150.150.150

In this case we can surmise that the path 192.168.1.1 -> 100.100.100.100 -> 200.200.200.200 is the path that your server takes to exit its Autonomous System and that 123.123.123.123 is the entry-point to ClientA's Autonomous System and 180.180.180.180 is the entry-point to ClientB's Autonomous System. Therefore a traceroute from ClientA to ClientB may look like:

75.75.75.75
123.123.123.123
180.180.180.180
150.150.150.150

Of course this isn't guaranteed to be accurate. There may be an alternate path through ClientA's internal network that puts them closer to ClientB, so they may use a different entry-point. Still, it's better than nothing.

Regarding Cordova

Cordova is a framework for creating mobile applications (Android apps) using HTML, JavaScript, and CSS. Unlike operating in a browser where you're limited to the DOM API and a few other HTML5 APIs, Cordova grants you access to the full Android system via a custom API. This way you can access their SD card, camera, microphone, etc.

Cordova is able to perform a traceroute not because it's JavaScript, but because it's Android. The JavaScript is actually making a call (via an API) to an external program written in either Java or C/C++ which makes the traceroute

If you are creating a mobile application and not a website, then this may be an option for you

stevendesu
  • 15,753
  • 22
  • 105
  • 182