hyper_middleware/
remote_addr.rs

1//! Module representing the remote (peer) address of a connection.
2
3use hyper::server::conn::AddrStream;
4use std::net::SocketAddr;
5
6/// Defines a method to get the remote (peer) address of a connection.
7///
8/// This trait might be needed to be implemented by for example custom TLS implementations.
9pub trait RemoteAddr {
10    /// Returns the remote (peer) address of this connection.
11    fn remote_addr(&self) -> Option<SocketAddr>;
12}
13
14impl RemoteAddr for AddrStream {
15    fn remote_addr(&self) -> Option<SocketAddr> {
16        Some(self.remote_addr())
17    }
18}