Skip to content

Commit 527c2e3

Browse files
authored
Merge pull request #2752 from fermyon/fix-cidr
Fix checking of cidr ranges
2 parents b9ed65a + 7d15bdd commit 527c2e3

File tree

1 file changed

+8
-1
lines changed
  • crates/outbound-networking/src

1 file changed

+8
-1
lines changed

crates/outbound-networking/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl HostConfig {
175175
HostConfig::List(l) => l.iter().any(|h| h.as_str() == host),
176176
HostConfig::ToSelf => false,
177177
HostConfig::Cidr(c) => {
178-
let Ok(ip) = host.parse::<ipnet::IpNet>() else {
178+
let Ok(ip) = host.parse::<std::net::IpAddr>() else {
179179
return false;
180180
};
181181
c.contains(&ip)
@@ -776,4 +776,11 @@ mod test {
776776
.allows(&OutboundUrl::parse("mysql://user%3Apass%[email protected]", "mysql").unwrap()));
777777
assert!(allowed.allows(&OutboundUrl::parse("user%3Apass%[email protected]", "mysql").unwrap()));
778778
}
779+
780+
#[test]
781+
fn test_cidr() {
782+
let allowed =
783+
AllowedHostsConfig::parse(&["*://127.0.0.1/24:63551"], &dummy_resolver()).unwrap();
784+
assert!(allowed.allows(&OutboundUrl::parse("tcp://127.0.0.1:63551", "tcp").unwrap()));
785+
}
779786
}

0 commit comments

Comments
 (0)