fix(core): update
This commit is contained in:
parent
068177b09d
commit
c308589d28
49
package-lock.json
generated
49
package-lock.json
generated
@ -12,6 +12,7 @@
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smartstring": "^3.0.24",
|
||||
"@types/default-gateway": "^3.0.1",
|
||||
"icmp": "^2.0.1",
|
||||
"isopen": "^1.3.0",
|
||||
"public-ip": "^4.0.4",
|
||||
"systeminformation": "^5.11.3"
|
||||
@ -8443,6 +8444,15 @@
|
||||
"ms": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/icmp": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://verdaccio.lossless.one/icmp/-/icmp-2.0.1.tgz",
|
||||
"integrity": "sha512-M7r2J6pjZOwZFSjsFNvYlWvtpVbCckwCd2EQSHc4Mzscwp9X7DUpnPcQiVceKI9YQ42INb53cMmgIzaRs87Jmg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"raw-socket": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://verdaccio.lossless.one/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
@ -12449,6 +12459,22 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/raw-socket": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://verdaccio.lossless.one/raw-socket/-/raw-socket-1.7.0.tgz",
|
||||
"integrity": "sha512-mXqWihgwaFNmV5le0dWk5o+03M3A2zBIkC9BNaE6R0CJN9eYot++j2FIqgNSDq6/Vmu32PPI155SiiWNV2yyFQ==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"nan": "2.14.*"
|
||||
}
|
||||
},
|
||||
"node_modules/raw-socket/node_modules/nan": {
|
||||
"version": "2.14.2",
|
||||
"resolved": "https://verdaccio.lossless.one/nan/-/nan-2.14.2.tgz",
|
||||
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/readable-stream": {
|
||||
"version": "2.3.7",
|
||||
"resolved": "https://verdaccio.lossless.one/readable-stream/-/readable-stream-2.3.7.tgz",
|
||||
@ -22139,6 +22165,14 @@
|
||||
"ms": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"icmp": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://verdaccio.lossless.one/icmp/-/icmp-2.0.1.tgz",
|
||||
"integrity": "sha512-M7r2J6pjZOwZFSjsFNvYlWvtpVbCckwCd2EQSHc4Mzscwp9X7DUpnPcQiVceKI9YQ42INb53cMmgIzaRs87Jmg==",
|
||||
"requires": {
|
||||
"raw-socket": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://verdaccio.lossless.one/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
@ -25112,6 +25146,21 @@
|
||||
"unpipe": "1.0.0"
|
||||
}
|
||||
},
|
||||
"raw-socket": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://verdaccio.lossless.one/raw-socket/-/raw-socket-1.7.0.tgz",
|
||||
"integrity": "sha512-mXqWihgwaFNmV5le0dWk5o+03M3A2zBIkC9BNaE6R0CJN9eYot++j2FIqgNSDq6/Vmu32PPI155SiiWNV2yyFQ==",
|
||||
"requires": {
|
||||
"nan": "2.14.*"
|
||||
},
|
||||
"dependencies": {
|
||||
"nan": {
|
||||
"version": "2.14.2",
|
||||
"resolved": "https://verdaccio.lossless.one/nan/-/nan-2.14.2.tgz",
|
||||
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.7",
|
||||
"resolved": "https://verdaccio.lossless.one/readable-stream/-/readable-stream-2.3.7.tgz",
|
||||
|
@ -22,6 +22,7 @@
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smartstring": "^3.0.24",
|
||||
"@types/default-gateway": "^3.0.1",
|
||||
"icmp": "^2.0.1",
|
||||
"isopen": "^1.3.0",
|
||||
"public-ip": "^4.0.4",
|
||||
"systeminformation": "^5.11.3"
|
||||
|
16
test/test.ping.ts
Normal file
16
test/test.ping.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import {tap, expect, expectAsync} from '@pushrocks/tapbundle';
|
||||
|
||||
import * as smartnetwork from '../ts';
|
||||
|
||||
let testSmartnetwork: smartnetwork.SmartNetwork;
|
||||
|
||||
tap.test('should create a vlid instance of SmartNetwork', async () => {
|
||||
testSmartnetwork = new smartnetwork.SmartNetwork();
|
||||
expect(testSmartnetwork).toBeInstanceOf(smartnetwork.SmartNetwork);
|
||||
})
|
||||
|
||||
tap.test('should send a ping to Google', async () => {
|
||||
expectAsync(testSmartnetwork.ping('https://lossless.com')).toBeTrue();
|
||||
})
|
||||
|
||||
tap.start();
|
@ -1 +1 @@
|
||||
export * from './smartnetwork.classes.smartnetwork';
|
||||
export * from './smartnetwork.classes.smartnetwork';
|
@ -16,6 +16,19 @@ export class SmartNetwork {
|
||||
return test;
|
||||
}
|
||||
|
||||
public async ping(hostArg: string, timeoutArg: number = 500): Promise<boolean> {
|
||||
if (process.getuid() !== 0 ) {
|
||||
console.log('icmp not allowed for nonroot!');
|
||||
return;
|
||||
}
|
||||
const result = await plugins.icmp.ping(hostArg, timeoutArg).catch();
|
||||
if (result) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a promise with a boolean answer
|
||||
* note: false also resolves with false as argument
|
||||
|
@ -13,7 +13,8 @@ export { smartpromise, smartstring };
|
||||
|
||||
// @third party scope
|
||||
const isopen = require('isopen');
|
||||
import publicIp from 'public-ip';
|
||||
const icmp = require('icmp');
|
||||
import * as publicIp from 'public-ip';
|
||||
import * as systeminformation from 'systeminformation';
|
||||
|
||||
export { isopen, publicIp, systeminformation };
|
||||
export { isopen, icmp, publicIp, systeminformation };
|
||||
|
Loading…
Reference in New Issue
Block a user