-
Notifications
You must be signed in to change notification settings - Fork 23.9k
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
SOCKS5 proxy support for uri module #67715
base: devel
Are you sure you want to change the base?
Conversation
The test
|
if socks5_proxy: | ||
host, port = socks5_proxy.split(':') | ||
socks.set_default_proxy(socks.SOCKS5, host, port=int(port)) | ||
socket.socket = socks.socksocket |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this should be a function of the uri
module, but probably implemented in ansible.module_utils.urls
instead. However, with that being said, we wouldn't be able to use this specific line, as it could cause other issues, in that this would become a global change, and not specific to just a single request.
As such, we'd probably want to make use of sockshandler
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. I also wanted to do that in ansible.module_utils.urls
with use of sockshandler (as mentioned earlier) but that is not possible because urllib
which ansible.module_utils.urls
uses doesn't support SOCKS handlers.
With that being said, until urllib
supports SOCKS it is actually beneficial that this default socket redirect is scoped to a single request only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urls.py
does not use urllib
. It uses urllib2
on py2, and urllib.request
on py3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used urllib
as a shortcut :) As far as I checked this doesn't change anything, or am I wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a wider change, and honor the appropriate http_proxy environment variables.
This would be an interesting feature in conjunction with openssh-client's remote socks proxy via -R flag. |
SUMMARY
Because SOCKS proxies are not currently supported by the urllib on which Ansible is dependent, this patch provides a simple workaround to enable SOCKS5 support for the uri module.
For the same reason there is no option to give that support more generally - through handler to the urllib's opener.
Fixes #44338
ISSUE TYPE
COMPONENT NAME
uri
ADDITIONAL INFORMATION