java.lang.Object
net.i2p.util.EventDispatcherImpl
net.i2p.i2ptunnel.I2PTunnelTask
net.i2p.i2ptunnel.I2PTunnelClientBase
net.i2p.i2ptunnel.irc.I2PTunnelDCCClient
- All Implemented Interfaces:
Runnable, EventDispatcher
A standard client, using an existing socket manager. Targets a single destination and port. Naming resolution is delayed until connect time.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classJust so we can do the callbacks.Field Summary
Modifier and TypeFieldDescriptionprivate final StringDestination of the DCC peer, resolved only at connect time.private longWhen this client's tunnel stops being kept alive, in ms.private final intPort the DCC peer listens on.static final StringEvent fired when DCC connection starts.static final StringEvent fired when DCC connection stops.private static final longHow long an inbound DCC tunnel is kept - 30 minutes.private static final longHow long after the last use an inbound DCC tunnel is stopped - 30 minutes.Fields inherited from class I2PTunnelClientBase
_clientId, _context, _executor, _log, _ownDest, DEFAULT_MAX_CONNECTIONS, DEFAULT_SOCKET_OPEN_TIMEOUT, dest, l, listenerReady, mySockets, PROP_MAX_CONNECTIONS, PROP_USE_SSL, sockLock, sockMgr, ssModifier and TypeFieldDescriptionprotected longThis client's ID.protected final I2PAppContextThe application context.protected ThreadPoolExecutorThread pool executor.protected final LogThe logger.protected booleanWhether we own our destination.static final intDefault cap on concurrently handled client connections.static final longDefault socket open timeout in ms, after whichI2PTunnelClientBase.close(boolean)will proceed even with active sockets.protected DestinationThe destination.protected final LoggingThe logging instance.protected booleanProtected for I2Ping since 0.9.11.List of active sockets.static final StringProperty name: max concurrently active client connections handled by one client tunnel.static final StringProperty turning on SSL between the proxy and the client.protected final ObjectGuards sockMgr and mySockets.protected I2PSocketManagerThe socket manager.protected ServerSocketServer socket.Constructor Summary
ConstructorsConstructorDescriptionI2PTunnelDCCClient(String dest, int localPort, int remotePort, Logging l, I2PSocketManager sktMgr, EventDispatcher notifyThis, I2PTunnel tunnel, long clientId) Create an IRC DCC client tunnel, offering one outbound file transfer connection to dest:remotePort.Method Summary
Public MethodsMethods inherited from class I2PTunnelClientBase
buildSocketManager, buildSocketManager, buildSocketManager, buildSocketManager, close, closeSocket, createI2PSocket, createI2PSocket, createI2PSocket, destroy, getDefaultOptions, getDefaultOptions, getListenHost, getLocalPort, getSocketManager, getSocketManager, getSocketOpenTimeout, manageConnection, optionsUpdated, poolIsDefinitivelyDown, poolState, run, startRunning, verifySocketManager, writeShedResponseModifier and TypeMethodDescriptionprotected I2PSocketManagerFor NON-SHARED clients (ownDest = true).protected static I2PSocketManagerbuildSocketManager(I2PTunnel tunnel) Create a disconnected socket manager for the tunnel, with no private key file.protected static I2PSocketManagerbuildSocketManager(I2PTunnel tunnel, String pkf) Create a disconnected socket manager for the tunnel, loading the persistent client dest from pkf if it is non-null.protected static I2PSocketManagerbuildSocketManager(I2PTunnel tunnel, String pkf, Logging log) Create a disconnected socket manager for the tunnel, loading the persistent client dest from pkf if it is non-null, and logging any key file error to log.booleanclose(boolean forced) Note that the tunnel can be reopened after this by calling startRunning().static voidClose a socket silently.createI2PSocket(Destination dest) Create a new I2PSocket towards to the specified destination, adding it to the list of connections actually managed by this tunnel.createI2PSocket(Destination dest, int port) Create a new I2PSocket towards to the specified destination, adding it to the list of connections actually managed by this tunnel.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.booleandestroy()Note that the tunnel cannot be reopened after this by calling startRunning(), as it will destroy the underlying socket manager.protected I2PSocketOptionsCreate the default options (using the default timeout, etc).protected I2PSocketOptionsgetDefaultOptions(Properties overrides) Create the default options (using the default timeout, etc).protected final InetAddressGet the listen host address.final intGet the local port.Returns the I2PSocketManager for this task.protected static I2PSocketManagergetSocketManager(I2PTunnel tunnel, String pkf) This is ONLY for shared clients.longReturns the socket open timeout in ms; close() will proceed after this even with active sockets.protected voidManage the connection just opened on the specified socket.voidoptionsUpdated(I2PTunnel tunnel) Update the I2PSocketManager.protected booleanAnd none are being built, so further connect retries cannot succeed.protected intRouter-context only, best-effort check of the client outbound tunnel pool.voidrun()Non-final since 0.9.11.voidActually open the local socket and start working on incoming connections.protected voidCreate the manager if it doesn't exist, AND connect it to the router and build tunnels.protected voidBest-effort shed response on the browser-facing socket, then close it.Methods inherited from class I2PTunnelTask
connected, disconnected, errorOccurred, getBooleanOption, getId, getTunnel, isOpen, reportAbuse, routerDisconnected, setId, setName, setTunnel, toStringModifier and TypeMethodDescriptionvoidconnected(I2PSession session) For tasks that don't callI2PTunnel.addSession(I2PSession)directly.voiddisconnected(I2PSession session) Called when a session is disconnected.voiderrorOccurred(I2PSession session, String message, Throwable error) Does nothing here.protected booleangetBooleanOption(String opt, boolean dflt) Read a boolean client option from the tunnel's properties.intgetId()The id of the client list entry for this task.The I2PTunnel this task runs inside.booleanisOpen()Whether the tunnel is running and accepting connections.voidreportAbuse(I2PSession session, int severity) Does nothing here.protected voidTell the tunnel that the router connection has dropped.voidsetId(int id) Record the client list entry id for this task.protected voidRecord the display name for this task.voidRebind this task to a different tunnel.toString()The display name given to this task when it was constructed.Methods inherited from class EventDispatcherImpl
attachEventDispatcher, detachEventDispatcher, getEventDispatcher, getEvents, getEventValue, ignoreEvents, notifyEvent, unIgnoreEvents, waitEventValueModifier and TypeMethodDescriptionvoidAttach an EventDispatcher object to the events dispatching chain.voidDetach the specified EventDispatcher object from the events dispatching chain.Object to be used to deliver events (usuallythis, but YMMV).Retrieve the names of all the events that have been received.getEventValue(String name) Retrieve the value currently associated with the specified event value.voidIgnore further event notifications.voidnotifyEvent(String eventName, Object args) Deliver an event.voidAlmost like the method above :-).waitEventValue(String name) Wait until the given event has received a value.
Field Details
_dest
Destination of the DCC peer, resolved only at connect time._remotePort
private final int _remotePortPort the DCC peer listens on._expires
private long _expiresWhen this client's tunnel stops being kept alive, in ms.INBOUND_EXPIRE
private static final long INBOUND_EXPIREHow long an inbound DCC tunnel is kept - 30 minutes.- See Also:
INBOUND_STOP_EXPIRE
private static final long INBOUND_STOP_EXPIREHow long after the last use an inbound DCC tunnel is stopped - 30 minutes.- See Also:
CONNECT_START_EVENT
Event fired when DCC connection starts.- See Also:
CONNECT_STOP_EVENT
Event fired when DCC connection stops.- See Also:
Constructor Details
I2PTunnelDCCClient
public I2PTunnelDCCClient(String dest, int localPort, int remotePort, Logging l, I2PSocketManager sktMgr, EventDispatcher notifyThis, I2PTunnel tunnel, long clientId) throws IllegalArgumentException Create an IRC DCC client tunnel, offering one outbound file transfer connection to dest:remotePort. As of 0.9.20 this is fast, and does NOT connect the manager to the router, or open the local socket. You MUST call startRunning() for that.- Parameters:
dest- the target, presumably b32localPort- if 0, use any port, get actual port selected with getLocalPort()remotePort- port on the remote IRC side that the transfer will usel- logging implementation, passed to the superclass for this clientsktMgr- socket manager used to open the I2P socket and send on itnotifyThis- dispatcher notified of the connect and stop eventstunnel- the owning tunnel, supplying the router context and clockclientId- id handed to the superclass to tag jobs and log messages- Throws:
IllegalArgumentException- if the I2PTunnel does not contain valid config to contact the router
Method Details
clientConnectionRun
Accept one connection only.- Specified by:
clientConnectionRunin classI2PTunnelClientBase- Parameters:
s- the socket to manage
getExpires
public long getExpires()Returns the expiration time for this DCC connection.- Returns:
- the expiration time in milliseconds since epoch
getDest
Returns the destination base32 address for this DCC connection.- Returns:
- the destination Base32 address
getRemotePort
public int getRemotePort()Returns the remote port for this DCC connection.- Returns:
- the remote port number
stop
public void stop()Stop listening for new sockets. We can't call super.close() as it kills all sockets in the sockMgr.