-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnet.js
835 lines (759 loc) · 28.8 KB
/
net.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
const dns = require("dns");
const os = require("os");
const ip = require('ip');
const iplocation = require('iplocation');
const localdevices = require('local-devices');
const network = require('network');
const arp = require('node-arp');
const getIP = require('external-ip')();
const speedtestNet = require('speedtest-net');
const request = require('request');
const tcpping = require('tcp-ping');
const Traceroute = require('nodejs-traceroute');
// Host constructor
function Host() {
this.name = ''; // host name
this.ip = '';
this.mac = '';
this.vendor = ''; // interface vendor registered with the mac address
this.interface_type = ''; // wireless, ethernet - empty means unknown
this.is_public = false;
// a host can have one or more of the following roles:
// - "nat" (if the host is nated)
// - "gateway" (in this context 'gateway' is the gateway to the internet)
// - "public" (public host is the host with the first public ip. public side of the internet 'gateway'
// - "router" (the host is a router)
// - "firewall" (currently not supported)
// - "dhcp" (currently not supported - indicates host is also a dhcp server)
// - "dns" (currently not supported - indicates the host is also a dns server)
// - "proxy" (currently not supported - indicates the host is providing proxy services)
// - "remote" (host that is not on the local network and does not belong to the local network)
// - "device" (connected network device)
// - "client" (client host - where diagnostic is being run)
//
// if roles is an empty array then roles have not been discovered or
// no roles are known which probably indicates the host is just another
// client on the network such as a connected phone or desktop or laptop.
this.roles = []; // "nat", "gateway", "router", "dns", "public", "remote"
// no dns entries returns an empty dns object
//
// if it's not empty then all the fields will be present
// even if empty.
// Note: currently not implemented.
//dns: {},
// geo only possibly available when the ip is public.
// no geo entries returns an empty geo object.
//
// if it's not empty then all the fields will be present
// even if those individual fields are empty.
this.geo = {};
}
// HostGeo constructor
function HostGeo() {
this.city = ""; // city
this.state = ""; // state/region code
this.country = ""; // country code
this.zip = ""; // zip/postal code
this.lat = 0.00; // registered lat
this.lon = 0.00; // registered lon
this.org = ""; // org name of the local network public ip is the isp.
}
// hostNameLookup will do a reverse dns lookup of the provided
// host object 'ip' property.
// If there is an error then the hostname is simply
// not populated.
// The callback function 'cb' receives a single parameter
// containing a host.
//
// Note that if host.name is already populated
// then the lookup will be skipped.
function hostNameLookup(hst, cb) { // returns promise
if (hst.name.length > 0 && hst.ip.length === 0) {
// in this case, only pick the first
// host name when more than one is present
// since it will just reside in the h.name field.
dns.reverse(hst.ip, (rErr, hNames) => {
// ignore error so that if the promise is called with Promise.all
// the rest will get a try.
// if no hNames are found then hNames is 'undefined' so
// normalize such as hNames is always an array even if it's empty.
if (Array.isArray(hNames) && hNames.length > 0) {
hst.name = hNames[0];
}
cb(hst);
});
} else {
cb(hst);
}
}
// hostGeoLookup will do a geo
// lookup if:
// - host geo object is empty
// - ip is public
// - ip is valid
function hostGeoLookup(hst, cb) {
if (Object.keys(hst.geo).length > 0) {
cb(hst);
} else if (!hst.is_public) {
cb(hst); // geo lookup only available for public ips.
} else {
iplocation(hst.ip, (ipErr, geo) => {
if (ipErr) {
cb(hst);
} else {
hst.geo = new HostGeo();
hst.geo.city = geo.city;
hst.geo.state = geo.region_code;
hst.geo.country = geo.country;
hst.geo.zip = geo.postal;
hst.geo.lat = geo.latitude;
hst.geo.lon = geo.longitude;
hst.geo.org = geo.org;
cb(hst);
}
});
}
}
// hostVendorLookup will make an http
// call to lookup the vendor associated
// with the mac address.
//
// The lookup is only performed if:
// - there is a mac address
// - the vendor does not already have a value
//
// Please note that, at the moment the api calls are not
// rate limited by the library which means that
// a maximum of 1 request/second can be made before
// getting rate limited by macvendors.com with a 429 response
// code.
// https://macvendors.com/api
function hostVendorLookup(hst, cb) {
if (hst.mac.length > 0 && hst.vendor.length === 0) {
request('https://api.macvendors.com/' + hst.mac, (rErr, res, body) => {
if (rErr) {
cb(hst);
} else if (res) {
if (res.statusCode === 200) {
hst.vendor = body;
cb(hst);
} else {
cb(hst);
}
}
});
} else {
cb(hst);
}
}
// hostIpLookup will do a dns lookup
// to obtain the ip address for the provided
// host name.
//
// if the host.name value is empty then
// no lookup will be made.
function hostIpLookup(hst, cb) {
if (hst.name.length > 0 && hst.ip.length === 0) {
dns.lookup(hst.name, (lErr, hostIp, family) => {
if (lErr) {
cb(hst);
} else {
hst.ip = hostIp;
hst.is_public = ip.isPublic(hst.ip);
cb(hst);
}
});
} else {
cb(hst);
}
}
// publicHost will provide the public internet host which is
// the first host out on the internet with a
// public ip. It is the 'public' side of the internet gateway host.
// geo info lookup is included.
//
// cb = (error, hst) => {}
// hst == public internet host which is a host object
function publicHost(cb) {
let hst = new Host();
// not currently marked with 'gateway' or 'nat' roles.
// maybe consider changing the role designation and/or adding
// roles.
hst.roles = ['public'];
getIP((ipErr, pubIp) => {
hst.ip = pubIp;
hst.is_public = true;
if (ipErr) {
cb(ipErr, hst);
} else {
// reverse dns lookup to discover a host name
hostNameLookup(hst, (hst) => {
// geo lookup
hostGeoLookup(hst, (hst) => {
cb(null, hst);
})
});
}
});
}
// clientHost provides the client host information - current
// active network interface.
function clientHost(cb) {
let hst = new Host();
hst.roles = ["client"];
network.get_active_interface((iErr, actInterface) => {
if (iErr) {
cb(hst);
} else {
hst.mac = actInterface.mac_address;
hst.interface_type = actInterface.type.toLowerCase();
hst.ip = actInterface.ip_address;
hst.is_public = ip.isPublic(hst.ip); // surprised if this is public, but check anyway
// add geo (unlikely but it doesn't hurt)
hostGeoLookup(hst, (hst) => {
// try vendor lookup
// Note: if a lot of other things are going
// on then could be rate limited.
hostVendorLookup(hst, (hst) => {
// if there are local network dns
// the client could have a host name
// so give it a shot.
hostNameLookup(hst, (hst) => {
cb(hst); // done!
})
})
})
}
})
}
// client contains information about the client host
// as well as general information about the client machine.
function client(cb) {
clientHost((hst) => {
cb({
host: hst,
os_user: os.userInfo().username,
os_hostname: os.hostname(),
os_platform: os.platform(),
});
});
}
// nats will provide the local network nats on
// the outbound path to the internet. The nat
// with the role 'gateway' is the internet gateway.
function nats(cb) {
let h = new Host();
h.ip = '8.8.8.8'; // google dns
traceroute(h, (trErr, hops) => {
let nts = []; // nat nodes
// iterate through the path until a public ip is found.
// the private ips up until the first public ip are
// nats.
for (let i = 0; i < hops.length; i++) {
if (hops[i].is_public) {
break;
} else {
let n = new Host(); // nat host
// the inner nat will have the role of 'nat' and 'router'. The outermost
// nat will have the 'nat', 'router' and 'gateway' roles. The 'gateway'
// in this case is being defined as the 'gateway to the internet'.
// in the weird case that there is one or more NATs in-between
// the inner and internet gateway, the 'router' and 'nat' roles are assigned.
//
// all nats have the 'nat' and 'router' roles.
hops[i].roles = ["nat", "router"];
// delete extra hop fields
delete hops[i].latency;
delete hops[i].ttl;
delete hops[i].err_msg;
nts.push(hops[i]);
}
}
// misc modifications
if (nts.length > 0) {
// update the outermost node by adding the
// 'gateway' role.
nts[nts.length - 1].roles.push("gateway");
// attempt to find and record the MAC address of the innermost
// NAT. Don't even try to find the MAC addresses of the other NATs
// b/c there is not going to be access and even if somehow there were
// access there could still be address collisions. Maybe there is another
// trick to at least obtain the mac address of the internet gateway but
// I don't know it.
arp.getMAC(nts[0].ip, (macErr, mac) => {
// just get what's possible. macErr is not
// taken into consideration. If the mac is provided
// then it is assigned.
if (typeof mac === 'string') {
nts[0].mac = mac;
}
// attempt to get the vendor name
// it may not show up if too many other vendor calls are
// being made at the same time. The rate limit is 1 per second.
hostVendorLookup(nts[0], (hst) => {
// attempt a host name lookup in the case of
// a local network dns.
hostNameLookup(hst, (hst) => {
// reassignment not necessary
// since the same object is operated on.
cb(nts);
});
});
});
} else {
cb(nts);
}
});
}
// coreLocalNetwork obtains the core players
// in the client local network.
//
// An attempt is made to locate the following
// host types:
// - internet host (interface associated with the public ip)
// - internet gateway (nat on the private side of the internet gateway)
// - other nats (the network may have more than one nat besides the
// internet gateway)
// - client host (the host info of the client)
//
// to be supported in the future:
// - other nats and routers that are not just
// located on the out-bound internet path.
// - other routers
// - client dns hosts (dns hosts the client is currently using)
//
// cb = (error, hsts) => {}
// callback function simply returns an array of hosts.
function coreLocalNetwork(cb) {
let hsts = [];
// obtain public internet host - the public face of the local
// network.
publicHost((phErr, hst) => {
hsts.push(hst);
// client host
clientHost((hst) => {
hsts.push(hst);
// nats/gateways
nats((nts) => {
hsts.push(...nts);
cb(phErr, hsts);
});
})
});
}
// localNetwork will get as much localnetwork connected
// device imformation as it can. Tries to present a list
// of all connected devices. It is a superset of coreLocalNetwork
//
// let cb = (error, hosts) => {}
function localNetwork(cb) {
coreLocalNetwork((lnErr, hsts) => {
let coreCnt = hsts.length;
// add remaining misc nodes
localdevices().then(
devices => {
// translate 'devices' format to 'host' format
// and push to local host list.
for (let i = 0; i < devices.length; i++) {
let h = new Host();
let d = devices[i];
if (d.name !== "?") {
h.name = d.name;
}
h.ip = d.ip;
h.mac = d.mac;
h.roles = ["device"];
// check that device host doesn't already exist
// on the core network.
// If it does exist check if the host name is available
// and add it.
let isCore = false;
for (let j = 0; j < coreCnt; j++) {
// check that the mac addresses are also the same
// to rule out and 'outer' nat that doesn't have
// a mac address but does have the same private ip
// as a host on the 'inner' network.
if (hsts[j].ip === h.ip && hsts[j].mac.length > 0) {
isCore = true;
if (hsts[j].name.length === 0 && h.name.length > 0) {
hsts[j].name = h.name;
}
}
}
// only add device hosts if not already included in the
// core local network.
if (!isCore) {
hsts.push(h);
}
// Note: not going to perform a vendor lookup since
// vendor lookup is rate limited to 1 per second.
}
// dedup - for some reason seeing a lot of dups
let dedupedKeys = {};
for (let i = 0; i < hsts.length; i++) {
dedupedKeys[hsts[i].ip + hsts[i].mac] = hsts[i];
}
let deduped = [];
for (var key in dedupedKeys) {
if (dedupedKeys.hasOwnProperty(key)) {
deduped.push(dedupedKeys[key]);
}
}
cb(lnErr, deduped);
}
).catch(
lErr => {
cb(lErr, hsts);
}
);
});
}
// traceroute provides low configuration traceroute functionality similar
// to 'traceroute' cli. While it will lookup all host names
// associated with the ip it will not find all the ips. In
// this way the returned ips represent the actual ips reported back
// by each server along the way.
//
// Note that traceroute is performed with 64 bit packet sizes.
// For now the max number of hops is not configurable.
//
// Traceroute hosts have two additional object fields:
// - latency (roundtrip latency from user client to that host)
// - ttl
// - err_msg (representing some kind of error on that hop)
//
// cb = (err, hops) => {}
function traceroute(destHst, cb) {
let hops = []; // array of hosts with 'latency' and 'ttl' fields added.
try {
let tracer = new Traceroute();
tracer
.on('hop', (hop) => {
if (ip.isV4Format(hop.ip)) {
let hopHst = new Host();
hopHst.ip = hop.ip;
hopHst.is_public = ip.isPublic(hopHst.ip);
if (hopHst.is_public) {
hopHst.roles = ['remote'];
} else {
hopHst.roles = ['nat', 'router']
}
// extra special host fields
if (hop.rtt1 === "<1 ms") {
hopHst.latency = 1;
} else if (hop.rtt1 === "*") {
hopHst.latency = 0; // probabl won't happen since host.ip won't be valid
} else {
// expecting format of "10 ms"
let pieces = hop.rtt1.split(" ");
if (pieces.length > 0) {
hopHst.latency = Number(pieces[0]);
if (isNaN(hopHst.latency)) {
hopHst.latency = 0;
}
}
}
hopHst.ttl = hop.hop;
// only hops where information
// could be collected is pushed.
hops.push(hopHst);
}
})
.on('close', () => {
// TODO: consider adding geo
// TODO: consider adding host name lookup
cb(null, hops);
});
let dest = "";
if (destHst.name.length > 0) {
dest = destHst.name;
} else {
dest = destHst.ip;
}
tracer.trace(dest);
} catch (ex) {
cb(ex, hops);
}
}
function PingsCfg() {
this.target = ''; // ping target; can be ip or hostname
this.port = 80; // default port 80
this.num_pings = 1;
}
function PingResult(pingHost = '', port = 80) {
this.packet_size = 64; // for now not an option.
this.ping_host = pingHost; // destination host
this.ping_port = port;
this.sent = 1; // num of pings sent; default is 1
this.returned = 0; // num of returned pings
this.loss = 0; // ping loss; sent - returned
this.min_latency = 0; // min ping latency
this.max_latency = 0; // max ping latency
this.avg_latency = 0; // avg ping latency
this.jitter = 0; // jitter (std deviation) ping latency
this.pings = []; // array of numeric values representing millisecond ping latency
}
// pings will do a series of tcp based pings. Default port
// is port 80. In tests on windows 10 it seems to hang if the
// port is wrong.
// cb = (error, results) => {}
function pings(pingsCfg, cb) {
// create host to represent ping destination
let hst = new Host();
hst.roles = ['remote'];
// check if target is ip address or host name.
if (ip.isV4Format(pingsCfg.target)) {
hst.ip = pingsCfg.target;
} else {
hst.name = pingsCfg.target;
}
let result = new PingResult(hst, pingsCfg.port);
// numPings option
if (typeof pingsCfg.num_pings === 'number') {
// numPings must at least be 1 or greater.
if (pingsCfg.num_pings > 0) {
result.sent = pingsCfg.num_pings;
}
}
// get the target host ip - if needed
// not going to bother with reverse lookup.
hostIpLookup(hst, (hst) => {
hst.is_public = ip.isPublic();
// dest host geo lookup
hostGeoLookup(hst, (hst) => {
let cnt = 0;
let pa = () => {
// quick check that the ip:port exists and is taking ping traffic.
tcpping.ping({ address: hst.ip, port: pingsCfg.port, attempts: 1, timeout: 250 }, (probeErr, probeRslt) => {
if (probeErr) {
cb(probeErr, result);
return
}
let available = probeRslt.min !== undefined;
if (available) {
tcpping.ping({
address: hst.ip,
port: pingsCfg.port,
attempts: pingsCfg.num_pings,
timeout: 1000,
}, (error, pRslt) => {
// translate ping times
pRslt.results.forEach((p) => {
result.pings.push(p.time);
});
// stats
result.returned = result.pings.length;
result.loss = result.sent - result.returned;
result.min_latency = Math.min(...result.pings);
result.max_latency = Math.max(...result.pings);
result.avg_latency = (
() => {
let sum = 0.0;
for (let i = 0; i < result.pings.length; i++) {
sum += result.pings[i];
}
return sum/result.pings.length;
}
)();
// jitter is just a sample standard deviation
// note: if there is just one ping then jitter is NaN.
result.jitter = (
() => {
let sumSq = 0.0; // diff around the mean squared and summed.
for (let i = 0; i < result.pings.length; i++) {
sumSq += Math.pow(result.pings[i] - result.avg_latency, 2);
}
return Math.sqrt(sumSq /(result.pings.length-1)) // n = sample size - 1
}
)();
cb(error, result);
})
} else {
cb(new Error("could not reach address"), result);
}
});
};
pa();
});
});
}
// ping is simple wrapper around pings. It just
// does one ping on default port 80.
function ping(target, cb) {
let cfg = new PingsCfg();
cfg.target = target;
cfg.port = 80;
cfg.num_pings = 1;
pings(cfg, cb);
}
// pingUrl checks a single
// http(s) endpoint and returns the endpoint
// checked along with the returned http response code.
//
// Notes:
// - only supports the GET action method at the moment.
// - does not follow redirects.
//
// should be a complete url such as
// "http://www.google.com/path?var1=value1"
// "https://www.google.com/path"
//
// cb = (err, resp) => {}
// resp = {url: 'url', response_code: 200}
function pingUrl(url, cb) {
request(url, (rErr, res, body) => {
let responseCode = 0;
if (res && res.statusCode) {
responseCode = res.statusCode;
}
cb(rErr, {url: url, response_code: responseCode});
});
}
// pingUrls is like pingUrl for an array of destinations.
// destinations = array of http(s) destination strings.
// cb = (err, urls) => {}
function pingUrls(urls, cb) {
let p = (url) => {
return new Promise(
(resolve, reject) => {
pingUrl(url, (pErr, url) => {
if (pErr) {
reject(pErr);
} else {
resolve(url)
}
});
}
);
};
let promises = []; // pingUrl promises
for (let i = 0; i < urls.length; i++) {
promises.push(p(urls[i]));
}
Promise.all(promises).then(
urlObjs => {
cb(null, urlObjs);
}
).catch(
pErr => {
cb(pErr, []);
}
);
}
// speed performs an upload speed test to a specified
// destination endpoint.
// look at: https://github.com/nesk/network.js
// let stOptions = {
// progressCb: (progress) => {}, // progress callback
// };
// let progress = {
// msg: "", // progress point message
// at: 0, // touch point number (progress point number)
// of: 0, // total number of touch points.
// perComplete: 0.00, // approximate percent complete.
// };
function speed(stOptions) {
return new Promise(
(resolve, reject) => {
let totalProgress = 8.0;
let currentProgress = 0;
// p indicates returns a progress
// object with the current progress info.
let p = (pMsg) => {
let tp = ++currentProgress;
// for now it's a float string so that
// the precision stays forced at 2 decimal places.
let perComplete = ((tp/totalProgress) * 100).toFixed(2);
return {
msg: pMsg,
at: tp,
of: totalProgress,
percent_complete: perComplete,
}
};
speedtestNet().on('data', stResult => {
// convert to standard host object format
let result = {
download_mbps: 0,
upload_mbps: 0,
download_size: 0, // in bytes
upload_size: 0, // in bytes
distance_mi: 0, // in miles
ping_ms: 0,
client_isp: '',
server_sponsor: '', // speed test server sponsor name
client: new Host(),
server: new Host(),
};
// extract and translate results
result.download_mbps = stResult.speeds.download;
result.upload_mbps = stResult.speeds.upload;
result.download_size = stResult.speeds.originalDownload;
result.upload_size = stResult.speeds.originalUpload;
result.distance_mi = stResult.server.distanceMi;
result.ping_ms = stResult.server.ping;
result.client_isp = stResult.client.isp;
result.server_sponsor = stResult.server.sponsor;
// client
result.client.ip = stResult.client.ip;
result.client.is_public = ip.isPublic(result.client.ip); // can't imagine it wouldn't be public
result.client.roles = ['public'];
// server
result.server.name = stResult.server.host;
result.server.roles = ['remote'];
// client host name lookup
hostNameLookup(result.client, (cHst) => {
// client geo lookup
hostGeoLookup(result.client, (cHst) => {
if (result.client.geo.org !== '') {
result.client_isp = result.client.geo.org;
}
// server ip lookup
hostIpLookup(result.server, (sHst) => {
// server geo lookup
hostGeoLookup(result.server, (sHst) => {
resolve(result);
})
});
});
});
}).on('error', stErr => {
reject(stErr);
}).on('config', ()=> {
stOptions.progressCb(p("obtained server config"));
}).on('servers', servers => {
stOptions.progressCb(p("accessing list of speed test servers"));
}).on('bestservers', bestservers => {
stOptions.progressCb(p("found best speed test server"));
}).on('testserver', testserver => {
stOptions.progressCb(p("checking server"));
}).on('downloadspeed', speed => {
stOptions.progressCb(p("download speed: " + parseFloat(speed).toFixed(2)));
}).on('uploadspeed', speed => {
stOptions.progressCb(p("upload speed: " + parseFloat(speed).toFixed(2)));
}).on('done', dataOverload => {
stOptions.progressCb(p("speed test complete"));
});
}
);
}
module.exports.Host = Host;
module.exports.HostGeo = HostGeo;
module.exports.hostNameLookup = hostNameLookup;
module.exports.hostIpLookup = hostIpLookup;
module.exports.hostGeoLookup = hostGeoLookup;
module.exports.hostVendorLookup = hostVendorLookup;
module.exports.traceroute = traceroute;
module.exports.publicHost = publicHost;
module.exports.clientHost = clientHost;
module.exports.client = client;
module.exports.nats = nats;
module.exports.coreLocalNetwork = coreLocalNetwork;
module.exports.localNetwork = localNetwork;
module.exports.PingsCfg = PingsCfg;
module.exports.PingResult = PingResult;
module.exports.pings = pings;
module.exports.ping = ping;
module.exports.pingUrl = pingUrl;
module.exports.pingUrls = pingUrls;
module.exports.speed = speed;