DefaultProxySelector socks override

2013-03-27 Thread Christos Zoulas

This trivial patch add socksNonProxyHosts to the default proxy,
so that we can select which socket traffic will be directed to
the proxy and which not. There is currently no way to do this. In
my scenario, I have applications that would benefit in terms of
performance to connect directly to our internal network hosts, and
at the same time need to connect to the outside via our socks proxy.
Having all of them go through the socks proxy would require me to
buy a very expensive proxy, and suffer the latency anyway. I would 
also like to note that the socksNonProxyHosts variable is in:

jdk/src/share/native/java/lang/System.c:PUTPROP(props, 
socksNonProxyHosts, sprops-exceptionList);

for MacOS/X but nowhere else. Finally (not in this patch), it would
be nice to provide socks.nonProxyHosts etc. to be symmetric with the
other http, https, and ftp variables. But this is purely cosmetic. And
here's the patch...

Enjoy,

christos

--- jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java.origWed Mar 
27 10:26:36 2013 -0400
+++ jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java Wed Mar 27 
10:28:15 2013 -0400
@@ -124,6 +124,7 @@
 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,7 +187,9 @@
 pinfo = NonProxyInfo.httpNonProxyInfo;
 } else if (ftp.equalsIgnoreCase(protocol)) {
 pinfo = NonProxyInfo.ftpNonProxyInfo;
-}
+} else if (socket.equalsIgnoreCase(protocol)) {
+pinfo = NonProxyInfo.socksNonProxyInfo;
+}
 
 /**
  * Let's check the System properties for that protocol


Re: DefaultProxySelector socks override

2013-03-27 Thread Chris Hegarty
[cc'ing net-dev, we can then probably drop core-libs-dev and continue 
the discussion over on net-dev]


Christos,

SOCKS is really old and not as widely deployed as other proxies. That 
said, I don't have any specific problem with your proposal. SOCKS is 
really in maintenance mode in the JDK, but I do see this as a reasonable 
request/proposal.


Since socksNonProxyHosts is only set on Mac I can only presume that it 
is a remanent of the mac port. I would prefer to make the cosmetic 
changes as part of this patch. I cannot see that we need to keep 
socksNonProxyHosts, as it does nothing in the JDK anyway.


Can you do this?

-Chris.

On 03/27/2013 02:41 PM, chris...@zoulas.com wrote:

This trivial patch add socksNonProxyHosts to the default proxy,
so that we can select which socket traffic will be directed to
the proxy and which not. There is currently no way to do this. In
my scenario, I have applications that would benefit in terms of
performance to connect directly to our internal network hosts, and
at the same time need to connect to the outside via our socks proxy.
Having all of them go through the socks proxy would require me to
buy a very expensive proxy, and suffer the latency anyway. I would
also like to note that the socksNonProxyHosts variable is in:

jdk/src/share/native/java/lang/System.c:PUTPROP(props, 
socksNonProxyHosts, sprops-exceptionList);

for MacOS/X but nowhere else. Finally (not in this patch), it would
be nice to provide socks.nonProxyHosts etc. to be symmetric with the
other http, https, and ftp variables. But this is purely cosmetic. And
here's the patch...

Enjoy,

christos

--- jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java.origWed Mar 
27 10:26:36 2013 -0400
+++ jdk/src/share/classes/sun/net/spi/DefaultProxySelector.java Wed Mar 27 
10:28:15 2013 -0400
@@ -124,6 +124,7 @@
  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,7 +187,9 @@
  pinfo = NonProxyInfo.httpNonProxyInfo;
  } else if (ftp.equalsIgnoreCase(protocol)) {
  pinfo = NonProxyInfo.ftpNonProxyInfo;
-}
+} else if (socket.equalsIgnoreCase(protocol)) {
+pinfo = NonProxyInfo.socksNonProxyInfo;
+}

  /**
   * Let's check the System properties for that protocol



Re: DefaultProxySelector socks override

2013-03-27 Thread Christos Zoulas
On Mar 27,  3:54pm, chris.hega...@oracle.com (Chris Hegarty) wrote:
-- Subject: Re: DefaultProxySelector socks override

Hi Chris,

| [cc'ing net-dev, we can then probably drop core-libs-dev and continue 
| the discussion over on net-dev]
| 
| Christos,
| 
| SOCKS is really old and not as widely deployed as other proxies. That 
| said, I don't have any specific problem with your proposal. SOCKS is 
| really in maintenance mode in the JDK, but I do see this as a reasonable 
| request/proposal.

I totally understand; this is a legacy application for us too...

| Since socksNonProxyHosts is only set on Mac I can only presume that it 
| is a remanent of the mac port. I would prefer to make the cosmetic 
| changes as part of this patch. I cannot see that we need to keep 
| socksNonProxyHosts, as it does nothing in the JDK anyway.
| 
| Can you do this?

Sure, I just requested a subscription to net-dev so I might not see the
first few messages. To clarify:

1. I will add socks.proxyHost and socks.proxyPort for consistency
   with the other protocols, leaving as is socksProxyHost and
   socksProxyPort for compatibility.
2. I will add socks.nonProxyHosts and not socksNonProxyHosts.

Is that what you had in mind?

christos


Re: DefaultProxySelector socks override

2013-03-27 Thread Chris Hegarty

On 03/27/2013 05:22 PM, chris...@zoulas.com wrote:


Sure, I just requested a subscription to net-dev so I might not see the
first few messages. To clarify:

1. I will add socks.proxyHost and socks.proxyPort for consistency
   with the other protocols, leaving as is socksProxyHost and
   socksProxyPort for compatibility.
2. I will add socks.nonProxyHosts and not socksNonProxyHosts.

Is that what you had in mind?


Re-checking the code I take back my previous comment. We already have

   socksProxyHost, socksProxyPort, socksProxyVersion

so your original proposal of 'socksNonProxyHosts' is probably best, and 
consistent with existing properties.


-Chris.



christos



Re: DefaultProxySelector socks override

2013-03-27 Thread Christos Zoulas
On Mar 27,  5:30pm, chris.hega...@oracle.com (Chris Hegarty) wrote:
-- Subject: Re: DefaultProxySelector socks override

| On 03/27/2013 05:22 PM, chris...@zoulas.com wrote:
|  
|  Sure, I just requested a subscription to net-dev so I might not see the
|  first few messages. To clarify:
| 
|  1. I will add socks.proxyHost and socks.proxyPort for consistency
| with the other protocols, leaving as is socksProxyHost and
| socksProxyPort for compatibility.
|  2. I will add socks.nonProxyHosts and not socksNonProxyHosts.
| 
|  Is that what you had in mind?
| 
| Re-checking the code I take back my previous comment. We already have
| 
| socksProxyHost, socksProxyPort, socksProxyVersion
| 
| so your original proposal of 'socksNonProxyHosts' is probably best, and 
| consistent with existing properties.

I concur. Nothing for me to do :-)

Best,

christos