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:
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)
try:
# 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)
if not ssock:
break
logger.debug(
f'CONNECTION from {address!r} (pid: {os.getpid()})'
)
await group.spawn(processSocket, ssock)
await group.spawn(processSocket, ssock, address)
except Exception:
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)
try:
while not do_stop:
try:
client, addr = sock.accept()
client.settimeout(3.0)
logger.info('CONNECTION from %s', addr[0])
# Select BEST process for sending this new connection
@ -242,9 +237,6 @@ def tunnel_main():
pass # Continue and retry
except Exception as e:
logger.error('LOOP: %s', e)
except Exception as e:
sys.stderr.write(f'Error: {e}\n')
logger.error('MAIN: %s', e)
if sock:
sock.close()