Update socket2 requirement from 0.3.19 to 0.4.0 (#1997)

* Update socket2 requirement from 0.3.19 to 0.4.0

Updates the requirements on [socket2](https://github.com/rust-lang/socket2) to permit the latest version.
- [Release notes](https://github.com/rust-lang/socket2/releases)
- [Changelog](https://github.com/rust-lang/socket2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/socket2/compare/v0.3.19...v0.3.19)

Signed-off-by: dependabot[bot] <support@github.com>

* Adapt to API and feature changes.

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Roman S. Borschel <roman@parity.io>
This commit is contained in:
dependabot[bot]
2021-03-15 17:33:49 +01:00
committed by GitHub
parent 375690d396
commit 9dbc90efe7
4 changed files with 11 additions and 11 deletions

View File

@ -21,7 +21,7 @@ libp2p-swarm = { version = "0.28.0", path = "../../swarm" }
log = "0.4.14"
rand = "0.8.3"
smallvec = "1.6.1"
socket2 = { version = "0.3.19", features = ["reuseport"] }
socket2 = { version = "0.4.0", features = ["all"] }
void = "1.0.2"
[dev-dependencies]

View File

@ -122,15 +122,15 @@ impl Mdns {
pub async fn new(config: MdnsConfig) -> io::Result<Self> {
let recv_socket = {
let socket = Socket::new(
Domain::ipv4(),
Type::dgram(),
Some(socket2::Protocol::udp()),
Domain::IPV4,
Type::DGRAM,
Some(socket2::Protocol::UDP),
)?;
socket.set_reuse_address(true)?;
#[cfg(unix)]
socket.set_reuse_port(true)?;
socket.bind(&SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 5353).into())?;
let socket = socket.into_udp_socket();
let socket = UdpSocket::from(socket);
socket.set_multicast_loop_v4(true)?;
socket.set_multicast_ttl_v4(255)?;
Async::new(socket)?

View File

@ -19,7 +19,7 @@ ipnet = "2.0.0"
libc = "0.2.80"
libp2p-core = { version = "0.27.0", path = "../../core" }
log = "0.4.11"
socket2 = { version = "0.3.17", features = ["reuseport"] }
socket2 = { version = "0.4.0", features = ["all"] }
tokio-crate = { package = "tokio", version = "1.0.1", default-features = false, features = ["net"], optional = true }
[features]

View File

@ -313,11 +313,11 @@ where
fn create_socket(&self, socket_addr: &SocketAddr) -> io::Result<Socket> {
let domain = if socket_addr.is_ipv4() {
Domain::ipv4()
Domain::IPV4
} else {
Domain::ipv6()
Domain::IPV6
};
let socket = Socket::new(domain, Type::stream(), Some(socket2::Protocol::tcp()))?;
let socket = Socket::new(domain, Type::STREAM, Some(socket2::Protocol::TCP))?;
if socket_addr.is_ipv6() {
socket.set_only_v6(true)?;
}
@ -340,7 +340,7 @@ where
socket.bind(&socket_addr.into())?;
socket.listen(self.backlog as _)?;
socket.set_nonblocking(true)?;
TcpListenStream::<T>::new(socket.into_tcp_listener(), self.port_reuse)
TcpListenStream::<T>::new(socket.into(), self.port_reuse)
}
async fn do_dial(self, socket_addr: SocketAddr) -> Result<T::Stream, io::Error> {
@ -360,7 +360,7 @@ where
Err(err) => return Err(err),
};
let stream = T::new_stream(socket.into_tcp_stream()).await?;
let stream = T::new_stream(socket.into()).await?;
Ok(stream)
}
}