mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
udp: statistics: properly handle ipv4-mapped ipv6 addresses
This commit is contained in:
parent
f001c69dc7
commit
3a4056058b
1 changed files with 14 additions and 13 deletions
|
|
@ -240,20 +240,8 @@ fn read_requests(
|
|||
Request::from_bytes(&buffer[..amt], config.protocol.max_scrape_torrents);
|
||||
|
||||
let src = match src {
|
||||
src @ SocketAddr::V4(_) => {
|
||||
if res_request.is_ok() {
|
||||
requests_received_ipv4 += 1;
|
||||
}
|
||||
bytes_received_ipv4 += amt;
|
||||
|
||||
src
|
||||
}
|
||||
src @ SocketAddr::V4(_) => src,
|
||||
SocketAddr::V6(src) => {
|
||||
if res_request.is_ok() {
|
||||
requests_received_ipv6 += 1;
|
||||
}
|
||||
bytes_received_ipv6 += amt;
|
||||
|
||||
match src.ip().octets() {
|
||||
// Convert IPv4-mapped address (available in std but nightly-only)
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, a, b, c, d] => {
|
||||
|
|
@ -267,6 +255,19 @@ fn read_requests(
|
|||
}
|
||||
};
|
||||
|
||||
// Update statistics for converted address
|
||||
if src.is_ipv4() {
|
||||
if res_request.is_ok() {
|
||||
requests_received_ipv4 += 1;
|
||||
}
|
||||
bytes_received_ipv4 += amt;
|
||||
} else {
|
||||
if res_request.is_ok() {
|
||||
requests_received_ipv6 += 1;
|
||||
}
|
||||
bytes_received_ipv6 += amt;
|
||||
}
|
||||
|
||||
handle_request(
|
||||
config,
|
||||
connections,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue