Skip to content

Commit eb26c79

Browse files
authored
💄 style: add auth support for PROXY_URL (lobehub#5304)
Signed-off-by: WindSpiritSR <[email protected]>
1 parent dfab4ce commit eb26c79

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

scripts/serverLauncher/startServer.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const isValidIP = (ip, version = 4) => {
2929

3030
// Function to parse protocol, host and port from a URL
3131
const parseUrl = (url) => {
32-
const { protocol, hostname: host, port } = new URL(url);
33-
return { host, port: port || 443, protocol: protocol.replace(':', '') };
32+
const { protocol, hostname: host, port, username: user, password: pass } = new URL(url);
33+
return { host, pass, port: port || 443, protocol: protocol.replace(':', ''), user };
3434
};
3535

3636
// Function to resolve host IP via DNS
@@ -55,7 +55,7 @@ const resolveHostIP = async (host, version = 4) => {
5555

5656
// Function to generate proxychains configuration
5757
const runProxyChainsConfGenerator = async (url) => {
58-
const { protocol, host, port } = parseUrl(url);
58+
const { protocol, host, port, user, pass } = parseUrl(url);
5959

6060
if (!['http', 'socks4', 'socks5'].includes(protocol)) {
6161
console.error(
@@ -76,18 +76,21 @@ const runProxyChainsConfGenerator = async (url) => {
7676

7777
const configContent = `
7878
localnet 127.0.0.0/255.0.0.0
79+
localnet 10.0.0.0/255.0.0.0
80+
localnet 172.16.0.0/255.240.0.0
81+
localnet 192.168.0.0/255.255.0.0
7982
localnet ::1/128
8083
proxy_dns
8184
remote_dns_subnet 224
8285
strict_chain
8386
tcp_connect_time_out 8000
8487
tcp_read_time_out 15000
8588
[ProxyList]
86-
${protocol} ${ip} ${port}
89+
${protocol} ${ip} ${port} ${user} ${pass}
8790
`.trim();
8891

8992
await fs.writeFile(PROXYCHAINS_CONF_PATH, configContent);
90-
console.log(`✅ ProxyChains: All outgoing traffic routed via ${protocol}://${ip}:${port}.`);
93+
console.log(`✅ ProxyChains: All outgoing traffic routed via ${url}.`);
9194
console.log('-------------------------------------');
9295
};
9396

0 commit comments

Comments
 (0)