Merge pull request #1246 from madhawap/master

Make proxy configuration optional
4.x.x
Rasika Perera 7 years ago committed by GitHub
commit 88496d2ba5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -71,6 +71,10 @@ public class Utils {
private static final String SSLV3 = "SSLv3"; private static final String SSLV3 = "SSLv3";
private static final String DEFAULT_HOST = "localhost";
private static final String DEFAULT_HOST_IP = "127.0.0.1";
//This method is only used if the mb features are within DAS. //This method is only used if the mb features are within DAS.
public static String replaceProperties(String text) { public static String replaceProperties(String text) {
@ -98,19 +102,22 @@ public class Utils {
final ProxySelector proxySelector = new ProxySelector() { final ProxySelector proxySelector = new ProxySelector() {
@Override @Override
public java.util.List<Proxy> select(final URI uri) { public java.util.List<Proxy> select(URI uri) {
final List<Proxy> proxyList = new ArrayList<Proxy>(1); List<Proxy> proxyList = new ArrayList<>();
String host = uri.getHost();
final String host = uri.getHost();
if (!StringUtils.isEmpty(host)) {
if (host.startsWith("127.0.0.1") || host.startsWith("localhost") || StringUtils.contains if (host.startsWith(DEFAULT_HOST_IP) || host.startsWith(DEFAULT_HOST) || StringUtils
(nonProxyHostsValue, host)) { .isEmpty(nonProxyHostsValue) || StringUtils.contains(nonProxyHostsValue, host) ||
proxyList.add(Proxy.NO_PROXY); StringUtils.isEmpty(proxyHost) || StringUtils.isEmpty(proxyPort)) {
proxyList.add(Proxy.NO_PROXY);
} else {
proxyList.add(new Proxy(Proxy.Type.HTTP,
new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort))));
}
} else { } else {
proxyList.add(new Proxy(Proxy.Type.HTTP, log.error("Host is null. Host could not be empty or null");
new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort))));
} }
return proxyList; return proxyList;
} }

Loading…
Cancel
Save