java.lang.Object
net.i2p.i2ptunnel.udp.I2PSink
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionprotected final DestinationDestination every datagram is addressed to, fixed at construction.protected final I2PDatagramMakerRepliable datagram wrapper, null when raw.protected final booleanTrue to send data unwrapped, false to wrap it in a repliable datagram.protected final I2PSessionSession the datagrams are sent out on.protected final intI2CP destination port sent with every datagram.Constructor Summary
ConstructorsConstructorDescriptionI2PSink(I2PSession sess, Destination dest) 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 MethodsModifier and TypeMethodDescriptionvoidsend(Destination src, int fromPort, int ignToPort, byte[] data) Sends data to the fixed destination configured in the constructor.
Field Details
raw
protected final boolean rawTrue to send data unwrapped, false to wrap it in a repliable datagram.sess
Session the datagrams are sent out on.dest
Destination every datagram is addressed to, fixed at construction.maker
Repliable datagram wrapper, null when raw.toPort
protected final int toPortI2CP destination port sent with every datagram.
Constructor Details
I2PSink
Creates a repliable (non-raw) sink for the given session and destination.- Parameters:
sess- the I2P session to send throughdest- the fixed destination to send to
I2PSink
Creates a sink for the given session and destination.- Parameters:
sess- the I2P session to send throughdest- the fixed destination to send toraw- true for raw datagrams, false for repliable
I2PSink
Creates a sink for the given session, destination, and port.- Parameters:
sess- the I2P session to send throughdest- the fixed destination to send toraw- true for raw datagrams, false for repliabletoPort- I2CP destination port, 0-65535
Method Details
send
Sends data to the fixed destination configured in the constructor.- Specified by:
sendin interfaceSink- Parameters:
src- ignored; the destination is fixed by the constructorfromPort- I2CP source port, 0-65535ignToPort- ignored; the destination port is fixed by the constructordata- the data to send- Throws:
RuntimeException- if the session is closed