Skip to content

feat(allow_hosts): support CIDR network entries - #479

Merged
miketheman merged 1 commit into
mainfrom
feat/cidr-allow-hosts
May 15, 2026
Merged

miketheman merged 1 commit into
mainfrom
feat/cidr-allow-hosts

Conversation

@miketheman

Copy link
Copy Markdown
Owner

Entries containing "/" in --allow-hosts (CLI and marker) are parsed as IPv4 or IPv6 networks via ipaddress.ip_network(strict=False). Plain hosts continue through the existing hostname/IP resolution path; CIDR strings render verbatim in blocked-connect errors.

The membership check is gated on is_ipaddress(host) so a hostname-style connect arg under a CIDR-only allow-list raises SocketConnectBlockedError rather than crashing with ValueError — the failure mode that blocked #185 from merging.

Closes #185

Entries containing "/" in --allow-hosts (CLI and marker) are parsed
as IPv4 or IPv6 networks via ipaddress.ip_network(strict=False).
Plain hosts continue through the existing hostname/IP resolution
path; CIDR strings render verbatim in blocked-connect errors.

The membership check is gated on is_ipaddress(host) so a
hostname-style connect arg under a CIDR-only allow-list raises
SocketConnectBlockedError rather than crashing with ValueError —
the failure mode that blocked #185 from merging.

Closes #185

Signed-off-by: Mike Fiedler <[email protected]>
@miketheman miketheman added the enhancement New feature or request label May 15, 2026
@miketheman
miketheman enabled auto-merge (squash) May 15, 2026 14:23
@miketheman
miketheman merged commit 8dc6286 into main May 15, 2026
26 checks passed
@miketheman
miketheman deleted the feat/cidr-allow-hosts branch May 15, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant