mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
Use CanonicalSocketAddr in ws and http; remove old option from common
This commit is contained in:
parent
380ca222de
commit
8889ab586c
9 changed files with 36 additions and 62 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use ahash::RandomState;
|
||||
|
|
@ -92,19 +92,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn convert_ipv4_mapped_ipv6(ip_address: IpAddr) -> IpAddr {
|
||||
if let IpAddr::V6(ip) = ip_address {
|
||||
if let [0, 0, 0, 0, 0, 0xffff, ..] = ip.segments() {
|
||||
ip.to_ipv4().expect("convert ipv4-mapped ip").into()
|
||||
} else {
|
||||
ip_address
|
||||
}
|
||||
} else {
|
||||
ip_address
|
||||
}
|
||||
}
|
||||
|
||||
/// SocketAddr that is not an IPv6-mapped IPv4 address
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct CanonicalSocketAddr(SocketAddr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue