Skip to content

Commit

Permalink
💄 style: add auth support for PROXY_URL (#5304)
Browse files Browse the repository at this point in the history
Signed-off-by: WindSpiritSR <simon343riley@gmail.com>
  • Loading branch information
WindSpiritSR authored Jan 15, 2025
1 parent dfab4ce commit eb26c79
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scripts/serverLauncher/startServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -76,18 +76,21 @@ 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
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('-------------------------------------');
};

Expand Down

0 comments on commit eb26c79

Please sign in to comment.