Package net.i2p.router.client
Class ClientManager
java.lang.Object
net.i2p.router.client.ClientManager
Coordinate connections and various tasks
- Author:
- jrandom
-
Field Summary
Modifier and TypeFieldDescriptionprotected final RouterContext
protected boolean
protected final List<ClientListenerRunner>
protected final int
protected boolean
static final SessionId
65535 -
Constructor Summary
ConstructorDescriptionClientManager
(RouterContext context, int port) Does not start the listeners. -
Method Summary
Modifier and TypeMethodDescriptionint
destinationEstablished
(ClientConnectionRunner runner, Destination dest) Add to the clients list.(package private) void
distributeMessage
(Destination fromDest, Destination toDest, Payload payload, MessageId msgId, long messageNonce, long expiration, int flags) Distribute message to a local or remote destination.Return the client's current config, or null if not connectedReturn the client's SessionKeyManager Use this instead of the RouterContext.sessionKeyManager() to prevent correlation attacks across destinations(package private) ClientConnectionRunner
getRunner
(Destination dest) Unsynchronized(package private) Set<Destination>
The InternalClientManager interface.boolean
isAlive()
As of 0.9.45, this returns true iff the ClientManager is running.boolean
isLocal
(Destination dest) Unsynchronized.boolean
Unsynchronized.Unsynchronized.void
messageDeliveryStatusUpdate
(Destination fromDest, MessageId id, long messageNonce, int status) void
void
boolean
registerEncryptedDestination
(ClientConnectionRunner runner, Hash hash) Call after destinationEstablished(), when an encrypted leaseset is created, so we know it's local.void
registerMetaDest
(Destination dest) Declare that we're going to publish a meta LS for this destination.void
renderStatusHTML
(Writer out) Deprecated.unusedvoid
reportAbuse
(Destination dest, String reason, int severity) Unusedvoid
requestLeaseSet
(Destination dest, LeaseSet set, long timeout, Job onCreateJob, Job onFailedJob) Request that a particular client authorize the Leases contained in the LeaseSet, after which the onCreateJob is queued up.void
requestLeaseSet
(Hash dest, LeaseSet ls) Request that a particular client authorize the Leases contained in the LeaseSet.void
restart()
boolean
shouldPublishLeaseSet
(Hash destHash) void
void
start()
protected void
Call from synchronized method Todo: Start a 3rd listener for IPV6?void
Remove all sessions for this runner.void
unregisterEncryptedDestination
(ClientConnectionRunner runner, Hash hash) Remove the hash for the encrypted LS.void
Declare that we're no longer going to publish a meta LS for this destination.void
unregisterSession
(SessionId id, Destination dest) Remove only the following session.
-
Field Details
-
_listeners
-
_ctx
-
_port
protected final int _port -
_isStarted
protected volatile boolean _isStarted -
_wasStarted
protected volatile boolean _wasStarted -
UNKNOWN_SESSION_ID
65535
-
-
Constructor Details
-
ClientManager
Does not start the listeners. Caller must call start()
-
-
Method Details
-
start
public void start()- Since:
- 0.9.8
-
startListeners
protected void startListeners()Call from synchronized method Todo: Start a 3rd listener for IPV6? -
restart
public void restart() -
shutdown
- Parameters:
msg
- message to send to the clients
-
internalConnect
The InternalClientManager interface. Connects to the router, receiving a message queue to talk to the router with.- Throws:
I2PSessionException
- if the router isn't ready- Since:
- 0.8.3
-
isAlive
public boolean isAlive()As of 0.9.45, this returns true iff the ClientManager is running. Prior to that, it also required all external I2CP listeners that were registered to be running. Since most of our connections are in-JVM, we now return true even if we have I2CP port conflicts. -
registerConnection
-
unregisterConnection
Remove all sessions for this runner. -
unregisterSession
Remove only the following session. Does not remove the runner if it has more.- Since:
- 0.9.21
-
unregisterEncryptedDestination
Remove the hash for the encrypted LS. Call before unregisterConnection, or when the hash changes.- Since:
- 0.9.39
-
destinationEstablished
Add to the clients list. Check for a dup destination. Side effect: Sets the session ID of the runner. Caller must call runner.disconnectClient() on failure.- Returns:
- SessionStatusMessage return code, 1 for success, != 1 for failure
-
registerEncryptedDestination
Call after destinationEstablished(), when an encrypted leaseset is created, so we know it's local. Add to the clients list. Check for a dup hash. Caller must call runner.disconnectClient() on failure.- Parameters:
hash
- the location of the encrypted LS, will change every day- Returns:
- success, false on dup
- Since:
- 0.9.39
-
registerMetaDest
Declare that we're going to publish a meta LS for this destination. Must be called before publishing the leaseset.- Throws:
I2PSessionException
- on duplicate dest- Since:
- 0.9.41
-
unregisterMetaDest
Declare that we're no longer going to publish a meta LS for this destination.- Since:
- 0.9.41
-
distributeMessage
void distributeMessage(Destination fromDest, Destination toDest, Payload payload, MessageId msgId, long messageNonce, long expiration, int flags) Distribute message to a local or remote destination.- Parameters:
msgId
- the router's ID for this messagemessageNonce
- the client's ID for this messageflags
- ignored for local
-
requestLeaseSet
public void requestLeaseSet(Destination dest, LeaseSet set, long timeout, Job onCreateJob, Job onFailedJob) Request that a particular client authorize the Leases contained in the LeaseSet, after which the onCreateJob is queued up. If that doesn't occur within the timeout specified, queue up the onFailedJob. This call does not block. UNUSED, the call below without jobs is always used.- Parameters:
dest
- Destination from which the LeaseSet's authorization should be requestedset
- LeaseSet with requested leases - this object must be updated to contain the signed version (as well as any changed/added/removed Leases). The LeaseSet contains Leases only; it is unsigned and does not have the destination set.timeout
- ms to wait before failingonCreateJob
- Job to run after the LeaseSet is authorizedonFailedJob
- Job to run after the timeout passes without receiving authorization
-
requestLeaseSet
Request that a particular client authorize the Leases contained in the LeaseSet.- Parameters:
dest
- Destination from which the LeaseSet's authorization should be requestedls
- LeaseSet with requested leases - this object must be updated to contain the signed version (as well as any changed/added/removed Leases). The LeaseSet contains Leases only; it is unsigned and does not have the destination set.
-
isLocal
Unsynchronized. DOES contain meta destinations. -
isLocal
Unsynchronized. DOES contain meta destinations. -
shouldPublishLeaseSet
- Returns:
- true if we don't know about this destination at all
-
listClients
Unsynchronized. Does NOT contain meta destinations. -
getRunner
Unsynchronized -
getClientSessionConfig
Return the client's current config, or null if not connected -
getClientSessionKeyManager
Return the client's SessionKeyManager Use this instead of the RouterContext.sessionKeyManager() to prevent correlation attacks across destinations -
messageDeliveryStatusUpdate
public void messageDeliveryStatusUpdate(Destination fromDest, MessageId id, long messageNonce, int status) - Parameters:
id
- the router's ID for this messagemessageNonce
- the client's ID for this message, greater than zerostatus
- see I2CP MessageStatusMessage for success/failure codes
-
getRunnerDestinations
Set<Destination> getRunnerDestinations()- Returns:
- unmodifiable, not a copy
-
reportAbuse
Unused- Parameters:
dest
- null for all local destinations
-
renderStatusHTML
Deprecated.unused- Throws:
IOException
-
messageReceived
-