Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
d8044507ed | |||
b9380be999 | |||
1b9c354d69 | |||
a8f4ecf98f | |||
6350088d2a | |||
10ef1d0455 | |||
f709238e50 | |||
49940635d5 | |||
ec4121cbcf | |||
ea9a2572f9 | |||
cc0f1c40a6 | |||
9da04081e4 | |||
4ae0925043 | |||
4e862e784b | |||
cf8abfd4f0 | |||
93c4488b9b |
@ -33,7 +33,7 @@ auditProductionDependencies:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
|
||||
|
5748
package-lock.json
generated
5748
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartnetwork",
|
||||
"version": "1.1.20",
|
||||
"version": "2.0.5",
|
||||
"private": false,
|
||||
"description": "network diagnostics",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -9,24 +9,24 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)"
|
||||
"build": "(tsbuild --web)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tstest": "^1.0.43",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"tslint": "^5.20.1",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"@pushrocks/smartstring": "^3.0.18",
|
||||
"@pushrocks/smartpromise": "^3.1.3",
|
||||
"@pushrocks/smartstring": "^3.0.24",
|
||||
"@types/default-gateway": "^3.0.1",
|
||||
"default-gateway": "^5.0.5",
|
||||
"isopen": "^1.3.0",
|
||||
"public-ip": "^4.0.2",
|
||||
"speedtest-net": "^1.6.0",
|
||||
"systeminformation": "^4.26.10"
|
||||
"public-ip": "^4.0.3",
|
||||
"speed-cloudflare-cli": "^2.0.3",
|
||||
"speedtest-net": "^2.1.1",
|
||||
"systeminformation": "^5.6.12"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
@ -9,13 +9,13 @@ tap.test('should create a valid instance of SmartNetwork', async () => {
|
||||
});
|
||||
|
||||
tap.test('should perform a speedtest', async () => {
|
||||
let result = await testSmartNetwork.getSpeed();
|
||||
console.log(`Download speed for this instance is ${result.speeds.download}`);
|
||||
console.log(`Upload speed for this instance is ${result.speeds.upload}`);
|
||||
const result = await testSmartNetwork.getSpeed();
|
||||
// console.log(`Download speed for this instance is ${result.download.bandwidth}`);
|
||||
// console.log(`Upload speed for this instance is ${result.download.bandwidth}`);
|
||||
});
|
||||
|
||||
tap.test('should determine wether a port is free', async () => {
|
||||
await expect(testSmartNetwork.isLocalPortAvailable(8080)).to.eventually.be.true;
|
||||
await expect(testSmartNetwork.isLocalPortUnused(8080)).to.eventually.be.true;
|
||||
});
|
||||
|
||||
tap.test('should scan a port', async () => {
|
||||
|
@ -1,34 +1,31 @@
|
||||
import * as plugins from './smartnetwork.plugins';
|
||||
|
||||
export interface ISpeedtestData {
|
||||
speeds: {
|
||||
download: number;
|
||||
upload: number;
|
||||
originalDownload: number;
|
||||
originalUpload: number;
|
||||
};
|
||||
client: {
|
||||
ip: string;
|
||||
lat: number;
|
||||
lon: number;
|
||||
isp: string;
|
||||
isprating: string;
|
||||
rating: number;
|
||||
ispdlavg: number;
|
||||
ispulavg: number;
|
||||
timestamp: Date;
|
||||
ping: { jitter: number; latency: number };
|
||||
download: { bandwidth: number; bytes: number; elapsed: number };
|
||||
upload: { bandwidth: number; bytes: number; elapsed: number };
|
||||
packetLoss: number;
|
||||
isp: string;
|
||||
interface: {
|
||||
internalIp: string;
|
||||
name: string;
|
||||
macAddr: string;
|
||||
isVpn: false;
|
||||
externalIp: string;
|
||||
};
|
||||
server: {
|
||||
host: string;
|
||||
lat: number;
|
||||
lon: number;
|
||||
id: number;
|
||||
name: string;
|
||||
location: string;
|
||||
country: string;
|
||||
cc: string;
|
||||
sponsor: string;
|
||||
distance: number;
|
||||
distanceMi: number;
|
||||
ping: number;
|
||||
host: string;
|
||||
port: number;
|
||||
ip: string;
|
||||
};
|
||||
result: {
|
||||
id: string;
|
||||
url: string;
|
||||
};
|
||||
}
|
||||
|
||||
@ -40,16 +37,9 @@ export class SmartNetwork {
|
||||
* get network speed
|
||||
* @param measurementTime
|
||||
*/
|
||||
public async getSpeed(measurementTime = 5000): Promise<ISpeedtestData> {
|
||||
const done = plugins.smartpromise.defer<ISpeedtestData>();
|
||||
const test = plugins.speedtestNet({ maxTime: measurementTime });
|
||||
test.on('data', (data) => {
|
||||
done.resolve(data);
|
||||
});
|
||||
test.on('error', (err) => {
|
||||
done.reject(err);
|
||||
});
|
||||
return await done.promise;
|
||||
public async getSpeed() {
|
||||
const test = null;
|
||||
return test;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,7 +47,7 @@ export class SmartNetwork {
|
||||
* note: false also resolves with false as argument
|
||||
* @param port
|
||||
*/
|
||||
public async isLocalPortAvailable(port: number): Promise<boolean> {
|
||||
public async isLocalPortUnused(port: number): Promise<boolean> {
|
||||
const doneIpV4 = plugins.smartpromise.defer<boolean>();
|
||||
const doneIpV6 = plugins.smartpromise.defer<boolean>();
|
||||
const net = await import('net'); // creates only one instance of net ;) even on multiple calls
|
||||
|
@ -12,7 +12,6 @@ export { smartpromise, smartstring };
|
||||
// @third party scope
|
||||
import isopen from 'isopen';
|
||||
import publicIp from 'public-ip';
|
||||
import speedtestNet from 'speedtest-net';
|
||||
import * as systeminformation from 'systeminformation';
|
||||
|
||||
export { isopen, publicIp, speedtestNet, systeminformation };
|
||||
export { isopen, publicIp, systeminformation };
|
||||
|
Reference in New Issue
Block a user