diff --git a/package.json b/package.json index 9a4c556..081dc94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "universal-speedtest", - "version": "2.0.1", + "version": "2.0.2", "description": "This library allows you to test speed with various speed testing sites.", "main": "dist/index.js", "scripts": { diff --git a/src/Cloudflare.ts b/src/Cloudflare.ts index cc3a2b1..8ce379a 100644 --- a/src/Cloudflare.ts +++ b/src/Cloudflare.ts @@ -1,3 +1,4 @@ +import {performance} from "perf_hooks"; import {HttpClientResponse, IncomingHttpHeaders} from "urllib"; import {createRequest} from "./helpers/UrllibHelper"; import {avg, convertUnits, getDistance, getQuartile, jitter, sortObject} from "./Utils"; diff --git a/src/Speedtest.ts b/src/Speedtest.ts index 0b043e6..15a5116 100644 --- a/src/Speedtest.ts +++ b/src/Speedtest.ts @@ -1,3 +1,4 @@ +import {performance} from "perf_hooks"; import * as path from "path"; import {Worker} from "worker_threads"; import {IncomingHttpHeaders} from "urllib"; diff --git a/src/helpers/UrllibHelper.ts b/src/helpers/UrllibHelper.ts index e47f568..7634870 100644 --- a/src/helpers/UrllibHelper.ts +++ b/src/helpers/UrllibHelper.ts @@ -1,3 +1,4 @@ +import {performance} from "perf_hooks"; import {HttpClientResponse, IncomingHttpHeaders, request} from "urllib"; import {parseString} from "xml2js"; import {validate} from "fast-xml-parser"; @@ -14,7 +15,7 @@ import {validate} from "fast-xml-parser"; * @returns Promise */ export function createRequest(url: string, headers: IncomingHttpHeaders, secure = true, data = {}, bump = "0", timeout = 10, withBump = false): Promise> { - headers["user-agent"] = "Mozilla/5.0 (" + process.platform + "; U; " + process.arch + "; en-us) TypeScript/" + process.version + " (KHTML, like Gecko) UniversalSpeedTest/2.0.1"; + headers["user-agent"] = "Mozilla/5.0 (" + process.platform + "; U; " + process.arch + "; en-us) TypeScript/" + process.version + " (KHTML, like Gecko) UniversalSpeedTest/2.0.2"; headers["cache-control"] = "no-cache"; return request(((url[0] == ":") ? (secure) ? "https" : "http" : "") + url + ((withBump) ? (((url.includes("?")) ? "&" : "?") + "x=" + performance.now() + bump) : ""), { diff --git a/src/thread_workers/download_worker.ts b/src/thread_workers/download_worker.ts index 3b496e6..d0c70f5 100644 --- a/src/thread_workers/download_worker.ts +++ b/src/thread_workers/download_worker.ts @@ -1,3 +1,4 @@ +import {performance} from "perf_hooks"; import {parentPort, workerData} from "worker_threads"; import {createRequest} from "../helpers/UrllibHelper"; import {HTTPDownloader} from "../helpers/HTTPDownloader"; diff --git a/src/thread_workers/upload_worker.ts b/src/thread_workers/upload_worker.ts index b72dc88..418bb03 100644 --- a/src/thread_workers/upload_worker.ts +++ b/src/thread_workers/upload_worker.ts @@ -1,3 +1,4 @@ +import {performance} from "perf_hooks"; import {parentPort, workerData} from "worker_threads"; import {createRequest} from "../helpers/UrllibHelper"; import {HTTPUploader} from "../helpers/HTTPUploader"; diff --git a/tests/Cloudflare.test.ts b/tests/Cloudflare.test.ts index 8f3c681..bca0e8a 100644 --- a/tests/Cloudflare.test.ts +++ b/tests/Cloudflare.test.ts @@ -11,5 +11,5 @@ describe("Cloudflare test", () => { expect(result.ping).to.be.below(60); expect(result.uploadSpeed).not.to.be.undefined; expect(result.downloadSpeed).to.be.above(20); - }).timeout(90000); + }).timeout(120000); }); \ No newline at end of file diff --git a/tests/Speedtest.test.ts b/tests/Speedtest.test.ts index 49c8a6a..22eddb9 100644 --- a/tests/Speedtest.test.ts +++ b/tests/Speedtest.test.ts @@ -11,5 +11,5 @@ describe("Speedtest test", () => { expect(result.ping).to.be.below(60); expect(result.uploadSpeed).to.be.undefined; expect(result.downloadSpeed).to.be.above(20); - }).timeout(90000); + }).timeout(120000); }); \ No newline at end of file