From 73784275d6b13d48993d9414adf24648e0cbf55e Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 26 May 2026 19:01:34 +0300 Subject: [PATCH] code changes --- config.yml | 21 +++++++++++++++++++++ index.js | 12 ++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 config.yml diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..20cb343 --- /dev/null +++ b/config.yml @@ -0,0 +1,21 @@ +########################################################################### +########################################################################### +##################just an example, need set real ips####################### +########################################################################### +########################################################################### +server: + port: 4000 + +targets: + hosts: + - url: http://127.0.0.1:7088 + name: proxy-city + - url: http://127.0.0.1:7089 + name: proxy-optima + + endpoints: + - /testmontools/curl + - /testmontools/traceroute + - /testmontools/ping + + timeout: 120000 \ No newline at end of file diff --git a/index.js b/index.js index 5b5af9f..498d4a5 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ const configPath = path.join(__dirname, "config.yml"); const config = yaml.load(fs.readFileSync(configPath, "utf8")); const PORT = config.server?.port || 4000; -const HOSTS = config.targets?.hosts || ["http://127.0.0.1:7088"]; +const HOSTS = config.targets?.hosts || ["http://127.0.0.1:7088", name: "my-server"]; const ENDPOINTS = config.targets?.endpoints || []; const TIMEOUT = config.targets?.timeout || 120_000; @@ -52,7 +52,7 @@ app.post("/api/parallel-fetch", async (req, res) => { socket.emit("batch:start", { url, total: tasks.length }); const promises = tasks.map(({ host, endpoint }) => { - const fullUrl = host + endpoint; + const fullUrl = host.url + endpoint; const start = Date.now(); return axios({ @@ -66,7 +66,9 @@ app.post("/api/parallel-fetch", async (req, res) => { const elapsed = Date.now() - start; console.log(`[OK] ${host} ${endpoint} (${elapsed}ms)`); socket.emit("tool:response", { - host, endpoint, + host: host.url, + serverName: host.name, + endpoint, ok: true, status: response.status, data: response.data, @@ -77,7 +79,9 @@ app.post("/api/parallel-fetch", async (req, res) => { const elapsed = Date.now() - start; console.log(`[ERROR] ${host} ${endpoint} (${elapsed}ms) — ${err.message}`); socket.emit("tool:error", { - host, endpoint, + host: host.url, + serverName: host.name, + endpoint, ok: false, error: err.message, code: err.code || null,