8224081: SOCKS v4 doesn't work with IPv6
Reviewed-by: chegar, dfuchs, mullan, vtewari
Contributed-by: aeubanks@google.com
--- a/test/jdk/java/net/Socks/SocksProxyVersion.java Wed May 29 11:58:30 2019 -0700
+++ b/test/jdk/java/net/Socks/SocksProxyVersion.java Thu May 16 15:58:15 2019 -0700
@@ -24,6 +24,7 @@
/*
* @test
* @bug 6964547 5001942 8129444
+ * @library /test/lib
* @run main/othervm SocksProxyVersion
* @summary test socksProxyVersion system property
*/
@@ -35,6 +36,7 @@
import java.io.IOException;
import java.net.InetAddress;
import java.net.Proxy;
+import jdk.test.lib.net.IPSupport;
public class SocksProxyVersion implements Runnable {
final ServerSocket ss;
@@ -80,14 +82,16 @@
Proxy proxy = new Proxy(Proxy.Type.SOCKS,
new InetSocketAddress(addr, port));
- // SOCKS V4
- System.setProperty("socksProxyVersion", Integer.toString(4));
- this.expected = 4;
- check(new Socket(), addr, port);
- check(new Socket(proxy), addr, port);
+ if (IPSupport.hasIPv4()) {
+ // SOCKS V4 (requires IPv4)
+ System.setProperty("socksProxyVersion", "4");
+ this.expected = 4;
+ check(new Socket(), addr, port);
+ check(new Socket(proxy), addr, port);
+ }
// SOCKS V5
- System.setProperty("socksProxyVersion", Integer.toString(5));
+ System.setProperty("socksProxyVersion", "5");
this.expected = 5;
check(new Socket(), addr, port);
check(new Socket(proxy), addr, port);
--- a/test/jdk/sun/security/x509/URICertStore/SocksProxy.java Wed May 29 11:58:30 2019 -0700
+++ b/test/jdk/sun/security/x509/URICertStore/SocksProxy.java Thu May 16 15:58:15 2019 -0700
@@ -22,6 +22,7 @@
*/
import java.io.IOException;
+import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Objects;
@@ -30,7 +31,7 @@
import javax.net.ServerSocketFactory;
/*
- * A simple socks4 proxy for traveling socket.
+ * A simple socks proxy for traveling socket.
*/
class SocksProxy implements Runnable, AutoCloseable {
@@ -49,10 +50,11 @@
ServerSocket server
= ServerSocketFactory.getDefault().createServerSocket(0);
- System.setProperty("socksProxyHost", "127.0.0.1");
+ System.setProperty("socksProxyHost",
+ InetAddress.getLoopbackAddress().getHostAddress());
System.setProperty("socksProxyPort",
String.valueOf(server.getLocalPort()));
- System.setProperty("socksProxyVersion", "4");
+ System.setProperty("socksProxyVersion", "5");
SocksProxy proxy = new SocksProxy(server, socketConsumer);
Thread proxyThread = new Thread(proxy, "Proxy");