fix socks
This commit is contained in:
@@ -12,6 +12,7 @@ import asyncio
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
@@ -140,6 +141,17 @@ def _is_addr_in_use_error(exc: OSError) -> bool:
|
||||
)
|
||||
|
||||
|
||||
def _bind_target_from_error(exc: OSError, config: dict) -> tuple[str, int]:
|
||||
text = str(exc)
|
||||
match = re.search(r"\('([^']+)',\s*(\d+)\)", text)
|
||||
if match:
|
||||
return match.group(1), int(match.group(2))
|
||||
return (
|
||||
config.get("listen_host", "127.0.0.1"),
|
||||
config.get("listen_port", 8080),
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
config_path = args.config
|
||||
@@ -216,6 +228,13 @@ def main():
|
||||
mode = config.get("mode", "domain_fronting")
|
||||
log.info("DomainFront Tunnel starting (mode: %s)", mode)
|
||||
|
||||
if config.get("socks5_enabled"):
|
||||
log.info(
|
||||
"SOCKS5 address : %s:%d",
|
||||
config.get("listen_host", "127.0.0.1"),
|
||||
config.get("socks5_port", 1080),
|
||||
)
|
||||
|
||||
if mode == "custom_domain":
|
||||
log.info("Custom domain : %s", config["custom_domain"])
|
||||
elif mode == "google_fronting":
|
||||
@@ -263,8 +282,7 @@ def main():
|
||||
asyncio.run(ProxyServer(config).start())
|
||||
except OSError as e:
|
||||
if _is_addr_in_use_error(e):
|
||||
host = config.get("listen_host", "127.0.0.1")
|
||||
port = config.get("listen_port", 8080)
|
||||
host, port = _bind_target_from_error(e, config)
|
||||
log.error("Cannot listen on %s:%d because that address is already in use.", host, port)
|
||||
details = _windows_listener_details(host, port)
|
||||
if details:
|
||||
|
||||
Reference in New Issue
Block a user