java.lang.Object
net.i2p.router.ClientManagerFacade
net.i2p.router.client.ClientManagerFacadeImpl
- All Implemented Interfaces:
InternalClientManager, Service
Base impl of the client facade.
Field Summary
Modifier and TypeFieldDescriptionprivate final RouterContextThe router running the clients.private final ConcurrentHashMap<Hash, Long> When each client's expiration was last logged.private final LogLogger for this class.private ClientManagerThe manager doing the work, null while rebuilding.static final StringDefault host.static final intDefault port.private static final longThrottle lease expiration logging - only log once per client per interval.private static final longLongest to wait for a rebuild - up to 10 minutes.static final StringNote that this is different than the property the client side uses,i2cp.tcp.host.static final StringNote that this is different than the property the client side uses,i2cp.tcp.port.Fields inherited from class ClientManagerFacade
PROP_CLIENT_ONLYConstructor Summary
ConstructorsConstructorDescriptionClientManagerFacadeImpl(RouterContext context) Creates the facade without starting anything; callstartup()to listen for I2CP connections.Method Summary
Modifier and TypeMethodDescriptionconnect()The InternalClientManager interface.getClientFloodfillNetworkDatabaseFacade(Hash destHash) The FloodfillNetworkDatabaseFacade associated with a particular client destination.Return the client's current config, or null if not connected.Return the client's current manager or null if not connected.longMinimum time to lease expiry across all clients.All the primary hashes for all the clients as a set.static intGets the cap on the client writer's outgoing message queue.booleanisAlive()Whether the client manager is running.booleanisLocal(Destination dest) Determine if the destination specified is managed locally.booleanDetermine if the destination specified is managed locally.Return the list of locally connected clients.voidmessageDeliveryStatusUpdate(Destination fromDest, MessageId id, long messageNonce, int status) Report whether a client message was delivered or lost.voidReceive a message from the network for a local client.(package private) static intpruneStaleExpiredLogEntries(ConcurrentHashMap<Hash, Long> map, Set<Hash> active) Remove lease-expiration log-throttle entries whose destination no longer has a live runner.voidregisterMetaDest(Destination dest) Declare that we're going to publish a meta LS for this destination.voidreportAbuse(Destination dest, String reason, int severity) Instruct the client (or all clients) that they are under attack.voidrequestLeaseSet(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.voidrequestLeaseSet(Hash dest, LeaseSet set) Request that a particular client authorize the Leases contained in the LeaseSet.voidrestart()Restart the service.static voidsetWriterQueueSize(int val) Sets the cap on the client writer's outgoing message queue.booleanshouldPublishLeaseSet(Hash destinationHash) Whether the lease set for the destination should be published.voidshutdown()Shut down the client manager, disconnecting all clients.voidDisconnect all clients with the given error message.voidstartup()Start the client manager to accept I2CP connections.voidDeclare that we're no longer going to publish a meta LS for this destination.booleanVerify that client lease sets are still live, requesting renewal when they have expired or are about to expire.Methods inherited from class ClientManagerFacade
renderStatusHTML
Field Details
_log
Logger for this class._manager
The manager doing the work, null while rebuilding._context
The router running the clients.LOG_THROTTLE
private static final long LOG_THROTTLEThrottle lease expiration logging - only log once per client per interval.- See Also:
_lastExpiredLogTime
When each client's expiration was last logged.PROP_CLIENT_PORT
Note that this is different than the property the client side uses,i2cp.tcp.port.- See Also:
DEFAULT_PORT
PROP_CLIENT_HOST
Note that this is different than the property the client side uses,i2cp.tcp.host.- See Also:
DEFAULT_HOST
MAX_TIME_TO_REBUILD
private static final long MAX_TIME_TO_REBUILDLongest to wait for a rebuild - up to 10 minutes.- See Also:
Constructor Details
ClientManagerFacadeImpl
Creates the facade without starting anything; callstartup()to listen for I2CP connections.- Parameters:
context- the router context this facade and the manager it creates are scoped to
Method Details
startup
shutdown
shutdown
Disconnect all clients with the given error message.- Specified by:
shutdownin classClientManagerFacade- Parameters:
msg- message to send to the clients
restart
isAlive
public boolean isAlive()Whether the client manager is running.- Overrides:
isAlivein classClientManagerFacade- Returns:
- true if the manager exists and is running
getMinTimeToLeaseExpiry
public long getMinTimeToLeaseExpiry()Minimum time to lease expiry across all clients. Used by RouterWatchdog to adjust the sleep interval.- Returns:
- minimum time to expiry in milliseconds, or Long.MAX_VALUE if no leases
verifyClientLiveliness
public boolean verifyClientLiveliness()Verify that client lease sets are still live, requesting renewal when they have expired or are about to expire.- Overrides:
verifyClientLivelinessin classClientManagerFacade- Returns:
- true if the client manager is alive
pruneStaleExpiredLogEntries
Remove lease-expiration log-throttle entries whose destination no longer has a live runner. The throttle is only consulted for currently-connected clients (seeverifyClientLiveliness()), so an entry for a disconnected destination can never be read again — retaining it would let the map grow with every I2CP client the router has ever served.- Parameters:
map- the throttle map to prune in placeactive- the destination hashes that currently have a live runner- Returns:
- the number of stale entries removed
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.
- Specified by:
requestLeaseSetin classClientManagerFacade- 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.- Specified by:
requestLeaseSetin classClientManagerFacade- 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.
reportAbuse
Instruct the client (or all clients) that they are under attack. This call does not block.- Specified by:
reportAbusein classClientManagerFacade- Parameters:
dest- Destination under attack, or null if all destinations are affectedreason- Why the router thinks that there is abusive behaviorseverity- How severe the abuse is, with 0 being not severe and 255 is the max
isLocal
Determine if the destination specified is managed locally. This call DOES block.- Specified by:
isLocalin classClientManagerFacade- Parameters:
dest- Destination to be checked- Returns:
- true if a local client is running for that destination
isLocal
Determine if the destination specified is managed locally. This call DOES block.- Specified by:
isLocalin classClientManagerFacade- Parameters:
destHash- Hash of Destination to be checked- Returns:
- true if a local client is running for that destination
shouldPublishLeaseSet
Whether the lease set for the destination should be published.- Overrides:
shouldPublishLeaseSetin classClientManagerFacade- Parameters:
destinationHash- the destination hash to check- Returns:
- whether publish lease set
messageDeliveryStatusUpdate
public void messageDeliveryStatusUpdate(Destination fromDest, MessageId id, long messageNonce, int status) Report whether a client message was delivered or lost.- Specified by:
messageDeliveryStatusUpdatein classClientManagerFacade- Parameters:
fromDest- the source destination of the messageid- the router's ID for this messagemessageNonce- the client's ID for this message, greater than zerostatus- see I2CP MessageStatusMessage for success/failure codes
messageReceived
Description copied from class:ClientManagerFacadeReceive a message from the network for a local client.- Specified by:
messageReceivedin classClientManagerFacade- Parameters:
msg- the received client message
getClientSessionConfig
Return the client's current config, or null if not connected.- Specified by:
getClientSessionConfigin classClientManagerFacade- Parameters:
dest- the client destination- Returns:
- the client session config
getClientSessionKeyManager
Return the client's current manager or null if not connected.- Specified by:
getClientSessionKeyManagerin classClientManagerFacade- Parameters:
dest- the destination hash- Returns:
- the client session key manager
listClients
Return the list of locally connected clients.- Overrides:
listClientsin classClientManagerFacade- Returns:
- set of Destination objects
connect
The InternalClientManager interface. Connect to the router, receiving a message queue to talk to the router with.- Specified by:
connectin interfaceInternalClientManager- Returns:
- the message queue for communicating with the router
- Throws:
I2PSessionException- if the router isn't ready
registerMetaDest
Declare that we're going to publish a meta LS for this destination. Must be called before publishing the leaseset.- Overrides:
registerMetaDestin classClientManagerFacade- Parameters:
dest- the destination to register- Throws:
I2PSessionException- on duplicate dest
unregisterMetaDest
Declare that we're no longer going to publish a meta LS for this destination.- Overrides:
unregisterMetaDestin classClientManagerFacade- Parameters:
dest- the destination to unregister
getClientFloodfillNetworkDatabaseFacade
The FloodfillNetworkDatabaseFacade associated with a particular client destination. This is inside the runner, so it won't be there if the runner isn't ready.- Specified by:
getClientFloodfillNetworkDatabaseFacadein classClientManagerFacade- Parameters:
destHash- destination hash associated with the client who's subDb we're looking for- Returns:
- the netdb or null
getPrimaryHashes
All the primary hashes for all the clients as a set.- Specified by:
getPrimaryHashesin classClientManagerFacade- Returns:
- all the hashes or an empty set, non-null
getWriterQueueSize
public static int getWriterQueueSize()Gets the cap on the client writer's outgoing message queue.- Returns:
- the current client writer queue limit, in messages
setWriterQueueSize
public static void setWriterQueueSize(int val) Sets the cap on the client writer's outgoing message queue.- Parameters:
val- the requested queue limit in messages, clamped to 32..2048