com.mindbright.net
Class SocksProxySocket

java.lang.Object
  extended by com.mindbright.net.SocksProxySocket

public class SocksProxySocket
extends java.lang.Object

Socket that connects through a socks proxy. Note that the proxy setup is done in blocking mdoe so this will block until the socket is connected, or it gives up. This supports both Socks4 and Socks5


Method Summary
 java.lang.String getServerDesc()
           
static NetworkConnection getSocks4Proxy(java.lang.String targetHost, int targetPort, java.lang.String proxyHost, int proxyPort, long proxyTimeout, java.lang.String userId)
          Connect through a proxy speaking the socks4 protocol Note that the connection is done synchronously so this call will block until the connection is established.
static NetworkConnection getSocks4Proxy(java.lang.String targetHost, int targetPort, java.lang.String proxyHost, int proxyPort, java.lang.String userId)
          Connect through a proxy speaking the socks4 protocol Note that the connection is done synchronously so this call will block until the connection is established.
static NetworkConnection getSocks5Proxy(java.lang.String targetHost, int targetPort, java.lang.String proxyHost, int proxyPort, boolean localLookup, ProxyAuthenticator auth)
          Connect through a proxy speaking the socks5 protocol Note that the connection is done synchronously so this call will block until the connection is established.
static NetworkConnection getSocks5Proxy(java.lang.String targetHost, int targetPort, java.lang.String proxyHost, int proxyPort, long proxyTimeout, boolean localLookup, ProxyAuthenticator auth)
          Connect through a proxy speaking the socks5 protocol Note that the connection is done synchronously so this call will block until the connection is established.
static NetworkConnection getSocks5Proxy(java.lang.String targetHost, int targetPort, java.lang.String proxyHost, int proxyPort, long proxyTimeout, ProxyAuthenticator auth)
          Connect through a proxy speaking the socks5 protocol Note that the connection is done synchronously so this call will block until the connection is established.
static NetworkConnection getSocks5Proxy(java.lang.String targetHost, int targetPort, java.lang.String proxyHost, int proxyPort, ProxyAuthenticator auth)
          Connect through a proxy speaking the socks5 protocol Note that the connection is done synchronously so this call will block until the connection is established.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getServerDesc

public java.lang.String getServerDesc()

getSocks4Proxy

public static NetworkConnection getSocks4Proxy(java.lang.String targetHost,
                                               int targetPort,
                                               java.lang.String proxyHost,
                                               int proxyPort,
                                               java.lang.String userId)
                                        throws java.io.IOException,
                                               java.net.UnknownHostException
Connect through a proxy speaking the socks4 protocol Note that the connection is done synchronously so this call will block until the connection is established.

Parameters:
targetHost - Host we want to connect to
targetPort - Port on host we want to connect to
proxyHost - Address or proxy server
proxyPort - Port on proxy server
userId - User to connect as
Returns:
A NetworkConnection which is connected to the destination hos through the proxy.
Throws:
java.io.IOException
java.net.UnknownHostException

getSocks4Proxy

public static NetworkConnection getSocks4Proxy(java.lang.String targetHost,
                                               int targetPort,
                                               java.lang.String proxyHost,
                                               int proxyPort,
                                               long proxyTimeout,
                                               java.lang.String userId)
                                        throws java.io.IOException,
                                               java.net.UnknownHostException
Connect through a proxy speaking the socks4 protocol Note that the connection is done synchronously so this call will block until the connection is established.

Parameters:
targetHost - Host we want to connect to
targetPort - Port on host we want to connect to
proxyHost - Address or proxy server
proxyPort - Port on proxy server
proxyTimeout - How many milliseconds to wait before giving
userId - User to connect as
Returns:
A NetworkConnection which is connected to the destination hos through the proxy.
Throws:
java.io.IOException
java.net.UnknownHostException

getSocks5Proxy

public static NetworkConnection getSocks5Proxy(java.lang.String targetHost,
                                               int targetPort,
                                               java.lang.String proxyHost,
                                               int proxyPort,
                                               ProxyAuthenticator auth)
                                        throws java.io.IOException,
                                               java.net.UnknownHostException
Connect through a proxy speaking the socks5 protocol Note that the connection is done synchronously so this call will block until the connection is established.

Parameters:
targetHost - Host we want to connect to
targetPort - Port on host we want to connect to
proxyHost - Address or proxy server
proxyPort - Port on proxy server
auth - Used to athenticate (if needed)
Returns:
A NetworkConnection which is connected to the destination hos through the proxy.
Throws:
java.io.IOException
java.net.UnknownHostException

getSocks5Proxy

public static NetworkConnection getSocks5Proxy(java.lang.String targetHost,
                                               int targetPort,
                                               java.lang.String proxyHost,
                                               int proxyPort,
                                               boolean localLookup,
                                               ProxyAuthenticator auth)
                                        throws java.io.IOException,
                                               java.net.UnknownHostException
Connect through a proxy speaking the socks5 protocol Note that the connection is done synchronously so this call will block until the connection is established.

Parameters:
targetHost - Host we want to connect to
targetPort - Port on host we want to connect to
proxyHost - Address or proxy server
proxyPort - Port on proxy server
localLookup - If true then the targetHost is resolved locally. If false then the socks server will resolve.
auth - Used to athenticate (if needed)
Returns:
A NetworkConnection which is connected to the destination hos through the proxy.
Throws:
java.io.IOException
java.net.UnknownHostException

getSocks5Proxy

public static NetworkConnection getSocks5Proxy(java.lang.String targetHost,
                                               int targetPort,
                                               java.lang.String proxyHost,
                                               int proxyPort,
                                               long proxyTimeout,
                                               ProxyAuthenticator auth)
                                        throws java.io.IOException,
                                               java.net.UnknownHostException
Connect through a proxy speaking the socks5 protocol Note that the connection is done synchronously so this call will block until the connection is established.

Parameters:
targetHost - Host we want to connect to
targetPort - Port on host we want to connect to
proxyHost - Address or proxy server
proxyPort - Port on proxy server
proxyTimeout - How many milliseconds to wait before giving
auth - Used to athenticate (if needed)
Returns:
A NetworkConnection which is connected to the destination hos through the proxy.
Throws:
java.io.IOException
java.net.UnknownHostException

getSocks5Proxy

public static NetworkConnection getSocks5Proxy(java.lang.String targetHost,
                                               int targetPort,
                                               java.lang.String proxyHost,
                                               int proxyPort,
                                               long proxyTimeout,
                                               boolean localLookup,
                                               ProxyAuthenticator auth)
                                        throws java.io.IOException,
                                               java.net.UnknownHostException
Connect through a proxy speaking the socks5 protocol Note that the connection is done synchronously so this call will block until the connection is established.

Parameters:
targetHost - Host we want to connect to
targetPort - Port on host we want to connect to
proxyHost - Address or proxy server
proxyPort - Port on proxy server
proxyTimeout - How many milliseconds to wait before giving
localLookup - If true then the targetHost is resolved locally. If false then the socks server will resolve.
auth - Used to athenticate (if needed)
Returns:
A NetworkConnection which is connected to the destination hos through the proxy.
Throws:
java.io.IOException
java.net.UnknownHostException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object