Initial commit
This commit is contained in:
1121
node_modules/ping/.eslintrc.json
generated
vendored
Normal file
1121
node_modules/ping/.eslintrc.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
17
node_modules/ping/.gitattributes
generated
vendored
Normal file
17
node_modules/ping/.gitattributes
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text eol=lf
|
||||
|
||||
# Custom for Visual Studio
|
||||
*.cs diff=csharp
|
||||
|
||||
# Standard to msysgit
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
4
node_modules/ping/.travis.yml
generated
vendored
Normal file
4
node_modules/ping/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- node
|
||||
- lts/*
|
69
node_modules/ping/CONTRIBUTING.md
generated
vendored
Normal file
69
node_modules/ping/CONTRIBUTING.md
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
# Contributing
|
||||
|
||||
We welcome patches and features. There are however a few things that are
|
||||
required before your pull request can be merged.
|
||||
|
||||
# Tests
|
||||
|
||||
## How to write a new test case
|
||||
|
||||
As output from system ping varied on languages and OS, our parser may fail
|
||||
on new languages or OS. To improve the correctness and coverage for this
|
||||
module, we need to gather output from those system pings.
|
||||
|
||||
### Upload a fixture about system ping
|
||||
|
||||
Suppose you are using `macos` in language `en`, you have a problem for running
|
||||
our module. Please upload a capture of your system ping in folder
|
||||
`test/fixture/$OS/$LANGUAGE`. In this case, the name of folder will be
|
||||
`test/fixture/macos/en`
|
||||
|
||||
### Write expected answer in answer.json
|
||||
|
||||
NOTE: we recommend to use [this online editor][1] for editing the content for
|
||||
`answer.json`
|
||||
|
||||
To verify the correctness of our module on your new fixture, please provide
|
||||
the expected answer in `test/fixture/answer.json`.
|
||||
|
||||
Format of the key name is `$OS_$LANGUAGE_$FILENAME`. In our case, this is
|
||||
`macos_en_sample1`.
|
||||
|
||||
Value of that key should be the result from our command.
|
||||
|
||||
```
|
||||
{
|
||||
"host": "google.com",
|
||||
"numeric_host": "172.217.24.46",
|
||||
"alive": true,
|
||||
"output": "PING google.com (172.217.24.46): 56 data bytes\n64 bytes from 172.217.24.46: icmp_seq=0 ttl=54 time=5.371 ms\n64 bytes from 172.217.24.46: icmp_seq=1 ttl=54 time=4.269 ms\n64 bytes from 172.217.24.46: icmp_seq=2 ttl=54 time=4.970 ms\n64 bytes from 172.217.24.46: icmp_seq=3 ttl=54 time=5.228 ms\n\n--- google.com ping statistics ---\n4 packets transmitted, 4 packets received, 0.0% packet loss\nround-trip min/avg/max/stddev = 4.269/4.960/5.371/0.424 ms\n",
|
||||
"time": 5.371,
|
||||
"times": [
|
||||
5.371,
|
||||
4.269,
|
||||
4.97,
|
||||
5.228
|
||||
],
|
||||
"min": 4.269,
|
||||
"max": 4.96,
|
||||
"avg": 5.371,
|
||||
"packageLoss": 0.0
|
||||
"stddev": 0.424
|
||||
}
|
||||
```
|
||||
|
||||
## Running test cases
|
||||
|
||||
We trust tested codes. Please run below command for testing before sending
|
||||
a pull request
|
||||
|
||||
```
|
||||
$ grunt test
|
||||
```
|
||||
|
||||
## Running ipv6 test cases
|
||||
|
||||
As #67 introduces ipv6 mechanism, fixture file names with `v6` will enable v6.
|
||||
Please refer to window/de/v6_sample.txt for an example
|
||||
|
||||
[1]: https://jsoneditoronline.org
|
22
node_modules/ping/Gruntfile.js
generated
vendored
Normal file
22
node_modules/ping/Gruntfile.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt) {
|
||||
grunt.initConfig({
|
||||
eslint: {
|
||||
src: ['lib/*.js', 'lib/**/*.js'],
|
||||
options: {
|
||||
configFile: '.eslintrc.json',
|
||||
},
|
||||
},
|
||||
mochaTest: {
|
||||
src: ['test/test-*.js'],
|
||||
options: {
|
||||
reporter: 'dot',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('gruntify-eslint');
|
||||
grunt.loadNpmTasks('grunt-mocha-test');
|
||||
grunt.registerTask('test', ['eslint', 'mochaTest']);
|
||||
};
|
8
node_modules/ping/LICENSE
generated
vendored
Normal file
8
node_modules/ping/LICENSE
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
MIT License
|
||||
Copyright (c) 2016 Daniel Zelisko
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
201
node_modules/ping/README.md
generated
vendored
Normal file
201
node_modules/ping/README.md
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
# NODE-PING [](https://travis-ci.com/danielzzz/node-ping)
|
||||
|
||||
a ping wrapper for nodejs
|
||||
|
||||
@last-modified: 2020-12-26
|
||||
|
||||
# LICENSE MIT
|
||||
|
||||
(C) Daniel Zelisko
|
||||
|
||||
http://github.com/danielzzz/node-ping
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
node-ping is a simple wrapper for the system ping utility
|
||||
|
||||
# INSTALLATION
|
||||
|
||||
npm install ping
|
||||
|
||||
# USAGE
|
||||
|
||||
Below are examples extracted from `examples`
|
||||
|
||||
## Tradition calls
|
||||
|
||||
```js
|
||||
var ping = require('ping');
|
||||
|
||||
var hosts = ['192.168.1.1', 'google.com', 'yahoo.com'];
|
||||
hosts.forEach(function(host){
|
||||
ping.sys.probe(host, function(isAlive){
|
||||
var msg = isAlive ? 'host ' + host + ' is alive' : 'host ' + host + ' is dead';
|
||||
console.log(msg);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
## Tradition calls with configuration
|
||||
|
||||
```js
|
||||
var cfg = {
|
||||
timeout: 10,
|
||||
// WARNING: -i 2 may not work in other platform like windows
|
||||
extra: ['-i', '2'],
|
||||
};
|
||||
|
||||
hosts.forEach(function(host){
|
||||
ping.sys.probe(host, function(isAlive){
|
||||
var msg = isAlive ? 'host ' + host + ' is alive' : 'host ' + host + ' is dead';
|
||||
console.log(msg);
|
||||
}, cfg);
|
||||
});
|
||||
```
|
||||
|
||||
## Promise wrapper
|
||||
|
||||
```js
|
||||
var ping = require('ping');
|
||||
|
||||
var hosts = ['192.168.1.1', 'google.com', 'yahoo.com'];
|
||||
|
||||
hosts.forEach(function (host) {
|
||||
ping.promise.probe(host)
|
||||
.then(function (res) {
|
||||
console.log(res);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
## Promise Wrapper with configurable ping options
|
||||
|
||||
```js
|
||||
hosts.forEach(function (host) {
|
||||
// WARNING: -i 2 argument may not work in other platform like windows
|
||||
ping.promise.probe(host, {
|
||||
timeout: 10,
|
||||
extra: ['-i', '2'],
|
||||
}).then(function (res) {
|
||||
console.log(res);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## Async-Await
|
||||
```js
|
||||
var ping = require('ping');
|
||||
|
||||
var hosts = ['192.168.1.1', 'google.com', 'yahoo.com'];
|
||||
|
||||
for(let host of hosts){
|
||||
let res = await ping.promise.probe(host);
|
||||
console.log(res);
|
||||
}
|
||||
```
|
||||
|
||||
## Async-Await with configurable ping options
|
||||
```js
|
||||
var ping = require('ping');
|
||||
|
||||
var hosts = ['192.168.1.1', 'google.com', 'yahoo.com'];
|
||||
|
||||
for(let host of hosts){
|
||||
// WARNING: -i 2 argument may not work in other platform like windows
|
||||
let res = await ping.promise.probe(host, {
|
||||
timeout: 10,
|
||||
extra: ['-i', '2'],
|
||||
});
|
||||
console.log(res);
|
||||
}
|
||||
```
|
||||
### Support configuration
|
||||
|
||||
Below is the possible configuration
|
||||
|
||||
```js
|
||||
/**
|
||||
* Cross platform config representation
|
||||
* @typedef {Object} PingConfig
|
||||
* @property {boolean} numeric - Map IP address to hostname or not
|
||||
* @property {number} timeout - Timeout in seconds for each ping request.
|
||||
* Behaviour varies between platforms. Check platform ping documentation for more information.
|
||||
* @property {number} deadline - Specify a timeout, in seconds, before ping exits regardless of
|
||||
how many packets have been sent or received. In this case ping
|
||||
does not stop after count packet are sent, it waits either for
|
||||
deadline expire or until count probes are answered or for some
|
||||
error notification from network. This option is only available on linux and mac.
|
||||
* @property {number} min_reply - Exit after sending number of ECHO_REQUEST
|
||||
* @property {boolean} v6 - Ping via ipv6 or not. Default is false
|
||||
* @property {string} sourceAddr - source address for sending the ping
|
||||
* @property {number} packetSize - Specifies the number of data bytes to be sent
|
||||
Default: Linux / MAC: 56 Bytes, Windows: 32 Bytes
|
||||
* @property {string[]} extra - Optional options does not provided
|
||||
*/
|
||||
```
|
||||
|
||||
### Output specification
|
||||
|
||||
* For callback based implementation:
|
||||
|
||||
```js
|
||||
/**
|
||||
* Callback after probing given host
|
||||
* @callback probeCallback
|
||||
* @param {boolean} isAlive - Whether target is alive or not
|
||||
* @param {Object} error - Null if no error occurs
|
||||
*/
|
||||
```
|
||||
|
||||
* For promise based implementation
|
||||
|
||||
```js
|
||||
/**
|
||||
* Parsed response
|
||||
* @typedef {object} PingResponse
|
||||
* @param {string} inputHost - The input IP address or HOST
|
||||
* @param {string} host - Parsed host from system command's output
|
||||
* @param {string} numeric_host - Target IP address
|
||||
* @param {boolean} alive - True for existed host
|
||||
* @param {string} output - Raw stdout from system ping
|
||||
* @param {number} time - Time (float) in ms for first successful ping response
|
||||
* @param {Array} times - Array of Time (float) in ms for each ping response
|
||||
* @param {string} min - Minimum time for collection records
|
||||
* @param {string} max - Maximum time for collection records
|
||||
* @param {string} avg - Average time for collection records
|
||||
* @param {string} packetLoss - Packet Losses in percent (100% -> "100.000")
|
||||
* @param {string} stddev - Standard deviation time for collected records
|
||||
*/
|
||||
```
|
||||
|
||||
#### Note
|
||||
|
||||
* Since `ping` in this module relies on the `ping` from underlying platform,
|
||||
arguments in `PingConfig.extra` will definitely be varied across different
|
||||
platforms.
|
||||
|
||||
* However, `numeric`, `timeout` and `min_reply` have been abstracted. Values for
|
||||
them are expected to be cross platform.
|
||||
|
||||
* By setting `numeric`, `timeout` or `min_reply` to false, you can run `ping`
|
||||
without corresponding arguments.
|
||||
|
||||
# FAQ
|
||||
|
||||
* It does not work with busybox's ping implemetation [#89](https://github.com/danielzzz/node-ping/issues/89)
|
||||
|
||||
Try to install package `iputils`. For example, running `apk add iputils`
|
||||
|
||||
* For questions regarding to the implementation of `timeout`, and `deadline`, please checkout discussions in
|
||||
[#101](https://github.com/danielzzz/node-ping/issues/101)
|
||||
|
||||
* For questions regarding to the defintions of `host`, `inputHost`, and `numeric_host`, please checkout
|
||||
discussions in [#133](https://github.com/danielzzz/node-ping/issues/133)
|
||||
|
||||
# Contributing
|
||||
|
||||
Before opening a pull request please make sure your changes follow the
|
||||
[contribution guidelines][1].
|
||||
|
||||
[1]: https://github.com/danielzzz/node-ping/blob/master/CONTRIBUTING.md
|
30
node_modules/ping/examples/example.js
generated
vendored
Normal file
30
node_modules/ping/examples/example.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// -------- example -----------------------
|
||||
|
||||
'use strict';
|
||||
|
||||
var ping = require('../index');
|
||||
|
||||
var hosts = ['192.168.1.1', 'google.com', 'yahoo.com'];
|
||||
hosts.forEach(function (host) {
|
||||
// Running with default config
|
||||
ping.sys.probe(host, function (isAlive) {
|
||||
var msg = isAlive ?
|
||||
'host ' + host + ' is alive' : 'host ' + host + ' is dead';
|
||||
console.log(msg);
|
||||
});
|
||||
|
||||
// Running with custom config
|
||||
ping.sys.probe(host, function (isAlive) {
|
||||
var msg = isAlive ?
|
||||
'host ' + host + ' is alive' : 'host ' + host + ' is dead';
|
||||
console.log(msg);
|
||||
}, {extra: ['-i', '2']});
|
||||
|
||||
// Running ping with some default argument gone
|
||||
ping.sys.probe(host, function (isAlive) {
|
||||
var msg = isAlive ?
|
||||
'host ' + host + ' is alive' : 'host ' + host + ' is dead';
|
||||
console.log(msg);
|
||||
}, {extra: ['-i', '2'], timeout: false});
|
||||
});
|
||||
|
41
node_modules/ping/examples/example2.js
generated
vendored
Normal file
41
node_modules/ping/examples/example2.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
var ping = require('../index');
|
||||
|
||||
var hosts = ['192.168.1.1', 'google.com', 'yahoo.com'];
|
||||
|
||||
// Running with default config
|
||||
hosts.forEach(function (host) {
|
||||
ping.promise.probe(host)
|
||||
.then(function (res) {
|
||||
console.log(res);
|
||||
})
|
||||
.done();
|
||||
});
|
||||
|
||||
// Running with custom config
|
||||
hosts.forEach(function (host) {
|
||||
// WARNING: -i 2 argument may not work in other platform like window
|
||||
ping.promise.probe(host, {
|
||||
timeout: 10,
|
||||
extra: ['-i', '2'],
|
||||
})
|
||||
.then(function (res) {
|
||||
console.log(res);
|
||||
})
|
||||
.done();
|
||||
});
|
||||
|
||||
// Running ping with some default argument gone
|
||||
hosts.forEach(function (host) {
|
||||
// WARNING: -i 2 argument may not work in other platform like window
|
||||
ping.promise.probe(host, {
|
||||
timeout: false,
|
||||
// Below extra arguments may not work in platforms other than linux
|
||||
extra: ['-i', '2'],
|
||||
})
|
||||
.then(function (res) {
|
||||
console.log(res);
|
||||
})
|
||||
.done();
|
||||
});
|
35
node_modules/ping/examples/example_win_de_v6.js
generated
vendored
Normal file
35
node_modules/ping/examples/example_win_de_v6.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
// -------- example -----------------------
|
||||
|
||||
'use strict';
|
||||
|
||||
var ping = require('../index');
|
||||
|
||||
var hosts = ['google.de']; // , '192.168.1.1', 'google.com', 'yahoo.com'];
|
||||
|
||||
// Running with custom config
|
||||
hosts.forEach(function (host) {
|
||||
ping.promise.probe(host, {
|
||||
// v6: true,
|
||||
min_reply: 2,
|
||||
sourceAddr: 'your NIC\'s IPv6 address',
|
||||
// sourceAddr: false,
|
||||
})
|
||||
.then(function (res) {
|
||||
console.log('\n');
|
||||
console.log(res);
|
||||
})
|
||||
.done();
|
||||
|
||||
// Running ping with some default argument gone
|
||||
ping.sys.probe(host, function (isAlive) {
|
||||
var msg = isAlive ?
|
||||
'host ' + host + ' is alive' : 'host ' + host + ' is dead';
|
||||
console.log('\n');
|
||||
console.log(msg);
|
||||
}, {
|
||||
timeout: false,
|
||||
// v6: true,
|
||||
min_reply: 2,
|
||||
sourceAddr: 'your NIC\'s IPv6 address',
|
||||
});
|
||||
});
|
7
node_modules/ping/index.js
generated
vendored
Normal file
7
node_modules/ping/index.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
var ping = {};
|
||||
|
||||
ping.sys = require('./lib/ping-sys');
|
||||
//ping.pcap = require('./lib/ping-pcap');
|
||||
ping.promise = require("./lib/ping-promise");
|
||||
|
||||
module.exports = ping;
|
113
node_modules/ping/lib/builder/factory.js
generated
vendored
Normal file
113
node_modules/ping/lib/builder/factory.js
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
'use strict';
|
||||
|
||||
var __ = require('underscore');
|
||||
var util = require('util');
|
||||
|
||||
// Our library
|
||||
var linuxBuilder = require('./linux');
|
||||
var macBuilder = require('./mac');
|
||||
var winBuilder = require('./win');
|
||||
|
||||
/**
|
||||
* A factory creates argument builders for different platform
|
||||
* @constructor
|
||||
*/
|
||||
function factory() {}
|
||||
|
||||
/**
|
||||
* Check out linux platform
|
||||
*/
|
||||
factory.isLinux = function (p) {
|
||||
var platforms = [
|
||||
'aix',
|
||||
'android',
|
||||
'linux',
|
||||
];
|
||||
|
||||
return platforms.indexOf(p) >= 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check out macos platform
|
||||
*/
|
||||
factory.isMacOS = function (p) {
|
||||
var platforms = [
|
||||
'darwin',
|
||||
'freebsd',
|
||||
];
|
||||
|
||||
return platforms.indexOf(p) >= 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check out window platform
|
||||
*/
|
||||
factory.isWindow = function (p) {
|
||||
return p && p.match(/^win/) !== null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check whether given platform is supported
|
||||
* @param {string} p - Name of the platform
|
||||
* @return {bool} - True or False
|
||||
*/
|
||||
factory.isPlatformSupport = function (p) {
|
||||
return __.some([
|
||||
this.isWindow(p),
|
||||
this.isLinux(p),
|
||||
this.isMacOS(p),
|
||||
]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a path to the ping executable in the system
|
||||
* @param {string} platform - Name of the platform
|
||||
* @param {bool} v6 - Ping via ipv6 or not
|
||||
* @return {string} - Executable path for system command ping
|
||||
* @throw if given platform is not supported
|
||||
*/
|
||||
factory.getExecutablePath = function (platform, v6) {
|
||||
if (!this.isPlatformSupport(platform)) {
|
||||
throw new Error(util.format('Platform |%s| is not support', platform));
|
||||
}
|
||||
|
||||
var ret = null;
|
||||
|
||||
if (platform === 'aix') {
|
||||
ret = '/usr/sbin/ping';
|
||||
} else if (factory.isLinux(platform)) {
|
||||
ret = v6 ? 'ping6' : 'ping';
|
||||
} else if (factory.isWindow(platform)) {
|
||||
ret = process.env.SystemRoot + '/system32/ping.exe';
|
||||
} else if (factory.isMacOS(platform)) {
|
||||
ret = v6 ? '/sbin/ping6' : '/sbin/ping';
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a builder
|
||||
* @param {string} platform - Name of the platform
|
||||
* @return {object} - Argument builder
|
||||
* @throw if given platform is not supported
|
||||
*/
|
||||
factory.createBuilder = function (platform) {
|
||||
if (!this.isPlatformSupport(platform)) {
|
||||
throw new Error(util.format('Platform |%s| is not support', platform));
|
||||
}
|
||||
|
||||
var ret = null;
|
||||
|
||||
if (factory.isLinux(platform)) {
|
||||
ret = linuxBuilder;
|
||||
} else if (factory.isWindow(platform)) {
|
||||
ret = winBuilder;
|
||||
} else if (factory.isMacOS(platform)) {
|
||||
ret = macBuilder;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
module.exports = factory;
|
125
node_modules/ping/lib/builder/linux.js
generated
vendored
Normal file
125
node_modules/ping/lib/builder/linux.js
generated
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A builder builds command line arguments for ping in linux environment
|
||||
* @module lib/builder/linux
|
||||
*/
|
||||
var util = require('util');
|
||||
|
||||
var builder = {};
|
||||
|
||||
/**
|
||||
* Cross platform config representation
|
||||
* @typedef {Object} PingConfig
|
||||
* @property {boolean} numeric - Map IP address to hostname or not
|
||||
* @property {number} timeout - Time to wait for a response, in seconds.
|
||||
* The option affects only timeout in absence of any responses,
|
||||
* otherwise ping waits for two RTTs.
|
||||
* @property {number} deadline - Specify a timeout, in seconds,
|
||||
* before ping exits regardless of how many packets have been sent or received.
|
||||
* In this case ping does not stop after count packet are sent,
|
||||
* it waits either for deadline expire or until count probes are answered
|
||||
* or for some error notification from network.
|
||||
* This option is only available on linux and mac.
|
||||
* @property {number} min_reply - Exit after sending number of ECHO_REQUEST
|
||||
* @property {boolean} v6 - Use IPv4 (default) or IPv6
|
||||
* @property {string} sourceAddr - source address for sending the ping
|
||||
* @property {number} packetSize - Specifies the number of data bytes to be sent
|
||||
* Default: Linux / MAC: 56 Bytes,
|
||||
* Window: 32 Bytes
|
||||
* @property {string[]} extra - Optional options does not provided
|
||||
*/
|
||||
|
||||
var defaultConfig = {
|
||||
numeric: true,
|
||||
timeout: 2,
|
||||
deadline: false,
|
||||
min_reply: 1,
|
||||
v6: false,
|
||||
sourceAddr: '',
|
||||
packetSize: 56,
|
||||
extra: [],
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the finalized array of command line arguments
|
||||
* @param {string} target - hostname or ip address
|
||||
* @param {PingConfig} [config] - Configuration object for cmd line argument
|
||||
* @return {string[]} - Command line argument according to the configuration
|
||||
*/
|
||||
builder.getCommandArguments = function (target, config) {
|
||||
var _config = config || {};
|
||||
|
||||
// Empty argument
|
||||
var ret = [];
|
||||
|
||||
// Make every key in config has been setup properly
|
||||
var keys = ['numeric', 'timeout', 'deadline', 'min_reply', 'v6',
|
||||
'sourceAddr', 'extra', 'packetSize'];
|
||||
keys.forEach(function (k) {
|
||||
// Falsy value will be overridden without below checking
|
||||
if (typeof(_config[k]) !== 'boolean') {
|
||||
_config[k] = _config[k] || defaultConfig[k];
|
||||
}
|
||||
});
|
||||
|
||||
if (_config.numeric) {
|
||||
ret.push('-n');
|
||||
}
|
||||
|
||||
if (_config.timeout) {
|
||||
ret = ret.concat([
|
||||
'-W',
|
||||
util.format('%d', _config.timeout),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.deadline) {
|
||||
ret = ret.concat([
|
||||
'-w',
|
||||
util.format('%d', _config.deadline),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.min_reply) {
|
||||
ret = ret.concat([
|
||||
'-c',
|
||||
util.format('%d', _config.min_reply),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.sourceAddr) {
|
||||
ret = ret.concat([
|
||||
'-I',
|
||||
util.format('%s', _config.sourceAddr),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.packetSize) {
|
||||
ret = ret.concat([
|
||||
'-s',
|
||||
util.format('%d', _config.packetSize),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.extra) {
|
||||
ret = ret.concat(_config.extra);
|
||||
}
|
||||
|
||||
ret.push(target);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compute an option object for child_process.spawn
|
||||
* @return {object} - Refer to document of child_process.spawn
|
||||
*/
|
||||
builder.getSpawnOptions = function () {
|
||||
return {
|
||||
shell: false,
|
||||
env: Object.assign(process.env, {LANG: 'C'}),
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = builder;
|
129
node_modules/ping/lib/builder/mac.js
generated
vendored
Normal file
129
node_modules/ping/lib/builder/mac.js
generated
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A builder builds command line arguments for ping in mac environment
|
||||
* @module lib/builder/mac
|
||||
*/
|
||||
var util = require('util');
|
||||
|
||||
var builder = {};
|
||||
|
||||
/**
|
||||
* Cross platform config representation
|
||||
* @typedef {Object} PingConfig
|
||||
* @property {boolean} numeric - Map IP address to hostname or not
|
||||
* @property {number} timeout - Time to wait for a response, in seconds.
|
||||
* The option affects only timeout in absence of any responses,
|
||||
* otherwise ping waits for two RTTs.
|
||||
* @property {number} deadline - Specify a timeout, in seconds,
|
||||
* before ping exits regardless of how many packets have been sent or received.
|
||||
* In this case ping does not stop after count packet are sent,
|
||||
* it waits either for deadline expire or until count probes are answered
|
||||
* or for some error notification from network.
|
||||
* This option is only available on linux and mac.
|
||||
* @property {number} min_reply - Exit after sending number of ECHO_REQUEST
|
||||
* @property {boolean} v6 - Use IPv4 (default) or IPv6
|
||||
* @property {string} sourceAddr - source address for sending the ping
|
||||
* @property {number} packetSize - Specifies the number of data bytes to be sent
|
||||
* Default: Linux / MAC: 56 Bytes,
|
||||
* Window: 32 Bytes
|
||||
* @property {string[]} extra - Optional options does not provided
|
||||
*/
|
||||
|
||||
var defaultConfig = {
|
||||
numeric: true,
|
||||
timeout: 2,
|
||||
deadline: false,
|
||||
min_reply: 1,
|
||||
v6: false,
|
||||
sourceAddr: '',
|
||||
packetSize: 56,
|
||||
extra: [],
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the finalized array of command line arguments
|
||||
* @param {string} target - hostname or ip address
|
||||
* @param {PingConfig} [config] - Configuration object for cmd line argument
|
||||
* @return {string[]} - Command line argument according to the configuration
|
||||
* @throws If there are errors on building arguments with given inputs
|
||||
*/
|
||||
builder.getCommandArguments = function (target, config) {
|
||||
var _config = config || {};
|
||||
|
||||
// Empty argument
|
||||
var ret = [];
|
||||
|
||||
// Make every key in config has been setup properly
|
||||
var keys = ['numeric', 'timeout', 'deadline', 'min_reply', 'v6',
|
||||
'sourceAddr', 'extra', 'packetSize'];
|
||||
keys.forEach(function (k) {
|
||||
// Falsy value will be overridden without below checking
|
||||
if (typeof(_config[k]) !== 'boolean') {
|
||||
_config[k] = _config[k] || defaultConfig[k];
|
||||
}
|
||||
});
|
||||
|
||||
if (_config.numeric) {
|
||||
ret.push('-n');
|
||||
}
|
||||
|
||||
if (_config.timeout) {
|
||||
// XXX: There is no timeout option on mac's ping6
|
||||
if (config.v6) {
|
||||
throw new Error('There is no timeout option on ping6');
|
||||
}
|
||||
|
||||
ret = ret.concat([
|
||||
'-W',
|
||||
util.format('%d', _config.timeout * 1000),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.deadline) {
|
||||
ret = ret.concat([
|
||||
'-t',
|
||||
util.format('%d', _config.deadline),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.min_reply) {
|
||||
ret = ret.concat([
|
||||
'-c',
|
||||
util.format('%d', _config.min_reply),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.sourceAddr) {
|
||||
ret = ret.concat([
|
||||
'-S',
|
||||
util.format('%s', _config.sourceAddr),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.packetSize) {
|
||||
ret = ret.concat([
|
||||
'-s',
|
||||
util.format('%d', _config.packetSize),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.extra) {
|
||||
ret = ret.concat(_config.extra);
|
||||
}
|
||||
|
||||
ret.push(target);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compute an option object for child_process.spawn
|
||||
* @return {object} - Refer to document of child_process.spawn
|
||||
*/
|
||||
builder.getSpawnOptions = function () {
|
||||
return {};
|
||||
};
|
||||
|
||||
|
||||
module.exports = builder;
|
119
node_modules/ping/lib/builder/win.js
generated
vendored
Normal file
119
node_modules/ping/lib/builder/win.js
generated
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A builder builds command line arguments for ping in window environment
|
||||
* @module lib/builder/win
|
||||
*/
|
||||
var util = require('util');
|
||||
|
||||
var builder = {};
|
||||
|
||||
/**
|
||||
* Cross platform config representation
|
||||
* @typedef {Object} PingConfig
|
||||
* @property {boolean} numeric - Map IP address to hostname or not
|
||||
* @property {number} timeout - Timeout in seconds for each ping request
|
||||
* @property {number} min_reply - Exit after sending number of ECHO_REQUEST
|
||||
* @property {boolean} v6 - Use IPv4 (default) or IPv6
|
||||
* @property {string} sourceAddr - source address for sending the ping
|
||||
* @property {number} packetSize - Specifies the number of data bytes to be sent
|
||||
* Default: Linux / MAC: 56 Bytes,
|
||||
* Window: 32 Bytes
|
||||
* @property {string[]} extra - Optional options does not provided
|
||||
*/
|
||||
|
||||
var defaultConfig = {
|
||||
numeric: true,
|
||||
timeout: 5,
|
||||
min_reply: 1,
|
||||
v6: false,
|
||||
sourceAddr: '',
|
||||
packetSize: 32,
|
||||
extra: [],
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the finalized array of command line arguments
|
||||
* @param {string} target - hostname or ip address
|
||||
* @param {PingConfig} [config] - Configuration object for cmd line argument
|
||||
* @return {string[]} - Command line argument according to the configuration
|
||||
*/
|
||||
builder.getCommandArguments = function (target, config) {
|
||||
var _config = config || {};
|
||||
|
||||
// Empty argument
|
||||
var ret = [];
|
||||
|
||||
// Make every key in config has been setup properly
|
||||
var keys = [
|
||||
'numeric', 'timeout', 'min_reply', 'v6', 'sourceAddr', 'extra',
|
||||
'packetSize',
|
||||
];
|
||||
keys.forEach(function (k) {
|
||||
// Falsy value will be overrided without below checking
|
||||
if (typeof(_config[k]) !== 'boolean') {
|
||||
_config[k] = _config[k] || defaultConfig[k];
|
||||
}
|
||||
});
|
||||
|
||||
ret.push(_config.v6 ? '-6' : '-4');
|
||||
|
||||
if (!_config.numeric) {
|
||||
ret.push('-a');
|
||||
}
|
||||
|
||||
if (_config.timeout) {
|
||||
// refs #56: Unit problem
|
||||
// Our timeout is in second while timeout in window is in milliseconds
|
||||
// so we need to convert our units accordingly
|
||||
ret = ret.concat([
|
||||
'-w',
|
||||
util.format('%d', _config.timeout * 1000),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.deadline) {
|
||||
throw new Error('There is no deadline option on windows');
|
||||
}
|
||||
|
||||
if (_config.min_reply) {
|
||||
ret = ret.concat([
|
||||
'-n',
|
||||
util.format('%d', _config.min_reply),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.sourceAddr) {
|
||||
ret = ret.concat([
|
||||
'-S',
|
||||
util.format('%s', _config.sourceAddr),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.packetSize) {
|
||||
ret = ret.concat([
|
||||
'-l',
|
||||
util.format('%d', _config.packetSize),
|
||||
]);
|
||||
}
|
||||
|
||||
if (_config.extra) {
|
||||
ret = ret.concat(_config.extra);
|
||||
}
|
||||
|
||||
ret.push(target);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compute an option object for child_process.spawn
|
||||
* @return {object} - Refer to document of child_process.spawn
|
||||
*/
|
||||
builder.getSpawnOptions = function () {
|
||||
return {
|
||||
windowsHide: true,
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = builder;
|
203
node_modules/ping/lib/parser/base.js
generated
vendored
Normal file
203
node_modules/ping/lib/parser/base.js
generated
vendored
Normal file
@ -0,0 +1,203 @@
|
||||
'use strict';
|
||||
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
var __ = require('underscore');
|
||||
|
||||
/**
|
||||
* Parsed response
|
||||
* @typedef {object} PingResponse
|
||||
* @param {string} inputHost - The input IP address or HOST
|
||||
* @param {string} host - The input IP address or HOST
|
||||
* @param {string} numeric_host - Target IP address
|
||||
* @param {boolean} alive - True for existed host
|
||||
* @param {string} output - Raw stdout from system ping
|
||||
* @param {number} time - Time (float) in ms for first successful ping response
|
||||
* @param {string} min - Minimum time for collection records
|
||||
* @param {string} max - Maximum time for collection records
|
||||
* @param {string} avg - Average time for collection records
|
||||
* @param {number} packetLoss - Packet Losses in percent (number)
|
||||
* @param {string} stddev - Standard deviation time for collected records
|
||||
*/
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {string} addr - Hostname or ip addres
|
||||
* @param {PingConfig} config - Config object in probe()
|
||||
*/
|
||||
function parser(addr, config) {
|
||||
// Initial state is 0
|
||||
this._state = 0;
|
||||
|
||||
// Initial cache value
|
||||
this._response = {
|
||||
inputHost: addr,
|
||||
host: 'unknown',
|
||||
alive: false,
|
||||
output: 'unknown',
|
||||
time: 'unknown',
|
||||
times: [],
|
||||
min: 'unknown',
|
||||
max: 'unknown',
|
||||
avg: 'unknown',
|
||||
stddev: 'unknown',
|
||||
packetLoss: 'unknown',
|
||||
};
|
||||
|
||||
// Initial times storage for ping time
|
||||
this._times = [];
|
||||
|
||||
// Initial lines storage for ping output
|
||||
this._lines = [];
|
||||
|
||||
// strip string regexp
|
||||
this._stripRegex = /[ ]*\r?\n?$/g;
|
||||
|
||||
// Ping Config
|
||||
this._pingConfig = config || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum for parser states
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
*/
|
||||
parser.prototype.STATES = {
|
||||
INIT: 0,
|
||||
HEADER: 1,
|
||||
BODY: 2,
|
||||
FOOTER: 3,
|
||||
END: 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* Change state of this parser
|
||||
* @param {number} state - parser.STATES
|
||||
* @return {this} - This instance
|
||||
*/
|
||||
parser.prototype._changeState = function (state) {
|
||||
var states = __.values(this.STATES);
|
||||
if (states.indexOf(state) < 0) {
|
||||
throw new Error('Unknown state');
|
||||
}
|
||||
|
||||
this._state = state;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Process output's header
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
parser.prototype._processHeader = function (line) {
|
||||
throw new Error('Subclass should implement this method');
|
||||
};
|
||||
|
||||
/**
|
||||
* Process output's body
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
parser.prototype._processBody = function (line) {
|
||||
throw new Error('Subclass should implement this method');
|
||||
};
|
||||
|
||||
/**
|
||||
* Process output's footer
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
parser.prototype._processFooter = function (line) {
|
||||
throw new Error('Subclass should implement this method');
|
||||
};
|
||||
|
||||
/**
|
||||
* Process a line from system ping
|
||||
* @param {string} line - A line from system ping
|
||||
* @return {this} - This instance
|
||||
*/
|
||||
parser.prototype.eat = function (line) {
|
||||
var headerStates = [
|
||||
this.STATES.INIT,
|
||||
this.STATES.HEADER,
|
||||
];
|
||||
|
||||
// Store lines
|
||||
this._lines.push(line);
|
||||
|
||||
// Strip all space \r\n at the end
|
||||
var _line = line.replace(this._stripRegex, '');
|
||||
|
||||
if (_line.length === 0) {
|
||||
// Do nothing if this is an empty line
|
||||
} else if (headerStates.indexOf(this._state) >= 0) {
|
||||
this._processHeader(_line);
|
||||
} else if (this._state === this.STATES.BODY) {
|
||||
this._processBody(_line);
|
||||
} else if (this._state === this.STATES.FOOTER) {
|
||||
this._processFooter(_line);
|
||||
} else if (this._state === this.STATES.END) {
|
||||
// Do nothing
|
||||
} else {
|
||||
throw new Error('Unknown state');
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get results after parsing certain lines from system ping
|
||||
* @return {PingResponse} - Response from parsing ping output
|
||||
*/
|
||||
parser.prototype.getResult = function () {
|
||||
var ret = __.extend({}, this._response);
|
||||
|
||||
// Concat output
|
||||
ret.output = this._lines.join('\n');
|
||||
|
||||
// Determine alive
|
||||
ret.alive = this._times.length > 0;
|
||||
|
||||
// Update time at first successful line
|
||||
if (ret.alive) {
|
||||
this._response.time = this._times[0];
|
||||
ret.time = this._response.time;
|
||||
this._response.times = this._times;
|
||||
ret.times = this._response.times;
|
||||
}
|
||||
|
||||
// Get stddev
|
||||
if (
|
||||
ret.stddev === 'unknown' && ret.alive
|
||||
) {
|
||||
var numberOfSamples = this._times.length;
|
||||
|
||||
var sumOfAllSquareDifferences = __.reduce(
|
||||
this._times,
|
||||
function (memory, time) {
|
||||
var differenceFromMean = time - ret.avg;
|
||||
var squaredDifference =
|
||||
differenceFromMean * differenceFromMean;
|
||||
return memory + squaredDifference;
|
||||
},
|
||||
0
|
||||
);
|
||||
var variances = sumOfAllSquareDifferences / numberOfSamples;
|
||||
|
||||
ret.stddev = Math.round(
|
||||
Math.sqrt(variances) * 1000
|
||||
) / 1000;
|
||||
}
|
||||
|
||||
// Fix min, avg, max, stddev up to 3 decimal points
|
||||
__.each(['min', 'avg', 'max', 'stddev', 'packetLoss'], function (key) {
|
||||
var v = ret[key];
|
||||
if (__.isNumber(v)) {
|
||||
ret[key] = v.toFixed(3);
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
module.exports = parser;
|
44
node_modules/ping/lib/parser/factory.js
generated
vendored
Normal file
44
node_modules/ping/lib/parser/factory.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var builderFactory = require('../builder/factory');
|
||||
var WinParser = require('./win');
|
||||
var MacParser = require('./mac');
|
||||
var LinuxParser = require('./linux');
|
||||
|
||||
/**
|
||||
* A factory creates a parser for parsing output from system ping
|
||||
* @constructor
|
||||
*/
|
||||
function factory() {}
|
||||
|
||||
/**
|
||||
* Create a parser for a given platform
|
||||
* @param {string} addr - Hostname or ip addres
|
||||
* @param {string} platform - Name of the platform
|
||||
* @param {PingConfig} [config] - Config object in probe()
|
||||
* @return {object} - Parser
|
||||
* @throw if given platform is not supported
|
||||
*/
|
||||
factory.createParser = function (addr, platform, config) {
|
||||
// Avoid function reassignment
|
||||
var _config = config || {};
|
||||
|
||||
if (!builderFactory.isPlatformSupport(platform)) {
|
||||
throw new Error(util.format('Platform |%s| is not support', platform));
|
||||
}
|
||||
|
||||
var ret = null;
|
||||
if (builderFactory.isWindow(platform)) {
|
||||
ret = new WinParser(addr, _config);
|
||||
} else if (builderFactory.isMacOS(platform)) {
|
||||
ret = new MacParser(addr, _config);
|
||||
} else if (builderFactory.isLinux(platform)) {
|
||||
ret = new LinuxParser(addr, _config);
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
module.exports = factory;
|
59
node_modules/ping/lib/parser/linux.js
generated
vendored
Normal file
59
node_modules/ping/lib/parser/linux.js
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var base = require('./base');
|
||||
var MacParser = require('./mac');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {string} addr - Hostname or ip addres
|
||||
* @param {PingConfig} config - Config object in probe()
|
||||
*/
|
||||
function LinuxParser(addr, config) {
|
||||
base.call(this, addr, config);
|
||||
}
|
||||
|
||||
util.inherits(LinuxParser, base);
|
||||
|
||||
/**
|
||||
* Process output's body
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
LinuxParser.prototype._processHeader = function (line) {
|
||||
// Get host and numeric_host
|
||||
var tokens = line.split(' ');
|
||||
var isProbablyIPv4 = tokens[1].indexOf('(') === -1;
|
||||
|
||||
if (isProbablyIPv4) {
|
||||
this._response.host = tokens[1];
|
||||
this._response.numeric_host = tokens[2].slice(1, -1);
|
||||
} else {
|
||||
// Normalise into either a 2 or 3 element array
|
||||
var foundAddresses = tokens.slice(1, -3).join('').match(/([^\s()]+)/g);
|
||||
this._response.host = foundAddresses.shift();
|
||||
this._response.numeric_host = foundAddresses.pop();
|
||||
}
|
||||
|
||||
this._changeState(this.STATES.BODY);
|
||||
};
|
||||
|
||||
/**
|
||||
* Process output's body
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
LinuxParser.prototype._processBody = function (line) {
|
||||
// Reuse mac parser implementation
|
||||
MacParser.prototype._processBody.call(this, line);
|
||||
};
|
||||
|
||||
/**
|
||||
* Process output's footer
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
LinuxParser.prototype._processFooter = function (line) {
|
||||
// Reuse mac parser implementation
|
||||
MacParser.prototype._processFooter.call(this, line);
|
||||
};
|
||||
|
||||
module.exports = LinuxParser;
|
85
node_modules/ping/lib/parser/mac.js
generated
vendored
Normal file
85
node_modules/ping/lib/parser/mac.js
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var __ = require('underscore');
|
||||
|
||||
var base = require('./base');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {string} addr - Hostname or ip addres
|
||||
* @param {PingConfig} config - Config object in probe()
|
||||
*/
|
||||
function MacParser(addr, config) {
|
||||
base.call(this, addr, config);
|
||||
}
|
||||
|
||||
util.inherits(MacParser, base);
|
||||
|
||||
/**
|
||||
* Process output's header
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
MacParser.prototype._processHeader = function (line) {
|
||||
// Get host and numeric_host
|
||||
var tokens = line.split(' ');
|
||||
|
||||
this._response.host = tokens[1];
|
||||
this._response.numeric_host = tokens[2].slice(1, -2);
|
||||
|
||||
this._changeState(this.STATES.BODY);
|
||||
};
|
||||
|
||||
/**
|
||||
* Process output's body
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
MacParser.prototype._processBody = function (line) {
|
||||
// XXX: Assume there is at least 3 '=' can be found
|
||||
var count = (line.match(/=/g) || []).length;
|
||||
if (count >= 3) {
|
||||
var regExp = /([0-9.]+)[ ]*ms/;
|
||||
var match = regExp.exec(line);
|
||||
this._times.push(parseFloat(match[1], 10));
|
||||
}
|
||||
|
||||
// Change state if it see a '---'
|
||||
if (line.indexOf('---') >= 0) {
|
||||
this._changeState(this.STATES.FOOTER);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Process output's footer
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
MacParser.prototype._processFooter = function (line) {
|
||||
var packetLoss = line.match(/ ([\d.]+)%/);
|
||||
if (packetLoss) {
|
||||
this._response.packetLoss = parseFloat(packetLoss[1], 10);
|
||||
}
|
||||
|
||||
// XXX: Assume number of keywords '/' more than 3
|
||||
var count = (line.match(/[/]/g) || []).length;
|
||||
if (count >= 3) {
|
||||
var regExp = /([0-9.]+)/g;
|
||||
// XXX: Assume min avg max stddev
|
||||
var m1 = regExp.exec(line);
|
||||
var m2 = regExp.exec(line);
|
||||
var m3 = regExp.exec(line);
|
||||
var m4 = regExp.exec(line);
|
||||
|
||||
if (__.all([m1, m2, m3, m4])) {
|
||||
this._response.min = parseFloat(m1[1], 10);
|
||||
this._response.avg = parseFloat(m2[1], 10);
|
||||
this._response.max = parseFloat(m3[1], 10);
|
||||
this._response.stddev = parseFloat(m4[1], 10);
|
||||
this._changeState(this.STATES.END);
|
||||
}
|
||||
|
||||
this._changeState(this.STATES.END);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = MacParser;
|
179
node_modules/ping/lib/parser/win.js
generated
vendored
Normal file
179
node_modules/ping/lib/parser/win.js
generated
vendored
Normal file
@ -0,0 +1,179 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var __ = require('underscore');
|
||||
|
||||
var base = require('./base');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {string} addr - Hostname or ip addres
|
||||
* @param {PingConfig} config - Config object in probe()
|
||||
*/
|
||||
function WinParser(addr, config) {
|
||||
base.call(this, addr, config);
|
||||
this._ipv4Regex = /^([0-9]{1,3}\.){3}[0-9]{1,3}$/;
|
||||
}
|
||||
|
||||
util.inherits(WinParser, base);
|
||||
|
||||
/**
|
||||
* Process output's header
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
WinParser.prototype._processHeader = function (line) {
|
||||
// XXX: Expect to find [****] when pinging domain like google.com
|
||||
// Read fixture/win/**/* for the detail
|
||||
var isPingNumeric = line.indexOf('[') === -1;
|
||||
|
||||
// Get host and numeric_host
|
||||
var tokens = line.split(' ');
|
||||
|
||||
if (isPingNumeric) {
|
||||
// For those missing [***], get the first token which match IPV4 regex
|
||||
this._response.host = __.find(tokens, function (t) {
|
||||
return this._ipv4Regex.test(t);
|
||||
}, this);
|
||||
this._response.numeric_host = this._response.host;
|
||||
} else {
|
||||
// For those has [***], anchor with such token
|
||||
var numericHost = __.find(tokens, function (t) {
|
||||
return t.indexOf('[') !== -1;
|
||||
}, this);
|
||||
var numericHostIndex = tokens.indexOf(numericHost);
|
||||
var match = /\[(.*)\]/.exec(numericHost);
|
||||
|
||||
if (match) {
|
||||
// Capture IP inside [] only. refs #71
|
||||
this._response.numeric_host = match[1];
|
||||
} else {
|
||||
// Otherwise, just mark as NA to indicate an error
|
||||
this._response.numeric_host = 'NA';
|
||||
}
|
||||
this._response.host = tokens[numericHostIndex - 1];
|
||||
}
|
||||
|
||||
this._changeState(this.STATES.BODY);
|
||||
};
|
||||
|
||||
/**
|
||||
* Process ipv6 output's body
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
WinParser.prototype._processIPV6Body = function (line) {
|
||||
var tokens = line.split(' ');
|
||||
var dataFields = __.filter(tokens, function (token) {
|
||||
var isDataField = token.indexOf('=') >= 0 || token.indexOf('<') >= 0;
|
||||
return isDataField;
|
||||
});
|
||||
|
||||
// refs #65: Support system like french which has an extra space
|
||||
dataFields = __.map(dataFields, function (dataField) {
|
||||
var ret = dataField;
|
||||
var dataFieldIndex = tokens.indexOf(dataField);
|
||||
var nextIndex = dataFieldIndex + 1;
|
||||
|
||||
// Append the missing *ms*
|
||||
if (nextIndex < tokens.length) {
|
||||
if (tokens[nextIndex] === 'ms') {
|
||||
ret += 'ms';
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
});
|
||||
|
||||
var expectDataFieldInReplyLine = 1;
|
||||
if (dataFields.length >= expectDataFieldInReplyLine) {
|
||||
// XXX: Assume time will alaways get keyword ms for all language
|
||||
var timeKVP = __.find(dataFields, function (dataField) {
|
||||
return dataField.search(/(ms|мс)/i) >= 0;
|
||||
});
|
||||
var regExp = /([0-9.]+)/;
|
||||
var match = regExp.exec(timeKVP);
|
||||
|
||||
this._times.push(parseFloat(match[1], 10));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Process ipv4 output's body
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
WinParser.prototype._processIPV4Body = function (line) {
|
||||
var tokens = line.split(' ');
|
||||
var byteTimeTTLFields = __.filter(tokens, function (token) {
|
||||
var isDataField = token.indexOf('=') >= 0 || token.indexOf('<') >= 0;
|
||||
return isDataField;
|
||||
});
|
||||
|
||||
var expectDataFieldInReplyLine = 3;
|
||||
var isReplyLine = byteTimeTTLFields.length >= expectDataFieldInReplyLine;
|
||||
if (isReplyLine) {
|
||||
var packetSize = this._pingConfig.packetSize;
|
||||
var byteField = __.find(byteTimeTTLFields, function (dataField) {
|
||||
var packetSizeToken = util.format('=%d', packetSize);
|
||||
var isByteField = dataField.indexOf(packetSizeToken) >= 0;
|
||||
return isByteField;
|
||||
});
|
||||
|
||||
// XXX: Assume time field will always be next of byte field
|
||||
var byteFieldIndex = byteTimeTTLFields.indexOf(byteField);
|
||||
var timeFieldIndex = byteFieldIndex + 1;
|
||||
var timeKVP = byteTimeTTLFields[timeFieldIndex];
|
||||
|
||||
var regExp = /([0-9.]+)/;
|
||||
var match = regExp.exec(timeKVP);
|
||||
|
||||
this._times.push(parseFloat(match[1], 10));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Process output's body
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
WinParser.prototype._processBody = function (line) {
|
||||
var isPingSummaryLineShown = line.slice(-1) === ':';
|
||||
if (isPingSummaryLineShown) {
|
||||
this._changeState(this.STATES.FOOTER);
|
||||
return;
|
||||
}
|
||||
|
||||
var isIPV6 = this._pingConfig.v6;
|
||||
if (isIPV6) {
|
||||
this._processIPV6Body(line);
|
||||
} else {
|
||||
this._processIPV4Body(line);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Process output's footer
|
||||
* @param {string} line - A line from system ping
|
||||
*/
|
||||
WinParser.prototype._processFooter = function (line) {
|
||||
var packetLoss = line.match(/([\d.]+)%/);
|
||||
if (packetLoss) {
|
||||
this._response.packetLoss = parseFloat(packetLoss[1], 10);
|
||||
}
|
||||
|
||||
// XXX: Assume there is a keyword ms
|
||||
if (line.search(/(ms|мсек)/i) >= 0) {
|
||||
// XXX: Assume the ordering is Min Max Avg
|
||||
var regExp = /([0-9.]+)/g;
|
||||
var m1 = regExp.exec(line);
|
||||
var m2 = regExp.exec(line);
|
||||
var m3 = regExp.exec(line);
|
||||
|
||||
if (__.all([m1, m2, m3])) {
|
||||
this._response.min = parseFloat(m1[1], 10);
|
||||
this._response.max = parseFloat(m2[1], 10);
|
||||
this._response.avg = parseFloat(m3[1], 10);
|
||||
this._changeState(this.STATES.END);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = WinParser;
|
46
node_modules/ping/lib/ping-pcap.js
generated
vendored
Executable file
46
node_modules/ping/lib/ping-pcap.js
generated
vendored
Executable file
@ -0,0 +1,46 @@
|
||||
/* eslint-disable */
|
||||
|
||||
/**
|
||||
* LICENSE MIT
|
||||
* (C) Daniel Zelisko
|
||||
* http://github.com/danielzzz/node-ping
|
||||
*
|
||||
* A poor man's ping for node.js
|
||||
* It uses UDP_scanning (as node is not able to generate iCPM packets)
|
||||
* http://en.wikipedia.org/wiki/Port_scanner#UDP_scanning
|
||||
* it may not work correct for hosts that silently drop UDP traffic on their firewall
|
||||
* you need at pcap version 0.1.9 or higher
|
||||
*
|
||||
*/
|
||||
|
||||
var sys = require("util"),
|
||||
pcap = require('pcap');
|
||||
|
||||
var addr = process.argv[3] || 'localhost';
|
||||
setInterval(function() {probe(addr)}, 1000);
|
||||
|
||||
|
||||
function probe(addr) {
|
||||
sys.puts('sending a probe to ' + addr);
|
||||
var dgram = require('dgram');
|
||||
var message = new Buffer("Some bytes");
|
||||
var client = dgram.createSocket("udp4");
|
||||
client.send(message, 0, message.length, 21111, addr);
|
||||
client.close();
|
||||
}
|
||||
|
||||
// create a pcap session
|
||||
pcap_session = pcap.createSession(process.argv[2] || 'eth0', "");
|
||||
|
||||
|
||||
// listen for packets, decode them, and feed the simple printer
|
||||
pcap_session.addListener('packet', function (raw_packet) {
|
||||
var packet = pcap.decode.packet(raw_packet);
|
||||
if (packet.link && packet.link.ip && packet.link.ip.saddr==addr) {
|
||||
packet.link && packet.link.ip && sys.puts(packet.link.ip.saddr + " is alive");
|
||||
}
|
||||
});
|
||||
|
||||
//-------- example ------------------------
|
||||
|
||||
|
111
node_modules/ping/lib/ping-promise.js
generated
vendored
Normal file
111
node_modules/ping/lib/ping-promise.js
generated
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* LICENSE MIT
|
||||
* (C) Daniel Zelisko
|
||||
* http://github.com/danielzzz/node-ping
|
||||
*
|
||||
* a simple wrapper for ping
|
||||
* Now with support of not only english Windows.
|
||||
*
|
||||
*/
|
||||
|
||||
// System library
|
||||
var util = require('util');
|
||||
var net = require('net');
|
||||
var cp = require('child_process');
|
||||
var os = require('os');
|
||||
|
||||
// 3rd-party library
|
||||
var Q = require('q');
|
||||
var __ = require('underscore');
|
||||
|
||||
// Our library
|
||||
var builderFactory = require('./builder/factory');
|
||||
var parserFactory = require('./parser/factory');
|
||||
|
||||
/**
|
||||
* Refer to probe()
|
||||
*/
|
||||
function _probe(addr, config) {
|
||||
// Do not reassign function argument
|
||||
var _config = config || {};
|
||||
if (_config.v6 === undefined) {
|
||||
_config.v6 = net.isIPv6(addr);
|
||||
}
|
||||
|
||||
// Convert callback base system command to promise base
|
||||
var deferred = Q.defer();
|
||||
|
||||
// Spawn a ping process
|
||||
var ping = null;
|
||||
var platform = os.platform();
|
||||
try {
|
||||
var argumentBuilder = builderFactory.createBuilder(platform);
|
||||
var pingExecutablePath = builderFactory.getExecutablePath(
|
||||
platform, _config.v6
|
||||
);
|
||||
var pingArgs = argumentBuilder.getCommandArguments(addr, _config);
|
||||
var spawnOptions = argumentBuilder.getSpawnOptions();
|
||||
ping = cp.spawn(pingExecutablePath, pingArgs, spawnOptions);
|
||||
} catch (err) {
|
||||
deferred.reject(err);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
// Initial parser
|
||||
var parser = parserFactory.createParser(addr, platform, _config);
|
||||
|
||||
// Register events from system ping
|
||||
ping.once('error', function () {
|
||||
var err = new Error(
|
||||
util.format(
|
||||
'ping.probe: %s. %s',
|
||||
'there was an error while executing the ping program. ',
|
||||
'Check the path or permissions...'
|
||||
)
|
||||
);
|
||||
deferred.reject(err);
|
||||
});
|
||||
|
||||
// Cache all lines from the system ping
|
||||
var outstring = [];
|
||||
ping.stdout.on('data', function (data) {
|
||||
outstring.push(String(data));
|
||||
});
|
||||
|
||||
// Parse lines we have on closing system ping
|
||||
ping.once('close', function () {
|
||||
// Merge lines we have and split it by \n
|
||||
var lines = outstring.join('').split('\n');
|
||||
|
||||
// Parse line one by one
|
||||
__.each(lines, parser.eat, parser);
|
||||
|
||||
// Get result
|
||||
var ret = parser.getResult();
|
||||
|
||||
deferred.resolve(ret);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class::PromisePing
|
||||
* @param {string} addr - Hostname or ip addres
|
||||
* @param {PingConfig} config - Configuration for command ping
|
||||
* @return {Promise}
|
||||
*/
|
||||
function probe(addr, config) {
|
||||
try {
|
||||
var probePromise = _probe(addr, config);
|
||||
return probePromise;
|
||||
} catch (error) {
|
||||
var errorPromise = Q.reject(error);
|
||||
return errorPromise;
|
||||
}
|
||||
}
|
||||
|
||||
exports.probe = probe;
|
44
node_modules/ping/lib/ping-sys.js
generated
vendored
Executable file
44
node_modules/ping/lib/ping-sys.js
generated
vendored
Executable file
@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* LICENSE MIT
|
||||
* (C) Daniel Zelisko
|
||||
* http://github.com/danielzzz/node-ping
|
||||
*
|
||||
* a simple wrapper for ping
|
||||
* Now with support of not only english Windows.
|
||||
*
|
||||
*/
|
||||
|
||||
// Promise implementation
|
||||
var ping = require('./ping-promise');
|
||||
|
||||
// TODO:
|
||||
// 1. Port round trip time to this callback
|
||||
// 2. However, it may breaks backward compatability
|
||||
// 3. Need discussion
|
||||
/**
|
||||
* Callback after probing given host
|
||||
* @callback probeCallback
|
||||
* @param {boolean} isAlive - Whether target is alive or not
|
||||
* @param {Object} error - Null if no error occurs
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class::Ping construtor
|
||||
* @param {string} addr - Hostname or ip addres
|
||||
* @param {probeCallback} cb - Callback
|
||||
* @param {PingConfig} config - Configuration for command ping
|
||||
*/
|
||||
function probe(addr, cb, config) {
|
||||
// Do not reassign function parameter
|
||||
var _config = config || {};
|
||||
|
||||
return ping.probe(addr, _config).then(function (res) {
|
||||
cb(res.alive, null);
|
||||
}).catch(function (err) {
|
||||
cb(null, err);
|
||||
}).done();
|
||||
}
|
||||
|
||||
exports.probe = probe;
|
59
node_modules/ping/package.json
generated
vendored
Normal file
59
node_modules/ping/package.json
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"author": "danielzzz <daniel@zelisko.net> (http://daniel.zelisko.net)",
|
||||
"scripts": {
|
||||
"test": "grunt test"
|
||||
},
|
||||
"contributors": [
|
||||
"Mond Wan <mondwan.1015@gmail.com>",
|
||||
"dougluce <doug@tenousiperochhelical.con.com>",
|
||||
"weihua44",
|
||||
"GermanBluefox",
|
||||
"mabukar",
|
||||
"microacup <xiangmain@gmail.com>",
|
||||
"Andrew Fadeev",
|
||||
"Joshua Pruitt <firefly777@gmail.com>",
|
||||
"Stephan van Rooij <stephan@svrooij.nl> (http://svrooij.nl)",
|
||||
"Krispin Schulz <krispinone@googlemail.com> (http://kr1sp1n.io)",
|
||||
"Kathy Hill",
|
||||
"mrMuppet",
|
||||
"Adam Heath <adam@adamheath.me> (http://www.adamheath.me)",
|
||||
"BlessJah <blessjah@jacekowski.org>",
|
||||
"jritsema"
|
||||
],
|
||||
"name": "ping",
|
||||
"description": "a simple wrapper for ping",
|
||||
"version": "0.4.1",
|
||||
"homepage": "http://github.com/danielzzz/node-ping",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/danielzzz/node-ping.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"q": "1.x",
|
||||
"underscore": "^1.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^10.1.0",
|
||||
"chai": "4.2.0",
|
||||
"eslint": "^7.16.0",
|
||||
"eslint-plugin-jsdoc": "^30.7.9",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-react-hooks": "^4.2.0",
|
||||
"eslint-config-airbnb": "^18.2.1",
|
||||
"eslint-config-eslint": "^6.0.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-jsx-a11y": "^6.4.1",
|
||||
"eslint-plugin-react": "^7.21.5",
|
||||
"glob": "^7.1.6",
|
||||
"grunt": "^1.3.0",
|
||||
"grunt-mocha-test": "^0.13.3",
|
||||
"gruntify-eslint": "^5.0.0",
|
||||
"mocha": "^8.2.1",
|
||||
"sinon": "9.2.2"
|
||||
},
|
||||
"main": "index.js"
|
||||
}
|
304
node_modules/ping/test/fixture/answer.json
generated
vendored
Normal file
304
node_modules/ping/test/fixture/answer.json
generated
vendored
Normal file
@ -0,0 +1,304 @@
|
||||
{
|
||||
"macos_en_sample1": {
|
||||
"inputHost": "whatever",
|
||||
"host": "google.com",
|
||||
"numeric_host": "172.217.24.46",
|
||||
"alive": true,
|
||||
"output": "PING google.com (172.217.24.46): 56 data bytes\n64 bytes from 172.217.24.46: icmp_seq=0 ttl=54 time=5.371 ms\n64 bytes from 172.217.24.46: icmp_seq=1 ttl=54 time=4.269 ms\n64 bytes from 172.217.24.46: icmp_seq=2 ttl=54 time=4.970 ms\n64 bytes from 172.217.24.46: icmp_seq=3 ttl=54 time=5.228 ms\n\n--- google.com ping statistics ---\n4 packets transmitted, 4 packets received, 0.0% packet loss\nround-trip min/avg/max/stddev = 4.269/4.960/5.371/0.424 ms\n",
|
||||
"time": 5.371,
|
||||
"times": [
|
||||
5.371,
|
||||
4.269,
|
||||
4.97,
|
||||
5.228
|
||||
],
|
||||
"min": "4.269",
|
||||
"max": "5.371",
|
||||
"avg": "4.960",
|
||||
"packetLoss": "0.000",
|
||||
"stddev": "0.424"
|
||||
},
|
||||
"linux_en_sample1": {
|
||||
"inputHost": "whatever",
|
||||
"host": "localhost",
|
||||
"numeric_host": "127.0.0.1",
|
||||
"alive": true,
|
||||
"output": "PING localhost (127.0.0.1) 56(84) bytes of data.\n64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.022 ms\n64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.027 ms\n64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.029 ms\n64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.030 ms\n\n--- localhost ping statistics ---\n4 packets transmitted, 4 received, 0% packet loss, time 2999ms\nrtt min/avg/max/mdev = 0.022/0.027/0.030/0.003 ms\n",
|
||||
"time": 0.022,
|
||||
"times": [
|
||||
0.022,
|
||||
0.027,
|
||||
0.029,
|
||||
0.03
|
||||
],
|
||||
"min": "0.022",
|
||||
"max": "0.030",
|
||||
"avg": "0.027",
|
||||
"stddev": "0.003",
|
||||
"packetLoss": "0.000"
|
||||
},
|
||||
"linux_en_sample2": {
|
||||
"inputHost": "whatever",
|
||||
"host": "10.48.249.8",
|
||||
"numeric_host": "10.48.249.8",
|
||||
"alive": true,
|
||||
"output": "PING 10.48.249.8 (10.48.249.8) 56(84) bytes of data.\n64 bytes from 10.48.249.8: icmp_seq=1 ttl=64 time=2.98 ms\n64 bytes from 10.48.249.8: icmp_seq=2 ttl=64 time=0.890 ms\n64 bytes from 10.48.249.8: icmp_seq=3 ttl=64 time=0.711 ms\n64 bytes from 10.48.249.8: icmp_seq=4 ttl=64 time=0.863 ms\n64 bytes from 10.48.249.8: icmp_seq=5 ttl=64 time=1.20 ms\nping: sendmsg: Network is unreachable\nping: sendmsg: Network is unreachable\nping: sendmsg: Network is unreachable\n64 bytes from 10.48.249.8: icmp_seq=14 ttl=64 time=797 ms\n64 bytes from 10.48.249.8: icmp_seq=15 ttl=64 time=3.86 ms\n64 bytes from 10.48.249.8: icmp_seq=16 ttl=64 time=1.62 ms\n64 bytes from 10.48.249.8: icmp_seq=17 ttl=64 time=0.702 ms\n64 bytes from 10.48.249.8: icmp_seq=18 ttl=64 time=0.783 ms\n64 bytes from 10.48.249.8: icmp_seq=19 ttl=64 time=0.646 ms\n\n--- 10.48.249.8 ping statistics ---\n19 packets transmitted, 11 received, 42% packet loss, time 18195ms\nrtt min/avg/max/mdev = 0.646/73.819/797.744/228.927 ms\n",
|
||||
"time": 2.98,
|
||||
"times": [
|
||||
2.98,
|
||||
0.89,
|
||||
0.711,
|
||||
0.863,
|
||||
1.2,
|
||||
797,
|
||||
3.86,
|
||||
1.62,
|
||||
0.702,
|
||||
0.783,
|
||||
0.646
|
||||
],
|
||||
"min": "0.646",
|
||||
"max": "797.744",
|
||||
"avg": "73.819",
|
||||
"packetLoss": "42.000",
|
||||
"stddev": "228.927"
|
||||
},
|
||||
"linux_en_sample3": {
|
||||
"inputHost": "whatever",
|
||||
"host": "10.48.249.150",
|
||||
"numeric_host": "10.48.249.150",
|
||||
"alive": false,
|
||||
"output": "PING 10.48.249.150 (10.48.249.150) 56(84) bytes of data.\nFrom 10.48.249.95 icmp_seq=1 Destination Host Unreachable\nFrom 10.48.249.95 icmp_seq=2 Destination Host Unreachable\nFrom 10.48.249.95 icmp_seq=3 Destination Host Unreachable\n\n--- 10.48.249.150 ping statistics ---\n5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4079ms\n",
|
||||
"time": "unknown",
|
||||
"times": [],
|
||||
"min": "unknown",
|
||||
"max": "unknown",
|
||||
"avg": "unknown",
|
||||
"packetLoss": "100.000",
|
||||
"stddev": "unknown"
|
||||
},
|
||||
"linux_en_v6_sample1": {
|
||||
"inputHost": "whatever",
|
||||
"host": "2606:4700:4700::1111",
|
||||
"numeric_host": "2606:4700:4700::1111",
|
||||
"alive": true,
|
||||
"output": "PING 2606:4700:4700::1111(2606:4700:4700::1111) 56 data bytes\n64 bytes from 2606:4700:4700::1111: icmp_seq=1 ttl=57 time=0.672 ms\n64 bytes from 2606:4700:4700::1111: icmp_seq=2 ttl=57 time=1.00 ms\n\n--- 2606:4700:4700::1111 ping statistics ---\n2 packets transmitted, 2 received, 0% packet loss, time 1000ms\nrtt min/avg/max/mdev = 0.672/0.840/1.009/0.170 ms\n",
|
||||
"time": 0.672,
|
||||
"times": [
|
||||
0.672,
|
||||
1.00
|
||||
],
|
||||
"min": "0.672",
|
||||
"max": "1.009",
|
||||
"avg": "0.840",
|
||||
"packetLoss": "0.000",
|
||||
"stddev": "0.170"
|
||||
},
|
||||
"linux_en_v6_sample2": {
|
||||
"inputHost": "whatever",
|
||||
"host": "one.one.one.one",
|
||||
"numeric_host": "2606:4700:4700::1111",
|
||||
"alive": true,
|
||||
"output": "PING one.one.one.one(one.one.one.one (2606:4700:4700::1111)) 56 data bytes\n64 bytes from one.one.one.one (2606:4700:4700::1111): icmp_seq=1 ttl=60 time=1.66 ms\n64 bytes from one.one.one.one (2606:4700:4700::1111): icmp_seq=2 ttl=60 time=1.42 ms\n\n--- one.one.one.one ping statistics ---\n2 packets transmitted, 2 received, 0% packet loss, time 1001ms\nrtt min/avg/max/mdev = 1.429/1.546/1.663/0.117 ms\n",
|
||||
"time": 1.66,
|
||||
"times": [
|
||||
1.66,
|
||||
1.42
|
||||
],
|
||||
"min": "1.429",
|
||||
"max": "1.663",
|
||||
"avg": "1.546",
|
||||
"packetLoss": "0.000",
|
||||
"stddev": "0.117"
|
||||
},
|
||||
"window_en_sample1": {
|
||||
"inputHost": "whatever",
|
||||
"host": "www.some-domain.com",
|
||||
"numeric_host": "127.0.0.1",
|
||||
"alive": true,
|
||||
"output": "Pinging www.some-domain.com [127.0.0.1] with 32 bytes of\nReply from 127.0.0.1: bytes=32 time=564ms TTL=237\nReply from 127.0.0.1: bytes=32 time=555ms TTL=237\nReply from 127.0.0.1: bytes=32 time=554ms TTL=237\nReply from 127.0.0.1: bytes=32 time=548ms TTL=237\n\nPing statistics for 127.0.0.1:\n Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)\n Approximate round trip times in milli-seconds:\n Minimum = 548ms, Maximum = 564ms, Average = 555ms\n",
|
||||
"time": 564,
|
||||
"times": [
|
||||
564,
|
||||
555,
|
||||
554,
|
||||
548
|
||||
],
|
||||
"min": "548.000",
|
||||
"max": "564.000",
|
||||
"avg": "555.000",
|
||||
"stddev": "5.723",
|
||||
"packetLoss": "0.000",
|
||||
"stddev": "5.723"
|
||||
},
|
||||
"window_fr_sample1": {
|
||||
"inputHost": "whatever",
|
||||
"host": "127.0.0.1",
|
||||
"numeric_host": "127.0.0.1",
|
||||
"alive": true,
|
||||
"output": "Envoi d’une requete 'Ping' 127.0.0.1 avec 32 octets de donnees :\nReponse de 127.0.0.1 : octets=32 temps<1ms TTL=128\nReponse de 127.0.0.1 : octets=32 temps<1ms TTL=128\nReponse de 127.0.0.1 : octets=32 temps<1ms TTL=128\nReponse de 127.0.0.1 : octets=32 temps<1ms TTL=128\n\nStatistiques Ping pour 127.0.0.1:\nPaquets : envoyes = 4, recus = 4, perdus = 0 (perte 0%),\nDuree approximative des boucles en millisecondes :\nMinimum = 0ms, Maximum = 0ms, Moyenne = 0ms\n",
|
||||
"time": 1,
|
||||
"times": [
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"min": "0.000",
|
||||
"max": "0.000",
|
||||
"avg": "0.000",
|
||||
"stddev": "1.000",
|
||||
"packetLoss": "0.000"
|
||||
},
|
||||
"window_fr_sample2": {
|
||||
"inputHost": "whatever",
|
||||
"host": "8.8.8.8",
|
||||
"numeric_host": "8.8.8.8",
|
||||
"alive": true,
|
||||
"output": "Envoi d’une requete 'Ping' 8.8.8.8 avec 32 octets de donnees :\nReponse de 8.8.8.8 : octets=32 temps=6 ms TTL=58\nReponse de 8.8.8.8 : octets=32 temps=6 ms TTL=58\nReponse de 8.8.8.8 : octets=32 temps=6 ms TTL=58\nReponse de 8.8.8.8 : octets=32 temps=6 ms TTL=58\n\nStatistiques Ping pour 8.8.8.8:\nPaquets : envoyes = 4, recus = 4, perdus = 0 (perte 0%),\nDuree approximative des boucles en millisecondes :\nMinimum = 6ms, Maximum = 6ms, Moyenne = 6ms\n",
|
||||
"time": 6,
|
||||
"times": [
|
||||
6,
|
||||
6,
|
||||
6,
|
||||
6
|
||||
],
|
||||
"min": "6.000",
|
||||
"max": "6.000",
|
||||
"avg": "6.000",
|
||||
"stddev": "0.000",
|
||||
"packetLoss": "0.000"
|
||||
},
|
||||
"window_ja_sample1": {
|
||||
"inputHost": "whatever",
|
||||
"host": "google.com",
|
||||
"numeric_host": "216.58.197.142",
|
||||
"alive": true,
|
||||
"output": "google.com [216.58.197.142]に ping を送信しています 32 バイトのデータ:\n216.58.197.142 からの応答: バイト数 =32 時間 =7ms TTL=55\n216.58.197.142 からの応答: バイト数 =32 時間 =5ms TTL=55\n216.58.197.142 からの応答: バイト数 =32 時間 =4ms TTL=55\n216.58.197.142 からの応答: バイト数 =32 時間 =4ms TTL=55\n\n216.58.197.142 の ping 統計:\n パケット数: 送信 = 4、受信 = 4、損失 = 0 (0% の損失)、\nラウンド トリップの概算時間 (ミリ秒):\n 最小 = 4ms、最大 = 7ms、平均 = 5ms\n",
|
||||
"time": 7,
|
||||
"times": [
|
||||
7,
|
||||
5,
|
||||
4,
|
||||
4
|
||||
],
|
||||
"min": "4.000",
|
||||
"max": "7.000",
|
||||
"avg": "5.000",
|
||||
"stddev": "1.225",
|
||||
"packetLoss": "0.000"
|
||||
},
|
||||
"window_ja_sample2": {
|
||||
"inputHost": "whatever",
|
||||
"host": "8.8.8.8",
|
||||
"numeric_host": "8.8.8.8",
|
||||
"alive": true,
|
||||
"output": "8.8.8.8 に ping を送信しています 32 バイトのデータ:\n8.8.8.8 からの応答: バイト数 =32 時間 =4ms TTL=58\n8.8.8.8 からの応答: バイト数 =32 時間 =4ms TTL=58\n8.8.8.8 からの応答: バイト数 =32 時間 =5ms TTL=58\n8.8.8.8 からの応答: バイト数 =32 時間 =6ms TTL=58\n\n8.8.8.8 の ping 統計:\n パケット数: 送信 = 4、受信 = 4、損失 = 0 (0% の損失)、\nラウンド トリップの概算時間 (ミリ秒):\n 最小 = 4ms、最大 = 6ms、平均 = 4ms\n",
|
||||
"time": 4,
|
||||
"times": [
|
||||
4,
|
||||
4,
|
||||
5,
|
||||
6
|
||||
],
|
||||
"min": "4.000",
|
||||
"max": "6.000",
|
||||
"avg": "4.000",
|
||||
"stddev": "1.118",
|
||||
"packetLoss": "0.000"
|
||||
},
|
||||
"window_zh_sample1": {
|
||||
"inputHost": "whatever",
|
||||
"host": "google.com",
|
||||
"numeric_host": "216.58.203.14",
|
||||
"alive": true,
|
||||
"output": "Ping google.com [216.58.203.14] (使用 32 位元組的資料):\n回覆自 216.58.203.14: 位元組=32 時間=2ms TTL=54\n回覆自 216.58.203.14: 位元組=32 時間=2ms TTL=54\n回覆自 216.58.203.14: 位元組=32 時間=3ms TTL=54\n回覆自 216.58.203.14: 位元組=32 時間=3ms TTL=54\n\n216.58.203.14 的 Ping 統計資料:\n 封包: 已傳送 = 4,已收到 = 4, 已遺失 = 0 (0% 遺失),\n 大約的來回時間 (毫秒):\n 最小值 = 2ms,最大值 = 3ms,平均 = 2ms\n",
|
||||
"time": 2,
|
||||
"times": [
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
3
|
||||
],
|
||||
"min": "2.000",
|
||||
"max": "3.000",
|
||||
"avg": "2.000",
|
||||
"stddev": "0.707",
|
||||
"packetLoss": "0.000"
|
||||
},
|
||||
"window_zh_sample2": {
|
||||
"inputHost": "whatever",
|
||||
"host": "google.com",
|
||||
"numeric_host": "216.58.203.14",
|
||||
"alive": true,
|
||||
"output": "\nPing google.com [216.58.203.14] (使用 32 位元組的資料):\n回覆自 216.58.203.14: 位元組=32 時間=2ms TTL=54\n回覆自 216.58.203.14: 位元組=32 時間=2ms TTL=54\n回覆自 216.58.203.14: 位元組=32 時間=3ms TTL=54\n回覆自 216.58.203.14: 位元組=32 時間=3ms TTL=54\n\n216.58.203.14 的 Ping 統計資料:\n 封包: 已傳送 = 4,已收到 = 4, 已遺失 = 0 (0% 遺失),\n 大約的來回時間 (毫秒):\n 最小值 = 2ms,最大值 = 3ms,平均 = 2ms\n",
|
||||
"time": 2,
|
||||
"times": [
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
3
|
||||
],
|
||||
"min": "2.000",
|
||||
"max": "3.000",
|
||||
"avg": "2.000",
|
||||
"stddev": "0.707",
|
||||
"packetLoss": "0.000"
|
||||
},
|
||||
"window_zh_sample3": {
|
||||
"inputHost": "whatever",
|
||||
"host": "127.0.0.1",
|
||||
"numeric_host": "127.0.0.1",
|
||||
"alive": true,
|
||||
"output": "\nPing 127.0.0.1 (使用 32 位元組的資料):\n回覆自 127.0.0.1: 位元組=32 時間<1ms TTL=128\n回覆自 127.0.0.1: 位元組=32 時間<1ms TTL=128\n回覆自 127.0.0.1: 位元組=32 時間<1ms TTL=128\n回覆自 127.0.0.1: 位元組=32 時間<1ms TTL=128\n\n127.0.0.1 的 Ping 統計資料:\n 封包: 已傳送 = 4,已收到 = 4, 已遺失 = 0 (0% 遺失),\n 大約的來回時間 (毫秒):\n 最小值 = 0ms,最大值 = 0ms,平均 = 0ms\n",
|
||||
"time": 1,
|
||||
"times": [
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"min": "0.000",
|
||||
"max": "0.000",
|
||||
"avg": "0.000",
|
||||
"stddev": "1.000",
|
||||
"packetLoss": "0.000"
|
||||
},
|
||||
"window_ru_sample1": {
|
||||
"inputHost": "whatever",
|
||||
"host": "8.8.8.8",
|
||||
"numeric_host": "8.8.8.8",
|
||||
"alive": true,
|
||||
"output": "Обмен пакетами с 8.8.8.8 по с 32 байтами данных:\nОтвет от 8.8.8.8: число байт=32 время=37мс TTL=55\nОтвет от 8.8.8.8: число байт=32 время=33мс TTL=55\nОтвет от 8.8.8.8: число байт=32 время=38мс TTL=55\nОтвет от 8.8.8.8: число байт=32 время=34мс TTL=55\n\nСтатистика Ping для 8.8.8.8:\n Пакетов: отправлено = 4, получено = 4, потеряно = 0\n (0% потерь)\nПриблизительное время приема-передачи в мс:\n Минимальное = 33мсек, Максимальное = 38 мсек, Среднее = 35 мсек",
|
||||
"time": 37,
|
||||
"times": [
|
||||
37,
|
||||
33,
|
||||
38,
|
||||
34
|
||||
],
|
||||
"min": "33.000",
|
||||
"max": "38.000",
|
||||
"avg": "35.000",
|
||||
"stddev": "2.121",
|
||||
"packetLoss": "0.000"
|
||||
},
|
||||
"window_de_v6_sample": {
|
||||
"inputHost": "whatever",
|
||||
"host": "google.de",
|
||||
"alive": true,
|
||||
"output": "Ping wird ausgeführt für google.de [2a00:1450:4001:810::2003] von 3001:4cb0:0:f282:ddf1:bec9:1e0:bfa9 mit 32 Bytes Daten:\nAntwort von 2a00:1450:4001:810::2003: Zeit=11ms\nAntwort von 2a00:1450:4001:810::2003: Zeit=11ms\nAntwort von 2a00:1450:4001:810::2003: Zeit=18ms\nAntwort von 2a00:1450:4001:810::2003: Zeit=11ms\n\nPing-Statistik für 2a00:1450:4001:810::2003:\n Pakete: Gesendet = 4, Empfangen = 4, Verloren = 0\n (0% Verlust),\nCa. Zeitangaben in Millisek.:\n Minimum = 11ms, Maximum = 18ms, Mittelwert = 12ms\n",
|
||||
"time": 11,
|
||||
"times": [
|
||||
11,
|
||||
11,
|
||||
18,
|
||||
11
|
||||
],
|
||||
"min": "11.000",
|
||||
"max": "18.000",
|
||||
"avg": "12.000",
|
||||
"packetLoss": "0.000",
|
||||
"stddev": "3.122",
|
||||
"numeric_host": "2a00:1450:4001:810::2003" }
|
||||
}
|
0
node_modules/ping/test/fixture/linux/.gitdirectory
generated
vendored
Normal file
0
node_modules/ping/test/fixture/linux/.gitdirectory
generated
vendored
Normal file
9
node_modules/ping/test/fixture/linux/en/sample1.txt
generated
vendored
Normal file
9
node_modules/ping/test/fixture/linux/en/sample1.txt
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
PING localhost (127.0.0.1) 56(84) bytes of data.
|
||||
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.022 ms
|
||||
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.027 ms
|
||||
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.029 ms
|
||||
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.030 ms
|
||||
|
||||
--- localhost ping statistics ---
|
||||
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
|
||||
rtt min/avg/max/mdev = 0.022/0.027/0.030/0.003 ms
|
19
node_modules/ping/test/fixture/linux/en/sample2.txt
generated
vendored
Normal file
19
node_modules/ping/test/fixture/linux/en/sample2.txt
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
PING 10.48.249.8 (10.48.249.8) 56(84) bytes of data.
|
||||
64 bytes from 10.48.249.8: icmp_seq=1 ttl=64 time=2.98 ms
|
||||
64 bytes from 10.48.249.8: icmp_seq=2 ttl=64 time=0.890 ms
|
||||
64 bytes from 10.48.249.8: icmp_seq=3 ttl=64 time=0.711 ms
|
||||
64 bytes from 10.48.249.8: icmp_seq=4 ttl=64 time=0.863 ms
|
||||
64 bytes from 10.48.249.8: icmp_seq=5 ttl=64 time=1.20 ms
|
||||
ping: sendmsg: Network is unreachable
|
||||
ping: sendmsg: Network is unreachable
|
||||
ping: sendmsg: Network is unreachable
|
||||
64 bytes from 10.48.249.8: icmp_seq=14 ttl=64 time=797 ms
|
||||
64 bytes from 10.48.249.8: icmp_seq=15 ttl=64 time=3.86 ms
|
||||
64 bytes from 10.48.249.8: icmp_seq=16 ttl=64 time=1.62 ms
|
||||
64 bytes from 10.48.249.8: icmp_seq=17 ttl=64 time=0.702 ms
|
||||
64 bytes from 10.48.249.8: icmp_seq=18 ttl=64 time=0.783 ms
|
||||
64 bytes from 10.48.249.8: icmp_seq=19 ttl=64 time=0.646 ms
|
||||
|
||||
--- 10.48.249.8 ping statistics ---
|
||||
19 packets transmitted, 11 received, 42% packet loss, time 18195ms
|
||||
rtt min/avg/max/mdev = 0.646/73.819/797.744/228.927 ms
|
7
node_modules/ping/test/fixture/linux/en/sample3.txt
generated
vendored
Normal file
7
node_modules/ping/test/fixture/linux/en/sample3.txt
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
PING 10.48.249.150 (10.48.249.150) 56(84) bytes of data.
|
||||
From 10.48.249.95 icmp_seq=1 Destination Host Unreachable
|
||||
From 10.48.249.95 icmp_seq=2 Destination Host Unreachable
|
||||
From 10.48.249.95 icmp_seq=3 Destination Host Unreachable
|
||||
|
||||
--- 10.48.249.150 ping statistics ---
|
||||
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4079ms
|
7
node_modules/ping/test/fixture/linux/en/v6_sample1.txt
generated
vendored
Normal file
7
node_modules/ping/test/fixture/linux/en/v6_sample1.txt
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
PING 2606:4700:4700::1111(2606:4700:4700::1111) 56 data bytes
|
||||
64 bytes from 2606:4700:4700::1111: icmp_seq=1 ttl=57 time=0.672 ms
|
||||
64 bytes from 2606:4700:4700::1111: icmp_seq=2 ttl=57 time=1.00 ms
|
||||
|
||||
--- 2606:4700:4700::1111 ping statistics ---
|
||||
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
|
||||
rtt min/avg/max/mdev = 0.672/0.840/1.009/0.170 ms
|
7
node_modules/ping/test/fixture/linux/en/v6_sample2.txt
generated
vendored
Normal file
7
node_modules/ping/test/fixture/linux/en/v6_sample2.txt
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
PING one.one.one.one(one.one.one.one (2606:4700:4700::1111)) 56 data bytes
|
||||
64 bytes from one.one.one.one (2606:4700:4700::1111): icmp_seq=1 ttl=60 time=1.66 ms
|
||||
64 bytes from one.one.one.one (2606:4700:4700::1111): icmp_seq=2 ttl=60 time=1.42 ms
|
||||
|
||||
--- one.one.one.one ping statistics ---
|
||||
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
|
||||
rtt min/avg/max/mdev = 1.429/1.546/1.663/0.117 ms
|
0
node_modules/ping/test/fixture/macos/.gitdirectory
generated
vendored
Normal file
0
node_modules/ping/test/fixture/macos/.gitdirectory
generated
vendored
Normal file
9
node_modules/ping/test/fixture/macos/en/sample1.txt
generated
vendored
Normal file
9
node_modules/ping/test/fixture/macos/en/sample1.txt
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
PING google.com (172.217.24.46): 56 data bytes
|
||||
64 bytes from 172.217.24.46: icmp_seq=0 ttl=54 time=5.371 ms
|
||||
64 bytes from 172.217.24.46: icmp_seq=1 ttl=54 time=4.269 ms
|
||||
64 bytes from 172.217.24.46: icmp_seq=2 ttl=54 time=4.970 ms
|
||||
64 bytes from 172.217.24.46: icmp_seq=3 ttl=54 time=5.228 ms
|
||||
|
||||
--- google.com ping statistics ---
|
||||
4 packets transmitted, 4 packets received, 0.0% packet loss
|
||||
round-trip min/avg/max/stddev = 4.269/4.960/5.371/0.424 ms
|
0
node_modules/ping/test/fixture/window/.gitdirectory
generated
vendored
Normal file
0
node_modules/ping/test/fixture/window/.gitdirectory
generated
vendored
Normal file
11
node_modules/ping/test/fixture/window/de/v6_sample.txt
generated
vendored
Normal file
11
node_modules/ping/test/fixture/window/de/v6_sample.txt
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
Ping wird ausgeführt für google.de [2a00:1450:4001:810::2003] von 3001:4cb0:0:f282:ddf1:bec9:1e0:bfa9 mit 32 Bytes Daten:
|
||||
Antwort von 2a00:1450:4001:810::2003: Zeit=11ms
|
||||
Antwort von 2a00:1450:4001:810::2003: Zeit=11ms
|
||||
Antwort von 2a00:1450:4001:810::2003: Zeit=18ms
|
||||
Antwort von 2a00:1450:4001:810::2003: Zeit=11ms
|
||||
|
||||
Ping-Statistik für 2a00:1450:4001:810::2003:
|
||||
Pakete: Gesendet = 4, Empfangen = 4, Verloren = 0
|
||||
(0% Verlust),
|
||||
Ca. Zeitangaben in Millisek.:
|
||||
Minimum = 11ms, Maximum = 18ms, Mittelwert = 12ms
|
10
node_modules/ping/test/fixture/window/en/sample1.txt
generated
vendored
Normal file
10
node_modules/ping/test/fixture/window/en/sample1.txt
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
Pinging www.some-domain.com [127.0.0.1] with 32 bytes of
|
||||
Reply from 127.0.0.1: bytes=32 time=564ms TTL=237
|
||||
Reply from 127.0.0.1: bytes=32 time=555ms TTL=237
|
||||
Reply from 127.0.0.1: bytes=32 time=554ms TTL=237
|
||||
Reply from 127.0.0.1: bytes=32 time=548ms TTL=237
|
||||
|
||||
Ping statistics for 127.0.0.1:
|
||||
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)
|
||||
Approximate round trip times in milli-seconds:
|
||||
Minimum = 548ms, Maximum = 564ms, Average = 555ms
|
10
node_modules/ping/test/fixture/window/fr/sample1.txt
generated
vendored
Normal file
10
node_modules/ping/test/fixture/window/fr/sample1.txt
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
Envoi d’une requete 'Ping' 127.0.0.1 avec 32 octets de donnees :
|
||||
Reponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
|
||||
Reponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
|
||||
Reponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
|
||||
Reponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
|
||||
|
||||
Statistiques Ping pour 127.0.0.1:
|
||||
Paquets : envoyes = 4, recus = 4, perdus = 0 (perte 0%),
|
||||
Duree approximative des boucles en millisecondes :
|
||||
Minimum = 0ms, Maximum = 0ms, Moyenne = 0ms
|
10
node_modules/ping/test/fixture/window/fr/sample2.txt
generated
vendored
Normal file
10
node_modules/ping/test/fixture/window/fr/sample2.txt
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
Envoi d’une requete 'Ping' 8.8.8.8 avec 32 octets de donnees :
|
||||
Reponse de 8.8.8.8 : octets=32 temps=6 ms TTL=58
|
||||
Reponse de 8.8.8.8 : octets=32 temps=6 ms TTL=58
|
||||
Reponse de 8.8.8.8 : octets=32 temps=6 ms TTL=58
|
||||
Reponse de 8.8.8.8 : octets=32 temps=6 ms TTL=58
|
||||
|
||||
Statistiques Ping pour 8.8.8.8:
|
||||
Paquets : envoyes = 4, recus = 4, perdus = 0 (perte 0%),
|
||||
Duree approximative des boucles en millisecondes :
|
||||
Minimum = 6ms, Maximum = 6ms, Moyenne = 6ms
|
10
node_modules/ping/test/fixture/window/ja/sample1.txt
generated
vendored
Normal file
10
node_modules/ping/test/fixture/window/ja/sample1.txt
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
google.com [216.58.197.142]に ping を送信しています 32 バイトのデータ:
|
||||
216.58.197.142 からの応答: バイト数 =32 時間 =7ms TTL=55
|
||||
216.58.197.142 からの応答: バイト数 =32 時間 =5ms TTL=55
|
||||
216.58.197.142 からの応答: バイト数 =32 時間 =4ms TTL=55
|
||||
216.58.197.142 からの応答: バイト数 =32 時間 =4ms TTL=55
|
||||
|
||||
216.58.197.142 の ping 統計:
|
||||
パケット数: 送信 = 4、受信 = 4、損失 = 0 (0% の損失)、
|
||||
ラウンド トリップの概算時間 (ミリ秒):
|
||||
最小 = 4ms、最大 = 7ms、平均 = 5ms
|
10
node_modules/ping/test/fixture/window/ja/sample2.txt
generated
vendored
Normal file
10
node_modules/ping/test/fixture/window/ja/sample2.txt
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
8.8.8.8 に ping を送信しています 32 バイトのデータ:
|
||||
8.8.8.8 からの応答: バイト数 =32 時間 =4ms TTL=58
|
||||
8.8.8.8 からの応答: バイト数 =32 時間 =4ms TTL=58
|
||||
8.8.8.8 からの応答: バイト数 =32 時間 =5ms TTL=58
|
||||
8.8.8.8 からの応答: バイト数 =32 時間 =6ms TTL=58
|
||||
|
||||
8.8.8.8 の ping 統計:
|
||||
パケット数: 送信 = 4、受信 = 4、損失 = 0 (0% の損失)、
|
||||
ラウンド トリップの概算時間 (ミリ秒):
|
||||
最小 = 4ms、最大 = 6ms、平均 = 4ms
|
11
node_modules/ping/test/fixture/window/ru/sample1.txt
generated
vendored
Normal file
11
node_modules/ping/test/fixture/window/ru/sample1.txt
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
Обмен пакетами с 8.8.8.8 по с 32 байтами данных:
|
||||
Ответ от 8.8.8.8: число байт=32 время=37мс TTL=55
|
||||
Ответ от 8.8.8.8: число байт=32 время=33мс TTL=55
|
||||
Ответ от 8.8.8.8: число байт=32 время=38мс TTL=55
|
||||
Ответ от 8.8.8.8: число байт=32 время=34мс TTL=55
|
||||
|
||||
Статистика Ping для 8.8.8.8:
|
||||
Пакетов: отправлено = 4, получено = 4, потеряно = 0
|
||||
(0% потерь)
|
||||
Приблизительное время приема-передачи в мс:
|
||||
Минимальное = 33мсек, Максимальное = 38 мсек, Среднее = 35 мсек
|
10
node_modules/ping/test/fixture/window/zh/sample1.txt
generated
vendored
Normal file
10
node_modules/ping/test/fixture/window/zh/sample1.txt
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
Ping google.com [216.58.203.14] (使用 32 位元組的資料):
|
||||
回覆自 216.58.203.14: 位元組=32 時間=2ms TTL=54
|
||||
回覆自 216.58.203.14: 位元組=32 時間=2ms TTL=54
|
||||
回覆自 216.58.203.14: 位元組=32 時間=3ms TTL=54
|
||||
回覆自 216.58.203.14: 位元組=32 時間=3ms TTL=54
|
||||
|
||||
216.58.203.14 的 Ping 統計資料:
|
||||
封包: 已傳送 = 4,已收到 = 4, 已遺失 = 0 (0% 遺失),
|
||||
大約的來回時間 (毫秒):
|
||||
最小值 = 2ms,最大值 = 3ms,平均 = 2ms
|
11
node_modules/ping/test/fixture/window/zh/sample2.txt
generated
vendored
Normal file
11
node_modules/ping/test/fixture/window/zh/sample2.txt
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
Ping google.com [216.58.203.14] (使用 32 位元組的資料):
|
||||
回覆自 216.58.203.14: 位元組=32 時間=2ms TTL=54
|
||||
回覆自 216.58.203.14: 位元組=32 時間=2ms TTL=54
|
||||
回覆自 216.58.203.14: 位元組=32 時間=3ms TTL=54
|
||||
回覆自 216.58.203.14: 位元組=32 時間=3ms TTL=54
|
||||
|
||||
216.58.203.14 的 Ping 統計資料:
|
||||
封包: 已傳送 = 4,已收到 = 4, 已遺失 = 0 (0% 遺失),
|
||||
大約的來回時間 (毫秒):
|
||||
最小值 = 2ms,最大值 = 3ms,平均 = 2ms
|
11
node_modules/ping/test/fixture/window/zh/sample3.txt
generated
vendored
Normal file
11
node_modules/ping/test/fixture/window/zh/sample3.txt
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
Ping 127.0.0.1 (使用 32 位元組的資料):
|
||||
回覆自 127.0.0.1: 位元組=32 時間<1ms TTL=128
|
||||
回覆自 127.0.0.1: 位元組=32 時間<1ms TTL=128
|
||||
回覆自 127.0.0.1: 位元組=32 時間<1ms TTL=128
|
||||
回覆自 127.0.0.1: 位元組=32 時間<1ms TTL=128
|
||||
|
||||
127.0.0.1 的 Ping 統計資料:
|
||||
封包: 已傳送 = 4,已收到 = 4, 已遺失 = 0 (0% 遺失),
|
||||
大約的來回時間 (毫秒):
|
||||
最小值 = 0ms,最大值 = 0ms,平均 = 0ms
|
62
node_modules/ping/test/load-fixture-path.js
generated
vendored
Normal file
62
node_modules/ping/test/load-fixture-path.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var glob = require('glob');
|
||||
|
||||
/**
|
||||
* Check out linux platform
|
||||
*/
|
||||
function isLinux(p) {
|
||||
var platforms = [
|
||||
'aix',
|
||||
'android',
|
||||
'linux',
|
||||
];
|
||||
|
||||
return platforms.indexOf(p) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check out macos platform
|
||||
*/
|
||||
function isMacOS(p) {
|
||||
var platforms = [
|
||||
'darwin',
|
||||
'freebsd',
|
||||
];
|
||||
|
||||
return platforms.indexOf(p) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check out window platform
|
||||
*/
|
||||
function isWindow(p) {
|
||||
return p && p.match(/^win/) !== null;
|
||||
}
|
||||
|
||||
module.exports = function (platform) {
|
||||
var dirname = null;
|
||||
|
||||
if (isLinux(platform)) {
|
||||
dirname = 'linux';
|
||||
} else if (isMacOS(platform)) {
|
||||
dirname = 'macos';
|
||||
} else if (isWindow(platform)) {
|
||||
dirname = 'window';
|
||||
}
|
||||
|
||||
var currentDirectory = path.dirname(__filename);
|
||||
|
||||
var targetDirectory = [currentDirectory, 'fixture'];
|
||||
if (dirname) {
|
||||
targetDirectory.push(dirname);
|
||||
}
|
||||
targetDirectory = targetDirectory.concat([
|
||||
'**',
|
||||
'*.txt',
|
||||
]);
|
||||
targetDirectory = path.posix.join.apply(path.posix, targetDirectory);
|
||||
|
||||
return glob.sync(targetDirectory);
|
||||
};
|
331
node_modules/ping/test/test-ping.js
generated
vendored
Normal file
331
node_modules/ping/test/test-ping.js
generated
vendored
Normal file
@ -0,0 +1,331 @@
|
||||
'use strict';
|
||||
|
||||
/* global describe it before after*/
|
||||
/* eslint no-unused-expressions: 0 */
|
||||
|
||||
var expect = require('chai').expect;
|
||||
var sinon = require('sinon');
|
||||
var os = require('os');
|
||||
var cp = require('child_process');
|
||||
var q = require('q');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var util = require('util');
|
||||
var events = require('events');
|
||||
|
||||
var loadFixturePath = require('./load-fixture-path');
|
||||
var ping = require('..');
|
||||
|
||||
// Some constants
|
||||
var ANSWER = require('./fixture/answer');
|
||||
|
||||
var PLATFORMS = [
|
||||
'window',
|
||||
'darwin',
|
||||
'freebsd',
|
||||
// 'aix',
|
||||
'android',
|
||||
'linux',
|
||||
];
|
||||
var PLATFORM_TO_EXTRA_ARGUMENTS = {
|
||||
window: ['-n', '2'],
|
||||
darwin: ['-c', '2'],
|
||||
freebsd: ['-c', '2'],
|
||||
android: ['-c', '2'],
|
||||
linux: ['-c', '2'],
|
||||
};
|
||||
|
||||
var pathToAnswerKey = function (p) {
|
||||
var basename = path.posix.basename(p, '.txt');
|
||||
var dirname = path.posix.basename(path.posix.dirname(p));
|
||||
var osname = path.posix.basename(
|
||||
path.posix.dirname(path.posix.dirname(p))
|
||||
);
|
||||
|
||||
return [osname, dirname, basename].join('_');
|
||||
};
|
||||
|
||||
var mockOutSpawn = function (fp) {
|
||||
return function () {
|
||||
var e = new events.EventEmitter();
|
||||
e.stdout = e;
|
||||
|
||||
var s = fs.createReadStream(fp);
|
||||
s.on('data', function (line) {
|
||||
e.emit('data', line);
|
||||
});
|
||||
s.on('close', function () {
|
||||
e.emit('close', 0);
|
||||
});
|
||||
|
||||
return e;
|
||||
};
|
||||
};
|
||||
|
||||
var createTestCase = function (platform, pingExecution) {
|
||||
var stubs = [];
|
||||
|
||||
describe(util.format('On %s platform', platform), function () {
|
||||
var fixturePaths = loadFixturePath(platform);
|
||||
|
||||
before(function () {
|
||||
stubs.push(
|
||||
sinon.stub(os, 'platform').callsFake(function () { return platform; })
|
||||
);
|
||||
});
|
||||
|
||||
after(function () {
|
||||
stubs.forEach(function (stub) {
|
||||
stub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
describe('runs with default config', function () {
|
||||
fixturePaths.forEach(function (fp) {
|
||||
it(
|
||||
util.format('Using |%s|', pathToAnswerKey(fp)),
|
||||
function () {
|
||||
return pingExecution(fp);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('runs with custom config', function () {
|
||||
fixturePaths.forEach(function (fp) {
|
||||
it(
|
||||
util.format('Using |%s|', pathToAnswerKey(fp)),
|
||||
function () {
|
||||
return pingExecution(fp, {
|
||||
timeout: 10,
|
||||
extra: PLATFORM_TO_EXTRA_ARGUMENTS[platform],
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('runs with custom config with default gone', function () {
|
||||
fixturePaths.forEach(function (fp) {
|
||||
it(
|
||||
util.format('Using |%s|', pathToAnswerKey(fp)),
|
||||
function () {
|
||||
return pingExecution(fp, {
|
||||
timeout: false,
|
||||
extra: PLATFORM_TO_EXTRA_ARGUMENTS[platform],
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
describe('ping timeout and deadline options', function () {
|
||||
describe('on linux platform', function () {
|
||||
beforeEach(function () {
|
||||
this.platformStub = sinon.stub(os, 'platform').callsFake(function () { return 'linux'; });
|
||||
const fixturePath = path.join(__dirname, 'fixture',
|
||||
'linux', 'en', 'sample1.txt');
|
||||
this.spawnStub = sinon.stub(cp, 'spawn').callsFake(mockOutSpawn(fixturePath));
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
this.platformStub.restore();
|
||||
this.spawnStub.restore();
|
||||
});
|
||||
|
||||
it('are forwarded to the ping binary', function () {
|
||||
return ping.promise.probe('whatever', {
|
||||
timeout: 47,
|
||||
deadline: 83,
|
||||
}).then(function () {
|
||||
const spawnArgs = this.spawnStub.getCalls()[0].args;
|
||||
const pingArgs = spawnArgs[1];
|
||||
expect(pingArgs[pingArgs.indexOf('-W') + 1]).to.equal('47');
|
||||
expect(pingArgs[pingArgs.indexOf('-w') + 1]).to.equal('83');
|
||||
}.bind(this));
|
||||
});
|
||||
});
|
||||
|
||||
describe('on windows platform', function () {
|
||||
beforeEach(function () {
|
||||
this.platformStub = sinon.stub(os, 'platform').callsFake(function () { return 'window'; });
|
||||
const fixturePath = path.join(__dirname, 'fixture',
|
||||
'window', 'en', 'sample1.txt');
|
||||
this.spawnStub = sinon.stub(cp, 'spawn').callsFake(mockOutSpawn(fixturePath));
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
this.platformStub.restore();
|
||||
this.spawnStub.restore();
|
||||
});
|
||||
|
||||
it('results in an error as deadline is not supported', function () {
|
||||
return ping.promise.probe('whatever', {
|
||||
timeout: 47,
|
||||
deadline: 83,
|
||||
}).then(function () {
|
||||
throw new Error('deadline should result in an error');
|
||||
}).catch(function () {});
|
||||
});
|
||||
});
|
||||
|
||||
describe('on mac platform', function () {
|
||||
beforeEach(function () {
|
||||
this.platformStub = sinon.stub(os, 'platform').callsFake(function () { return 'freebsd'; });
|
||||
const fixturePath = path.join(__dirname, 'fixture',
|
||||
'macos', 'en', 'sample1.txt');
|
||||
this.spawnStub = sinon.stub(cp, 'spawn').callsFake(mockOutSpawn(fixturePath));
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
this.platformStub.restore();
|
||||
this.spawnStub.restore();
|
||||
});
|
||||
|
||||
it('are forwarded to the ping binary', function () {
|
||||
return ping.promise.probe('whatever', {
|
||||
timeout: 47,
|
||||
deadline: 83,
|
||||
}).then(function () {
|
||||
const spawnArgs = this.spawnStub.getCalls()[0].args;
|
||||
const pingArgs = spawnArgs[1];
|
||||
expect(pingArgs[pingArgs.indexOf('-W') + 1]).to.equal('47000');
|
||||
expect(pingArgs[pingArgs.indexOf('-t') + 1]).to.equal('83');
|
||||
}.bind(this));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Ping in callback mode', function () {
|
||||
var pingExecution = function (fp, args) {
|
||||
var deferred = q.defer();
|
||||
|
||||
var stub = sinon.stub(cp, 'spawn').callsFake(mockOutSpawn(fp));
|
||||
|
||||
var cb = function (isAlive, err) {
|
||||
if (err) {
|
||||
deferred.reject(err);
|
||||
} else {
|
||||
deferred.resolve(isAlive);
|
||||
}
|
||||
};
|
||||
|
||||
var _args = args;
|
||||
if (fp.includes('v6')) {
|
||||
_args = _args || {};
|
||||
_args.v6 = true;
|
||||
}
|
||||
|
||||
ping.sys.probe('whatever', cb, _args);
|
||||
|
||||
stub.restore();
|
||||
|
||||
return deferred.promise.then(function (data) {
|
||||
var answerKey = pathToAnswerKey(fp);
|
||||
var actualIsAlive = data;
|
||||
var expectIsAlive = ANSWER[answerKey].alive;
|
||||
expect(actualIsAlive).to.equal(expectIsAlive);
|
||||
});
|
||||
};
|
||||
|
||||
PLATFORMS.forEach(function (platform) {
|
||||
createTestCase(platform, pingExecution);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Ping in promise mode', function () {
|
||||
var pingExecution = function (fp, args) {
|
||||
var stub = sinon.stub(cp, 'spawn').callsFake(mockOutSpawn(fp));
|
||||
|
||||
var ret = null;
|
||||
var _args = args;
|
||||
if (fp.includes('v6')) {
|
||||
_args = _args || {};
|
||||
_args.v6 = true;
|
||||
}
|
||||
ret = ping.promise.probe('whatever', _args);
|
||||
|
||||
stub.restore();
|
||||
|
||||
return ret.then(function (data) {
|
||||
var answerKey = pathToAnswerKey(fp);
|
||||
var actualData = data;
|
||||
var expectData = ANSWER[answerKey];
|
||||
expect(actualData).to.deep.equal(expectData);
|
||||
});
|
||||
};
|
||||
|
||||
PLATFORMS.forEach(function (platform) {
|
||||
createTestCase(platform, pingExecution);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Ping ipv6 on MAC OS', function () {
|
||||
var platform = 'darwin';
|
||||
var stubs = [];
|
||||
|
||||
before(function () {
|
||||
stubs.push(
|
||||
sinon.stub(os, 'platform').callsFake(function () { return platform; })
|
||||
);
|
||||
});
|
||||
|
||||
after(function () {
|
||||
stubs.forEach(function (stub) {
|
||||
stub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
describe('With timeout setting', function () {
|
||||
var fixturePaths = loadFixturePath(platform);
|
||||
|
||||
fixturePaths.forEach(function (fp) {
|
||||
it('Should raise an error', function (done) {
|
||||
var stub = sinon.stub(cp, 'spawn').callsFake(mockOutSpawn(fp));
|
||||
|
||||
var ret = ping.promise.probe(
|
||||
'whatever',
|
||||
{v6: true, timeout: 10}
|
||||
);
|
||||
|
||||
stub.restore();
|
||||
|
||||
ret.then(function () {
|
||||
done(new Error('It should not be success'));
|
||||
}).catch(function (err) {
|
||||
expect(err.message).to.be.a('string');
|
||||
expect(err.message).to.include('no timeout option');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Ping in promise mode with unknown exception', function () {
|
||||
var pingExecution = function (fp, args) {
|
||||
var unknownException = new Error('Unknown error!');
|
||||
var stub = sinon.stub(cp, 'spawn').throws(unknownException);
|
||||
|
||||
var ret = null;
|
||||
var _args = args;
|
||||
if (fp.includes('v6')) {
|
||||
_args = _args || {};
|
||||
_args.v6 = true;
|
||||
}
|
||||
ret = ping.promise.probe('whatever', _args);
|
||||
|
||||
stub.restore();
|
||||
|
||||
return ret.catch(function (err) {
|
||||
expect(err.message).to.be.a('string');
|
||||
expect(err.message).to.include('Unknown error!');
|
||||
});
|
||||
};
|
||||
|
||||
PLATFORMS.forEach(function (platform) {
|
||||
createTestCase(platform, pingExecution);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user