Compare commits

...

6 Commits

Author SHA1 Message Date
d8044507ed 2.0.5 2021-04-27 09:46:32 +00:00
b9380be999 fix(core): update 2021-04-27 09:46:31 +00:00
1b9c354d69 2.0.4 2021-04-13 13:05:48 +00:00
a8f4ecf98f fix(core): update 2021-04-13 13:05:47 +00:00
6350088d2a 2.0.3 2021-04-13 10:29:43 +00:00
10ef1d0455 fix(core): update 2021-04-13 10:29:42 +00:00
5 changed files with 34 additions and 39 deletions

7
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartnetwork", "name": "@pushrocks/smartnetwork",
"version": "2.0.2", "version": "2.0.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -11866,6 +11866,11 @@
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
"dev": true "dev": true
}, },
"speed-cloudflare-cli": {
"version": "2.0.3",
"resolved": "https://verdaccio.lossless.one/speed-cloudflare-cli/-/speed-cloudflare-cli-2.0.3.tgz",
"integrity": "sha512-aYnaj7ZhasoW+zhsVrO0tmGTxAfBY6eYFoIdoBJdJ0yZE1F/g11pt2AJqIuST0Qbe0x/pzwsEed267tCR6HuOA=="
},
"speedtest-net": { "speedtest-net": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://verdaccio.lossless.one/speedtest-net/-/speedtest-net-2.1.1.tgz", "resolved": "https://verdaccio.lossless.one/speedtest-net/-/speedtest-net-2.1.1.tgz",

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartnetwork", "name": "@pushrocks/smartnetwork",
"version": "2.0.2", "version": "2.0.5",
"private": false, "private": false,
"description": "network diagnostics", "description": "network diagnostics",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -24,6 +24,7 @@
"@types/default-gateway": "^3.0.1", "@types/default-gateway": "^3.0.1",
"isopen": "^1.3.0", "isopen": "^1.3.0",
"public-ip": "^4.0.3", "public-ip": "^4.0.3",
"speed-cloudflare-cli": "^2.0.3",
"speedtest-net": "^2.1.1", "speedtest-net": "^2.1.1",
"systeminformation": "^5.6.12" "systeminformation": "^5.6.12"
}, },

View File

@ -10,8 +10,8 @@ tap.test('should create a valid instance of SmartNetwork', async () => {
tap.test('should perform a speedtest', async () => { tap.test('should perform a speedtest', async () => {
const result = await testSmartNetwork.getSpeed(); const result = await testSmartNetwork.getSpeed();
console.log(`Download speed for this instance is ${result.speeds.download}`); // console.log(`Download speed for this instance is ${result.download.bandwidth}`);
console.log(`Upload speed for this instance is ${result.speeds.upload}`); // console.log(`Upload speed for this instance is ${result.download.bandwidth}`);
}); });
tap.test('should determine wether a port is free', async () => { tap.test('should determine wether a port is free', async () => {

View File

@ -1,34 +1,31 @@
import * as plugins from './smartnetwork.plugins'; import * as plugins from './smartnetwork.plugins';
export interface ISpeedtestData { export interface ISpeedtestData {
speeds: { timestamp: Date;
download: number; ping: { jitter: number; latency: number };
upload: number; download: { bandwidth: number; bytes: number; elapsed: number };
originalDownload: number; upload: { bandwidth: number; bytes: number; elapsed: number };
originalUpload: number; packetLoss: number;
}; isp: string;
client: { interface: {
ip: string; internalIp: string;
lat: number; name: string;
lon: number; macAddr: string;
isp: string; isVpn: false;
isprating: string; externalIp: string;
rating: number;
ispdlavg: number;
ispulavg: number;
}; };
server: { server: {
host: string; id: number;
lat: number; name: string;
lon: number;
location: string; location: string;
country: string; country: string;
cc: string; host: string;
sponsor: string; port: number;
distance: number; ip: string;
distanceMi: number; };
ping: number; result: {
id: string; id: string;
url: string;
}; };
} }
@ -40,16 +37,9 @@ export class SmartNetwork {
* get network speed * get network speed
* @param measurementTime * @param measurementTime
*/ */
public async getSpeed(measurementTime = 5000): Promise<ISpeedtestData> { public async getSpeed() {
const done = plugins.smartpromise.defer<ISpeedtestData>(); const test = null;
const test = plugins.speedtestNet({ maxTime: measurementTime }); return test;
test.on('data', (data) => {
done.resolve(data);
});
test.on('error', (err) => {
done.reject(err);
});
return await done.promise;
} }
/** /**

View File

@ -12,7 +12,6 @@ export { smartpromise, smartstring };
// @third party scope // @third party scope
import isopen from 'isopen'; import isopen from 'isopen';
import publicIp from 'public-ip'; import publicIp from 'public-ip';
import speedtestNet from 'speedtest-net';
import * as systeminformation from 'systeminformation'; import * as systeminformation from 'systeminformation';
export { isopen, publicIp, speedtestNet, systeminformation }; export { isopen, publicIp, systeminformation };