From fbb1fecd5b65563a2e1afe918ba33641bbaa630b Mon Sep 17 00:00:00 2001 From: chegar Date: Thu, 13 Jan 2011 13:24:58 +0000 Subject: [PATCH] 6964547: Impossible to set useV4 in SocksSocketImpl Summary: Add socksProxyVersion property Reviewed-by: alanb, michaelm --- make/sun/net/FILES_java.gmk | 1 + src/share/classes/java/io/PrintStream.java | 2 +- .../classes/java/net/SocksSocketImpl.java | 13 ++- .../java/net/doc-files/net-properties.html | 7 +- src/share/classes/sun/net/SocksProxy.java | 49 ++++++++++ .../sun/net/spi/DefaultProxySelector.java | 20 +++- test/java/net/Socks/SocksProxyVersion.java | 98 +++++++++++++++++++ 7 files changed, 182 insertions(+), 8 deletions(-) create mode 100644 src/share/classes/sun/net/SocksProxy.java create mode 100644 test/java/net/Socks/SocksProxyVersion.java diff --git a/make/sun/net/FILES_java.gmk b/make/sun/net/FILES_java.gmk index 23c94b42a..576159c47 100644 --- a/make/sun/net/FILES_java.gmk +++ b/make/sun/net/FILES_java.gmk @@ -33,6 +33,7 @@ FILES_java = \ sun/net/ProgressEvent.java \ sun/net/ProgressListener.java \ sun/net/ProgressMeteringPolicy.java \ + sun/net/SocksProxy.java \ sun/net/TelnetInputStream.java \ sun/net/TelnetOutputStream.java \ sun/net/TelnetProtocolException.java \ diff --git a/src/share/classes/java/io/PrintStream.java b/src/share/classes/java/io/PrintStream.java index 87d425bfe..9ed3ff6f9 100644 --- a/src/share/classes/java/io/PrintStream.java +++ b/src/share/classes/java/io/PrintStream.java @@ -70,7 +70,7 @@ public class PrintStream extends FilterOutputStream private OutputStreamWriter charOut; /** - * nonNull is explicitly delcared here so as not to create an extra + * nonNull is explicitly declared here so as not to create an extra * dependency on java.util.Objects.nonNull. PrintStream is loaded * early during system initialization. */ diff --git a/src/share/classes/java/net/SocksSocketImpl.java b/src/share/classes/java/net/SocksSocketImpl.java index 99161753c..4fb61efe6 100644 --- a/src/share/classes/java/net/SocksSocketImpl.java +++ b/src/share/classes/java/net/SocksSocketImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ import java.io.OutputStream; import java.io.BufferedOutputStream; import java.security.AccessController; import java.security.PrivilegedExceptionAction; +import sun.net.SocksProxy; import sun.net.www.ParseUtil; /* import org.ietf.jgss.*; */ @@ -397,6 +398,11 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { // Use getHostString() to avoid reverse lookups server = ((InetSocketAddress) p.address()).getHostString(); serverPort = ((InetSocketAddress) p.address()).getPort(); + if (p instanceof SocksProxy) { + if (((SocksProxy)p).protocolVersion() == 4) { + useV4 = true; + } + } // Connects to the SOCKS server try { @@ -700,6 +706,11 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { // Use getHostString() to avoid reverse lookups server = ((InetSocketAddress) p.address()).getHostString(); serverPort = ((InetSocketAddress) p.address()).getPort(); + if (p instanceof SocksProxy) { + if (((SocksProxy)p).protocolVersion() == 4) { + useV4 = true; + } + } // Connects to the SOCKS server try { diff --git a/src/share/classes/java/net/doc-files/net-properties.html b/src/share/classes/java/net/doc-files/net-properties.html index fffdfebc4..ae39fec8e 100644 --- a/src/share/classes/java/net/doc-files/net-properties.html +++ b/src/share/classes/java/net/doc-files/net-properties.html @@ -127,10 +127,15 @@ of proxies.

are specified. If SOCKS is supported by a Java SE implementation, the following properties will be used: