提交 3ec010d4 编写于 作者: D dxu

7122887: JDK ignores Gnome3 proxy settings

Summary: Fix GConf and add to use GProxyResolver to handle network proxy resolution
Reviewed-by: chegar
上级 efddb3da
/* /*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -33,29 +33,39 @@ import java.util.List; ...@@ -33,29 +33,39 @@ import java.util.List;
public class SystemProxies { public class SystemProxies {
static final String uriAuthority = "myMachine/"; static final String[] uriAuthority = { "myMachine/", "local", "localhost",
"127.0.0.1", "127.0.0.123",
"127.0.2.2", "127.3.3.3",
"128.0.0.1" };
static final ProxySelector proxySel = ProxySelector.getDefault(); static final ProxySelector proxySel = ProxySelector.getDefault();
public static void main(String[] args) { public static void main(String[] args) {
if (! "true".equals(System.getProperty("java.net.useSystemProxies"))) { if (! "true".equals(System.getProperty("java.net.useSystemProxies"))) {
System.out.println("Usage: java -Djava.net.useSystemProxies SystemProxies"); System.out.println("Usage: java -Djava.net.useSystemProxies=true SystemProxies");
return; return;
} }
printProxies("http://"); printProxies("http://");
printProxies("https://"); printProxies("https://");
printProxies("ftp://"); printProxies("ftp://");
printProxies("none://");
printProxies("gopher://");
printProxies("rtsp://");
printProxies("socket://");
} }
static void printProxies(String proto) { static void printProxies(String proto) {
String uriStr = proto + uriAuthority; System.out.println("Protocol:" + proto);
try { for (String uri : uriAuthority) {
List<Proxy> proxies = proxySel.select(new URI(uriStr)); String uriStr = proto + uri;
System.out.println("Proxies returned for " + uriStr); try {
for (Proxy proxy : proxies) List<Proxy> proxies = proxySel.select(new URI(uriStr));
System.out.println("\t" + proxy); System.out.println("\tProxies returned for " + uriStr);
} catch (URISyntaxException e) { for (Proxy proxy : proxies)
System.err.println(e); System.out.println("\t\t" + proxy);
} catch (URISyntaxException e) {
System.err.println(e);
}
} }
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册