Package net.i2p.i2ptunnel
Class I2PTunnelServer
java.lang.Object
net.i2p.util.EventDispatcherImpl
net.i2p.i2ptunnel.I2PTunnelTask
net.i2p.i2ptunnel.I2PTunnelServer
- All Implemented Interfaces:
Runnable
,EventDispatcher
- Direct Known Subclasses:
I2PTunnelDCCServer
,I2PTunnelHTTPServer
,I2PTunnelIRCServer
-
Field Summary
Modifier and TypeFieldDescriptionprotected static long
apparently unusedprotected ThreadPoolExecutor
protected final Log
protected boolean
protected I2PServerSocket
protected final Logging
protected int
static final String
static final String
static final String
protected long
default timeout - override if desiredprotected InetAddress
protected int
protected final Object
protected final I2PSocketManager
protected final Object
protected I2PTunnelTask
Fields inherited from class net.i2p.i2ptunnel.I2PTunnelTask
open
-
Constructor Summary
ConstructorDescriptionI2PTunnelServer
(InetAddress host, int port, File privkey, String privkeyname, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Non-blockingI2PTunnelServer
(InetAddress host, int port, InputStream privData, String privkeyname, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Non-blockingI2PTunnelServer
(InetAddress host, int port, String privData, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Non-blockingI2PTunnelServer
(InetAddress host, int port, I2PSocketManager sktMgr, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Non-blocking -
Method Summary
Modifier and TypeMethodDescriptionprotected void
blockingHandle
(I2PSocket socket) This is run in a thread from a limited-size thread pool via Handler.run(), except for a standard server (this class, no extension, as determined in getUsePool()), it is run directly in the acceptor thread (see run()).boolean
close
(boolean forced) Note that the tunnel can be reopened after this by calling startRunning().boolean
destroy()
Note that the tunnel cannot be reopened after this by calling startRunning(), as it will destroy the underlying socket manager.protected int
long
Get the read idle timeout for newly-created connections (in milliseconds).protected Socket
Get a regular or SSL socket depending on config and the incoming port.protected Socket
getSocket
(Hash from, InetAddress remoteHost, int remotePort) Get a regular or SSL socket depending on config.void
optionsUpdated
(I2PTunnel tunnel) Update the I2PSocketManager.void
run()
If usePool is set, this starts the executor pool.void
setReadTimeout
(long ms) Set the read idle timeout for newly-created connections (in milliseconds).boolean
void
Start running the I2PTunnelServer.Methods inherited from class net.i2p.i2ptunnel.I2PTunnelTask
connected, disconnected, errorOccurred, getId, getTunnel, isOpen, 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
-
_log
-
sockMgr
-
i2pss
-
slock
-
sslLock
-
remoteHost
-
remotePort
protected int remotePort -
l
-
readTimeout
protected long readTimeoutdefault timeout - override if desired -
PROP_USE_SSL
- See Also:
-
PROP_UNIQUE_LOCAL
- See Also:
-
PROP_ALT_PKF
- Since:
- 0.9.30
- See Also:
-
__serverId
protected static volatile long __serverIdapparently unused -
task
-
bidir
protected boolean bidir -
_clientExecutor
-
localPort
protected int localPort
-
-
Constructor Details
-
I2PTunnelServer
public I2PTunnelServer(InetAddress host, int port, String privData, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Non-blocking- Parameters:
privData
- Base64-encoded private key data, format is specified inPrivateKeyFile
- Throws:
IllegalArgumentException
- if the I2CP configuration is b0rked so badly that we cant create a socketManager
-
I2PTunnelServer
public I2PTunnelServer(InetAddress host, int port, File privkey, String privkeyname, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Non-blocking- Parameters:
privkey
- file containing the private key data, format is specified inPrivateKeyFile
privkeyname
- the name of the privKey file, just for logging- Throws:
IllegalArgumentException
- if the I2CP configuration is b0rked so badly that we cant create a socketManager
-
I2PTunnelServer
public I2PTunnelServer(InetAddress host, int port, InputStream privData, String privkeyname, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Non-blocking- Parameters:
privData
- stream containing the private key data, format is specified inPrivateKeyFile
privkeyname
- the name of the privKey file, just for logging- Throws:
IllegalArgumentException
- if the I2CP configuration is b0rked so badly that we cant create a socketManager
-
I2PTunnelServer
public I2PTunnelServer(InetAddress host, int port, I2PSocketManager sktMgr, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) Non-blocking- Parameters:
sktMgr
- the existing socket manager- Since:
- 0.8.9
-
-
Method Details
-
startRunning
public void startRunning()Start running the I2PTunnelServer. Warning, blocks while connecting to router and building tunnels;- Throws:
IllegalArgumentException
- if the I2CP configuration is b0rked so badly that we cant create a socketManager
-
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. Less than or equal to 0 means forever. Default -1 (forever) as of 0.9.36 for standard tunnels, but extending classes may override. Prior to that, default was 5 minutes, but did not work due to streaming bugs. Applies only to future connections; calling this does not affect existing connections.- Parameters:
ms
- in ms
-
getReadTimeout
public long getReadTimeout()Get the read idle timeout for newly-created connections (in milliseconds). Less than or equal to 0 means forever. Default -1 (forever) as of 0.9.36 for standard tunnels, but extending classes may override. Prior to that, default was 5 minutes, but did not work due to streaming bugs.- Returns:
- The read timeout used for connections
-
close
public boolean close(boolean forced) Note that the tunnel can be reopened after this by calling startRunning(). This does not release all resources. In particular, the I2PSocketManager remains and it may have timer threads that continue running. To release all resources permanently, call destroy().- Specified by:
close
in classI2PTunnelTask
- Returns:
- success
-
destroy
public boolean destroy()Note that the tunnel cannot be reopened after this by calling startRunning(), as it will destroy the underlying socket manager. This releases all resources.- Overrides:
destroy
in classI2PTunnelTask
- Returns:
- success
- Since:
- 0.9.17
-
optionsUpdated
Update the I2PSocketManager. And since 0.9.15, the target host and port.- Overrides:
optionsUpdated
in classI2PTunnelTask
- Since:
- 0.9.1
-
getHandlerCount
protected int getHandlerCount() -
run
public void run()If usePool is set, this starts the executor pool. Then, do the accept() loop, and either hands each I2P socket to the executor or runs it in-line. -
shouldUsePool
public boolean shouldUsePool() -
blockingHandle
This is run in a thread from a limited-size thread pool via Handler.run(), except for a standard server (this class, no extension, as determined in getUsePool()), it is run directly in the acceptor thread (see run()). In either case, this method and any overrides must spawn a thread and return quickly. If blocking while reading the headers (as in HTTP and IRC), the thread pool may be exhausted. See PROP_USE_POOL, DEFAULT_USE_POOL, PROP_HANDLER_COUNT, DEFAULT_HANDLER_COUNT -
getSocket
Get a regular or SSL socket depending on config and the incoming port. To configure a specific host:port as the server for incoming port xx, set option targetForPort.xx=host:port- Parameters:
from
- may be used to construct local address since 0.9.13- Throws:
IOException
- Since:
- 0.9.9
-
getSocket
Get a regular or SSL socket depending on config. The SSL config applies to all hosts/ports.- Parameters:
from
- may be used to construct local address since 0.9.13- Throws:
IOException
- Since:
- 0.9.9
-