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

public class I2PSinkextends Object implements Sink
I2P sink implementation that sends datagrams to a fixed destination specified in the constructor.

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

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Destination
    Destination every datagram is addressed to, fixed at construction.
    protected final I2PDatagramMaker
    Repliable datagram wrapper, null when raw.
    protected final boolean
    True to send data unwrapped, false to wrap it in a repliable datagram.
    protected final I2PSession
    Session the datagrams are sent out on.
    protected final int
    I2CP destination port sent with every datagram.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a repliable (non-raw) sink for the given session and destination.
    I2PSink(I2PSession sess, Destination dest, boolean raw)
    Creates a sink for the given session and destination.
    I2PSink(I2PSession sess, Destination dest, boolean raw, int toPort)
    Creates a sink for the given session, destination, and port.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    void
    send(Destination src, int fromPort, int ignToPort, byte[] data)
    Sends data to the fixed destination configured in the constructor.

    Methods inherited from class Object

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

    • raw

      protected final boolean raw
      True to send data unwrapped, false to wrap it in a repliable datagram.
    • sess

      protected final I2PSession sess
      Session the datagrams are sent out on.
    • dest

      protected final Destination dest
      Destination every datagram is addressed to, fixed at construction.
    • maker

      protected final I2PDatagramMaker maker
      Repliable datagram wrapper, null when raw.
    • toPort

      protected final int toPort
      I2CP destination port sent with every datagram.
  • Constructor Details

    • I2PSink

      public I2PSink(I2PSession sess, Destination dest)
      Creates a repliable (non-raw) sink for the given session and destination.
      Parameters:
      sess - the I2P session to send through
      dest - the fixed destination to send to
    • I2PSink

      public I2PSink(I2PSession sess, Destination dest, boolean raw)
      Creates a sink for the given session and destination.
      Parameters:
      sess - the I2P session to send through
      dest - the fixed destination to send to
      raw - true for raw datagrams, false for repliable
    • I2PSink

      public I2PSink(I2PSession sess, Destination dest, boolean raw, int toPort)
      Creates a sink for the given session, destination, and port.
      Parameters:
      sess - the I2P session to send through
      dest - the fixed destination to send to
      raw - true for raw datagrams, false for repliable
      toPort - I2CP destination port, 0-65535
  • Method Details

    • send

      public void send(Destination src, int fromPort, int ignToPort, byte[] data)
      Sends data to the fixed destination configured in the constructor.
      Specified by:
      send in interface Sink
      Parameters:
      src - ignored; the destination is fixed by the constructor
      fromPort - I2CP source port, 0-65535
      ignToPort - ignored; the destination port is fixed by the constructor
      data - the data to send
      Throws:
      RuntimeException - if the session is closed