public interface SocksProxy
SocksProxy
define a SOCKS proxy. it's will be used by
SocksSocket
or Socks5DatagramSocket
Modifier and Type | Field and Description |
---|---|
static int |
SOCKS_DEFAULT_PORT
Default SOCKS server port.
|
Modifier and Type | Method and Description |
---|---|
Socket |
accept()
When binded server has income connection, this method will read second response message from
SOCKS server.
|
void |
buildConnection()
Connect SOCKS server using SOCKS protocol.
|
SocksProxy |
copy()
This method can create a same SocksProxy instance.
|
SocksProxy |
copyWithoutChainProxy()
Copy the
SocksProxy . |
Socket |
createProxySocket()
Creates a unconnected socket.
|
Socket |
createProxySocket(InetAddress address,
int port)
Creates a proxy socket.
|
List<SocksMethod> |
getAcceptableMethods()
Gets clent's acceptable methods.
|
SocksProxy |
getChainProxy()
Returns the chain proxy.
|
Credentials |
getCredentials()
Gets credentials from the SocksProxy.
|
InetAddress |
getInetAddress()
Get SOCKS server's address as IPv4 or IPv6.
|
InputStream |
getInputStream()
Gets InputStream from the socket that connected SOCKS server.
|
OutputStream |
getOutputStream()
Gets OutputStream from the socket that connected SOCKS server.
|
int |
getPort()
Get SOCKS Server port.
|
Socket |
getProxySocket()
Get the socket which connect SOCKS server.
|
SocksMethodRequestor |
getSocksMethodRequestor()
Gets
SocksMethodRequestor . |
int |
getSocksVersion()
Gets version of SOCKS protocol.
|
CommandReplyMesasge |
requestBind(InetAddress inetAddress,
int port)
This method will send a BIND command to SOKCS server.
|
CommandReplyMesasge |
requestBind(String host,
int port)
This method will send a BIND command to SOKCS server.
|
CommandReplyMesasge |
requestConnect(InetAddress address,
int port)
This method will send a CONNECT command to SOCKS server and ask SOCKS server to connect remote
server.
|
CommandReplyMesasge |
requestConnect(SocketAddress address)
This method will send a CONNECT command to SOCKS server and ask SOCKS server to connect remote
server.
|
CommandReplyMesasge |
requestConnect(String host,
int port)
This method will send a CONNECT command to SOCKS server and ask SOCKS server to connect remote
server.
|
CommandReplyMesasge |
requestUdpAssociat(InetAddress address,
int port)
This method will send a UDP ASSOCIAT command to SOCKS server and ask SOCKS server to establish
a relay server.
|
CommandReplyMesasge |
requestUdpAssociat(String host,
int port)
This method will send a UDP ASSOCIAT command to SOCKS server and ask SOCKS server to establish
a relay server.
|
SocksProxy |
setAcceptableMethods(List<SocksMethod> methods)
Sets client's acceptable methods.
|
SocksProxy |
setChainProxy(SocksProxy chainProxy)
Returns the instance of
SocksProxy . |
SocksProxy |
setCredentials(Credentials credentials)
Sets credentials.
|
SocksProxy |
setHost(String host)
Set SOCKS server's host.
|
SocksProxy |
setPort(int port)
Set SOCKS server port.
|
SocksProxy |
setProxySocket(Socket socket)
Set a unconnected socket which will be used to connect SOCKS server.
|
SocksProxy |
setSocksMethodRequestor(SocksMethodRequestor requestor)
Sets
SocksMethodRequestor . |
static final int SOCKS_DEFAULT_PORT
Socket getProxySocket()
int getPort()
SocksProxy setPort(int port)
port
- SOCKS server's port.InetAddress getInetAddress()
SocksProxy setHost(String host) throws UnknownHostException
host
- SOCKS server's host.UnknownHostException
- if host can't resolve to InetAddress
SocksProxy setProxySocket(Socket socket)
socket
- a unconnected socket.void buildConnection() throws IOException, SocksException
This method will ask SOCKS server to select a method from the methods listed by client. If
SOCKS server need authentication, it will do authentication. If SOCKS server select 0xFF,It
means that none of the methods listed by the client are acceptable and this method should throw
SocksException
.
IOException
- if any IO error occurs.SocksException
- if any error about SOCKS protocol occurs.CommandReplyMesasge requestConnect(String host, int port) throws SocksException, IOException
host
- Remote server's host.port
- Remote server's port.SocksException
- If any error about SOCKS protocol occurs.IOException
- if any I/O error occurs.CommandReplyMesasge requestConnect(InetAddress address, int port) throws SocksException, IOException
address
- Remote server's address as java.net.InetAddress instance.port
- Remote server's port.SocksException
- If any error about SOCKS protocol occurs.IOException
- If any I/O error occurs.CommandReplyMesasge requestConnect(SocketAddress address) throws SocksException, IOException
address
- Remote server's address as java.net.SocketAddress instance.SocksException
- If any error about SOCKS protocol occurs.IOException
- If any I/O error occurs.CommandReplyMesasge requestBind(String host, int port) throws SocksException, IOException
host
- Remote server's host.port
- Remote server's port.SocksException
- If any error about SOCKS protocol occurs.IOException
- If any I/O error occurs.CommandReplyMesasge requestBind(InetAddress inetAddress, int port) throws SocksException, IOException
inetAddress
- Remote server's IP address.port
- Remote server's port.SocksException
- If any error about SOCKS protocol occurs.IOException
- If any I/O error occurs.Socket accept() throws SocksException, IOException
SocksException
- If any error about SOCKS protocol occurs.IOException
- If any I/O error occurs.CommandReplyMesasge requestUdpAssociat(String host, int port) throws SocksException, IOException
host
- Remote UDP server's host.port
- Remote UDP server's port.SocksException
- If any error about SOCKS protocol occurs.IOException
- If any I/O error occurs.CommandReplyMesasge requestUdpAssociat(InetAddress address, int port) throws SocksException, IOException
address
- Remote UDP server's address.port
- Remote UDP server's port.SocksException
- If any error about SOCKS protocol occurs.IOException
- If any I/O error occurs.InputStream getInputStream() throws IOException
IOException
- if any I/O error occurs.OutputStream getOutputStream() throws IOException
IOException
- if any I/O error occurs.SocksProxy setCredentials(Credentials credentials)
credentials
- Credentials
instance.UsernamePasswordCredentials
,
AnonymousCredentials
Credentials getCredentials()
Credentials
instance.SocksProxy setAcceptableMethods(List<SocksMethod> methods)
methods
- methods.List<SocksMethod> getAcceptableMethods()
SocksProxy setSocksMethodRequestor(SocksMethodRequestor requestor)
SocksMethodRequestor
.requestor
- SocksMethodRequestor
SocksMethodRequestor getSocksMethodRequestor()
SocksMethodRequestor
.SocksMethodRequestor
.int getSocksVersion()
SocksProxy copy()
The new instance created by this method has the same properties with the original instance, but they have different socket instance. The new instance's socket is also unconnected.
SocksProxy copyWithoutChainProxy()
SocksProxy
. It will copy all properties of the
SocksProxy
but without chain proxy.SocksProxy getChainProxy()
SocksProxy setChainProxy(SocksProxy chainProxy)
SocksProxy
.chainProxy
- chain proxy.SocksProxy
.Socket createProxySocket(InetAddress address, int port) throws IOException
address
- address.port
- port.IOException
- If an I\O error occurred.Socket createProxySocket() throws IOException
IOException
Copyright © 2015. All rights reserved.