Package net.i2p.i2ptunnel.udpTunnel
Class I2PTunnelUDPClientBase
java.lang.Object
net.i2p.util.EventDispatcherImpl
net.i2p.i2ptunnel.I2PTunnelTask
net.i2p.i2ptunnel.udpTunnel.I2PTunnelUDPClientBase
- All Implemented Interfaces:
Sink
,Source
,EventDispatcher
- Direct Known Subclasses:
SOCKSUDPTunnel
,StreamrConsumer
public abstract class I2PTunnelUDPClientBase extends I2PTunnelTask implements Source, Sink
Base client class that sets up an I2P Datagram client destination.
The UDP side is not implemented here, as there are at least
two possibilities:
1) UDP side is a "server"
Example: Streamr Consumer
- Configure a destination host and port
- External application sends no data
- Extending class must have a constructor with host and port arguments
2) UDP side is a client/server
Example: SOCKS UDP (DNS requests?)
- configure an inbound port and a destination host and port
- External application sends and receives data
- Extending class must have a constructor with host and 2 port arguments
So the implementing class must create a UDPSource and/or UDPSink,
and must call setSink().
- Author:
- zzz with portions from welterde's streamr
-
Field Summary
Fields Modifier and Type Field Description protected long
_clientId
protected I2PAppContext
_context
(package private) static long
DEFAULT_CONNECT_TIMEOUT
protected Logging
l
-
Constructor Summary
Constructors Constructor Description I2PTunnelUDPClientBase(String destination, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel)
-
Method Summary
Modifier and Type Method Description boolean
close(boolean forced)
I2PTunnelTask Methods Classes should override to close UDP side as wellvoid
send(Destination to, byte[] data)
Sink Methodsvoid
setSink(Sink s)
Source Methods Sets the receiver of the UDP datagrams from I2P Subclass must call this after constructor and before start()void
start()
start the sourcevoid
startRunning()
Actually start working on outgoing connections.Methods inherited from class net.i2p.i2ptunnel.I2PTunnelTask
connected, destroy, disconnected, errorOccurred, getId, getTunnel, isOpen, optionsUpdated, reportAbuse, routerDisconnected, setId, setName, setTunnel, toString
Methods inherited from class net.i2p.util.EventDispatcherImpl
attachEventDispatcher, detachEventDispatcher, getEventDispatcher, getEvents, getEventValue, ignoreEvents, notifyEvent, unIgnoreEvents, waitEventValue
-
Field Details
-
_context
-
l
-
DEFAULT_CONNECT_TIMEOUT
static final long DEFAULT_CONNECT_TIMEOUT- See Also:
- Constant Field Values
-
_clientId
protected long _clientId
-
-
Constructor Details
-
I2PTunnelUDPClientBase
public I2PTunnelUDPClientBase(String destination, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) throws IllegalArgumentException- Throws:
IllegalArgumentException
- if the I2CP configuration is b0rked so badly that we cant create a socketManager
-
-
Method Details
-
startRunning
public void startRunning()Actually start working on outgoing connections. Classes should override to start UDP side as well. Not specified in I2PTunnelTask but used in both I2PTunnelClientBase and I2PTunnelServer so let's implement it here too. -
close
public boolean close(boolean forced)I2PTunnelTask Methods Classes should override to close UDP side as well- Specified by:
close
in classI2PTunnelTask
- Returns:
- success
-
setSink
Source Methods Sets the receiver of the UDP datagrams from I2P Subclass must call this after constructor and before start() -
start
public void start()start the source -
send
Sink Methods- Specified by:
send
in interfaceSink
- Parameters:
to
- - ignored if configured for a single destination (we use the dest specified in the constructor)- Throws:
RuntimeException
- if session is closed
-