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

public class SOCKSUDPUnwrapperextends Object implements Source, Sink
Strip a SOCKS header off a datagram, convert it to a Destination and port Ref: RFC 1928.
  • Field Details

  • Constructor Details

    • SOCKSUDPUnwrapper

      public SOCKSUDPUnwrapper(Map<I2PSocketAddress, SOCKSHeader> cache)
      Hold the header cache that maps each unwrapped destination back to the SOCKS header its returning datagrams must be re-encased with.
      Parameters:
      cache - put headers here to pass to SOCKSUDPWrapper
  • Method Details

    • setSink

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

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

      public void send(Destination ignoredFrom, int fromPort, int toPort, byte[] data)
      May throw RuntimeException from underlying sink.
      Specified by:
      send in interface Sink
      Parameters:
      ignoredFrom - unused; the SOCKS header in the data supplies the destination instead, as this unwrapper never sends from itself
      fromPort - will be passed along
      toPort - the UDP port to send to, taken from the SOCKS header rather than from this argument
      data - the datagram payload to deliver to the destination
      Throws:
      RuntimeException - if the downstream sink fails to send the unwrapped data