|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.net.Socket
anecho.extranet.Socks5socket
public class Socks5socket
Extension of the standard Socket class to enable connections through a socks5 server.
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 Summary | |
|---|---|
Socks5socket(java.lang.String hostname,
int port)
the standardconstructor. |
|
Socks5socket(java.lang.String hostname,
int port,
java.lang.String s5Host,
int s5Port)
|
|
| Method Summary | |
|---|---|
java.lang.String |
getHost()
Returns the IP address of the Socks server. |
int |
getPort()
Returns the portnumber of the Socks server. |
| Methods inherited from class java.net.Socket |
|---|
bind, close, connect, connect, getChannel, getInetAddress, getInputStream, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getOutputStream, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public 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.UnknownHostException
java.io.IOException| Method Detail |
|---|
public 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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||