Package net.i2p.i2ptunnel.udpTunnel
Class I2PTunnelUDPServerBase
java.lang.Object
net.i2p.util.EventDispatcherImpl
net.i2p.i2ptunnel.I2PTunnelTask
net.i2p.i2ptunnel.udpTunnel.I2PTunnelUDPServerBase
- All Implemented Interfaces:
Sink
,Source
,EventDispatcher
- Direct Known Subclasses:
StreamrProducer
Base client class that sets up an I2P Datagram server destination.
The UDP side is not implemented here, as there are at least
two possibilities:
1) UDP side is a "client"
Example: Streamr Producer
- configure an inbound port
- External application receives no data
- Extending class must have a constructor with a port argument
2) UDP side is a client/server
Example: DNS
- 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
Modifier and TypeFieldDescriptionprotected Logging
protected long
default timeout to 3 minutes - override if desiredprotected Object
Fields inherited from class net.i2p.i2ptunnel.I2PTunnelTask
open
-
Constructor Summary
ConstructorDescriptionI2PTunnelUDPServerBase
(File privkey, String privkeyname, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) -
Method Summary
Modifier and TypeMethodDescriptionboolean
close
(boolean forced) I2PTunnelTask Methods Classes should override to close UDP side as welllong
Get the read idle timeout for newly-created connections (in milliseconds).void
send
(Destination to, int fromPort, int toPort, byte[] data) Sink Methodsvoid
setReadTimeout
(long ms) Set the read idle timeout for newly-created connections (in milliseconds).void
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
Classes should override to start UDP side as well.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
-
slock
-
l
-
readTimeout
protected long readTimeoutdefault timeout to 3 minutes - override if desired
-
-
Constructor Details
-
I2PTunnelUDPServerBase
public I2PTunnelUDPServerBase(File privkey, String privkeyname, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) - Throws:
IllegalArgumentException
- if the I2CP configuration is b0rked so badly that we cant create a socketManager
-
-
Method Details
-
startRunning
public void startRunning()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. -
setReadTimeout
public void setReadTimeout(long ms) Set the read idle timeout for newly-created connections (in milliseconds). After this time expires without data being reached from the I2P network, the connection itself will be closed. -
getReadTimeout
public long getReadTimeout()Get the read idle timeout for newly-created connections (in milliseconds).- Returns:
- The read timeout used for connections
-
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
-fromPort
- I2CP source port, 0-65535toPort
- I2CP destination port, 0-65535- Throws:
RuntimeException
- if session is closed- Since:
- 0.9.53 added fromPort and toPort parameters
-