public class Socks5Server
extends java.lang.Object
CONNECT requests (i.e., no
BIND).
Example usage:
Socks5Server server = new Socks5Server(sockIn, sockOut);
if (server.acceptAuthentication() && server.readRequest()) {
server.sendReply(ResponseCode.SUCCESS);
} else {
/* handle failure */
}
| Modifier and Type | Class and Description |
|---|---|
static class |
Socks5Server.Command
Command that a client can request.
|
static class |
Socks5Server.ResponseCode |
| Constructor and Description |
|---|
Socks5Server(java.io.InputStream in,
java.io.OutputStream out) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptAuthentication()
Begin the authentication with the client.
|
java.net.InetAddress |
getAddress() |
Socks5Server.Command |
getCommand() |
java.lang.String |
getHostName() |
int |
getPort() |
boolean |
readRequest()
Reads the type of request the client has made.
|
void |
sendReply(Socks5Server.ResponseCode response)
Send back to the client the given
response. |
public Socks5Server(java.io.InputStream in,
java.io.OutputStream out)
public boolean acceptAuthentication()
throws java.io.IOException
true.
Otherwise, the server must hang up on the client.true when authentication succeedsjava.io.IOException - when the underlying stream has a problempublic boolean readRequest()
throws java.io.IOException
true if the client request was validjava.io.IOException - when the underlying stream has a problemgetCommand(),
getAddress(),
getPort()public void sendReply(Socks5Server.ResponseCode response) throws java.io.IOException
response. If the SUCCESS code is returned,
the server must immediately connect the input and output streams to the requested socket. If any other code is
returned, then the server must hang up on the client.response - code to send back to the clientjava.io.IOException - when the underlying stream has a problempublic Socks5Server.Command getCommand()
public java.net.InetAddress getAddress()
public java.lang.String getHostName()
public int getPort()