|
@ -52,6 +52,26 @@ def main(): |
|
|
udp_servers = [] |
|
|
udp_servers = [] |
|
|
dns_resolver = asyncdns.DNSResolver() |
|
|
dns_resolver = asyncdns.DNSResolver() |
|
|
for port, password in config['port_password'].items(): |
|
|
for port, password in config['port_password'].items(): |
|
|
|
|
|
a_config = config.copy() |
|
|
|
|
|
ipv6_ok = False |
|
|
|
|
|
if 'server_ipv6' in a_config: |
|
|
|
|
|
try: |
|
|
|
|
|
if len(a_config['server_ipv6']) > 2 and a_config['server_ipv6'][0] == "[" and a_config['server_ipv6'][-1] == "]": |
|
|
|
|
|
a_config['server_ipv6'] = a_config['server_ipv6'][1:-1] |
|
|
|
|
|
a_config['server_port'] = int(port) |
|
|
|
|
|
a_config['password'] = password |
|
|
|
|
|
a_config['server'] = a_config['server_ipv6'] |
|
|
|
|
|
logging.info("starting server at %s:%d" % |
|
|
|
|
|
(a_config['server'], int(port))) |
|
|
|
|
|
tcp_servers.append(tcprelay.TCPRelay(a_config, dns_resolver, False)) |
|
|
|
|
|
udp_servers.append(udprelay.UDPRelay(a_config, dns_resolver, False)) |
|
|
|
|
|
if a_config['server_ipv6'] == "::": |
|
|
|
|
|
ipv6_ok = True |
|
|
|
|
|
except Exception as e: |
|
|
|
|
|
shell.print_exception(e) |
|
|
|
|
|
|
|
|
|
|
|
if not ipv6_ok: |
|
|
|
|
|
try: |
|
|
a_config = config.copy() |
|
|
a_config = config.copy() |
|
|
a_config['server_port'] = int(port) |
|
|
a_config['server_port'] = int(port) |
|
|
a_config['password'] = password |
|
|
a_config['password'] = password |
|
@ -59,6 +79,8 @@ def main(): |
|
|
(a_config['server'], int(port))) |
|
|
(a_config['server'], int(port))) |
|
|
tcp_servers.append(tcprelay.TCPRelay(a_config, dns_resolver, False)) |
|
|
tcp_servers.append(tcprelay.TCPRelay(a_config, dns_resolver, False)) |
|
|
udp_servers.append(udprelay.UDPRelay(a_config, dns_resolver, False)) |
|
|
udp_servers.append(udprelay.UDPRelay(a_config, dns_resolver, False)) |
|
|
|
|
|
except Exception as e: |
|
|
|
|
|
shell.print_exception(e) |
|
|
|
|
|
|
|
|
def run_server(): |
|
|
def run_server(): |
|
|
def child_handler(signum, _): |
|
|
def child_handler(signum, _): |
|
|