mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-25 18:09:22 +02:00
fix ssh handshake timeout
This commit is contained in:
@ -176,12 +176,15 @@ where
|
||||
/// Applies timeout to request prcoessing.
|
||||
pub(crate) struct AcceptorTimeout<T> {
|
||||
inner: T,
|
||||
timeout: u64,
|
||||
timeout: Duration,
|
||||
}
|
||||
|
||||
impl<T: NewService> AcceptorTimeout<T> {
|
||||
pub(crate) fn new(timeout: u64, inner: T) -> Self {
|
||||
Self { inner, timeout }
|
||||
Self {
|
||||
inner,
|
||||
timeout: Duration::from_millis(timeout),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +207,7 @@ impl<T: NewService> NewService for AcceptorTimeout<T> {
|
||||
#[doc(hidden)]
|
||||
pub(crate) struct AcceptorTimeoutFut<T: NewService> {
|
||||
fut: T::Future,
|
||||
timeout: u64,
|
||||
timeout: Duration,
|
||||
}
|
||||
|
||||
impl<T: NewService> Future for AcceptorTimeoutFut<T> {
|
||||
@ -225,7 +228,7 @@ impl<T: NewService> Future for AcceptorTimeoutFut<T> {
|
||||
/// Applies timeout to request prcoessing.
|
||||
pub(crate) struct AcceptorTimeoutService<T> {
|
||||
inner: T,
|
||||
timeout: u64,
|
||||
timeout: Duration,
|
||||
}
|
||||
|
||||
impl<T: Service> Service for AcceptorTimeoutService<T> {
|
||||
@ -241,7 +244,7 @@ impl<T: Service> Service for AcceptorTimeoutService<T> {
|
||||
fn call(&mut self, req: Self::Request) -> Self::Future {
|
||||
AcceptorTimeoutResponse {
|
||||
fut: self.inner.call(req),
|
||||
sleep: sleep(Duration::from_millis(self.timeout)),
|
||||
sleep: sleep(self.timeout),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,18 +59,6 @@ where
|
||||
);
|
||||
|
||||
if secure {
|
||||
Either::A(ServerMessageAcceptor::new(
|
||||
settings.clone(),
|
||||
TcpAcceptor::new(acceptor.create().map_err(AcceptorError::Service))
|
||||
.map_err(|_| ())
|
||||
.map_init_err(|_| ())
|
||||
.and_then(
|
||||
HttpService::new(settings)
|
||||
.map_init_err(|_| ())
|
||||
.map_err(|_| ()),
|
||||
),
|
||||
))
|
||||
} else {
|
||||
Either::B(ServerMessageAcceptor::new(
|
||||
settings.clone(),
|
||||
TcpAcceptor::new(AcceptorTimeout::new(
|
||||
@ -84,25 +72,23 @@ where
|
||||
.map_err(|_| ()),
|
||||
),
|
||||
))
|
||||
} else {
|
||||
Either::A(ServerMessageAcceptor::new(
|
||||
settings.clone(),
|
||||
TcpAcceptor::new(acceptor.create().map_err(AcceptorError::Service))
|
||||
.map_err(|_| ())
|
||||
.map_init_err(|_| ())
|
||||
.and_then(
|
||||
HttpService::new(settings)
|
||||
.map_init_err(|_| ())
|
||||
.map_err(|_| ()),
|
||||
),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<F, H, A> Clone for HttpServiceBuilder<F, H, A>
|
||||
where
|
||||
F: Fn() -> H + Send + Clone,
|
||||
H: IntoHttpHandler,
|
||||
A: AcceptorServiceFactory,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
HttpServiceBuilder {
|
||||
factory: self.factory.clone(),
|
||||
acceptor: self.acceptor.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<F, H, A> ServiceProvider for HttpServiceBuilder<F, H, A>
|
||||
where
|
||||
F: Fn() -> H + Send + Clone + 'static,
|
||||
|
Reference in New Issue
Block a user