fix(edge): IPv6 bind, configurable relay idle, per-gateway budget, PROXY identity
- bind.address is parsed as IpAddr (no ":::port"), the socket domain follows the family, and "::" binds dual-stack. IPv6 was impossible before. - limits.relay_idle_timeout_secs (default 300, 1..=86400) replaces the hardcoded relay constant; the deploy examples document it. - The connection budget is an Arc<Semaphore> owned by Gateway instead of a process-wide OnceLock, so tests and multiple gateways stay independent. - PROXY header identity is validated: unspecified, loopback, link-local, multicast, broadcast and addresses inside trusted_cidrs are rejected, and IPv4-mapped IPv6 is normalised first. An invalid header falls back to the transport peer. Bans targeting trusted_cidrs are suppressed, closing the ban-amplification path through a trusted load balancer. - TrustedProxyCidr::contains no longer overflows its mask for IPv6 prefixes shorter than /96.
This commit is contained in:
parent
9baae25acb
commit
324ef12b27
15 changed files with 530 additions and 76 deletions
|
|
@ -238,6 +238,30 @@ fn rejects_rate_limit_burst_below_one() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn relay_idle_timeout_defaults_to_300_and_accepts_the_full_range() {
|
||||
let config = Config::parse_str("").expect("empty config must parse");
|
||||
assert_eq!(config.limits.relay_idle_timeout_secs, 300);
|
||||
|
||||
for secs in [1u64, 60, 300, 86_400] {
|
||||
let toml = format!("[limits]\nrelay_idle_timeout_secs = {secs}\n");
|
||||
let config = Config::parse_str(&toml).expect("in-range idle timeout must parse");
|
||||
assert_eq!(config.limits.relay_idle_timeout_secs, secs);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_out_of_range_relay_idle_timeout() {
|
||||
for secs in [0u64, 86_401] {
|
||||
let toml = format!("[limits]\nrelay_idle_timeout_secs = {secs}\n");
|
||||
let err = Config::parse_str(&toml).expect_err("idle timeout outside 1..=86400 must be rejected");
|
||||
assert!(
|
||||
err.to_string().contains("limits.relay_idle_timeout_secs"),
|
||||
"idle timeout '{secs}' must be rejected"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_out_of_range_ban_duration() {
|
||||
let err = Config::parse_str("[ban]\nban_duration_secs = 0\n").expect_err("zero ban duration must be rejected");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue