From 4639542fce50cf10a3ccbdd9b5c6e52a2fe92727 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 25 Jan 2023 10:49:48 +0100 Subject: [PATCH] rest-server: PeerAddress for Pin> since this is how tokio-openssl's SslStream is used in practice Signed-off-by: Wolfgang Bumiller --- proxmox-rest-server/src/rest.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs index 833e2fb6..43c36ebb 100644 --- a/proxmox-rest-server/src/rest.rs +++ b/proxmox-rest-server/src/rest.rs @@ -101,6 +101,15 @@ pub trait PeerAddress { fn peer_addr(&self) -> Result; } +// 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> +impl PeerAddress for Pin> { + fn peer_addr(&self) -> Result { + T::peer_addr(&*self) + } +} + impl PeerAddress for tokio_openssl::SslStream { fn peer_addr(&self) -> Result { self.get_ref().peer_addr()