Skip to content

Commit

Permalink
broker: detect messages that are meant for a tunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Mar 7, 2020
1 parent a477d03 commit c471eb5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions broker/src/tunneldigger_broker/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,22 @@ def create_tunnel(self, address, uuid, remote_tunnel_id, client_features):
"""

return self.tunnel_manager.create_tunnel(self, address, uuid, remote_tunnel_id, client_features)

def message(self, address, msg_type, msg_data, raw_length):
"""
Called when a new protocol message is received.
:param address: Source address (host, port) tuple
:param msg_type: Message type
:param msg_data: Message payload
:param raw_length: Length of the raw message (including headers)
"""

# Due to SO_REUSEPORT bugs, we also see messags here that really ought to
# go to an established tunnel. So check the tunnels first.
for tunnel in self.tunnel_manager.tunnels.values():
if tunnel.address == self.address and tunnel.endpoint == address:
return tunnel.message(address, msg_type, msg_data, raw_length)

# Fall back to normal broker processing.
return super(Broker, self).message(address, msg_type, msg_data, raw_length)

0 comments on commit c471eb5

Please sign in to comment.