mirror of https://github.com/fafhrd91/actix-net
				
				
				
			migrate server rustls support
This commit is contained in:
		
							parent
							
								
									ed83360605
								
							
						
					
					
						commit
						b6f9a78011
					
				| 
						 | 
					@ -26,9 +26,6 @@ nativetls = ["native-tls", "tokio-tls"]
 | 
				
			||||||
openssl = ["open-ssl", "tokio-openssl", "actix-server-config/openssl"]
 | 
					openssl = ["open-ssl", "tokio-openssl", "actix-server-config/openssl"]
 | 
				
			||||||
rustls = ["rust-tls", "tokio-rustls", "webpki", "webpki-roots", "actix-server-config/rustls"]
 | 
					rustls = ["rust-tls", "tokio-rustls", "webpki", "webpki-roots", "actix-server-config/rustls"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# uds
 | 
					 | 
				
			||||||
# uds = ["mio-uds", "tokio-uds", "actix-server-config/uds"]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[dependencies]
 | 
					[dependencies]
 | 
				
			||||||
actix-rt = "1.0.0-alpha.1"
 | 
					actix-rt = "1.0.0-alpha.1"
 | 
				
			||||||
actix-service = "1.0.0-alpha.1"
 | 
					actix-service = "1.0.0-alpha.1"
 | 
				
			||||||
| 
						 | 
					@ -49,7 +46,6 @@ tokio-timer = "0.3.0-alpha.6"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# unix domain sockets
 | 
					# unix domain sockets
 | 
				
			||||||
mio-uds = { version = "0.6.7", optional = true }
 | 
					mio-uds = { version = "0.6.7", optional = true }
 | 
				
			||||||
#tokio-uds = { version="0.2.5", optional = true }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# nativetls
 | 
					# nativetls
 | 
				
			||||||
native-tls = { version = "0.2", optional = true }
 | 
					native-tls = { version = "0.2", optional = true }
 | 
				
			||||||
| 
						 | 
					@ -61,7 +57,8 @@ tokio-openssl = { version = "0.4.0-alpha.6", optional = true }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# rustls
 | 
					# rustls
 | 
				
			||||||
rust-tls = { version = "0.16.0", package = "rustls", optional = true }
 | 
					rust-tls = { version = "0.16.0", package = "rustls", optional = true }
 | 
				
			||||||
tokio-rustls = { version = "0.12.0-alpha.2", optional = true }
 | 
					# tokio-rustls = { version = "0.12.0-alpha.2", optional = true }
 | 
				
			||||||
 | 
					tokio-rustls = { git = "https://github.com/quininer/tokio-rustls.git", branch = "tokio-0.2", optional = true }
 | 
				
			||||||
webpki = { version = "0.21", optional = true }
 | 
					webpki = { version = "0.21", optional = true }
 | 
				
			||||||
webpki-roots = { version = "0.17", optional = true }
 | 
					webpki-roots = { version = "0.17", optional = true }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,10 +13,10 @@ mod nativetls;
 | 
				
			||||||
#[cfg(feature = "nativetls")]
 | 
					#[cfg(feature = "nativetls")]
 | 
				
			||||||
pub use self::nativetls::NativeTlsAcceptor;
 | 
					pub use self::nativetls::NativeTlsAcceptor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//#[cfg(feature = "rustls")]
 | 
					#[cfg(feature = "rustls")]
 | 
				
			||||||
//mod rustls;
 | 
					mod rustls;
 | 
				
			||||||
//#[cfg(feature = "rustls")]
 | 
					#[cfg(feature = "rustls")]
 | 
				
			||||||
//pub use self::rustls::RustlsAcceptor;
 | 
					pub use self::rustls::RustlsAcceptor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Sets the maximum per-worker concurrent ssl connection establish process.
 | 
					/// Sets the maximum per-worker concurrent ssl connection establish process.
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,7 +43,7 @@ impl<T, P> Clone for RustlsAcceptor<T, P> {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<T: AsyncRead + AsyncWrite, P> ServiceFactory for RustlsAcceptor<T, P> {
 | 
					impl<T: AsyncRead + AsyncWrite + Unpin, P> ServiceFactory for RustlsAcceptor<T, P> {
 | 
				
			||||||
    type Request = Io<T, P>;
 | 
					    type Request = Io<T, P>;
 | 
				
			||||||
    type Response = Io<TlsStream<T>, P>;
 | 
					    type Response = Io<TlsStream<T>, P>;
 | 
				
			||||||
    type Error = io::Error;
 | 
					    type Error = io::Error;
 | 
				
			||||||
| 
						 | 
					@ -72,13 +72,13 @@ pub struct RustlsAcceptorService<T, P> {
 | 
				
			||||||
    conns: Counter,
 | 
					    conns: Counter,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<T: AsyncRead + AsyncWrite, P> Service for RustlsAcceptorService<T, P> {
 | 
					impl<T: AsyncRead + AsyncWrite + Unpin, P> Service for RustlsAcceptorService<T, P> {
 | 
				
			||||||
    type Request = Io<T, P>;
 | 
					    type Request = Io<T, P>;
 | 
				
			||||||
    type Response = Io<TlsStream<T>, P>;
 | 
					    type Response = Io<TlsStream<T>, P>;
 | 
				
			||||||
    type Error = io::Error;
 | 
					    type Error = io::Error;
 | 
				
			||||||
    type Future = RustlsAcceptorServiceFut<T, P>;
 | 
					    type Future = RustlsAcceptorServiceFut<T, P>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
 | 
					    fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
 | 
				
			||||||
        if self.conns.available(cx) {
 | 
					        if self.conns.available(cx) {
 | 
				
			||||||
            Poll::Ready(Ok(()))
 | 
					            Poll::Ready(Ok(()))
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
| 
						 | 
					@ -99,7 +99,7 @@ impl<T: AsyncRead + AsyncWrite, P> Service for RustlsAcceptorService<T, P> {
 | 
				
			||||||
#[pin_project]
 | 
					#[pin_project]
 | 
				
			||||||
pub struct RustlsAcceptorServiceFut<T, P>
 | 
					pub struct RustlsAcceptorServiceFut<T, P>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    T: AsyncRead + AsyncWrite,
 | 
					    T: AsyncRead + AsyncWrite + Unpin,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    #[pin]
 | 
					    #[pin]
 | 
				
			||||||
    fut: Accept<T>,
 | 
					    fut: Accept<T>,
 | 
				
			||||||
| 
						 | 
					@ -107,16 +107,15 @@ where
 | 
				
			||||||
    _guard: CounterGuard,
 | 
					    _guard: CounterGuard,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<T: AsyncRead + AsyncWrite, P> Future for RustlsAcceptorServiceFut<T, P> {
 | 
					impl<T: AsyncRead + AsyncWrite + Unpin, P> Future for RustlsAcceptorServiceFut<T, P> {
 | 
				
			||||||
    type Output = Result<Io<TlsStream<T>, P>, io::Error>;
 | 
					    type Output = Result<Io<TlsStream<T>, P>, io::Error>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
 | 
					    fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
 | 
				
			||||||
        let this = self.project();
 | 
					        let this = self.project();
 | 
				
			||||||
        let io = futures::ready!(this.fut.poll(cx));
 | 
					        let params = this.params.take().unwrap();
 | 
				
			||||||
        Poll::Ready(Ok(Io::from_parts(
 | 
					        Poll::Ready(
 | 
				
			||||||
            io,
 | 
					            futures::ready!(this.fut.poll(cx))
 | 
				
			||||||
            this.params.take().unwrap(),
 | 
					                .map(move |io| Io::from_parts(io, params, Protocol::Unknown)),
 | 
				
			||||||
            Protocol::Unknown,
 | 
					        )
 | 
				
			||||||
        )))
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue