java.lang.Object
net.i2p.i2ptunnel.socks.SOCKSUDPPort
All Implemented Interfaces:
Sink, Source

public class SOCKSUDPPortextends Object implements Source, Sink
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

    Fields
    Modifier and Type
    Field
    Description
    private final UDPSink
    Sends datagrams into the tunnel.
    private final UDPSource
    Delivers datagrams arriving from the tunnel.
    private final SOCKSUDPUnwrapper
    Removes the SOCKS framing on the way in.
    private final SOCKSUDPWrapper
    Adds the SOCKS framing on the way out.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SOCKSUDPPort(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 Methods
    Modifier and Type
    Method
    Description
    int
    Returns the UDP port number that this port is listening on.
    void
    send(Destination from, int fromPort, int toPort, byte[] data)
    May throw RuntimeException from underlying sink.
    void
    setSink(Sink sink)
    Sets the sink for incoming UDP datagrams from I2P.
    void
    Starts the UDP source to begin receiving datagrams.
    void
    Stops the UDP source and sink, closing the underlying sockets.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • udpsink

      private final UDPSink udpsink
      Sends datagrams into the tunnel.
    • udpsource

      private final UDPSource udpsource
      Delivers datagrams arriving from the tunnel.
    • wrapper

      private final SOCKSUDPWrapper wrapper
      Adds the SOCKS framing on the way out.
    • unwrapper

      private final SOCKSUDPUnwrapper unwrapper
      Removes the SOCKS framing on the way in.
  • Constructor Details

    • SOCKSUDPPort

      public SOCKSUDPPort(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.
      Parameters:
      host - the local address to bind the UDP socket to
      port - the local UDP port to bind, or 0 to let the OS choose one
      replyMap - 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

      public void setSink(Sink sink)
      Sets the sink for incoming UDP datagrams from I2P.
      Specified by:
      setSink in interface Source
      Parameters:
      sink - the sink to receive processed UDP datagrams
    • start

      public void start()
      Starts the UDP source to begin receiving datagrams.
      Specified by:
      start in interface Source
    • stop

      public void stop()
      Stops the UDP source and sink, closing the underlying sockets.
    • send

      public void send(Destination from, int fromPort, int toPort, byte[] data)
      May throw RuntimeException from underlying sink.
      Specified by:
      send in interface Sink
      Parameters:
      from - will be passed along
      fromPort - will be passed along
      toPort - will be passed along
      data - the datagram payload to deliver to the destination
      Throws:
      RuntimeException - if the wrapped sink fails to send the data