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

public class SOCKSUDPWrapperextends Object implements Source, Sink
Put a SOCKS header on a datagram Ref: RFC 1928.
  • Field Details

  • Constructor Details

    • SOCKSUDPWrapper

      public SOCKSUDPWrapper(Map<I2PSocketAddress, SOCKSHeader> cache)
      Create a wrapper sharing an existing per-destination header cache.
      Parameters:
      cache - the header cache to reuse for outgoing datagrams, keyed by destination address
  • Method Details

    • setSink

      public void setSink(Sink sink)
      Sets the sink for outgoing wrapped UDP datagrams.
      Specified by:
      setSink in interface Source
      Parameters:
      sink - the sink to receive SOCKS-wrapped datagrams
    • start

      public void start()
      Starts the wrapper. No-op for this implementation.
      Specified by:
      start in interface Source
    • send

      public void send(Destination from, int fromPort, int toPort, byte[] data)
      Use the cached header, which should have the host string and port

      May throw RuntimeException from underlying sink.

      Specified by:
      send in interface Sink
      Parameters:
      from - some implementations may ignore, may be null in some implementations
      fromPort - I2CP source port, 0-65535
      toPort - I2CP destination port, 0-65535
      data - the datagram payload to deliver to the destination
      Throws:
      RuntimeException - if the wrapped sink fails to send the data