SOCKS5 proxy support for uri module#67715
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.
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.
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.
urls.py does not use urllib. It uses urllib2 on py2, and urllib.request on py3.
There was a problem hiding this comment.
I used urllib as a shortcut :) As far as I checked this doesn't change anything, or am I wrong?
jamescassell
left a comment
There was a problem hiding this comment.
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