Skip to content

Commit b9a00d4

Browse files
authoredJul 14, 2022
Update tcp_tunnel.py
fix: Endless loop
1 parent b33c151 commit b9a00d4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎tcp_tunnel.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ async def server_handle(self, reader: asyncio.StreamReader, writer: asyncio.Stre
3636
data = await reader.read(self.HEADER_SIZE)
3737
if len(data) != self.HEADER_SIZE:
3838
writer.close()
39+
return
3940
size = struct.unpack('!I', data[:self.HEADER_SIZE])[0]
4041
data = await reader.read(size)
41-
while len(data) < size:
42+
while len(data) < size and not reader.at_eof():
4243
data += await reader.read(size - len(data))
4344
tunnel_req = json.loads(data.decode())
4445
dst_reader, dst_writer = await asyncio.open_connection(tunnel_req['dst_host'], tunnel_req['dst_port'])

0 commit comments

Comments
 (0)
Please sign in to comment.