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

Extend ProxyHandler to support CIDR ranges for no_proxy #83085

Open
wants to merge 7 commits into
base: devel
Choose a base branch
from

Conversation

sivel
Copy link
Member

@sivel sivel commented Apr 18, 2024

SUMMARY

Extend ProxyHandler to support CIDR ranges for no_proxy

ISSUE TYPE
  • Feature Pull Request
ADDITIONAL INFORMATION

@ansibot ansibot added feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Apr 18, 2024
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Apr 18, 2024
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Apr 18, 2024
return False
return host in bypass_network

def proxy_open(self, req, *args):
Copy link
Member Author

@sivel sivel Apr 18, 2024

Choose a reason for hiding this comment

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

The biggest concern I have about this implementation, is in overriding this method. proxy_open is not a documented method at https://docs.python.org/3/library/urllib.request.html

At closest it the <protocol>_open methods are described as part of https://docs.python.org/3/library/urllib.request.html#protocol-open but proxy isn't really a protocol like http, https, file, etc are.

And further more, it's highly dependent on urllib.request.ProxyHandler.__init__: https://github.com/python/cpython/blob/8f25cc992021d6ffc62bb110545b97a92f7cb295/Lib/urllib/request.py#L770-L774

However, the use of proxy_open has been around, unchanged for 25+ years, so it seems relatively safe and stable: python/cpython@6d7e47b

I guess at a minimum, this is why we have tests, which this PR includes.

@webknjaz
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -0,0 +1,35 @@
- name: install proxy.py
pip:
name: proxy.py
Copy link
Member

Choose a reason for hiding this comment

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

It might be a good idea to pin it to the most recent release candidate (otherwise it may end up being pretty old). FYI.

@@ -0,0 +1,2 @@
- name: stop proxy.py
command: kill {{ proxy_py_pid.content|b64decode }}
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain why is re-encoding of a.. number is needed? I'm a bit confused here. Oh, is it because it was produced by a slurp? Can we decode and put into a var right after reading the file? This piece of logic seems disconnected...

Copy link
Member Author

Choose a reason for hiding this comment

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

It is because of slurp. Technically we could do a set_fact afterwards. Once we get the proejctions feature in, maybe for 2.18 we can do it as part of the register itself.

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Apr 22, 2024
@ansibot
Copy link
Contributor

ansibot commented Apr 22, 2024

The test ansible-test sanity --test yamllint [explain] failed with 2 errors:

test/integration/targets/setup_proxy/tasks/main.yml:38:15: error: syntax error: mapping values are not allowed here (syntax)
test/integration/targets/setup_proxy/tasks/main.yml:38:15: unparsable-with-libyaml: None - mapping values are not allowed in this context

click here for bot help

@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Apr 22, 2024
sivel and others added 2 commits April 25, 2024 09:34
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants