Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ’„ style: add auth support for PROXY_URL #5304

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading