All Implemented Interfaces:
Sink, Source, EventDispatcher

public class SOCKSUDPTunnelextends I2PTunnelUDPClientBase
A Datagram Tunnel that can have multiple bidirectional ports on the UDP side.

TX: (multiple SOCKSUDPPorts -> ) I2PSink

RX: (SOCKSUDPWrapper in multiple SOCKSUDPPorts <- ) MultiSink <- I2PSource

The replies must be to the same I2CP toPort as the outbound fromPort. If the server does not honor that, the replies will be dropped.

The replies must be repliable. Raw datagrams are not supported, and would require a unique source port for each target.

Preliminary, untested, possibly incomplete.

  • Field Details

  • Constructor Details

    • SOCKSUDPTunnel

      public SOCKSUDPTunnel(I2PTunnel tunnel)
      Set up a tunnel with no UDP side yet. Use add() for each port.
      Parameters:
      tunnel - the parent tunnel supplying the logging facility, event dispatcher, I2CP session and client options for the UDP association
  • Method Details

    • add

      public int add(InetAddress host, int port)
      Adds a new UDP port to the tunnel for bidirectional SOCKS UDP communication.
      Parameters:
      host - the local address to bind to
      port - the local port to bind to, or 0 for any available port
      Returns:
      the actual port number the socket was bound to
    • remove

      public void remove(Integer port)
      Removes a UDP port from the tunnel and stops its associated resources.
      Parameters:
      port - the UDP port number to remove
    • startRunning

      public final void startRunning()
      Starts the tunnel and begins processing datagrams. Ports must be added after this call.
      Overrides:
      startRunning in class I2PTunnelUDPClientBase
    • close

      public boolean close(boolean forced)
      Closes the tunnel and all associated ports.
      Overrides:
      close in class I2PTunnelUDPClientBase
      Parameters:
      forced - if true, force immediate close without graceful shutdown
      Returns:
      true if closed successfully
    • startall

      private void startall()
      You should really add() after startRunning().
    • stopall

      private void stopall()
      Closes every open UDP port.