Skip to content

Commit

Permalink
Fix 4ca1fb4: properly fix not assuming proxy-protocol for SOCKS traff…
Browse files Browse the repository at this point in the history
…ic (#282)
  • Loading branch information
TrueBrain authored Jul 5, 2023
1 parent 4ca1fb4 commit bbf1ddb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion master_server/application/master_server_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def send_via_socks():
transport, _ = await request
try:
data = await response
protocol.datagram_received(data, server_addr)
protocol.datagram_received(data, server_addr, is_socks=True)
finally:
transport.close()

Expand Down
8 changes: 4 additions & 4 deletions master_server/openttd/udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def connection_made(self, transport):
else:
self.is_ipv6 = False

def _detect_source_ip_port(self, socket_addr, data):
if not self.proxy_protocol or self.socks_proxy:
def _detect_source_ip_port(self, socket_addr, data, is_socks=False):
if not self.proxy_protocol or is_socks:
source = Source(self, socket_addr, socket_addr[0], socket_addr[1])
return source, data

Expand Down Expand Up @@ -81,9 +81,9 @@ async def guard(self, coro):
except Exception:
log.exception("Error while processing packet")

def datagram_received(self, data, socket_addr):
def datagram_received(self, data, socket_addr, is_socks=False):
try:
source, data = self._detect_source_ip_port(socket_addr, data)
source, data = self._detect_source_ip_port(socket_addr, data, is_socks=is_socks)
except Exception as err:
log.exception("Error detecting PROXY protocol %r: %r", socket_addr, err)
return
Expand Down

0 comments on commit bbf1ddb

Please sign in to comment.