class ClientManager extends Object
| Modifier and Type | Field and Description |
|---|---|
protected RouterContext | _ctxrouter context |
protected boolean | _isStartedtrue after start() completes |
protected List<ClientListenerRunner> | _listenersregistered client listener runners |
protected int | _portI2CP listen port |
protected boolean | _wasStartedtrue if start() was ever called |
static SessionId | UNKNOWN_SESSION_IDSentinel session ID for unknown/unidentified sessions. |
| Constructor and Description |
|---|
ClientManager(RouterContext context,
int port)Does not start the listeners. |
| Modifier and Type | Method and Description |
|---|---|
int | destinationEstablished(ClientConnectionRunner runner,
Destination dest)Add to the clients list. |
(package private) void | distributeMessage(ClientConnectionRunner sender,
Destination fromDest,
Destination toDest,
Payload payload,
MessageId msgId,
long messageNonce,
long expiration,
int flags)Distribute message to a local or remote destination. |
FloodfillNetworkDatabaseFacade | getClientFloodfillNetworkDatabaseFacade(Hash destHash)get the FloodfillNetworkDatabaseFacade associated with a particular client destination. |
SessionConfig | getClientSessionConfig(Destination dest)Return the client's current config, or null if not connected |
SessionKeyManager | getClientSessionKeyManager(Hash dest)Return the client's SessionKeyManager
Use this instead of the RouterContext.sessionKeyManager()
to prevent correlation attacks across destinations |
Set<Hash> | getPrimaryHashes()get all the primary hashes for all the clients and return them as a set |
(package private) ClientConnectionRunner | getRunner(Destination dest)Unsynchronized |
(package private) Set<Destination> | getRunnerDestinations()Get the set of all runner destinations. |
I2CPMessageQueue | internalConnect()The InternalClientManager interface. |
boolean | isAlive()As of 0.9.45, this returns true iff the ClientManager is running. |
boolean | isLocal(Destination dest)Unsynchronized. |
boolean | isLocal(Hash destHash)Unsynchronized. |
Set<Destination> | listClients()Unsynchronized. |
void | messageDeliveryStatusUpdate(Destination fromDest,
MessageId id,
long messageNonce,
int status)Update the message delivery status for a client. |
void | messageReceived(ClientMessage msg)Receive and process an incoming client message inline. |
void | registerConnection(ClientConnectionRunner runner)Register a new client connection. |
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 | reportAbuse(Destination dest,
String reason,
int severity)Unused |
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. |
void | requestLeaseSet(Hash dest,
LeaseSet ls)Request that a particular client authorize the Leases contained in the
LeaseSet. |
void | restart()Restart the client manager, disconnecting and reconnecting all clients. |
boolean | shouldPublishLeaseSet(Hash destHash)Determine if we should publish a leaseSet for this hash. |
void | shutdown(String msg)Shutdown the client manager, disconnecting all clients. |
void | start()Start the listeners. |
protected void | startListeners()Call from synchronized method
Todo: Start a 3rd listener for IPV6? |
void | unregisterConnection(ClientConnectionRunner runner)Remove all sessions for this runner. |
void | unregisterEncryptedDestination(ClientConnectionRunner runner,
Hash hash)Remove the hash for the encrypted LS. |
void | unregisterMetaDest(Destination dest)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. |
protected final RouterContext _ctx
protected volatile boolean _isStarted
protected final List<ClientListenerRunner> _listeners
protected final int _port
protected volatile boolean _wasStarted
public static final SessionId UNKNOWN_SESSION_ID
public ClientManager(RouterContext context, int port)
context - the router contextport - the I2CP portpublic int destinationEstablished(ClientConnectionRunner runner, Destination dest)
runner - the runnerdest - the destinationvoid distributeMessage(ClientConnectionRunner sender, Destination fromDest, Destination toDest, Payload payload, MessageId msgId, long messageNonce, long expiration, int flags)
sender - non-nullmsgId - the router's ID for this messagemessageNonce - the client's ID for this messagefromDest - source destinationtoDest - target destinationpayload - the message payloadexpiration - message expirationflags - not used for local deliverypublic FloodfillNetworkDatabaseFacade getClientFloodfillNetworkDatabaseFacade(Hash destHash)
destHash - destination hash associated with the client who's subDb we're looking for, may be nullpublic SessionConfig getClientSessionConfig(Destination dest)
dest - the destinationpublic SessionKeyManager getClientSessionKeyManager(Hash dest)
dest - the destination hashpublic Set<Hash> getPrimaryHashes()
ClientConnectionRunner getRunner(Destination dest)
dest - the destinationSet<Destination> getRunnerDestinations()
public I2CPMessageQueue internalConnect() throws I2PSessionException
I2PSessionException - if the router isn't readypublic boolean isAlive()
public boolean isLocal(Destination dest)
dest - the destination to checkpublic boolean isLocal(Hash destHash)
destHash - the destination hash to checkpublic Set<Destination> listClients()
public void messageDeliveryStatusUpdate(Destination fromDest, MessageId id, long messageNonce, int status)
fromDest - the source destinationid - the router's ID for this messagemessageNonce - the client's ID for this message, greater than zerostatus - see I2CP MessageStatusMessage for success/failure codespublic void messageReceived(ClientMessage msg)
msg - the message to processpublic void registerConnection(ClientConnectionRunner runner)
runner - the runnerpublic boolean registerEncryptedDestination(ClientConnectionRunner runner, Hash hash)
hash - the location of the encrypted LS, will change every dayrunner - the runnerpublic void registerMetaDest(Destination dest) throws I2PSessionException
dest - the destinationI2PSessionException - on duplicate destpublic void reportAbuse(Destination dest, String reason, int severity)
dest - null for all local destinationsreason - the abuse reasonseverity - the abuse severitypublic void requestLeaseSet(Destination dest, LeaseSet set, long timeout, Job onCreateJob, Job onFailedJob)
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 authorizationpublic void requestLeaseSet(Hash dest, LeaseSet ls)
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.public void restart()
public boolean shouldPublishLeaseSet(Hash destHash)
destHash - the destination hashpublic void shutdown(String msg)
msg - message to send to the clientspublic void start()
protected void startListeners()
public void unregisterConnection(ClientConnectionRunner runner)
runner - the runnerpublic void unregisterEncryptedDestination(ClientConnectionRunner runner, Hash hash)
runner - the runnerhash - the hash to removepublic void unregisterMetaDest(Destination dest)
dest - the destinationpublic void unregisterSession(SessionId id, Destination dest)
id - the session IDdest - the destination