socks
Class Socks5Proxy

java.lang.Object
  extended by socks.Proxy
      extended by socks.Socks5Proxy
All Implemented Interfaces:
Cloneable

public class Socks5Proxy
extends Proxy
implements Cloneable

SOCKS5 Proxy.


Field Summary
 
Fields inherited from class socks.Proxy
chainProxy, defaultProxy, directHosts, in, out, proxyHost, proxyIP, proxyPort, proxySocket, SOCKS_ADDR_NOT_SUPPORTED, SOCKS_AUTH_FAILURE, SOCKS_AUTH_NOT_SUPPORTED, SOCKS_BADCONNECT, SOCKS_BADNETWORK, SOCKS_CMD_NOT_SUPPORTED, SOCKS_CONNECTION_REFUSED, SOCKS_DIRECT_FAILED, SOCKS_FAILURE, SOCKS_HOST_UNREACHABLE, SOCKS_JUST_ERROR, SOCKS_METHOD_NOTSUPPORTED, SOCKS_NO_PROXY, SOCKS_PROXY_IO_ERROR, SOCKS_PROXY_NO_CONNECT, SOCKS_SUCCESS, SOCKS_TTL_EXPIRE, version
 
Constructor Summary
Socks5Proxy(InetAddress proxyIP, int proxyPort)
          Creates SOCKS5 proxy.
Socks5Proxy(Proxy p, InetAddress proxyIP, int proxyPort)
          Creates SOCKS5 proxy.
Socks5Proxy(Proxy p, String proxyHost, int proxyPort)
          Creates SOCKS5 proxy.
Socks5Proxy(String proxyHost, int proxyPort)
          Creates SOCKS5 proxy.
 
Method Summary
 Object clone()
          Creates a clone of this Proxy.
protected  Proxy copy()
           
protected  ProxyMessage formMessage(InputStream in)
           
protected  ProxyMessage formMessage(int cmd, InetAddress ip, int port)
           
protected  ProxyMessage formMessage(int cmd, String host, int port)
           
 Authentication getAuthenticationMethod(int methodId)
          Get authentication method, which corresponds to given method id
 boolean resolveAddrLocally()
          Get current setting on how the addresses should be handled.
 boolean resolveAddrLocally(boolean doResolve)
          Wether to resolve address locally or to let proxy do so.
 boolean setAuthenticationMethod(int methodId, Authentication method)
          Adds another authentication method.
protected  void startSession()
           
 
Methods inherited from class socks.Proxy
accept, addDirect, addDirect, addDirect, bind, bind, connect, connect, endSession, exchange, getChainProxy, getDefaultProxy, getDirect, getInetAddress, getPort, isDirect, isDirect, parseProxy, readMsg, sendMsg, setChainProxy, setDefaultProxy, setDefaultProxy, setDefaultProxy, setDefaultProxy, setDefaultProxy, setDirect, toString, udpAssociate, udpAssociate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Socks5Proxy

public Socks5Proxy(Proxy p,
                   String proxyHost,
                   int proxyPort)
            throws UnknownHostException
Creates SOCKS5 proxy.

Parameters:
p - Proxy to use to connect to this proxy, allows proxy chaining.
proxyHost - Host on which a Proxy server runs.
proxyPort - Port on which a Proxy server listens for connections.
Throws:
UnknownHostException - If proxyHost can't be resolved.

Socks5Proxy

public Socks5Proxy(String proxyHost,
                   int proxyPort)
            throws UnknownHostException
Creates SOCKS5 proxy.

Parameters:
proxyHost - Host on which a Proxy server runs.
proxyPort - Port on which a Proxy server listens for connections.
Throws:
UnknownHostException - If proxyHost can't be resolved.

Socks5Proxy

public Socks5Proxy(Proxy p,
                   InetAddress proxyIP,
                   int proxyPort)
Creates SOCKS5 proxy.

Parameters:
p - Proxy to use to connect to this proxy, allows proxy chaining.
proxyIP - Host on which a Proxy server runs.
proxyPort - Port on which a Proxy server listens for connections.

Socks5Proxy

public Socks5Proxy(InetAddress proxyIP,
                   int proxyPort)
Creates SOCKS5 proxy.

Parameters:
proxyIP - Host on which a Proxy server runs.
proxyPort - Port on which a Proxy server listens for connections.
Method Detail

resolveAddrLocally

public boolean resolveAddrLocally(boolean doResolve)
Wether to resolve address locally or to let proxy do so.

SOCKS5 protocol allows to send host names rather then IPs in the requests, this option controls wether the hostnames should be send to the proxy server as names, or should they be resolved locally.

Parameters:
doResolve - Wether to perform resolution locally.
Returns:
Previous settings.

resolveAddrLocally

public boolean resolveAddrLocally()
Get current setting on how the addresses should be handled.

Returns:
Current setting for address resolution.
See Also:
resolveAddrLocally(boolean doResolve)

setAuthenticationMethod

public boolean setAuthenticationMethod(int methodId,
                                       Authentication method)
Adds another authentication method.

Parameters:
methodId - Authentication method id, see rfc1928
method - Implementation of Authentication
See Also:
Authentication

getAuthenticationMethod

public Authentication getAuthenticationMethod(int methodId)
Get authentication method, which corresponds to given method id

Parameters:
methodId - Authentication method id.
Returns:
Implementation for given method or null, if one was not set.

clone

public Object clone()
Creates a clone of this Proxy.

Overrides:
clone in class Object

copy

protected Proxy copy()
Specified by:
copy in class Proxy

startSession

protected void startSession()
                     throws SocksException
Overrides:
startSession in class Proxy
Throws:
SocksException

formMessage

protected ProxyMessage formMessage(int cmd,
                                   InetAddress ip,
                                   int port)
Specified by:
formMessage in class Proxy

formMessage

protected ProxyMessage formMessage(int cmd,
                                   String host,
                                   int port)
                            throws UnknownHostException
Specified by:
formMessage in class Proxy
Throws:
UnknownHostException

formMessage

protected ProxyMessage formMessage(InputStream in)
                            throws SocksException,
                                   IOException
Specified by:
formMessage in class Proxy
Throws:
SocksException
IOException


Copyright © 2013. All Rights Reserved.