mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_http: add ipv6 compact responses; fix ipv4/ipv6 issue
This commit is contained in:
parent
5ff00e866d
commit
43a33d80c4
6 changed files with 127 additions and 27 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use std::time::{Duration, Instant};
|
||||
use std::net::IpAddr;
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use rand::Rng;
|
||||
|
|
@ -77,4 +78,18 @@ pub fn extract_response_peers<K, V, R, F>(
|
|||
|
||||
peers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[inline]
|
||||
pub fn convert_ipv4_mapped_ipv4(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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue