mirror of
https://github.com/fafhrd91/actix-net
synced 2025-01-31 09:12:08 +01:00
testing: Replace net2
crate with socket2
This commit is contained in:
parent
8218a098e8
commit
ac6c78c476
@ -1,5 +1,9 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
* Replace deprecated `net2` crate with `socket2`
|
||||||
|
|
||||||
## [1.0.0] - 2019-12-11
|
## [1.0.0] - 2019-12-11
|
||||||
|
|
||||||
* Update actix-server to 1.0.0
|
* Update actix-server to 1.0.0
|
||||||
|
@ -23,4 +23,4 @@ actix-server = "1.0.0"
|
|||||||
actix-service = "1.0.0"
|
actix-service = "1.0.0"
|
||||||
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
net2 = "0.2"
|
socket2 = "0.3"
|
||||||
|
@ -7,7 +7,7 @@ use std::{net, thread};
|
|||||||
|
|
||||||
use actix_rt::{net::TcpStream, System};
|
use actix_rt::{net::TcpStream, System};
|
||||||
use actix_server::{Server, ServerBuilder, ServiceFactory};
|
use actix_server::{Server, ServerBuilder, ServiceFactory};
|
||||||
use net2::TcpBuilder;
|
use socket2::{Domain, Protocol, Socket, Type};
|
||||||
|
|
||||||
#[cfg(not(test))] // Work around for rust-lang/rust#62127
|
#[cfg(not(test))] // Work around for rust-lang/rust#62127
|
||||||
pub use actix_macros::test;
|
pub use actix_macros::test;
|
||||||
@ -110,10 +110,10 @@ impl TestServer {
|
|||||||
/// Get firat available unused local address
|
/// Get firat available unused local address
|
||||||
pub fn unused_addr() -> net::SocketAddr {
|
pub fn unused_addr() -> net::SocketAddr {
|
||||||
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
||||||
let socket = TcpBuilder::new_v4().unwrap();
|
let socket = Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
|
||||||
socket.bind(&addr).unwrap();
|
socket.bind(&addr.into()).unwrap();
|
||||||
socket.reuse_address(true).unwrap();
|
socket.set_reuse_address(true).unwrap();
|
||||||
let tcp = socket.to_tcp_listener().unwrap();
|
let tcp = socket.into_tcp_listener();
|
||||||
tcp.local_addr().unwrap()
|
tcp.local_addr().unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user