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

#271 add proxy with auth, #335

Merged
merged 1 commit into from Sep 22, 2014
Merged

Conversation

k-okada
Copy link
Contributor

@k-okada k-okada commented Jul 2, 2014

this is workaround for #271. but this code has not been tested, since i do not have test environment and our client who had this trouble somehow resolved this problem before I create this patch. I just create PR not to forget code.

if you find someone with proxy/auth trouble , please check if
https://gist.githubusercontent.com/k-okada/cf79038d1cffc943a8d3/raw/b4d21725af7de2ac318d5a27ca6003bb1e6e0d95/rosdep work

this workaround is based on http://stackoverflow.com/questions/34079/how-to-specify-an-authenticated-proxy-for-a-python-http-connection

proxy = urllib2.ProxyHandler({o.scheme: os.environ[o.scheme+'_proxy']})
auth = urllib2.HTTPBasicAuthHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
urllib2.install_opener(opener)
Copy link
Member

Choose a reason for hiding this comment

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

What is the scope of this call. It looks like it will set the opener for the duration of the program. I should probably use the non persistent call or cache the OpenerDirector object from the documentation you can just call "otherwise, simply call OpenerDirector.open() instead of urlopen()." which won't override all calls.

@tfoote
Copy link
Member

tfoote commented Jul 2, 2014

Overall this looks good. I think we should look at how we can promote this to be more reusable throughout the code base so that all our tools can work behind proxies.

@NikolausDemmel
Copy link
Contributor

This seems to be only for downloading the default sources (i.e. rosdep init). Don't we also need to use a proxy for downloading the rules files (i.e. rosdeb update)?

@tfoote
Copy link
Member

tfoote commented Jul 2, 2014

Yes, and we should also set it up to pass the proxy through to the internal invocations of apt (or other package managers) as well.

@k-okada
Copy link
Contributor Author

k-okada commented Jul 3, 2014

Thanks for comments.
From my short study, apt and wget works if https_proxy is setenv-ed, and urlib2 works if there are no authentication. proxy with authentication over urllib2 is the only problem.

BTW, does someone know how to test proxy? is there proxyserver that everyone can use for testing?

@NikolausDemmel
Copy link
Contributor

Thanks for looking into this. In terms of forwarding the proxy info to installers, apt is by far the most important case, but other's seem to be used a fair amount (pip, rpm, homebrew). If you have time, maybe you could look into those as well.

The most flexible approach to texting proxy is likely one or two Ubuntu VMs: https://wiki.ubuntu.com/Testing/Proxy . There are lots of free proxies out there, but I haven't seen any with authentication.

@tfoote
Copy link
Member

tfoote commented Jul 3, 2014

@k-okada you can relatively easily setup a squid proxy on your localhost by installing the squid package.

@NikolausDemmel we will need to update the abstract API to allow passing the proxy info so that will become an option for all. I agree that apt is a top priority.

@k-okada
Copy link
Contributor Author

k-okada commented Aug 18, 2014

ok, I have setup a squid on my local machine, add basic authentication, and confirmed it is working on both rosdep init and rosdep update

@NikolausDemmel
Copy link
Contributor

I would be ok to merge this as is and open a new ticket about extending the proxy support (briefly touched upon in the discussion above).

This PR seems to enhance the situation for some common scenarios, while not deteriorating other cases.

Installing a global opener is not the best design, but it is for now only done for the init and update verbs. In particular rosdep API calls etc are not affected.

@k-okada
Copy link
Contributor Author

k-okada commented Sep 6, 2014

Is there anything that blocks this to be merged?

@wjwwood
Copy link
Contributor

wjwwood commented Sep 22, 2014

I'm ok with merging it, someone speak up if you disagree (I can revert it).

wjwwood added a commit that referenced this pull request Sep 22, 2014
@wjwwood wjwwood merged commit c0f23cb into ros-infrastructure:master Sep 22, 2014
@@ -207,6 +207,16 @@ def check_for_sources_list_init(sources_cache_dir):
else:
return True

def setup_proxy_opener():
import urllib2
Copy link
Member

Choose a reason for hiding this comment

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

This patch breaks the Python 3 package. @k-okada Please add unit test coverage for the new code.

Copy link
Member

Choose a reason for hiding this comment

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

I fixed the incompatible code with #351 but it still needs to be covered by unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

does c36626a covers def setup_proxy_opener() ?

@k-okada k-okada deleted the auth_proxy branch February 27, 2015 09:58
@130s 130s mentioned this pull request Mar 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants