public class UDPRelayServer extends Object implements Runnable
UDPRelayServer
represents a UDP relay server.
The UDP relay server will receive datagram packets from a client and transmit them to the specified server. It will also receive datagram packets from other UDP servers and send them to client. UDP relay server must need to know the client's IP address and port to find out where the datagram packet from, because UDP is not long connection protocol.
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
logger
Logger that subclasses also can use.
|
Constructor and Description |
---|
UDPRelayServer()
Constructs a
UDPRelayServer instance. |
UDPRelayServer(InetAddress clientInetAddress,
int clientPort)
Constructs a
UDPRelayServer instance with client's IP address and port. |
UDPRelayServer(SocketAddress clientSocketAddresss) |
Modifier and Type | Method and Description |
---|---|
int |
getBufferSize()
Returns buffer size.
|
InetAddress |
getClientAddresss()
Returns client's IP address.
|
int |
getClientPort()
Returns client's port.
|
Socks5DatagramPacketHandler |
getDatagramPacketHandler()
Returns datagram packet handler.
|
DatagramSocket |
getServer()
Return UDP server.
|
protected boolean |
isFromClient(DatagramPacket packet)
Returns
true if the the datagram packet from client. |
boolean |
isRunning()
Return
true if the UDP relay server is running. |
void |
run() |
void |
setBufferSize(int bufferSize)
Sets buffer size.
|
void |
setClientAddresss(InetAddress clientAddresss)
Sets client's IP address.
|
void |
setClientPort(int clientPort)
Sets client's port.
|
void |
setDatagramPacketHandler(Socks5DatagramPacketHandler datagramPacketHandler)
Sets datagram packet handler.
|
void |
setServer(DatagramSocket server)
Sets UDP server.
|
SocketAddress |
start()
Starts a UDP relay server.
|
void |
stop()
Stop the UDP relay server.
|
protected static final org.slf4j.Logger logger
public UDPRelayServer()
UDPRelayServer
instance.public UDPRelayServer(InetAddress clientInetAddress, int clientPort)
UDPRelayServer
instance with client's IP address and port. The UDP relay
server will use client's IP and port to find out where the datagram packet from.clientInetAddress
- Client's IP address.clientPort
- Client's port.public UDPRelayServer(SocketAddress clientSocketAddresss)
public SocketAddress start() throws SocketException
SocketException
- If a SOCKS protocol error occurred.public void stop()
protected boolean isFromClient(DatagramPacket packet)
true
if the the datagram packet from client.packet
- Datagram packet the UDP server received.true
.public DatagramSocket getServer()
public void setServer(DatagramSocket server)
server
- UDP server.public int getBufferSize()
public void setBufferSize(int bufferSize)
bufferSize
- Buffer size.public Socks5DatagramPacketHandler getDatagramPacketHandler()
Socks5DatagramPacketHandler
.public void setDatagramPacketHandler(Socks5DatagramPacketHandler datagramPacketHandler)
datagramPacketHandler
- Datagram packet handler.public InetAddress getClientAddresss()
public void setClientAddresss(InetAddress clientAddresss)
clientAddresss
- client's IP address.public int getClientPort()
public void setClientPort(int clientPort)
clientPort
- client's port.public boolean isRunning()
true
if the UDP relay server is running.true
.Copyright © 2015. All rights reserved.