java.lang.Object
net.i2p.i2ptunnel.socks.SOCKSUDPPort
Implements a UDP port and Socks encapsulation / decapsulation. This is for a single port. If there is demuxing for multiple ports, it happens outside of here.
TX: UDPSource -> SOCKSUDPUnwrapper -> (I2PSink in SOCKSUDPTunnel)
RX: UDPSink <- SOCKSUDPWrapper ( <- MultiSink <- I2PSource in SOCKSUDPTunnel)
The Unwrapper passes headers to the Wrapper through a cache. MultiSink routes packets based on toPort.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final UDPSinkSends datagrams into the tunnel.private final UDPSourceDelivers datagrams arriving from the tunnel.private final SOCKSUDPUnwrapperRemoves the SOCKS framing on the way in.private final SOCKSUDPWrapperAdds the SOCKS framing on the way out.Constructor Summary
ConstructorsConstructorDescriptionSOCKSUDPPort(InetAddress host, int port, Map<Integer, SOCKSUDPPort> replyMap) Creates a SOCKS UDP port bound to a local address and port, wiring together the I2P and UDP halves of the encapsulation over a shared header cache.Method Summary
All MethodsModifier and TypeMethodDescriptionintgetPort()Returns the UDP port number that this port is listening on.voidsend(Destination from, int fromPort, int toPort, byte[] data) May throw RuntimeException from underlying sink.voidSets the sink for incoming UDP datagrams from I2P.voidstart()Starts the UDP source to begin receiving datagrams.voidstop()Stops the UDP source and sink, closing the underlying sockets.
Field Details
udpsink
Sends datagrams into the tunnel.udpsource
Delivers datagrams arriving from the tunnel.wrapper
Adds the SOCKS framing on the way out.unwrapper
Removes the SOCKS framing on the way in.
Constructor Details
SOCKSUDPPort
Creates a SOCKS UDP port bound to a local address and port, wiring together the I2P and UDP halves of the encapsulation over a shared header cache.- Parameters:
host- the local address to bind the UDP socket toport- the local UDP port to bind, or 0 to let the OS choose onereplyMap- the map from reply port to SOCKSUDPPort, used by the MultiSink for demux
Method Details
getPort
public int getPort()Returns the UDP port number that this port is listening on.- Returns:
- the local UDP port number
setSink
start
stop
public void stop()Stops the UDP source and sink, closing the underlying sockets.send
May throw RuntimeException from underlying sink.- Specified by:
sendin interfaceSink- Parameters:
from- will be passed alongfromPort- will be passed alongtoPort- will be passed alongdata- the datagram payload to deliver to the destination- Throws:
RuntimeException- if the wrapped sink fails to send the data