diff --git a/examples/http3_server.py b/examples/http3_server.py index dbab6cda..0d7f7675 100644 --- a/examples/http3_server.py +++ b/examples/http3_server.py @@ -256,8 +256,7 @@ def http_event_received(self, event: H3Event) -> None: path = path_bytes.decode() self._quic._logger.info("HTTP request %s %s", method, path) - # FIXME: add a public API to retrieve peer address - client_addr = self._http._quic._network_paths[0].addr + client_addr = self._http._quic.retrieve_peer_address() client = (client_addr[0], client_addr[1]) handler: Handler diff --git a/src/aioquic/quic/connection.py b/src/aioquic/quic/connection.py index 347a8270..669fd90f 100644 --- a/src/aioquic/quic/connection.py +++ b/src/aioquic/quic/connection.py @@ -457,6 +457,9 @@ def connect(self, addr: NetworkAddress, now: float) -> None: self._version = self._configuration.supported_versions[0] self._connect(now=now) + def retrieve_peer_address(self) -> Tuple[bytes, NetworkAddress]: + return self._network_paths[0].addr + def datagrams_to_send(self, now: float) -> List[Tuple[bytes, NetworkAddress]]: """ Return a list of `(data, addr)` tuples of datagrams which need to be