Skip to main content

addresses

Function addresses 

Source
pub fn addresses(list: &[SocketAddr]) -> impl Display + '_
Expand description

Renders a resolved address list at a length a log line can afford.

The list on the two refusal lines in crate::tunnel is what the resolver answered, before the policy filter, and nothing between getaddrinfo and the line bounds it: a name whose owner returns four thousand records — which a DNS answer over TCP has room for — puts every one of them on the line. The client picks the name, and on the blackhole line, which is deliberately not sampled because it fires on ordinary ad-blocked traffic, that is tens of kilobytes of INFO per request. The two debug lines naming the addresses a tunnel failed to reach come through here as well, so that a list this server prints has one length rule rather than one per call site.

So the head is printed and the rest is counted. The count is the part worth keeping: “and 3992 more” is itself the diagnosis, where a line that simply stopped would look like a short list.

The addresses go in with Display rather than a str field, and may: they are SocketAddrs this server parsed, not bytes a peer chose, which is the third rule above. Written as a lazy adapter so a filtered-out line pays for none of it.

let one: Vec<SocketAddr> = vec!["127.0.0.1:443".parse().unwrap()];
assert_eq!(addresses(&one).to_string(), "[127.0.0.1:443]");