public class Socks5socket
extends java.net.Socket
Does NO authentification yet!
This class is a straightforward implementation of the SOCKS5 client protocol as described in RFC.... Unfortunately it is just capable of identifying itself with username and password since I was not able to find a Java GSSAPI and furthermore was the administrator of the SOCKS server myself so I could configure it to accept username password authentification.
Usage:
private void tconnect(String host, int port, boolean socks){
Socket s=null;
String buff=null;
try{
if (socks) s=(Socket)new Socks5socket(host, port);
else s=new Socket(host, port);
...
}catch (IOException e){
output.append("Connection refused.\n"+e+"\n");
}finally{
output.append("Connection closed.\n");
if (s != null) try{s.close();}catch(IOException ce){;}
}
}
| Constructor | Description |
|---|---|
Socks5socket(java.lang.String hostname,
int port) |
the standardconstructor.
|
Socks5socket(java.lang.String hostname,
int port,
java.lang.String s5Host,
int s5Port) |
| Modifier and Type | Method | Description |
|---|---|---|
java.lang.String |
getHost() |
Returns the IP address of the Socks server.
|
int |
getPort() |
Returns the portnumber of the Socks server.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbind, close, connect, connect, getChannel, getInetAddress, getInputStream, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getOption, getOutputStream, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setOption, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, supportedOptions, toStringpublic Socks5socket(java.lang.String hostname,
int port)
throws java.net.UnknownHostException,
java.io.IOException
This constructor feels exactly like a standard Socket, it just opens a connection to the SOCKS server first, negotiates the credentials and requests a connect to the remote host on success.
hostname - the name of the remote host to connect to.port - the portnumber on the remote host to connect to.java.net.UnknownHostException - if the host could not be resolved.java.io.IOException - if any error occured on connection.public Socks5socket(java.lang.String hostname,
int port,
java.lang.String s5Host,
int s5Port)
throws java.net.UnknownHostException,
java.io.IOException
hostname - port - s5Host - s5Port - java.net.UnknownHostExceptionjava.io.IOExceptionpublic java.lang.String getHost()
This just prints out the IP-Address that was returned after the request. Eventually we need this in a cascaded proxy environment since the SOCKS definition is capable of load balancing connections between different servers.
public int getPort()
This just prints out the portnumber that was returned after the request. Eventually we need this in a cascaded proxy environment since the SOCKS definition is capable of load balancing connections between different servers.
getPort in class java.net.Socket