5001942: Missings SOCKS support for direct connections
Add support for socksNonProxyHosts Reviewed-by: chegar, khazra
This commit is contained in:
parent
efdece0bc7
commit
a7b0073f5a
@ -124,6 +124,7 @@ public class DefaultProxySelector extends ProxySelector {
|
||||
final String defaultVal;
|
||||
static NonProxyInfo ftpNonProxyInfo = new NonProxyInfo("ftp.nonProxyHosts", null, null, defStringVal);
|
||||
static NonProxyInfo httpNonProxyInfo = new NonProxyInfo("http.nonProxyHosts", null, null, defStringVal);
|
||||
static NonProxyInfo socksNonProxyInfo = new NonProxyInfo("socksNonProxyHosts", null, null, defStringVal);
|
||||
|
||||
NonProxyInfo(String p, String s, RegexpPool pool, String d) {
|
||||
property = p;
|
||||
@ -186,6 +187,8 @@ public class DefaultProxySelector extends ProxySelector {
|
||||
pinfo = NonProxyInfo.httpNonProxyInfo;
|
||||
} else if ("ftp".equalsIgnoreCase(protocol)) {
|
||||
pinfo = NonProxyInfo.ftpNonProxyInfo;
|
||||
} else if ("socket".equalsIgnoreCase(protocol)) {
|
||||
pinfo = NonProxyInfo.socksNonProxyInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6964547
|
||||
* @bug 6964547 5001942
|
||||
* @run main/othervm SocksProxyVersion
|
||||
* @summary test socksProxyVersion system property
|
||||
*/
|
||||
@ -34,6 +34,7 @@ import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
|
||||
public class SocksProxyVersion implements Runnable {
|
||||
final ServerSocket ss;
|
||||
@ -56,13 +57,19 @@ public class SocksProxyVersion implements Runnable {
|
||||
Thread serverThread = new Thread(this);
|
||||
serverThread.start();
|
||||
|
||||
System.setProperty("socksProxyHost", "localhost");
|
||||
/*
|
||||
* Retreving the IP Address of the machine
|
||||
* since "localhost" is bypassed as a non-proxy host
|
||||
*/
|
||||
String addr = InetAddress.getLocalHost().getHostAddress();
|
||||
|
||||
System.setProperty("socksProxyHost", addr);
|
||||
System.setProperty("socksProxyPort", Integer.toString(port));
|
||||
|
||||
// SOCKS V4
|
||||
System.setProperty("socksProxyVersion", Integer.toString(4));
|
||||
try (Socket s = new Socket()) {
|
||||
s.connect(new InetSocketAddress("localhost", port));
|
||||
s.connect(new InetSocketAddress(addr, port));
|
||||
} catch (SocketException e) {
|
||||
// java.net.SocketException: Malformed reply from SOCKS server
|
||||
// This exception is OK, since the "server" does not implement
|
||||
@ -72,7 +79,7 @@ public class SocksProxyVersion implements Runnable {
|
||||
// SOCKS V5
|
||||
System.setProperty("socksProxyVersion", Integer.toString(5));
|
||||
try (Socket s = new Socket()) {
|
||||
s.connect(new InetSocketAddress("localhost", port));
|
||||
s.connect(new InetSocketAddress(addr, port));
|
||||
} catch (SocketException e) { /* OK */ }
|
||||
|
||||
serverThread.join();
|
||||
|
Loading…
x
Reference in New Issue
Block a user