pingman 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +211 -204
- package/dist/src/builder/builder.d.ts +3 -3
- package/dist/src/builder/builder.js +30 -30
- package/dist/src/builder/linux.d.ts +3 -3
- package/dist/src/builder/linux.js +82 -82
- package/dist/src/builder/mac.d.ts +3 -3
- package/dist/src/builder/mac.js +88 -88
- package/dist/src/builder/windows.d.ts +3 -3
- package/dist/src/builder/windows.js +93 -93
- package/dist/src/errors.d.ts +10 -10
- package/dist/src/errors.js +25 -25
- package/dist/src/helper.d.ts +2 -2
- package/dist/src/helper.js +33 -33
- package/dist/src/helper.js.map +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +56 -56
- package/dist/src/log.d.ts +7 -7
- package/dist/src/log.js +25 -25
- package/dist/src/messages.d.ts +9 -9
- package/dist/src/messages.js +12 -12
- package/dist/src/parser/clonePingResponse.d.ts +3 -3
- package/dist/src/parser/clonePingResponse.js +20 -20
- package/dist/src/parser/linux.d.ts +7 -7
- package/dist/src/parser/linux.js +30 -30
- package/dist/src/parser/mac.d.ts +11 -11
- package/dist/src/parser/mac.js +46 -46
- package/dist/src/parser/parser.interface.d.ts +8 -8
- package/dist/src/parser/parser.interface.js +2 -2
- package/dist/src/parser/parserFactory.d.ts +3 -3
- package/dist/src/parser/parserFactory.js +124 -124
- package/dist/src/parser/windows.d.ts +13 -13
- package/dist/src/parser/windows.js +110 -110
- package/dist/src/ping.d.ts +3 -3
- package/dist/src/ping.js +22 -22
- package/dist/src/types.d.ts +44 -44
- package/dist/src/types.js +2 -2
- package/package.json +58 -58
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const messages_1 = require("../messages");
|
|
4
|
-
const process_1 = require("process");
|
|
5
|
-
const linux = (ip, options) => {
|
|
6
|
-
let defaultNumberOfEchoes = '4';
|
|
7
|
-
let args = [];
|
|
8
|
-
let buildCommand = {
|
|
9
|
-
command: 'ping',
|
|
10
|
-
arguments: args
|
|
11
|
-
};
|
|
12
|
-
//NO Allowing Unsanitized user input into spawn.Checking each param and assigning
|
|
13
|
-
if (!options) {
|
|
14
|
-
buildCommand.arguments.push('-c', defaultNumberOfEchoes);
|
|
15
|
-
args.push(ip);
|
|
16
|
-
return buildCommand;
|
|
17
|
-
}
|
|
18
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.numberOfEchos) === 'number') {
|
|
19
|
-
args.push('-c', options.numberOfEchos.toString());
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
args.push('-c', defaultNumberOfEchoes);
|
|
23
|
-
}
|
|
24
|
-
if (options === null || options === void 0 ? void 0 : options.soDebugOption) {
|
|
25
|
-
args.push('-d');
|
|
26
|
-
}
|
|
27
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
|
|
28
|
-
if (options === null || options === void 0 ? void 0 : options.floodPing) {
|
|
29
|
-
args.push('-f');
|
|
30
|
-
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning'); //Catch the warning and process it
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (options === null || options === void 0 ? void 0 : options.floodPing) {
|
|
37
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
|
|
38
|
-
args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
|
|
39
|
-
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
args.push('-f');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.interfaceAddress) === 'string') {
|
|
46
|
-
args.push('-I', options.interfaceAddress);
|
|
47
|
-
}
|
|
48
|
-
if (options === null || options === void 0 ? void 0 : options.suppressLoopback) {
|
|
49
|
-
args.push('-L');
|
|
50
|
-
}
|
|
51
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.TTL) === 'number') {
|
|
52
|
-
args.push('-t', options.TTL.toString());
|
|
53
|
-
}
|
|
54
|
-
if (options === null || options === void 0 ? void 0 : options.numeric) {
|
|
55
|
-
args.push('-n');
|
|
56
|
-
}
|
|
57
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.pattern) === 'string') {
|
|
58
|
-
args.push('-p', options.pattern);
|
|
59
|
-
}
|
|
60
|
-
if (options === null || options === void 0 ? void 0 : options.quiet) {
|
|
61
|
-
args.push('-q');
|
|
62
|
-
}
|
|
63
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.bufferSize) === 'number') {
|
|
64
|
-
args.push('-s', options.bufferSize.toString());
|
|
65
|
-
}
|
|
66
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.timeBeforeExit) === 'number') {
|
|
67
|
-
args.push('-W', options.timeBeforeExit.toString());
|
|
68
|
-
}
|
|
69
|
-
if (options === null || options === void 0 ? void 0 : options.verboseOutput) {
|
|
70
|
-
args.push('-v');
|
|
71
|
-
}
|
|
72
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.timeout) === 'number') {
|
|
73
|
-
args.push('-w', options.timeout.toString());
|
|
74
|
-
}
|
|
75
|
-
if (options === null || options === void 0 ? void 0 : options.IPV6) {
|
|
76
|
-
buildCommand.command = 'ping6';
|
|
77
|
-
}
|
|
78
|
-
args.push(ip);
|
|
79
|
-
buildCommand.arguments = args;
|
|
80
|
-
return buildCommand;
|
|
81
|
-
};
|
|
82
|
-
exports.default = linux;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const messages_1 = require("../messages");
|
|
4
|
+
const process_1 = require("process");
|
|
5
|
+
const linux = (ip, options) => {
|
|
6
|
+
let defaultNumberOfEchoes = '4';
|
|
7
|
+
let args = [];
|
|
8
|
+
let buildCommand = {
|
|
9
|
+
command: 'ping',
|
|
10
|
+
arguments: args
|
|
11
|
+
};
|
|
12
|
+
//NO Allowing Unsanitized user input into spawn.Checking each param and assigning
|
|
13
|
+
if (!options) {
|
|
14
|
+
buildCommand.arguments.push('-c', defaultNumberOfEchoes);
|
|
15
|
+
args.push(ip);
|
|
16
|
+
return buildCommand;
|
|
17
|
+
}
|
|
18
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.numberOfEchos) === 'number') {
|
|
19
|
+
args.push('-c', options.numberOfEchos.toString());
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
args.push('-c', defaultNumberOfEchoes);
|
|
23
|
+
}
|
|
24
|
+
if (options === null || options === void 0 ? void 0 : options.soDebugOption) {
|
|
25
|
+
args.push('-d');
|
|
26
|
+
}
|
|
27
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
|
|
28
|
+
if (options === null || options === void 0 ? void 0 : options.floodPing) {
|
|
29
|
+
args.push('-f');
|
|
30
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning'); //Catch the warning and process it
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (options === null || options === void 0 ? void 0 : options.floodPing) {
|
|
37
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
|
|
38
|
+
args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
|
|
39
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
args.push('-f');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.interfaceAddress) === 'string') {
|
|
46
|
+
args.push('-I', options.interfaceAddress);
|
|
47
|
+
}
|
|
48
|
+
if (options === null || options === void 0 ? void 0 : options.suppressLoopback) {
|
|
49
|
+
args.push('-L');
|
|
50
|
+
}
|
|
51
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.TTL) === 'number') {
|
|
52
|
+
args.push('-t', options.TTL.toString());
|
|
53
|
+
}
|
|
54
|
+
if (options === null || options === void 0 ? void 0 : options.numeric) {
|
|
55
|
+
args.push('-n');
|
|
56
|
+
}
|
|
57
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.pattern) === 'string') {
|
|
58
|
+
args.push('-p', options.pattern);
|
|
59
|
+
}
|
|
60
|
+
if (options === null || options === void 0 ? void 0 : options.quiet) {
|
|
61
|
+
args.push('-q');
|
|
62
|
+
}
|
|
63
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.bufferSize) === 'number') {
|
|
64
|
+
args.push('-s', options.bufferSize.toString());
|
|
65
|
+
}
|
|
66
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.timeBeforeExit) === 'number') {
|
|
67
|
+
args.push('-W', options.timeBeforeExit.toString());
|
|
68
|
+
}
|
|
69
|
+
if (options === null || options === void 0 ? void 0 : options.verboseOutput) {
|
|
70
|
+
args.push('-v');
|
|
71
|
+
}
|
|
72
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.timeout) === 'number') {
|
|
73
|
+
args.push('-w', options.timeout.toString());
|
|
74
|
+
}
|
|
75
|
+
if (options === null || options === void 0 ? void 0 : options.IPV6) {
|
|
76
|
+
buildCommand.command = 'ping6';
|
|
77
|
+
}
|
|
78
|
+
args.push(ip);
|
|
79
|
+
buildCommand.arguments = args;
|
|
80
|
+
return buildCommand;
|
|
81
|
+
};
|
|
82
|
+
exports.default = linux;
|
|
83
83
|
//# sourceMappingURL=linux.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { commandBuilder, extendedPingOptions } from '../types';
|
|
2
|
-
declare const mac: (ip: string, options?: extendedPingOptions) => commandBuilder;
|
|
3
|
-
export default mac;
|
|
1
|
+
import { commandBuilder, extendedPingOptions } from '../types';
|
|
2
|
+
declare const mac: (ip: string, options?: extendedPingOptions) => commandBuilder;
|
|
3
|
+
export default mac;
|
package/dist/src/builder/mac.js
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const process_1 = require("process");
|
|
4
|
-
const messages_1 = require("../messages");
|
|
5
|
-
const mac = (ip, options) => {
|
|
6
|
-
let defaultNumberOfEchoes = '4'; //default needed because mac by default has continous ping till we cancel
|
|
7
|
-
let args = [];
|
|
8
|
-
let buildCommand = {
|
|
9
|
-
command: '/sbin/ping',
|
|
10
|
-
arguments: args
|
|
11
|
-
};
|
|
12
|
-
//NO Allowing Unsanitized user input into spawn.Checking each param and assigning
|
|
13
|
-
if (!options) {
|
|
14
|
-
buildCommand.arguments.push('-c', defaultNumberOfEchoes);
|
|
15
|
-
args.push(ip);
|
|
16
|
-
return buildCommand;
|
|
17
|
-
}
|
|
18
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.numberOfEchos) === 'number') {
|
|
19
|
-
args.push('-c', options.numberOfEchos.toString());
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
args.push('-c', defaultNumberOfEchoes);
|
|
23
|
-
}
|
|
24
|
-
if (options === null || options === void 0 ? void 0 : options.soDebugOption) {
|
|
25
|
-
args.push('-d');
|
|
26
|
-
}
|
|
27
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
|
|
28
|
-
if (options === null || options === void 0 ? void 0 : options.floodPing) {
|
|
29
|
-
args.push('-f');
|
|
30
|
-
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (options === null || options === void 0 ? void 0 : options.floodPing) {
|
|
37
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
|
|
38
|
-
args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
args.push('-f');
|
|
42
|
-
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.interfaceAddress) === 'string') {
|
|
46
|
-
args.push('-I', options.interfaceAddress);
|
|
47
|
-
}
|
|
48
|
-
if (options === null || options === void 0 ? void 0 : options.suppressLoopback) {
|
|
49
|
-
args.push('-L');
|
|
50
|
-
}
|
|
51
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.TTL) === 'number') {
|
|
52
|
-
args.push('-m', options.TTL.toString()); //change to -t for linux
|
|
53
|
-
}
|
|
54
|
-
if (options.doNotFragment) {
|
|
55
|
-
args.push('-D');
|
|
56
|
-
}
|
|
57
|
-
if (options === null || options === void 0 ? void 0 : options.numeric) {
|
|
58
|
-
args.push('-n');
|
|
59
|
-
}
|
|
60
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.pattern) === 'string') {
|
|
61
|
-
args.push('-p', options.pattern);
|
|
62
|
-
}
|
|
63
|
-
if (options === null || options === void 0 ? void 0 : options.quiet) {
|
|
64
|
-
args.push('-q');
|
|
65
|
-
}
|
|
66
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.srcAddr) === 'string') {
|
|
67
|
-
args.push('-S', options.srcAddr); //Delete for Linux
|
|
68
|
-
}
|
|
69
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.bufferSize) === 'number') {
|
|
70
|
-
args.push('-s', options.bufferSize.toString());
|
|
71
|
-
}
|
|
72
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.timeBeforeExit) === 'number') {
|
|
73
|
-
args.push('-t', options.timeBeforeExit.toString()); //change to -w for linux
|
|
74
|
-
}
|
|
75
|
-
if (options === null || options === void 0 ? void 0 : options.verboseOutput) {
|
|
76
|
-
args.push('-v');
|
|
77
|
-
}
|
|
78
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.timeout) === 'number') {
|
|
79
|
-
args.push('-W', (options.timeout * 1000).toString());
|
|
80
|
-
}
|
|
81
|
-
if (options === null || options === void 0 ? void 0 : options.IPV6) {
|
|
82
|
-
buildCommand.command = '/sbin/ping6';
|
|
83
|
-
}
|
|
84
|
-
args.push(ip);
|
|
85
|
-
buildCommand.arguments = args;
|
|
86
|
-
return buildCommand;
|
|
87
|
-
};
|
|
88
|
-
exports.default = mac;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const process_1 = require("process");
|
|
4
|
+
const messages_1 = require("../messages");
|
|
5
|
+
const mac = (ip, options) => {
|
|
6
|
+
let defaultNumberOfEchoes = '4'; //default needed because mac by default has continous ping till we cancel
|
|
7
|
+
let args = [];
|
|
8
|
+
let buildCommand = {
|
|
9
|
+
command: '/sbin/ping',
|
|
10
|
+
arguments: args
|
|
11
|
+
};
|
|
12
|
+
//NO Allowing Unsanitized user input into spawn.Checking each param and assigning
|
|
13
|
+
if (!options) {
|
|
14
|
+
buildCommand.arguments.push('-c', defaultNumberOfEchoes);
|
|
15
|
+
args.push(ip);
|
|
16
|
+
return buildCommand;
|
|
17
|
+
}
|
|
18
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.numberOfEchos) === 'number') {
|
|
19
|
+
args.push('-c', options.numberOfEchos.toString());
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
args.push('-c', defaultNumberOfEchoes);
|
|
23
|
+
}
|
|
24
|
+
if (options === null || options === void 0 ? void 0 : options.soDebugOption) {
|
|
25
|
+
args.push('-d');
|
|
26
|
+
}
|
|
27
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
|
|
28
|
+
if (options === null || options === void 0 ? void 0 : options.floodPing) {
|
|
29
|
+
args.push('-f');
|
|
30
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (options === null || options === void 0 ? void 0 : options.floodPing) {
|
|
37
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
|
|
38
|
+
args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
args.push('-f');
|
|
42
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.interfaceAddress) === 'string') {
|
|
46
|
+
args.push('-I', options.interfaceAddress);
|
|
47
|
+
}
|
|
48
|
+
if (options === null || options === void 0 ? void 0 : options.suppressLoopback) {
|
|
49
|
+
args.push('-L');
|
|
50
|
+
}
|
|
51
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.TTL) === 'number') {
|
|
52
|
+
args.push('-m', options.TTL.toString()); //change to -t for linux
|
|
53
|
+
}
|
|
54
|
+
if (options.doNotFragment) {
|
|
55
|
+
args.push('-D');
|
|
56
|
+
}
|
|
57
|
+
if (options === null || options === void 0 ? void 0 : options.numeric) {
|
|
58
|
+
args.push('-n');
|
|
59
|
+
}
|
|
60
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.pattern) === 'string') {
|
|
61
|
+
args.push('-p', options.pattern);
|
|
62
|
+
}
|
|
63
|
+
if (options === null || options === void 0 ? void 0 : options.quiet) {
|
|
64
|
+
args.push('-q');
|
|
65
|
+
}
|
|
66
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.srcAddr) === 'string') {
|
|
67
|
+
args.push('-S', options.srcAddr); //Delete for Linux
|
|
68
|
+
}
|
|
69
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.bufferSize) === 'number') {
|
|
70
|
+
args.push('-s', options.bufferSize.toString());
|
|
71
|
+
}
|
|
72
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.timeBeforeExit) === 'number') {
|
|
73
|
+
args.push('-t', options.timeBeforeExit.toString()); //change to -w for linux
|
|
74
|
+
}
|
|
75
|
+
if (options === null || options === void 0 ? void 0 : options.verboseOutput) {
|
|
76
|
+
args.push('-v');
|
|
77
|
+
}
|
|
78
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.timeout) === 'number') {
|
|
79
|
+
args.push('-W', (options.timeout * 1000).toString());
|
|
80
|
+
}
|
|
81
|
+
if (options === null || options === void 0 ? void 0 : options.IPV6) {
|
|
82
|
+
buildCommand.command = '/sbin/ping6';
|
|
83
|
+
}
|
|
84
|
+
args.push(ip);
|
|
85
|
+
buildCommand.arguments = args;
|
|
86
|
+
return buildCommand;
|
|
87
|
+
};
|
|
88
|
+
exports.default = mac;
|
|
89
89
|
//# sourceMappingURL=mac.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { commandBuilder, extendedPingOptions } from '../types';
|
|
2
|
-
declare const windows: (ip: string, options?: extendedPingOptions) => commandBuilder;
|
|
3
|
-
export default windows;
|
|
1
|
+
import { commandBuilder, extendedPingOptions } from '../types';
|
|
2
|
+
declare const windows: (ip: string, options?: extendedPingOptions) => commandBuilder;
|
|
3
|
+
export default windows;
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const process_1 = require("process");
|
|
4
|
-
const messages_1 = require("../messages");
|
|
5
|
-
const windows = (ip, options) => {
|
|
6
|
-
let args = [];
|
|
7
|
-
const windowsRootPath = process.env.SystemRoot + '/system32/ping.exe';
|
|
8
|
-
//NO Allowing Unsanitized user input into spawn.Checking each param and assigning
|
|
9
|
-
if (!options) {
|
|
10
|
-
args.push(ip);
|
|
11
|
-
return {
|
|
12
|
-
command: windowsRootPath,
|
|
13
|
-
arguments: args
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
if (options === null || options === void 0 ? void 0 : options.numeric) {
|
|
18
|
-
args.push('-a');
|
|
19
|
-
}
|
|
20
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.numberOfEchos) === 'number') {
|
|
21
|
-
args.push('-n', options.numberOfEchos.toString());
|
|
22
|
-
}
|
|
23
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.bufferSize) === 'number') {
|
|
24
|
-
args.push('-l', options.bufferSize.toString());
|
|
25
|
-
}
|
|
26
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.TTL) === 'number') {
|
|
27
|
-
args.push('-i', options.TTL.toString());
|
|
28
|
-
}
|
|
29
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.timeout) === 'number') {
|
|
30
|
-
args.push('-w', (options.timeout * 1000).toString());
|
|
31
|
-
}
|
|
32
|
-
args.push(...(checkForIpV4SpecificFields(options)));
|
|
33
|
-
args.push(...(checkForIpV6SpecificFields(options)));
|
|
34
|
-
args.push(ip);
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
command: windowsRootPath,
|
|
38
|
-
arguments: args
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
//Checking for windows IPV4 fields as per official documentation
|
|
42
|
-
function checkForIpV4SpecificFields(options) {
|
|
43
|
-
let optionsUsed = "";
|
|
44
|
-
let args = [];
|
|
45
|
-
if (options === null || options === void 0 ? void 0 : options.IPV4) {
|
|
46
|
-
args.push('-4');
|
|
47
|
-
if (options.doNotFragment) {
|
|
48
|
-
args.push('-f');
|
|
49
|
-
}
|
|
50
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.recordRouteHops) === 'number') {
|
|
51
|
-
args.push('-r', options.recordRouteHops.toString());
|
|
52
|
-
}
|
|
53
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.hopTimestamp) === 'number') {
|
|
54
|
-
args.push('-s', options.hopTimestamp.toString());
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
if (options.doNotFragment) {
|
|
59
|
-
optionsUsed = optionsUsed.concat(',', options.doNotFragment.toString());
|
|
60
|
-
}
|
|
61
|
-
if (options.recordRouteHops) {
|
|
62
|
-
optionsUsed = optionsUsed.concat(',', options.recordRouteHops.toString());
|
|
63
|
-
}
|
|
64
|
-
if (options.hopTimestamp) {
|
|
65
|
-
optionsUsed = optionsUsed.concat(',', options.hopTimestamp.toString());
|
|
66
|
-
}
|
|
67
|
-
if (optionsUsed.length > 0) {
|
|
68
|
-
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.ENABLE_IPV4_EXPLICIT.replace('commands', optionsUsed), 'IPV4OnlyWarning');
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return args;
|
|
72
|
-
}
|
|
73
|
-
//Checking for windows IPV6 fields as per official documentation
|
|
74
|
-
function checkForIpV6SpecificFields(options) {
|
|
75
|
-
let optionsUsed = "";
|
|
76
|
-
let args = [];
|
|
77
|
-
if (options === null || options === void 0 ? void 0 : options.IPV6) {
|
|
78
|
-
args.push('-6');
|
|
79
|
-
if (options.srcAddr) {
|
|
80
|
-
args.push('-S', options.srcAddr);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
if (typeof options.srcAddr === 'string') {
|
|
85
|
-
optionsUsed = optionsUsed.concat(',', options.srcAddr);
|
|
86
|
-
}
|
|
87
|
-
if (optionsUsed.length > 0) {
|
|
88
|
-
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.ENABLE_IPV6_EXPLICIT.replace('commands', optionsUsed), 'IPV6OnlyWarning');
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return args;
|
|
92
|
-
}
|
|
93
|
-
exports.default = windows;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const process_1 = require("process");
|
|
4
|
+
const messages_1 = require("../messages");
|
|
5
|
+
const windows = (ip, options) => {
|
|
6
|
+
let args = [];
|
|
7
|
+
const windowsRootPath = process.env.SystemRoot + '/system32/ping.exe';
|
|
8
|
+
//NO Allowing Unsanitized user input into spawn.Checking each param and assigning
|
|
9
|
+
if (!options) {
|
|
10
|
+
args.push(ip);
|
|
11
|
+
return {
|
|
12
|
+
command: windowsRootPath,
|
|
13
|
+
arguments: args
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
if (options === null || options === void 0 ? void 0 : options.numeric) {
|
|
18
|
+
args.push('-a');
|
|
19
|
+
}
|
|
20
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.numberOfEchos) === 'number') {
|
|
21
|
+
args.push('-n', options.numberOfEchos.toString());
|
|
22
|
+
}
|
|
23
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.bufferSize) === 'number') {
|
|
24
|
+
args.push('-l', options.bufferSize.toString());
|
|
25
|
+
}
|
|
26
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.TTL) === 'number') {
|
|
27
|
+
args.push('-i', options.TTL.toString());
|
|
28
|
+
}
|
|
29
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.timeout) === 'number') {
|
|
30
|
+
args.push('-w', (options.timeout * 1000).toString());
|
|
31
|
+
}
|
|
32
|
+
args.push(...(checkForIpV4SpecificFields(options)));
|
|
33
|
+
args.push(...(checkForIpV6SpecificFields(options)));
|
|
34
|
+
args.push(ip);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
command: windowsRootPath,
|
|
38
|
+
arguments: args
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
//Checking for windows IPV4 fields as per official documentation
|
|
42
|
+
function checkForIpV4SpecificFields(options) {
|
|
43
|
+
let optionsUsed = "";
|
|
44
|
+
let args = [];
|
|
45
|
+
if (options === null || options === void 0 ? void 0 : options.IPV4) {
|
|
46
|
+
args.push('-4');
|
|
47
|
+
if (options.doNotFragment) {
|
|
48
|
+
args.push('-f');
|
|
49
|
+
}
|
|
50
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.recordRouteHops) === 'number') {
|
|
51
|
+
args.push('-r', options.recordRouteHops.toString());
|
|
52
|
+
}
|
|
53
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.hopTimestamp) === 'number') {
|
|
54
|
+
args.push('-s', options.hopTimestamp.toString());
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
if (options.doNotFragment) {
|
|
59
|
+
optionsUsed = optionsUsed.concat(',', options.doNotFragment.toString());
|
|
60
|
+
}
|
|
61
|
+
if (options.recordRouteHops) {
|
|
62
|
+
optionsUsed = optionsUsed.concat(',', options.recordRouteHops.toString());
|
|
63
|
+
}
|
|
64
|
+
if (options.hopTimestamp) {
|
|
65
|
+
optionsUsed = optionsUsed.concat(',', options.hopTimestamp.toString());
|
|
66
|
+
}
|
|
67
|
+
if (optionsUsed.length > 0) {
|
|
68
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.ENABLE_IPV4_EXPLICIT.replace('commands', optionsUsed), 'IPV4OnlyWarning');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return args;
|
|
72
|
+
}
|
|
73
|
+
//Checking for windows IPV6 fields as per official documentation
|
|
74
|
+
function checkForIpV6SpecificFields(options) {
|
|
75
|
+
let optionsUsed = "";
|
|
76
|
+
let args = [];
|
|
77
|
+
if (options === null || options === void 0 ? void 0 : options.IPV6) {
|
|
78
|
+
args.push('-6');
|
|
79
|
+
if (options.srcAddr) {
|
|
80
|
+
args.push('-S', options.srcAddr);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
if (typeof options.srcAddr === 'string') {
|
|
85
|
+
optionsUsed = optionsUsed.concat(',', options.srcAddr);
|
|
86
|
+
}
|
|
87
|
+
if (optionsUsed.length > 0) {
|
|
88
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.ENABLE_IPV6_EXPLICIT.replace('commands', optionsUsed), 'IPV6OnlyWarning');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return args;
|
|
92
|
+
}
|
|
93
|
+
exports.default = windows;
|
|
94
94
|
//# sourceMappingURL=windows.js.map
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare class pingError extends Error {
|
|
2
|
-
code?: string;
|
|
3
|
-
constructor(message: string, code?: string);
|
|
4
|
-
}
|
|
5
|
-
export declare class ipError extends pingError {
|
|
6
|
-
constructor(message: string);
|
|
7
|
-
}
|
|
8
|
-
export declare class supportedError extends pingError {
|
|
9
|
-
constructor(message: string);
|
|
10
|
-
}
|
|
1
|
+
export declare class pingError extends Error {
|
|
2
|
+
code?: string;
|
|
3
|
+
constructor(message: string, code?: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class ipError extends pingError {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class supportedError extends pingError {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
package/dist/src/errors.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.supportedError = exports.ipError = exports.pingError = void 0;
|
|
4
|
-
class pingError extends Error {
|
|
5
|
-
constructor(message, code) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = 'pingError';
|
|
8
|
-
this.code = code;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.pingError = pingError;
|
|
12
|
-
class ipError extends pingError {
|
|
13
|
-
constructor(message) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.name = 'ipError';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.ipError = ipError;
|
|
19
|
-
class supportedError extends pingError {
|
|
20
|
-
constructor(message) {
|
|
21
|
-
super(message);
|
|
22
|
-
this.name = 'platformNotSupportedError';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.supportedError = supportedError;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.supportedError = exports.ipError = exports.pingError = void 0;
|
|
4
|
+
class pingError extends Error {
|
|
5
|
+
constructor(message, code) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'pingError';
|
|
8
|
+
this.code = code;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.pingError = pingError;
|
|
12
|
+
class ipError extends pingError {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'ipError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ipError = ipError;
|
|
19
|
+
class supportedError extends pingError {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = 'platformNotSupportedError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.supportedError = supportedError;
|
|
26
26
|
//# sourceMappingURL=errors.js.map
|
package/dist/src/helper.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function validateIp(ip: string): boolean;
|
|
2
|
-
export declare function isPlatformSupported(platform: string): boolean;
|
|
1
|
+
export declare function validateIp(ip: string): boolean;
|
|
2
|
+
export declare function isPlatformSupported(platform: string): boolean;
|