mirror of
https://git.proxmox.com/git/proxmox
synced 2025-10-05 02:54:21 +00:00
rest-server: PeerAddress for Pin<Box<T>>
since this is how tokio-openssl's SslStream is used in practice Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
515cc729d0
commit
4639542fce
@ -101,6 +101,15 @@ pub trait PeerAddress {
|
|||||||
fn peer_addr(&self) -> Result<std::net::SocketAddr, Error>;
|
fn peer_addr(&self) -> Result<std::net::SocketAddr, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tokio_openssl's SslStream requires the stream to be pinned in order to accept it, and we need to
|
||||||
|
// accept before the peer address is requested, so let's just generally implement this for
|
||||||
|
// Pin<Box<T>>
|
||||||
|
impl<T: PeerAddress> PeerAddress for Pin<Box<T>> {
|
||||||
|
fn peer_addr(&self) -> Result<std::net::SocketAddr, Error> {
|
||||||
|
T::peer_addr(&*self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: PeerAddress> PeerAddress for tokio_openssl::SslStream<T> {
|
impl<T: PeerAddress> PeerAddress for tokio_openssl::SslStream<T> {
|
||||||
fn peer_addr(&self) -> Result<std::net::SocketAddr, Error> {
|
fn peer_addr(&self) -> Result<std::net::SocketAddr, Error> {
|
||||||
self.get_ref().peer_addr()
|
self.get_ref().peer_addr()
|
||||||
|
Loading…
Reference in New Issue
Block a user