From 315f638a728a416356f168af183985b6e9d80803 Mon Sep 17 00:00:00 2001 From: Boro Vukovic Date: Fri, 17 Jan 2025 20:28:40 -0500 Subject: [PATCH] upgrade http/https/socks proxy agents --- package-lock.json | 122 ++++++++++++++++++++++++++++++++-------------- package.json | 6 +-- server/proxy.js | 30 +++++------- 3 files changed, 101 insertions(+), 57 deletions(-) diff --git a/package-lock.json b/package-lock.json index c04af3851..c6abaa4bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "uptime-kuma", - "version": "1.23.15", + "version": "1.23.16", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "uptime-kuma", - "version": "1.23.15", + "version": "1.23.16", "license": "MIT", "dependencies": { "@grpc/grpc-js": "~1.8.22", @@ -35,8 +35,8 @@ "gamedig": "^4.2.0", "html-escaper": "^3.0.3", "http-graceful-shutdown": "~3.1.7", - "http-proxy-agent": "~5.0.0", - "https-proxy-agent": "~5.0.1", + "http-proxy-agent": "~7.0.2", + "https-proxy-agent": "~7.0.6", "iconv-lite": "~0.6.3", "isomorphic-ws": "^5.0.0", "jsesc": "~3.0.2", @@ -71,7 +71,7 @@ "semver": "~7.5.4", "socket.io": "~4.8.0", "socket.io-client": "~4.8.0", - "socks-proxy-agent": "6.1.1", + "socks-proxy-agent": "~8.0.5", "tar": "~6.2.1", "tcp-ping": "~0.1.1", "thirty-two": "~1.0.2", @@ -4593,6 +4593,18 @@ "node-pre-gyp": "bin/node-pre-gyp" } }, + "node_modules/@mapbox/node-pre-gyp/node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/@mongodb-js/saslprep": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.9.tgz", @@ -5979,15 +5991,6 @@ "integrity": "sha512-d/keJiNKfpHo+GmSB8QcsAwBx8h+V1UbdozA5TD+eSLXprNY53JAYub47J9evsSKWDdNG5uVj0FiMozLKuzowQ==", "license": "MIT" }, - "node_modules/@tootallnate/once": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", - "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", - "license": "MIT", - "engines": { - "node": ">= 10" - } - }, "node_modules/@types/accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/@types/accepts/-/accepts-1.3.7.tgz", @@ -11692,17 +11695,23 @@ } }, "node_modules/http-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", - "integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==", - "license": "MIT", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", "dependencies": { - "@tootallnate/once": "2", - "agent-base": "6", - "debug": "4" + "agent-base": "^7.1.0", + "debug": "^4.3.4" }, "engines": { - "node": ">= 6" + "node": ">= 14" + } + }, + "node_modules/http-proxy-agent/node_modules/agent-base": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", + "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", + "engines": { + "node": ">= 14" } }, "node_modules/http-signature": { @@ -11734,16 +11743,23 @@ } }, "node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "license": "MIT", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", "dependencies": { - "agent-base": "6", + "agent-base": "^7.1.2", "debug": "4" }, "engines": { - "node": ">= 6" + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent/node_modules/agent-base": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", + "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", + "engines": { + "node": ">= 14" } }, "node_modules/human-signals": { @@ -14057,6 +14073,19 @@ "node": ">= 6" } }, + "node_modules/make-fetch-happen/node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "optional": true, + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/make-fetch-happen/node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -14070,6 +14099,20 @@ "node": ">=10" } }, + "node_modules/make-fetch-happen/node_modules/socks-proxy-agent": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.2.1.tgz", + "integrity": "sha512-a6KW9G+6B3nWZ1yB8G7pJwL3ggLy1uTzKAgCb7ttblwqdz9fMGJUuTy3uFzEP48FAs9FLILlmzDlE2JJhVQaXQ==", + "optional": true, + "dependencies": { + "agent-base": "^6.0.2", + "debug": "^4.3.3", + "socks": "^2.6.2" + }, + "engines": { + "node": ">= 10" + } + }, "node_modules/make-fetch-happen/node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -17718,17 +17761,24 @@ } }, "node_modules/socks-proxy-agent": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.1.1.tgz", - "integrity": "sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew==", - "license": "MIT", + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz", + "integrity": "sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==", "dependencies": { - "agent-base": "^6.0.2", - "debug": "^4.3.1", - "socks": "^2.6.1" + "agent-base": "^7.1.2", + "debug": "^4.3.4", + "socks": "^2.8.3" }, "engines": { - "node": ">= 10" + "node": ">= 14" + } + }, + "node_modules/socks-proxy-agent/node_modules/agent-base": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", + "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", + "engines": { + "node": ">= 14" } }, "node_modules/sortablejs": { diff --git a/package.json b/package.json index 2ef1dc14e..995aef9dd 100644 --- a/package.json +++ b/package.json @@ -104,8 +104,8 @@ "gamedig": "^4.2.0", "html-escaper": "^3.0.3", "http-graceful-shutdown": "~3.1.7", - "http-proxy-agent": "~5.0.0", - "https-proxy-agent": "~5.0.1", + "http-proxy-agent": "~7.0.2", + "https-proxy-agent": "~7.0.6", "iconv-lite": "~0.6.3", "isomorphic-ws": "^5.0.0", "jsesc": "~3.0.2", @@ -140,7 +140,7 @@ "semver": "~7.5.4", "socket.io": "~4.8.0", "socket.io-client": "~4.8.0", - "socks-proxy-agent": "6.1.1", + "socks-proxy-agent": "~8.0.5", "tar": "~6.2.1", "tcp-ping": "~0.1.1", "thirty-two": "~1.0.2", diff --git a/server/proxy.js b/server/proxy.js index 660b9b411..f9b89c455 100644 --- a/server/proxy.js +++ b/server/proxy.js @@ -1,7 +1,7 @@ const { R } = require("redbean-node"); -const HttpProxyAgent = require("http-proxy-agent"); -const HttpsProxyAgent = require("https-proxy-agent"); -const SocksProxyAgent = require("socks-proxy-agent"); +const { HttpProxyAgent } = require("http-proxy-agent"); +const { HttpsProxyAgent } = require("https-proxy-agent"); +const { SocksProxyAgent } = require("socks-proxy-agent"); const { debug } = require("../src/util"); const { UptimeKumaServer } = require("./uptime-kuma-server"); @@ -97,41 +97,35 @@ class Proxy { let httpAgent; let httpsAgent; - const proxyOptions = { - protocol: proxy.protocol, - host: proxy.host, - port: proxy.port, - }; + const proxyUrl = new URL(`${proxy.protocol}://${proxy.host}:${proxy.port}`); if (proxy.auth) { - proxyOptions.auth = `${proxy.username}:${proxy.password}`; + proxyUrl.username = proxy.username; + proxyUrl.password = proxy.password; } - debug(`Proxy Options: ${JSON.stringify(proxyOptions)}`); + debug(`Proxy URL: ${proxyUrl.toString()}`); debug(`HTTP Agent Options: ${JSON.stringify(httpAgentOptions)}`); debug(`HTTPS Agent Options: ${JSON.stringify(httpsAgentOptions)}`); switch (proxy.protocol) { case "http": case "https": - httpAgent = new HttpProxyAgent({ - ...httpAgentOptions || {}, - ...proxyOptions + httpAgent = new HttpProxyAgent(proxyUrl.toString(), { + ...(httpAgentOptions || {}), }); - httpsAgent = new HttpsProxyAgent({ - ...httpsAgentOptions || {}, - ...proxyOptions, + httpsAgent = new HttpsProxyAgent(proxyUrl.toString(), { + ...(httpsAgentOptions || {}), }); break; case "socks": case "socks5": case "socks5h": case "socks4": - agent = new SocksProxyAgent({ + agent = new SocksProxyAgent(proxyUrl.toString(), { ...httpAgentOptions, ...httpsAgentOptions, - ...proxyOptions, tls: { rejectUnauthorized: httpsAgentOptions.rejectUnauthorized, },