There is an npm package for it!!
const Traceroute = require('nodejs-traceroute');
Below is a reference implementation from the package vendor
const Traceroute = require('nodejs-traceroute');
try {
const tracer = new Traceroute();
tracer
.on('pid', (pid) => {
console.log(`pid: ${pid}`);
})
.on('destination', (destination) => {
console.log(`destination: ${destination}`);
})
.on('hop', (hop) => {
console.log(`hop: ${JSON.stringify(hop)}`);
})
.on('close', (code) => {
console.log(`close: code ${code}`);
});
tracer.trace('github.com');
} catch (ex) {
console.log(ex);
}
Now having implemented this, looking at the response for the trace route
References:
https://www.npmjs.com/package/nodejs-traceroute
nice informative post. Thanks you for sharing.
ReplyDeleteNodeJS Development