Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
ad0fa8c65a | |||
88a9bfc20d | |||
0248d6f253 | |||
8d1b302e70 | |||
34bee225d5 | |||
ccece078a2 | |||
a04151e537 | |||
d71346e763 |
7
package-lock.json
generated
7
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartnetwork",
|
"name": "@pushrocks/smartnetwork",
|
||||||
"version": "1.1.10",
|
"version": "1.1.14",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -1804,6 +1804,11 @@
|
|||||||
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
|
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"systeminformation": {
|
||||||
|
"version": "4.14.8",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/systeminformation/-/systeminformation-4.14.8.tgz",
|
||||||
|
"integrity": "sha512-05wW1YaMBI6LlVtvw2wXQGr0thpX8E0IImYcpbqUiNanfmq8e+V89pDW2L5V/mN8kU37W0VtVySftQ0PwMIXKw=="
|
||||||
|
},
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"version": "8.3.0",
|
"version": "8.3.0",
|
||||||
"resolved": "https://verdaccio.lossless.one/ts-node/-/ts-node-8.3.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/ts-node/-/ts-node-8.3.0.tgz",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartnetwork",
|
"name": "@pushrocks/smartnetwork",
|
||||||
"version": "1.1.10",
|
"version": "1.1.14",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "network diagnostics",
|
"description": "network diagnostics",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -25,7 +25,8 @@
|
|||||||
"@types/portscanner": "^2.1.0",
|
"@types/portscanner": "^2.1.0",
|
||||||
"default-gateway": "^5.0.3",
|
"default-gateway": "^5.0.3",
|
||||||
"portscanner": "^2.2.0",
|
"portscanner": "^2.2.0",
|
||||||
"speedtest-net": "^1.5.1"
|
"speedtest-net": "^1.5.1",
|
||||||
|
"systeminformation": "^4.14.8"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/*",
|
"ts/*",
|
||||||
|
@ -24,9 +24,14 @@ tap.test('should scan a port', async () => {
|
|||||||
// await expect(testSmartNetwork.isRemotePortAvailable('lossless.com:444')).to.eventually.be.false;
|
// await expect(testSmartNetwork.isRemotePortAvailable('lossless.com:444')).to.eventually.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should get the default gateways', async () => {
|
tap.test('should get gateways', async () => {
|
||||||
const gatewayResult = await testSmartNetwork.getGateways();
|
const gatewayResult = await testSmartNetwork.getGateways();
|
||||||
console.log(gatewayResult);
|
console.log(gatewayResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should get the default gateway', async () => {
|
||||||
|
const gatewayResult = await testSmartNetwork.getDefaultGateway();
|
||||||
|
console.log(gatewayResult);
|
||||||
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -133,4 +133,18 @@ export class SmartNetwork {
|
|||||||
const result = plugins.os.networkInterfaces();
|
const result = plugins.os.networkInterfaces();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getDefaultGateway(): Promise<{ipv4: plugins.os.NetworkInterfaceInfo, ipv6: plugins.os.NetworkInterfaceInfo}> {
|
||||||
|
const defaultGatewayName = await plugins.systeminformation.networkInterfaceDefault();
|
||||||
|
if (!defaultGatewayName) {
|
||||||
|
console.log('Cannot determine default gateway');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const gateways = await this.getGateways();
|
||||||
|
const defaultGateway = gateways[defaultGatewayName];
|
||||||
|
return {
|
||||||
|
ipv4: defaultGateway[0],
|
||||||
|
ipv6: defaultGateway[1]
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,8 @@ import * as smartstring from '@pushrocks/smartstring';
|
|||||||
export { smartpromise, smartstring };
|
export { smartpromise, smartstring };
|
||||||
|
|
||||||
// @third party scope
|
// @third party scope
|
||||||
const speedtestNet = require('speedtest-net');
|
|
||||||
import * as portscanner from 'portscanner';
|
import * as portscanner from 'portscanner';
|
||||||
|
import speedtestNet from 'speedtest-net';
|
||||||
|
import * as systeminformation from 'systeminformation';
|
||||||
|
|
||||||
export { speedtestNet, portscanner };
|
export { speedtestNet, portscanner, systeminformation };
|
||||||
|
Reference in New Issue
Block a user