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

Add Proxy Support. #29

Closed
aadrian opened this issue Sep 4, 2020 · 5 comments
Closed

Add Proxy Support. #29

aadrian opened this issue Sep 4, 2020 · 5 comments

Comments

@aadrian
Copy link

aadrian commented Sep 4, 2020

Please add proxy support.

Many tools just check for environment variables https_proxy and no_proxy and use those if present.

At the moment, the Windows version won't work behind proxies with the error:

c:\>deps --version
Could not find clojure-tools-1.10.1.507.jar. Attempting download.
Exception in thread "main" java.net.UnknownHostException: download.clojure.org
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:220)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
        at java.net.Socket.connect(Socket.java:609)
        at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:285)
        at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:182)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:474)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:569)
        at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:265)
        at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:372)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:168)
        at borkdude.deps$download.invokeStatic(deps.clj:193)
        at borkdude.deps$clojure_tools_jar_download.invokeStatic(deps.clj:212)
        at borkdude.deps$_main$fn__111.invoke(deps.clj:317)
        at borkdude.deps$_main.invokeStatic(deps.clj:317)
        at borkdude.deps$_main.doInvoke(deps.clj:259)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at borkdude.deps.main(Unknown Source)

Thanks in advance.

@borkdude
Copy link
Owner

borkdude commented Sep 4, 2020

Have you read the README yet?

https://github.com/borkdude/deps.clj#proxy-environment-variables

@borkdude
Copy link
Owner

borkdude commented Sep 4, 2020

Oh I'm sorry, you mean for downloading the jar itself. Good point! You can read in this issue how to download the jar yourself:

#20

And a PR to add proxy for this is welcome. I think adding java properties to the executable:

-Dhttp[s].proxyHost and -Dhttp[s].proxyPort

like:

deps.exe -Dhttp.proxyHost=... -Spath 

might already work as of now, since GraalVM binaries do pick up these properties:

$ bb -Dhttp.proxyHost=foo -e '(System/getProperty "http.proxyHost")'
"foo"

@borkdude
Copy link
Owner

borkdude commented Sep 4, 2020

@sundbp Since you wrote the proxy stuff, you might know how to test/implement this?

@borkdude
Copy link
Owner

borkdude commented Sep 4, 2020

Ah, it seems to be effective!

$ rm -rf ~/.deps.clj
$ deps.exe -Dhttps.proxyHost=foo
Could not find clojure-tools-1.10.1.507.jar. Attempting download.
Exception in thread "main" java.net.UnknownHostException: foo

So maybe if we set these properties manually based on the environment variables, it will work.

@sundbp
Copy link
Contributor

sundbp commented Sep 4, 2020

Your workaround should work - my PR just set those same properties from env vars for non-first download cases (but not for the initial clojure jar download..).

My earlier PR probably should probably have done this but I must have worked around it by some other means e.g. same as your suggestions above. I'm not behind a proxy anymore but I think it's a relatively small change to this fn: https://github.com/borkdude/deps.clj/blob/master/src/borkdude/deps.clj#L188

Answers here shows how to add proxy info: https://stackoverflow.com/questions/1432961/how-do-i-make-httpurlconnection-use-a-proxy

I'll try to spend 30min on it later - no promises.

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

No branches or pull requests

3 participants