implement Servive for RateLimitedStream
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
e4bc3e0e8d
commit
b9d588ffde
@ -33,6 +33,7 @@ url = "2.1"
|
|||||||
proxmox = "0.15.0"
|
proxmox = "0.15.0"
|
||||||
proxmox-io = "1"
|
proxmox-io = "1"
|
||||||
proxmox-lang = "1"
|
proxmox-lang = "1"
|
||||||
|
proxmox-http = { version = "0.5.0", features = [ "client" ] }
|
||||||
proxmox-router = "1.1"
|
proxmox-router = "1.1"
|
||||||
proxmox-schema = { version = "1", features = [ "api-macro", "upid-api-impl" ] }
|
proxmox-schema = { version = "1", features = [ "api-macro", "upid-api-impl" ] }
|
||||||
proxmox-time = "1"
|
proxmox-time = "1"
|
||||||
|
@ -31,6 +31,8 @@ use proxmox_schema::{
|
|||||||
ParameterSchema,
|
ParameterSchema,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use proxmox_http::client::RateLimitedStream;
|
||||||
|
|
||||||
use pbs_tools::compression::{DeflateEncoder, Level};
|
use pbs_tools::compression::{DeflateEncoder, Level};
|
||||||
use pbs_tools::stream::AsyncReaderStream;
|
use pbs_tools::stream::AsyncReaderStream;
|
||||||
|
|
||||||
@ -73,6 +75,32 @@ impl RestServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Service<&Pin<Box<tokio_openssl::SslStream<RateLimitedStream<tokio::net::TcpStream>>>>>
|
||||||
|
for RestServer
|
||||||
|
{
|
||||||
|
type Response = ApiService;
|
||||||
|
type Error = Error;
|
||||||
|
type Future = Pin<Box<dyn Future<Output = Result<ApiService, Error>> + Send>>;
|
||||||
|
|
||||||
|
fn poll_ready(&mut self, _cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||||
|
Poll::Ready(Ok(()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn call(
|
||||||
|
&mut self,
|
||||||
|
ctx: &Pin<Box<tokio_openssl::SslStream<RateLimitedStream<tokio::net::TcpStream>>>>,
|
||||||
|
) -> Self::Future {
|
||||||
|
match ctx.get_ref().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(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Service<&Pin<Box<tokio_openssl::SslStream<tokio::net::TcpStream>>>>
|
impl Service<&Pin<Box<tokio_openssl::SslStream<tokio::net::TcpStream>>>>
|
||||||
for RestServer
|
for RestServer
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user