From f60afae4280230ccce1dce91840c9e6bffff34c5 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Wed, 4 Feb 2026 11:05:59 +0000 Subject: [PATCH] Add to_canonical() for ip check (#160) --- src/config.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index a7cbf94..142e2da 100644 --- a/src/config.rs +++ b/src/config.rs @@ -187,10 +187,12 @@ impl FederationConfig { // Resolve domain and see if it points to private IP // TODO: Use is_global() once stabilized // https://doc.rust-lang.org/std/net/enum.IpAddr.html#method.is_global - let mut ips = lookup_host((domain.to_owned(), 80)).await?; + let mut ips = lookup_host((domain.to_owned(), 80)) + .await? + .map(|s| s.ip().to_canonical()); let allow_local = std::env::var("DANGER_FEDERATION_ALLOW_LOCAL_IP").is_ok(); let invalid_ip = !allow_local - && ips.any(|addr| match addr.ip() { + && ips.any(|ip| match ip { IpAddr::V4(addr) => { addr.is_private() || addr.is_link_local()