Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for the NO_PROXY environment variable #705

Closed
BlackDex opened this issue Nov 7, 2019 · 6 comments · Fixed by #877
Closed

Added support for the NO_PROXY environment variable #705

BlackDex opened this issue Nov 7, 2019 · 6 comments · Fixed by #877
Labels
E-pr-welcome The feature is welcome to be added, instruction should be found in the issue.

Comments

@BlackDex
Copy link
Contributor

BlackDex commented Nov 7, 2019

Hello there,

Using the use_sys_proxy() feature does not support the NO_PROXY environment variable.
This causes Domains or IP's which should not go through the proxy to not work.

Most languages/tools support a simple comma separated list of items to skip proxy for.
This list can contain the following.

  • FQDN: github.com, localhost etc.. - Only matches github.com, not gist.github.com
  • FQDN Started with a dot: .github.com - matches gist.github.com, api.github.com, but not github.com
  • IP Address: 127.0.0.1,::1
  • CIDR: 10.0.0.0/8

Example:

NO_PROXY=localhost,127.0.0.1,::1,github.com,.github.com,10.0.0.0/8,192.168.0.5
@seanmonstar seanmonstar added the E-pr-welcome The feature is welcome to be added, instruction should be found in the issue. label Nov 7, 2019
@BlackDex
Copy link
Contributor Author

@seanmonstar
I'm not that high level skilled in rust, but i can find my way.
I was looking at the code, and am a bit puzzled as where the best place is to put this.

I figured the best thing would be to add it to the ProxyScheme or a bit more global in the Intercept enum. But i'm a bit at a loss where to start and where/how to add it.

Because i think i need to catch it in the Proxy::intercept() call, and return None in case the Dst.host() matches the NO_PROXY value. So i probably need to have something available within that function, which can do that pattern checking.

If possible, could you point me in a bit in the right direction?
Thx in advance :).

@seanmonstar
Copy link
Owner

The behavior would likely be contained in the Intercept::System variant. The matching happens here.

I'm not too familiar with all the rules that NO_PROXY can use. It kind of looks like the rules differ in curl vs Golang.

@BlackDex
Copy link
Contributor Author

There are some basics at least. But there are a lot of differences indeed.

Thx for the pointers, i will take a look there.

@AndrewGaspar
Copy link

I would be interested in seeing this problem fixed.

Thank you!

@jamescassell
Copy link

Curl works by splitting the "domains" in the no_proxy environment by comma (,), checking whether that matches exactly the domain, or whether the domain being considered is a "subdomain" of one of the no_proxy domains. I use quotes because you can specify a number like 1 and curl will consider 192.168.1.1 to be a "subdomain" and skip the proxy. (This is very handy for telling curl to only use the proxy for FQDN queries and bypass the proxy for IP-only queries.)

thomastaylor312 added a commit to thomastaylor312/reqwest that referenced this issue Apr 10, 2020
Adds support for loading from the `NO_PROXY` or `no_proxy` environment
variables. This should make reqwest support the system proxy settings.
Please note that I brought in one additional dependency in order to
handle CIDR blocks in the no proxy settings.

Closes seanmonstar#705
@thomastaylor312
Copy link
Contributor

Opened a PR for this: #877.

thomastaylor312 added a commit to thomastaylor312/reqwest that referenced this issue Apr 10, 2020
Adds support for loading from the `NO_PROXY` or `no_proxy` environment
variables. This should make reqwest support the system proxy settings.
Please note that I brought in one additional dependency in order to
handle CIDR blocks in the no proxy settings.

Closes seanmonstar#705
thomastaylor312 added a commit to thomastaylor312/reqwest that referenced this issue Apr 16, 2020
Adds support for loading from the `NO_PROXY` or `no_proxy` environment
variables. This should make reqwest support the system proxy settings.
Please note that I brought in one additional dependency in order to
handle CIDR blocks in the no proxy settings.

Closes seanmonstar#705
thomastaylor312 added a commit to thomastaylor312/reqwest that referenced this issue Apr 28, 2020
Adds support for loading from the `NO_PROXY` or `no_proxy` environment
variables. This should make reqwest support the system proxy settings.
Please note that I brought in one additional dependency in order to
handle CIDR blocks in the no proxy settings.

Closes seanmonstar#705
thomastaylor312 added a commit to thomastaylor312/reqwest that referenced this issue May 19, 2020
Adds support for loading from the `NO_PROXY` or `no_proxy` environment
variables. This should make reqwest support the system proxy settings.
Please note that I brought in one additional dependency in order to
handle CIDR blocks in the no proxy settings.

Closes seanmonstar#705
thomastaylor312 added a commit to thomastaylor312/reqwest that referenced this issue May 29, 2020
Adds support for loading from the `NO_PROXY` or `no_proxy` environment
variables. This should make reqwest support the system proxy settings.
Please note that I brought in one additional dependency in order to
handle CIDR blocks in the no proxy settings.

Closes seanmonstar#705
seanmonstar pushed a commit that referenced this issue Jun 8, 2020
* feat(proxy): Adds NO_PROXY environment variable support

Adds support for loading from the `NO_PROXY` or `no_proxy` environment
variables. This should make reqwest support the system proxy settings.
Please note that I brought in one additional dependency in order to
handle CIDR blocks in the no proxy settings.

Closes #705
Nutomic pushed a commit to Nutomic/reqwest that referenced this issue Nov 7, 2024
)

* feat(proxy): Adds NO_PROXY environment variable support

Adds support for loading from the `NO_PROXY` or `no_proxy` environment
variables. This should make reqwest support the system proxy settings.
Please note that I brought in one additional dependency in order to
handle CIDR blocks in the no proxy settings.

Closes seanmonstar#705
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-pr-welcome The feature is welcome to be added, instruction should be found in the issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants