java.lang.Object
net.i2p.i2ptunnel.udp.I2PSinkAnywhere
All Implemented Interfaces:
Sink

public class I2PSinkAnywhereextends Object implements Sink
I2P sink implementation that sends datagrams to any destination specified in each send(Destination, byte[]) call, rather than a fixed destination.

Supports both repliable and raw datagram modes. When not in raw mode, data is wrapped with I2PDatagramMaker before sending.

  • Field Details

    • raw

      protected final boolean raw
      True when datagrams are sent without I2P datagram wrapping.
    • sess

      protected final I2PSession sess
      The session datagrams are sent over.
    • maker

      protected final I2PDatagramMaker maker
      Wraps outgoing datagrams, or null in raw mode.
  • Constructor Details

    • I2PSinkAnywhere

      public I2PSinkAnywhere(I2PSession sess)
      Creates a repliable (non-raw) sink for the given session.
      Parameters:
      sess - the I2P session to send through
    • I2PSinkAnywhere

      public I2PSinkAnywhere(I2PSession sess, boolean raw)
      Creates a sink for the given session.
      Parameters:
      sess - the I2P session to send through
      raw - true for raw datagrams, false for repliable
  • Method Details

    • send

      public void send(Destination to, byte[] data)
      Sends data to the specified destination using default ports.
      Parameters:
      to - the destination to send to
      data - the data to send
      Throws:
      RuntimeException - if the session is closed
    • send

      public void send(Destination to, int fromPort, int toPort, byte[] data)
      Sends data to the specified destination using the given ports.
      Specified by:
      send in interface Sink
      Parameters:
      to - the destination to send to
      fromPort - I2CP source port, 0-65535
      toPort - I2CP destination port, 0-65535
      data - the data to send
      Throws:
      RuntimeException - if the session is closed