From b369687062b3d581b3fc69fc792ba06d56967d67 Mon Sep 17 00:00:00 2001 From: WindSpiritSR Date: Sun, 5 Jan 2025 18:33:59 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20auth=20support=20for?= =?UTF-8?q?=20PROXY=5FURL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: WindSpiritSR --- scripts/serverLauncher/startServer.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/serverLauncher/startServer.js b/scripts/serverLauncher/startServer.js index e5c80512eec4..a7ec5241723b 100644 --- a/scripts/serverLauncher/startServer.js +++ b/scripts/serverLauncher/startServer.js @@ -29,8 +29,8 @@ const isValidIP = (ip, version = 4) => { // Function to parse protocol, host and port from a URL const parseUrl = (url) => { - const { protocol, hostname: host, port } = new URL(url); - return { host, port: port || 443, protocol: protocol.replace(':', '') }; + const { protocol, hostname: host, port, username: user, password: pass } = new URL(url); + return { host, pass, port: port || 443, protocol: protocol.replace(':', ''), user }; }; // Function to resolve host IP via DNS @@ -55,7 +55,7 @@ const resolveHostIP = async (host, version = 4) => { // Function to generate proxychains configuration const runProxyChainsConfGenerator = async (url) => { - const { protocol, host, port } = parseUrl(url); + const { protocol, host, port, user, pass } = parseUrl(url); if (!['http', 'socks4', 'socks5'].includes(protocol)) { console.error( @@ -76,6 +76,9 @@ const runProxyChainsConfGenerator = async (url) => { const configContent = ` localnet 127.0.0.0/255.0.0.0 +localnet 10.0.0.0/255.0.0.0 +localnet 172.16.0.0/255.240.0.0 +localnet 192.168.0.0/255.255.0.0 localnet ::1/128 proxy_dns remote_dns_subnet 224 @@ -83,11 +86,11 @@ strict_chain tcp_connect_time_out 8000 tcp_read_time_out 15000 [ProxyList] -${protocol} ${ip} ${port} +${protocol} ${ip} ${port} ${user} ${pass} `.trim(); await fs.writeFile(PROXYCHAINS_CONF_PATH, configContent); - console.log(`✅ ProxyChains: All outgoing traffic routed via ${protocol}://${ip}:${port}.`); + console.log(`✅ ProxyChains: All outgoing traffic routed via ${url}.`); console.log('-------------------------------------'); };