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
[FIXED JENKINS-48561] Give precedence to proxy exclusion list system property over env var #243
Merged
6 commits merged into
jenkinsci:master
from
etiennebec:JENKINS-48561-jnlp-noproxy-precedence
Mar 5, 2018
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eb2b2d9
[FIXED JENKINS-48561] Give precedence to proxy exclusion list system …
etiennebec 9d929e0
Use English locale when converting host to lower case
etiennebec 559f628
Replace System.err.println with LOGGER.log call in JnlpAgentEndpointR…
etiennebec 24a0077
Remove import of Sun internal lib and implement Java9 non proxy handling
etiennebec 736678d
Add FIXME keyword on copy/pasted methods from hudson.remoting.Util
etiennebec 8410222
Add a warning when more than one wildcard is used in a nonProxyHosts …
etiennebec File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,8 @@ | |
import hudson.remoting.Base64; | ||
import org.jenkinsci.remoting.util.https.NoCheckHostnameVerifier; | ||
import org.jenkinsci.remoting.util.https.NoCheckTrustManager; | ||
import sun.misc.RegexpPool; | ||
import sun.net.NetProperties; | ||
|
||
import java.io.IOException; | ||
import java.net.ConnectException; | ||
|
@@ -56,6 +58,7 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.StringTokenizer; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import javax.annotation.CheckForNull; | ||
|
@@ -377,7 +380,30 @@ static InetSocketAddress getResolvedHttpProxyAddress(@Nonnull String host, int p | |
while (targetAddress == null && proxies.hasNext()) { | ||
Proxy proxy = proxies.next(); | ||
if (proxy.type() == Proxy.Type.DIRECT) { | ||
break; | ||
// Proxy.NO_PROXY with a DIRECT type is returned in two cases: | ||
// - when no proxy (none) has been configured in the JVM (either with system properties or by the operating system) | ||
// - when the URI host is part of the exclusion list defined by system property -Dhttp.nonProxyHosts | ||
// | ||
// Unfortunately, the Proxy class does not provide a way to differentiate both cases to fallback to | ||
// environment variables only when no proxy has been configured. Therefore, we have to recheck if the URI | ||
// host is in the exclusion list. | ||
String nonProxyHosts = NetProperties.get("http.nonProxyHosts"); | ||
if(nonProxyHosts != null && nonProxyHosts.length() != 0) { | ||
RegexpPool exclusionsPool = new RegexpPool(); | ||
StringTokenizer stringTokenizer = new StringTokenizer(nonProxyHosts, "|", false); | ||
try { | ||
while(stringTokenizer.hasMoreTokens()) { | ||
exclusionsPool.add(stringTokenizer.nextToken().toLowerCase(), Boolean.TRUE); | ||
} | ||
} catch(sun.misc.REException e) { | ||
System.err.println("Malformed exception list in http.nonProxyHosts system property: " + e.getMessage()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will need to rework everything to loggers |
||
} | ||
if(exclusionsPool.match(host.toLowerCase()) != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. locale |
||
return null; | ||
} else { | ||
break; | ||
} | ||
} | ||
} | ||
if (proxy.type() == Proxy.Type.HTTP) { | ||
final SocketAddress address = proxy.address(); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
toLowerCase()
is invoked without locale, it will cause FindBugs failures with #242 I'd guess