Skip to content

Support CIDR notation in NO_PROXY env variable#131397

Open
SapiensAnatis wants to merge 2 commits into
dotnet:mainfrom
SapiensAnatis:cidr-no-proxy-support
Open

Support CIDR notation in NO_PROXY env variable#131397
SapiensAnatis wants to merge 2 commits into
dotnet:mainfrom
SapiensAnatis:cidr-no-proxy-support

Conversation

@SapiensAnatis

Copy link
Copy Markdown

CIDR notation like 127.0.0.0/8 in the NO_PROXY/no_proxy environment variables is currently not handled. These entries will be silently ignored because only exact entries like 127.0.0.1 can cause HttpEnvironmentProxy.IsBypassed to return true.

Address this by introducing support for IPv4 and IPv6 CIDR notation into HttpEnvironmentProxy. The CIDR parsing is done at construction-time to minimize the time spent parsing on each individual HTTP request. Additionally, CIDR-based matching will not be performed unless at least one CIDR block is actually present in NO_PROXY.

Fix #131293

CIDR notation like 127.0.0.0/8 in the `NO_PROXY`/`no_proxy`
environment variables is currently not handled. These entries will be
silently ignored because only exact entries like 127.0.0.1 can cause
`HttpEnvironmentProxy.IsBypassed` to return `true`.

Address this by introducing support for IPv4 and IPv6 CIDR notation into
`HttpEnvironmentProxy`. The CIDR parsing is done at construction-time
to minimize the time spent parsing on each individual HTTP request.
Additionally, CIDR-based matching will not be performed unless at least
one CIDR block is actually present in `NO_PROXY`.

Fix dotnet#131293
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 26, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@MihaZupan MihaZupan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Net.Http community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for CIDR notation in the NO_PROXY environment variable

2 participants