-
-
Notifications
You must be signed in to change notification settings - Fork 954
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
Fix for #2989 - Cryptomator using the configured proxy #2993
Fix for #2989 - Cryptomator using the configured proxy #2993
Conversation
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 assumed the system proxy was used anyway. You live and learn.
We do use the java.net.http.HttpClient
in various other places as well. So I think we should add the ProxySelector in each of these places.
- better use of the Optional class - throws IllegalArgumentException is more appropriate when a required object is not present
Hello, I uploaded the updates including |
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.
Thank you, lgtm!
However I wonder why the provideHttpClient()
returns an Optional in the first place... 😅
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 already wondered, that this PR changes something, because in testing with a colleague only using the proxy selector the update checker still used the "normal" internet connection.
Not specifying the proxy let's automatically use the default proxy, see also the JDK implementation of the HttpClientImpl:
private HttpClientImpl(HttpClientBuilderImpl builder, SingleFacadeFactory facadeFactory) {
/* ... some code */
this.userProxySelector = builder.proxy;
this.proxySelector = Optional.ofNullable(userProxySelector)
.orElseGet(HttpClientImpl::getDefaultProxySelector);
/*...*/
}
What's doing the trick is using the property java.net.useSystemProxies=true. And this property needs to be set in our build scripts.
Given issue closes #2989 Cryptomator is not using system proxy to connect to Cryptomator update checker or hub.
During the debug I noticed that it was missing to inject the
ProxySelector.getDefault()
that returns the default proxy of the system. I performed the configurant tests via JVM Args and theJAVA_TOOL_OPTIONS
environment variable both using the parameters-Djava.net.useSystemProxies=true -Dhttp.proxyHost=186.248.206.147 -Dhttp.proxyPort=8080
.Remembering that without the definition of these attributes, the check update works normally
Unfortunately I was only able to test it on MacOS.