Fixed address passing to tunnel

This commit is contained in:
Adolfo Gómez García 2022-04-04 21:12:54 +02:00
parent b3047e366d
commit 2b5aa9c9a4

View File

@ -130,7 +130,7 @@ async def tunnel_proc_async(
if cfg.ssl_dhparam: if cfg.ssl_dhparam:
context.load_dh_params(cfg.ssl_dhparam) context.load_dh_params(cfg.ssl_dhparam)
async def processSocket(ssock: socket.socket) -> None: async def processSocket(ssock: socket.socket, address: typing.Any) -> None:
sock = curio.io.Socket(ssock) sock = curio.io.Socket(ssock)
try: try:
# First, ensure handshake (simple handshake) and command # First, ensure handshake (simple handshake) and command
@ -157,10 +157,7 @@ async def tunnel_proc_async(
ssock, address = await curio.run_in_thread(get_socket, pipe) ssock, address = await curio.run_in_thread(get_socket, pipe)
if not ssock: if not ssock:
break break
logger.debug( await group.spawn(processSocket, ssock, address)
f'CONNECTION from {address!r} (pid: {os.getpid()})'
)
await group.spawn(processSocket, ssock)
except Exception: except Exception:
logger.error('NEGOTIATION ERROR from %s', address[0]) logger.error('NEGOTIATION ERROR from %s', address[0])
@ -226,11 +223,9 @@ def tunnel_main():
prcs = processes.Processes(tunnel_proc_async, cfg, stats_collector.ns) prcs = processes.Processes(tunnel_proc_async, cfg, stats_collector.ns)
try:
while not do_stop: while not do_stop:
try: try:
client, addr = sock.accept() client, addr = sock.accept()
client.settimeout(3.0)
logger.info('CONNECTION from %s', addr[0]) logger.info('CONNECTION from %s', addr[0])
# Select BEST process for sending this new connection # Select BEST process for sending this new connection
@ -242,9 +237,6 @@ def tunnel_main():
pass # Continue and retry pass # Continue and retry
except Exception as e: except Exception as e:
logger.error('LOOP: %s', e) logger.error('LOOP: %s', e)
except Exception as e:
sys.stderr.write(f'Error: {e}\n')
logger.error('MAIN: %s', e)
if sock: if sock:
sock.close() sock.close()