Skip to content

Commit 26ba54a

Browse files
committed
allow relaying requested port to SimpleProxy by specifying port number 0
1 parent 09d4752 commit 26ba54a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pproxy/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def udp_packet_unpack(self, data):
270270
data = self.cipher.datagram.decrypt(data) if self.cipher else data
271271
return self.jump.udp_packet_unpack(self.rproto.udp_unpack(data))
272272
def destination(self, host, port):
273-
return self.host_name, self.port
273+
return self.host_name, self.port if self.port != 0 else port
274274
def udp_prepare_connection(self, host, port, data):
275275
data = self.jump.udp_prepare_connection(host, port, data)
276276
whost, wport = self.jump.destination(host, port)
@@ -289,7 +289,7 @@ def wait_open_connection(self, host, port, local_addr, family):
289289
if self.unix:
290290
return asyncio.open_unix_connection(path=self.bind)
291291
else:
292-
return asyncio.open_connection(host=self.host_name, port=self.port, local_addr=local_addr, family=family)
292+
return asyncio.open_connection(host=self.host_name, port=self.port if self.port != 0 else port, local_addr=local_addr, family=family)
293293
async def prepare_connection(self, reader_remote, writer_remote, host, port):
294294
reader_remote, writer_remote = proto.sslwrap(reader_remote, writer_remote, self.sslclient, False, self.host_name)
295295
_, writer_cipher_r = await prepare_ciphers(self.cipher, reader_remote, writer_remote, self.bind)

0 commit comments

Comments
 (0)