net.i2p.i2ptunnel
public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runnable
Modifier and Type | Field and Description |
---|---|
protected long |
_clientId |
protected I2PAppContext |
_context |
(package private) static Executor |
_executor
We keep a static pool of socket handlers for all clients,
as there is no need for isolation on the client side.
|
protected Log |
_log |
protected boolean |
_ownDest |
(package private) static long |
DEFAULT_CONNECT_TIMEOUT |
protected Destination |
dest |
protected Logging |
l |
protected List |
mySockets |
protected Object |
sockLock |
protected I2PSocketManager |
sockMgr |
open
Constructor and Description |
---|
I2PTunnelClientBase(int localPort,
boolean ownDest,
Logging l,
EventDispatcher notifyThis,
String handlerName,
I2PTunnel tunnel) |
I2PTunnelClientBase(int localPort,
boolean ownDest,
Logging l,
EventDispatcher notifyThis,
String handlerName,
I2PTunnel tunnel,
String pkf) |
I2PTunnelClientBase(int localPort,
Logging l,
I2PSocketManager sktMgr,
I2PTunnel tunnel,
EventDispatcher notifyThis,
long clientId) |
Modifier and Type | Method and Description |
---|---|
protected I2PSocketManager |
buildSocketManager() |
protected static I2PSocketManager |
buildSocketManager(I2PTunnel tunnel) |
protected static I2PSocketManager |
buildSocketManager(I2PTunnel tunnel,
String pkf) |
protected static I2PSocketManager |
buildSocketManager(I2PTunnel tunnel,
String pkf,
Logging log) |
protected abstract void |
clientConnectionRun(Socket s)
Manage a connection in a separate thread.
|
boolean |
close(boolean forced) |
static void |
closeSocket(Socket s) |
I2PSocket |
createI2PSocket(Destination dest)
Create a new I2PSocket towards to the specified destination,
adding it to the list of connections actually managed by this
tunnel.
|
I2PSocket |
createI2PSocket(Destination dest,
I2PSocketOptions opt)
Create a new I2PSocket towards to the specified destination,
adding it to the list of connections actually managed by this
tunnel.
|
protected I2PSocketOptions |
getDefaultOptions()
create the default options (using the default timeout, etc)
|
protected I2PSocketOptions |
getDefaultOptions(Properties overrides)
create the default options (using the default timeout, etc)
|
protected InetAddress |
getListenHost(Logging l) |
int |
getLocalPort() |
protected I2PSocketManager |
getSocketManager()
this is ONLY for shared clients
|
protected static I2PSocketManager |
getSocketManager(I2PTunnel tunnel)
this is ONLY for shared clients
|
protected static I2PSocketManager |
getSocketManager(I2PTunnel tunnel,
String pkf)
this is ONLY for shared clients
|
protected void |
manageConnection(Socket s)
Manage the connection just opened on the specified socket
|
void |
run() |
void |
startRunning()
Actually start working on incoming connections.
|
protected void |
verifySocketManager()
Sets the this.sockMgr field if it is null, or if we want a new one
We need a socket manager before getDefaultOptions() and most other things
|
attachEventDispatcher, detachEventDispatcher, disconnected, errorOccurred, getEventDispatcher, getEvents, getEventValue, getId, getTunnel, ignoreEvents, isOpen, notifyEvent, reportAbuse, routerDisconnected, setId, setName, setTunnel, toString, unIgnoreEvents, waitEventValue
protected final Log _log
protected final I2PAppContext _context
protected final Logging l
static final long DEFAULT_CONNECT_TIMEOUT
protected long _clientId
protected final Object sockLock
protected I2PSocketManager sockMgr
protected List mySockets
protected boolean _ownDest
protected Destination dest
static final Executor _executor
public I2PTunnelClientBase(int localPort, Logging l, I2PSocketManager sktMgr, I2PTunnel tunnel, EventDispatcher notifyThis, long clientId) throws IllegalArgumentException
IllegalArgumentException
public I2PTunnelClientBase(int localPort, boolean ownDest, Logging l, EventDispatcher notifyThis, String handlerName, I2PTunnel tunnel) throws IllegalArgumentException
IllegalArgumentException
public I2PTunnelClientBase(int localPort, boolean ownDest, Logging l, EventDispatcher notifyThis, String handlerName, I2PTunnel tunnel, String pkf) throws IllegalArgumentException
pkf
- null to generate a transient keyIllegalArgumentException
- if the I2CP configuration is b0rked so
badly that we cant create a socketManagerprotected void verifySocketManager()
IllegalArgumentException
- if the I2CP configuration is b0rked so
badly that we cant create a socketManagerprotected I2PSocketManager getSocketManager()
IllegalArgumentException
- if the I2CP configuration is b0rked so
badly that we cant create a socketManagerprotected static I2PSocketManager getSocketManager(I2PTunnel tunnel)
IllegalArgumentException
- if the I2CP configuration is b0rked so
badly that we cant create a socketManagerprotected static I2PSocketManager getSocketManager(I2PTunnel tunnel, String pkf)
IllegalArgumentException
- if the I2CP configuration is b0rked so
badly that we cant create a socketManagerprotected I2PSocketManager buildSocketManager()
IllegalArgumentException
- if the I2CP configuration is b0rked so
badly that we cant create a socketManagerprotected static I2PSocketManager buildSocketManager(I2PTunnel tunnel)
IllegalArgumentException
- if the I2CP configuration is b0rked so
badly that we cant create a socketManagerprotected static I2PSocketManager buildSocketManager(I2PTunnel tunnel, String pkf)
pkf
- absolute path or nullIllegalArgumentException
- if the I2CP configuration is b0rked so
badly that we cant create a socketManagerprotected static I2PSocketManager buildSocketManager(I2PTunnel tunnel, String pkf, Logging log)
pkf
- absolute path or nullIllegalArgumentException
- if the I2CP configuration is b0rked so
badly that we cant create a socketManagerpublic final int getLocalPort()
protected final InetAddress getListenHost(Logging l)
public void startRunning()
protected I2PSocketOptions getDefaultOptions()
protected I2PSocketOptions getDefaultOptions(Properties overrides)
public I2PSocket createI2PSocket(Destination dest) throws I2PException, ConnectException, NoRouteToHostException, InterruptedIOException
dest
- The destination to connect toI2PException
ConnectException
NoRouteToHostException
InterruptedIOException
public I2PSocket createI2PSocket(Destination dest, I2PSocketOptions opt) throws I2PException, ConnectException, NoRouteToHostException, InterruptedIOException
dest
- The destination to connect toopt
- Option to be used to open when opening the socketConnectException
- if the peer refuses the connectionNoRouteToHostException
- if the peer is not found or not reachableInterruptedIOException
- if the connection timeoutsI2PException
- if there is some other I2P-related problemprotected void manageConnection(Socket s)
s
- Socket to take care ofpublic boolean close(boolean forced)
close
in class I2PTunnelTask
public static void closeSocket(Socket s)
protected abstract void clientConnectionRun(Socket s)