Skip to content

Commit a094445

Browse files
committed
trying to narrow down #15
1 parent c3ecf37 commit a094445

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tcpproxy.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,21 @@ def start_proxy_thread(local_socket, args, in_modules, out_modules):
267267
read_sockets, _, _ = select.select(ssl_sockets, [], [])
268268

269269
for sock in read_sockets:
270-
peer = sock.getpeername()
270+
try:
271+
peer = sock.getpeername()
272+
except socket.error as serr:
273+
if serr.errno == errno.ENOTCONN:
274+
# kind of a blind shot at fixing issue #15
275+
# I don't yet understand how this error can happen, but if it happens I'll just shut down the thread
276+
# the connection is not in a useful state anymore
277+
for s in [remote_socket, local_socket]:
278+
s.close()
279+
running = False
280+
break
281+
else:
282+
print(f"{time.strftime('%Y%m%d-%H%M%S')}: Socket exception in start_proxy_thread")
283+
raise serr
284+
271285
data = receive_from(sock)
272286
log(args.logfile, 'Received %d bytes' % len(data))
273287

@@ -395,7 +409,7 @@ def main():
395409
print(e.strerror)
396410
sys.exit(5)
397411

398-
proxy_socket.listen(10)
412+
proxy_socket.listen(100)
399413
log(args.logfile, str(args))
400414
# endless loop until ctrl+c
401415
try:

0 commit comments

Comments
 (0)