fix(core): update

This commit is contained in:
Philipp Kunz 2022-10-21 17:13:06 +02:00
parent 15744d3c4e
commit bcfa3be58b
7 changed files with 4537 additions and 18419 deletions

18396
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,17 +14,19 @@
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.61",
"@gitzone/tsrun": "^1.2.39",
"@gitzone/tstest": "^1.0.69",
"@pushrocks/smartenv": "^5.0.0",
"@pushrocks/tapbundle": "^5.0.3"
"@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^18.11.3"
},
"dependencies": {
"@pushrocks/smartping": "^1.0.7",
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smartstring": "^4.0.2",
"@types/default-gateway": "^3.0.1",
"icmp": "^2.0.1",
"isopen": "^1.3.0",
"public-ip": "^4.0.4",
"public-ip": "^6.0.1",
"systeminformation": "^5.11.9"
},
"files": [

4501
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -10,9 +10,16 @@ tap.test('should create a vlid instance of SmartNetwork', async () => {
});
tap.test('should send a ping to Google', async () => {
expectAsync(testSmartnetwork.ping('https://lossless.com')).toBeTrue();
expectAsync(testSmartnetwork.ping('https://notthere.lossless.com')).toBeTrue();
expectAsync(testSmartnetwork.ping('192.168.186.999')).toBeFalse();
console.log(await testSmartnetwork.ping('google.com'));
await expectAsync(testSmartnetwork.ping('google.com')).property('alive').toBeTrue();
});
tap.test('should state when a ping is not alive ', async () => {
await expectAsync(testSmartnetwork.ping('notthere.lossless.com')).property('alive').toBeFalse();
});
tap.test('should send a ping to an IP', async () => {
await expectAsync(testSmartnetwork.ping('192.168.186.999')).property('alive').toBeFalse();
})
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartnetwork',
version: '3.0.1',
description: 'network diagnostics'
}

View File

@ -16,17 +16,10 @@ 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;
}
public async ping(hostArg: string, timeoutArg: number = 500): Promise<ReturnType<typeof plugins.smartping.Smartping.prototype.ping>> {
const smartpingInstance = new plugins.smartping.Smartping();
const pingResult = await smartpingInstance.ping(hostArg, timeoutArg);
return pingResult;
}
/**
@ -127,10 +120,14 @@ export class SmartNetwork {
public async getPublicIps() {
return {
v4: await plugins.publicIp.v4({
v4: await plugins.publicIp.publicIpv4({
timeout: 1000,
onlyHttps: true,
}),
v6: await plugins.publicIp.publicIpv6({
timeout: 1000,
onlyHttps: true,
})
};
}
}

View File

@ -6,18 +6,17 @@ import * as perfHooks from 'perf_hooks';
export { os, https, perfHooks };
// @pushrocks scope
import * as smartping from '@pushrocks/smartping';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartstring from '@pushrocks/smartstring';
export { smartpromise, smartstring };
export { smartpromise, smartping, smartstring };
// @third party scope
// @ts-ignore
import isopen from 'isopen';
// @ts-ignore
import icmp from 'icmp';
// @ts-ignore
import publicIp from 'public-ip';
import * as publicIp from 'public-ip';
import * as systeminformation from 'systeminformation';
export { isopen, icmp, publicIp, systeminformation };
export { isopen, publicIp, systeminformation };