<?xml version="1.0"?><rss version="2.0">
<channel>
  <title>Alan&#039;s Ramblings - proxy tag</title>
  <link>http://bleaklow.com:80/tags/proxy/</link>
  <description>My opinions may be incorrect, but they are my own</description>
  <language>en</language>
  <copyright>Alan Burlison</copyright>
  <lastBuildDate>Wed, 29 Feb 2012 20:50:00 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  <image>
    <url>http://bleaklow.com/images/misc/logo.gif</url>
    <title>Alan&#039;s Ramblings</title>
    <link>http://bleaklow.com:80/</link>
  </image>
  <item>
    <title>Java, Java Webstart and SOCKS</title>
    <link>http://bleaklow.com:80/2004/01/12/java_java_webstart_and_socks.html</link>
    <description>
          &lt;p&gt;
When connected to work  via VPN I live behind the corporate firewall.  Unfortunately this means that I can&#039;t connect to the various Go servers, as the firewall won&#039;t allow you to connect to arbitrary port numbers.  There is a way through the firewall, using a &lt;a href=&#034;http://www.socks.permeo.com/&#034;&gt;SOCKS&lt;/a&gt; proxy, but most of the various Go server clients are &lt;a href=&#034;http://java.sun.com/products/javawebstart/index.jsp&#034;&gt;Java Webstart&lt;/a&gt; applications, and WebStart applications can&#039;t unfortunately talk SOCKS, nor can they be successfully SOCKSified using the normal &lt;code&gt;runsocks&lt;/code&gt; wrapper.  In fact as far as I can tell, Java apps in general can&#039;t talk SOCKS unless they have been specifically written to do so.  The consequence of this was that I had to keep dropping the VPN connection every time I wanted to play Go, which was a pain.  Never one to let a little adversity to stand in my way, I came up with a solution, which might be of interest to others - if you are such a person, read on.
&lt;/p&gt;
&lt;p&gt;
The obvious solution is to put an intermediate proxy that &lt;strong&gt;can&lt;/strong&gt; talk  SOCKS between the Java client and the SOCKS proxy - the Java client talks vanilla TCP/IP to the intermediate proxy, and the intermediate proxy then talks SOCKS to the SOCKS server.  I thought it would be a snap to find something out there in OpenSourceLand to do this.  I wanted something simple, lightweight and entirely userland, but to my surprise I couldn&#039;t seem to find anything.  I therefore hacked something together myself.
&lt;/p&gt;
&lt;p&gt;
What I ended up with was a simple userland port forwarder - it listens on a  range of given ports, and each time it receives a connection it spawns a thread that connects to a specified destination port and transfers data from/to the two endpoints.  An example configuration file is shown below:
&lt;/p&gt;
&lt;pre&gt;
#
# socksy configuration file.
# Edit as appropriate, then run:
#     $ export $(runsocks env | grep SOCKS_SERVER)
#     $ socksy -d socksy.config
#
# File format is
# &lt;local addr&gt;:&lt;local port&gt; -&gt; &lt;remote addr&gt;:&lt;remote port&gt; [ , ...]
# &lt;local addr&gt; can be &#034;* to wildcard the local interface.
#

# Internet Go Server.
*:7777 -&gt; igs.joyjoy.net:7777, igs.joyjoy.net:6969

# Kisedo Go Server.
*:2379 -&gt; kgs.kiseido.com:2379

# Perl IRC
*:6667 -&gt; irc.perl.org:6667, grouch.irc.perl.org:6667, london.irc.perl.org:6667
&lt;/pre&gt;
&lt;p&gt;
Where more than one destination is specified, each is tried in order until one succeeds.  The code works fine as it is, but isn&#039;t exactly feature rich - for example UDP isn&#039;t supported.  There&#039;s also no logging, and no client access control.  However TCP Out Of Band data is catered for correctly.  I&#039;m happy to share the code if anyone wants it, and if someone feels then need extra bells &amp;amp; whistles, contributions are gratefully accepted :-)
&lt;/p&gt;
&lt;p&gt;
The code has only been tested on Solaris, so I haven&#039;t put a link to the source as I don&#039;t want people downloading it and then complaining it doesn&#039;t work on Linux, as I don&#039;t have access to a Linux box.  If you wan the source and are prepared to make it work on Linux, let me know.  In fact I&#039;ve put this entry here in the hope that if I scatter it with enough keywords, someone will find it with Google and come and talk to me about it;-)
&lt;/p&gt;</description>
      <category>Web</category>
    <category>Tech</category>
    <comments>http://bleaklow.com:80/2004/01/12/java_java_webstart_and_socks.html#comments</comments>
    <guid isPermaLink="true">http://bleaklow.com:80/2004/01/12/java_java_webstart_and_socks.html</guid>
    <pubDate>Mon, 12 Jan 2004 06:35:47 GMT</pubDate>
  </item>
  </channel>
</rss>

