- Update use of ip_constructors: The unspecified() function in libstd has been replaced with the UNSPECIFIED constants. - Implement Into> for CookieReply so that copying the underlying vector is not needed in cases where copying said vector is unnecessary. Signed-off-by: Dan Robertson --- src/interface/peer_server.rs | 2 +- src/lib.rs | 1 - src/message.rs | 6 ++++++ src/udp/mod.rs | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/interface/peer_server.rs b/src/interface/peer_server.rs index a7c82cd..31dd78c 100644 --- a/src/interface/peer_server.rs +++ b/src/interface/peer_server.rs @@ -368,7 +368,7 @@ impl PeerServer { IpAddr::V6(ip) => self.cookie.generate_reply(index, mac1, &ip.octets())?, }; - self.send_to_peer((addr, reply.to_vec())) // TODO: impl into() to avoid copies/allocs + self.send_to_peer((addr, reply.into())) } fn send_handshake_init(&mut self, peer_ref: &SharedPeer) -> Result { diff --git a/src/lib.rs b/src/lib.rs index 99c8fa4..19c7646 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,6 @@ #![allow(unknown_lints)] #![warn(clippy)] -#![feature(ip_constructors)] #![feature(try_trait)] #![feature(try_from)] #![feature(test)] diff --git a/src/message.rs b/src/message.rs index 12b2eb7..5777368 100644 --- a/src/message.rs +++ b/src/message.rs @@ -138,6 +138,12 @@ impl CookieReply { } } +impl Into> for CookieReply { + fn into(self) -> Vec { + self.0 + } +} + impl TryFrom> for CookieReply { type Error = Error; diff --git a/src/udp/mod.rs b/src/udp/mod.rs index 2a512cd..a519ad4 100644 --- a/src/udp/mod.rs +++ b/src/udp/mod.rs @@ -117,8 +117,8 @@ impl UdpSocket { setsockopt(socket4.as_raw_fd(), sockopt::Ipv4PacketInfo, &true); setsockopt(socket6.as_raw_fd(), sockopt::Ipv6RecvPacketInfo, &true); - socket4.bind(&SocketAddr::from((Ipv4Addr::unspecified(), port)).into())?; - socket6.bind(&SocketAddr::from((Ipv6Addr::unspecified(), port)).into())?; + socket4.bind(&SocketAddr::from((Ipv4Addr::UNSPECIFIED, port)).into())?; + socket6.bind(&SocketAddr::from((Ipv6Addr::UNSPECIFIED, port)).into())?; let socket4 = mio::net::UdpSocket::from_socket(socket4.into_udp_socket())?; let socket6 = mio::net::UdpSocket::from_socket(socket6.into_udp_socket())?; -- 2.19.1