fix(core): update
This commit is contained in:
parent
f709238e50
commit
10ef1d0455
@ -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 () => {
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,15 +38,8 @@ export class SmartNetwork {
|
|||||||
* @param measurementTime
|
* @param measurementTime
|
||||||
*/
|
*/
|
||||||
public async getSpeed(measurementTime = 5000): Promise<ISpeedtestData> {
|
public async getSpeed(measurementTime = 5000): Promise<ISpeedtestData> {
|
||||||
const done = plugins.smartpromise.defer<ISpeedtestData>();
|
const test = await plugins.speedtestNet({ maxTime: measurementTime, acceptGdpr: true });
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user