Skip to main content

is_loopback_bind

Function is_loopback_bind 

Source
pub fn is_loopback_bind(bind: &str) -> bool
Expand description

True when bind is a loopback/desktop address, for which the per-IP DoS rate limiter (build_rate_limiter, #13) is intentionally SKIPPED. The desktop sidecar serves the local frontend, which legitimately bursts ~45 hashed /assets/* requests on load and would otherwise trip the 429 limit (burst default 20). Mirrors the loopback special-casing already used for CORS; network binds (0.0.0.0) are still throttled.

Classification is via IpAddr::is_loopback (so the whole 127.0.0.0/8 range, not just 127.0.0.1, and a bracketed IPv6 literal like [::1] are correctly recognized) plus a literal "localhost" match, since that’s a hostname rather than an address IpAddr can parse. #428: previously this was a strict string allowlist (127.0.0.1 / localhost / ::1), so e.g. 127.0.0.2 or [::1] were misclassified as non-loopback — which failed SAFE (the limiter was applied) but was still wrong.