From 099d7d4bc95e7cbd367205a21c9862b3a203e962 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 15 Mar 2021 16:04:57 +0600 Subject: [PATCH] update socket2 --- ntex/CHANGES.md | 2 ++ ntex/Cargo.toml | 2 +- ntex/src/server/builder.rs | 6 +++--- ntex/src/server/socket.rs | 4 ++-- ntex/src/server/test.rs | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ntex/CHANGES.md b/ntex/CHANGES.md index 906e4dc89..25f4e4745 100644 --- a/ntex/CHANGES.md +++ b/ntex/CHANGES.md @@ -4,6 +4,8 @@ * framed: refactor api +* update socket2 0.4 + ## [0.3.8] - 2021-03-11 * http: fix expect/continue support, wake up write task diff --git a/ntex/Cargo.toml b/ntex/Cargo.toml index 787075c19..78e36c516 100644 --- a/ntex/Cargo.toml +++ b/ntex/Cargo.toml @@ -67,7 +67,7 @@ slab = "0.4" serde = { version = "1.0", features=["derive"] } serde_json = "1.0" serde_urlencoded = "0.7" -socket2 = "0.3" +socket2 = "0.4" url = "2.1" coo-kie = { version = "0.15", package = "cookie", optional = true } time = { version = "0.2", default-features = false, features = ["std"] } diff --git a/ntex/src/server/builder.rs b/ntex/src/server/builder.rs index 253dca671..f9b9c76f1 100644 --- a/ntex/src/server/builder.rs +++ b/ntex/src/server/builder.rs @@ -501,8 +501,8 @@ pub(crate) fn create_tcp_listener( backlog: i32, ) -> io::Result { let builder = match addr { - net::SocketAddr::V4(_) => Socket::new(Domain::ipv4(), Type::stream(), None)?, - net::SocketAddr::V6(_) => Socket::new(Domain::ipv6(), Type::stream(), None)?, + net::SocketAddr::V4(_) => Socket::new(Domain::IPV4, Type::STREAM, None)?, + net::SocketAddr::V6(_) => Socket::new(Domain::IPV6, Type::STREAM, None)?, }; // On Windows, this allows rebinding sockets which are actively in use, @@ -513,7 +513,7 @@ pub(crate) fn create_tcp_listener( builder.bind(&SockAddr::from(addr))?; builder.listen(backlog)?; - Ok(builder.into_tcp_listener()) + Ok(net::TcpListener::from(builder)) } #[cfg(test)] diff --git a/ntex/src/server/socket.rs b/ntex/src/server/socket.rs index e92ee3427..a8fdc5512 100644 --- a/ntex/src/server/socket.rs +++ b/ntex/src/server/socket.rs @@ -217,10 +217,10 @@ mod tests { assert_eq!(format!("{}", addr), "127.0.0.1:8080"); let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap(); - let socket = Socket::new(Domain::ipv4(), Type::stream(), None).unwrap(); + let socket = Socket::new(Domain::IPV4, Type::STREAM, None).unwrap(); socket.set_reuse_address(true).unwrap(); socket.bind(&SockAddr::from(addr)).unwrap(); - let tcp = socket.into_tcp_listener(); + let tcp = net::TcpListener::from(socket); let lst = Listener::Tcp(mio::net::TcpListener::from_std(tcp)); assert!(format!("{:?}", lst).contains("TcpListener")); assert!(format!("{}", lst).contains("127.0.0.1")); diff --git a/ntex/src/server/test.rs b/ntex/src/server/test.rs index d884cea7d..741b1f640 100644 --- a/ntex/src/server/test.rs +++ b/ntex/src/server/test.rs @@ -118,10 +118,10 @@ impl TestServer { /// Get first available unused address pub fn unused_addr() -> net::SocketAddr { let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap(); - let socket = Socket::new(Domain::ipv4(), Type::stream(), None).unwrap(); + let socket = Socket::new(Domain::IPV4, Type::STREAM, None).unwrap(); socket.set_reuse_address(true).unwrap(); socket.bind(&SockAddr::from(addr)).unwrap(); - let tcp = socket.into_tcp_listener(); + let tcp = net::TcpListener::from(socket); tcp.local_addr().unwrap() } }