From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4C1AD706D5 for ; Wed, 29 Sep 2021 08:28:08 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3F05FEC5A for ; Wed, 29 Sep 2021 08:28:08 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 4BEB4EC4C for ; Wed, 29 Sep 2021 08:28:07 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1E8C844B3E for ; Wed, 29 Sep 2021 08:28:07 +0200 (CEST) Message-ID: <556bb335-5bc6-d10d-c956-82058bf1f547@proxmox.com> Date: Wed, 29 Sep 2021 08:27:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Thunderbird/93.0 Content-Language: en-US To: Proxmox Backup Server development discussion , Dominik Csapak References: <20210928091152.2151682-1-d.csapak@proxmox.com> <20210928091152.2151682-2-d.csapak@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20210928091152.2151682-2-d.csapak@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 1.761 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -3.03 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pbs-devel] [PATCH proxmox-backup v2 1/3] rest-server: use hypers AddrStream for proxmox-backup-api X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Sep 2021 06:28:08 -0000 On 28.09.21 11:11, Dominik Csapak wrote: > so that the StaticIncoming wrapper is not necessary anymore. since when and why? IIRC it was some addition to tokio that fixed it. Such info is important for review and git history, especially for such a crucial code part... > The only > thing we have to do is to change the Service impl from tokio::net::TcpStream > to hyper::server::conn::AddStream to fulfill the trait requirements. > > Signed-off-by: Dominik Csapak > --- > new in v2 > proxmox-rest-server/src/rest.rs | 18 ++++++++---------- > src/bin/proxmox-backup-api.rs | 3 ++- > 2 files changed, 10 insertions(+), 11 deletions(-) > > diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs > index ba2edf11..8c1e34a3 100644 > --- a/proxmox-rest-server/src/rest.rs > +++ b/proxmox-rest-server/src/rest.rs > @@ -93,7 +93,7 @@ impl tower_service::Service<&Pin } > } > > -impl tower_service::Service<&tokio::net::TcpStream> for RestServer { > +impl tower_service::Service<&hyper::server::conn::AddrStream> for RestServer { > type Response = ApiService; > type Error = Error; > type Future = Pin> + Send>>; > @@ -102,15 +102,13 @@ impl tower_service::Service<&tokio::net::TcpStream> for RestServer { > Poll::Ready(Ok(())) > } > > - fn call(&mut self, ctx: &tokio::net::TcpStream) -> Self::Future { > - match ctx.peer_addr() { > - Err(err) => future::err(format_err!("unable to get peer address - {}", err)).boxed(), > - Ok(peer) => future::ok(ApiService { > - peer, > - api_config: self.api_config.clone(), > - }) > - .boxed(), > - } > + fn call(&mut self, ctx: &hyper::server::conn::AddrStream) -> Self::Future { > + let peer = ctx.remote_addr(); > + future::ok(ApiService { > + peer, > + api_config: self.api_config.clone(), > + }) > + .boxed() > } > } > > diff --git a/src/bin/proxmox-backup-api.rs b/src/bin/proxmox-backup-api.rs > index 86650de6..e3f2531f 100644 > --- a/src/bin/proxmox-backup-api.rs > +++ b/src/bin/proxmox-backup-api.rs > @@ -108,7 +108,8 @@ async fn run() -> Result<(), Error> { > let server = daemon::create_daemon( > ([127,0,0,1], 82).into(), > move |listener, ready| { > - let incoming = proxmox_backup::tools::async_io::StaticIncoming::from(listener); > + let incoming = hyper::server::conn::AddrIncoming::from_listener(listener)?; > + > Ok(ready > .and_then(|_| hyper::Server::builder(incoming) > .serve(rest_server) >