fix(core): update
This commit is contained in:
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartnetwork',
|
||||
version: '3.0.1',
|
||||
description: 'network diagnostics'
|
||||
}
|
@ -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,
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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 };
|
||||
|
Reference in New Issue
Block a user