Function zebra_network::peer_set::candidate_set::validate_addrs

source ·
fn validate_addrs(
    addrs: impl IntoIterator<Item = MetaAddr>,
    last_seen_limit: DateTime32,
) -> impl Iterator<Item = MetaAddr>
Expand description

Check new addrs before adding them to the address book.

last_seen_limit is the maximum permitted last seen time, typically Utc::now.

If the data in an address is invalid, this function can:

  • modify the address data, or
  • delete the address.

§Security

Adjusts untrusted last seen times so they are not in the future. This stops malicious peers keeping all their addresses at the front of the connection queue. Honest peers with future clock skew also get adjusted.

Rejects all addresses if any calculated times overflow or underflow.