From e4dcbbb562b33d452be7d4760989a91c97bf0407 Mon Sep 17 00:00:00 2001 From: Egbert Bouman Date: Sat, 27 Jan 2024 14:06:26 +0100 Subject: [PATCH] Add UDP associate functions to the Python wrapper --- ipv8_rust_tunnels/endpoint.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ipv8_rust_tunnels/endpoint.py b/ipv8_rust_tunnels/endpoint.py index 9d96067..17cc786 100644 --- a/ipv8_rust_tunnels/endpoint.py +++ b/ipv8_rust_tunnels/endpoint.py @@ -100,6 +100,19 @@ def set_peer_flags(self, max_relay_early: int) -> None: if self.is_open(): self.rust_ep.set_peer_flags(max_relay_early) + def create_udp_associate(self, port: int, hops: int) -> int: + """ + Create a SOCKS5 UDP associate socket using the given port and hop count. + Returns the port on which the socket was created (in case port 0 was given as argument). + """ + return self.rust_ep.create_udp_associate(port, hops) + + def close_udp_associate(self, port: int) -> None: + """ + Close the SOCKS5 UDP associate socket that's bound to the given port. + """ + return self.rust_ep.close_udp_associate(port) + def datagram_received(self, ip: str, port: int, datagram: bytes) -> None: """ Process incoming data that's coming directly from the socket.