项目作者: zulhilmizainuddin

项目描述 :
Node.js wrapper around tracert and traceroute process
高级语言: JavaScript
项目地址: git://github.com/zulhilmizainuddin/nodejs-traceroute.git
创建时间: 2016-07-23T01:44:49Z
项目社区:https://github.com/zulhilmizainuddin/nodejs-traceroute

开源协议:MIT License

下载


nodejs-traceroute Build Status Code Climate

NPM

Node.js wrapper around tracert and traceroute process

Install

  1. npm install --save nodejs-traceroute

Force IPv4 or IPv6

By default, the domain name given will be automatically resolved. Explicitly force IPv4 or IPv6 tracerouting by passing either ipv4 or ipv6 to the constructor.

Usage Example

  1. const Traceroute = require('nodejs-traceroute');
  2. try {
  3. const tracer = new Traceroute();
  4. tracer
  5. .on('pid', (pid) => {
  6. console.log(`pid: ${pid}`);
  7. })
  8. .on('destination', (destination) => {
  9. console.log(`destination: ${destination}`);
  10. })
  11. .on('hop', (hop) => {
  12. console.log(`hop: ${JSON.stringify(hop)}`);
  13. })
  14. .on('close', (code) => {
  15. console.log(`close: code ${code}`);
  16. });
  17. tracer.trace('github.com');
  18. } catch (ex) {
  19. console.log(ex);
  20. }

Result Example

  1. pid: 4414
  2. destination: 192.30.253.112
  3. hop: {"hop":1,"ip":"192.168.0.1","rtt1":"1.817 ms"}
  4. hop: {"hop":2,"ip":"10.233.33.58","rtt1":"3.149 ms"}
  5. hop: {"hop":3,"ip":"10.55.96.182","rtt1":"7.820 ms"}
  6. hop: {"hop":4,"ip":"128.241.1.205","rtt1":"178.187 ms"}
  7. hop: {"hop":5,"ip":"129.250.2.9","rtt1":"211.609 ms"}
  8. hop: {"hop":6,"ip":"129.250.3.43","rtt1":"229.458 ms"}
  9. hop: {"hop":7,"ip":"129.250.2.163","rtt1":"237.948 ms"}
  10. hop: {"hop":8,"ip":"129.250.2.138","rtt1":"237.913 ms"}
  11. hop: {"hop":9,"ip":"129.250.2.133","rtt1":"241.748 ms"}
  12. hop: {"hop":10,"ip":"*","rtt1":"*"}
  13. hop: {"hop":11,"ip":"*","rtt1":"*"}
  14. hop: {"hop":12,"ip":"*","rtt1":"*"}
  15. hop: {"hop":13,"ip":"*","rtt1":"*"}
  16. hop: {"hop":14,"ip":"*","rtt1":"*"}
  17. hop: {"hop":15,"ip":"*","rtt1":"*"}
  18. hop: {"hop":16,"ip":"*","rtt1":"*"}
  19. hop: {"hop":17,"ip":"*","rtt1":"*"}
  20. hop: {"hop":18,"ip":"*","rtt1":"*"}
  21. hop: {"hop":19,"ip":"*","rtt1":"*"}
  22. hop: {"hop":20,"ip":"*","rtt1":"*"}
  23. hop: {"hop":21,"ip":"*","rtt1":"*"}
  24. hop: {"hop":22,"ip":"*","rtt1":"*"}
  25. hop: {"hop":23,"ip":"*","rtt1":"*"}
  26. hop: {"hop":24,"ip":"*","rtt1":"*"}
  27. hop: {"hop":25,"ip":"*","rtt1":"*"}
  28. hop: {"hop":26,"ip":"*","rtt1":"*"}
  29. hop: {"hop":27,"ip":"*","rtt1":"*"}
  30. hop: {"hop":28,"ip":"*","rtt1":"*"}
  31. hop: {"hop":29,"ip":"*","rtt1":"*"}
  32. hop: {"hop":30,"ip":"*","rtt1":"*"}
  33. close: code 0