java.lang.Object
net.i2p.router.client.ClientConnectionRunner
net.i2p.router.client.QueuedClientConnectionRunner
Zero-copy in-JVM. While super() starts both a reader and a writer thread, we only need a reader thread here.
Field Summary
FieldsFields inherited from class ClientConnectionRunner
_context, _log, _manager, _readerModifier and TypeFieldDescriptionprotected final RouterContextRouter context.protected final LogLogger for the runner.protected final ClientManagerClient manager managing this runner.protected I2CPMessageReaderReads and processes incoming I2CP messages from the client.Constructor Summary
ConstructorsConstructorDescriptionQueuedClientConnectionRunner(RouterContext context, ClientManager manager, I2CPMessageQueue queue) Create a new runner with the given queues.Method Summary
Modifier and TypeMethodDescription(package private) voiddoSend(I2CPMessage msg) Actually send the I2CPMessage to the client.(package private) voiddoSendWait(I2CPMessage msg, long timeoutMs) Send the I2CPMessage, giving the client's queue up to timeoutMs to make room.The client version.private I2CPMessageExceptionThe error for a client that is not draining its I2CP queue.voidsetClientVersion(String version) Does nothing.voidStarts the reader thread.voidCalls super() to stop the reader, and sends a poison message to the client.(package private) voidwriteMessage(I2CPMessage msg) In super(), doSend queues it to the writer thread and the writer thread calls writeMessage() to write to the output stream.Methods inherited from class ClientConnectionRunner
ackSendMessage, createListener, disconnectClient, disconnectClient, disconnected, distributeMessage, failLeaseRequest, getAddress, getConfig, getConfig, getDestHash, getDestHash, getDestination, getDestinations, getFloodfillNetworkDatabaseFacade, getIsDead, getLeaseRequest, getLeaseSet, getNextMessageId, getPayload, getPrimaryConfig, getSessionId, getSessionIds, getSessionKeyManager, isDead, leaseSetCreated, receiveMessage, receiveMessage, registerEncryptedLS, removePayload, removeSession, reportAbuse, requestLeaseSet, rerequestAfterTransientPublishFailure, sessionEstablished, setPayload, setSessionId, updateMessageDeliveryStatusModifier and TypeMethodDescription(package private) voidackSendMessage(SessionId sid, MessageId id, long nonce) Send a notification to the client that their message (id specified) was accepted for delivery (but not necessarily delivered) Doesn't do anything ifi2cp.messageReliability= "none" or if the nonce is 0.Allow override for testing.(package private) voiddisconnectClient(String reason) Send a DisconnectMessage and log with level Log.ERROR.(package private) voiddisconnectClient(String reason, int logLevel) Disconnect the client with the given reason and log level.(package private) voidThe client was disconnected.(package private) MessageIddistributeMessage(SendMessageMessage message) Distribute the message.voidFail the given lease request and track consecutive failures.The address of the client socket.Current client's config, will be null if session not found IS subsession aware.Current client's config, will be null if session not found IS subsession aware.Equivalent toClientConnectionRunner.getConfig(Hash).getDestination().calculateHash(); will be null before session is established Not subsession aware.getDestHash(SessionId id) Return the hash for the given ID.Return the dest for the given ID.(package private) List<Destination> Subsession aware.The FloodfillNetworkDatabaseFacade for this runner, the client netDb.(package private) booleanCheck if the runner is dead.(package private) LeaseRequestStateData for the current leaseRequest, or null if there is no active leaseSet request.getLeaseSet(Hash h) Currently allocated leaseSet.intGet the next message id.(package private) PayloadgetPayload(MessageId id) Only call if _dontSendMSMOnReceive is false, otherwise will always be null.Primary client's config, will be null if session not set up.(package private) SessionIdgetSessionId(Hash h) Subsession aware.Subsession aware.The current client's SessionKeyManager.(package private) booleanisDead()Already closed?(package private) voidCalled after a new leaseSet is granted by the client and the NetworkDb has been updated.(package private) booleanreceiveMessage(Destination toDest, Destination fromDest, Payload payload) Synchronously deliver the message to the current runner(package private) booleanreceiveMessage(Hash toHash, Destination fromDest, Payload payload) Synchronously deliver the message to the current runnerbooleanregisterEncryptedLS(Hash hash) Call after destinationEstablished(), when an encrypted leaseset is created, so we know it's local.(package private) voidOnly call if _dontSendMSMOnReceive is false.(package private) voidKill the session.voidreportAbuse(Destination dest, String reason, int severity) Send async abuse message to the client.(package private) voidrequestLeaseSet(Hash h, LeaseSet set, long expirationTime, Job onCreateJob, Job onFailedJob) Request that a particular client authorize the Leases contained in the LeaseSet, after which the onCreateJob is queued up.(package private) booleanRe-queue the pending lease request after netdb publish() rejected the client's LeaseSet as expired (client clock skew or slow signing).intsessionEstablished(SessionConfig config) Caller must send a SessionStatusMessage to the client with the returned code.(package private) voidsetPayload(MessageId id, Payload payload) Only call if _dontSendMSMOnReceive is false.(package private) voidsetSessionId(Hash hash, SessionId id) To be called only byClientManager.(package private) voidupdateMessageDeliveryStatus(Destination dest, MessageId id, long messageNonce, int status) Send a notification to the client that their message (id specified) was delivered (or failed delivery) Note that this sends the Guaranteed status codes, even though we only support best effort.
Field Details
queue
The queue shared with the client.
Constructor Details
QueuedClientConnectionRunner
public QueuedClientConnectionRunner(RouterContext context, ClientManager manager, I2CPMessageQueue queue) Create a new runner with the given queues.- Parameters:
context- the router contextmanager- the client managerqueue- the I2CP message queue
Method Details
startRunning
public void startRunning()Starts the reader thread. Does not call super().- Overrides:
startRunningin classClientConnectionRunner
stopRunning
public void stopRunning()Calls super() to stop the reader, and sends a poison message to the client.- Overrides:
stopRunningin classClientConnectionRunner
writeMessage
In super(), doSend queues it to the writer thread and the writer thread calls writeMessage() to write to the output stream. Since we have no writer thread this shouldn't happen.- Overrides:
writeMessagein classClientConnectionRunner- Parameters:
msg- the message to write
doSend
Actually send the I2CPMessage to the client. Non-blocking.- Overrides:
doSendin classClientConnectionRunner- Parameters:
msg- the message to send- Throws:
I2CPMessageException- if queue full or on other errors
doSendWait
Send the I2CPMessage, giving the client's queue up to timeoutMs to make room.The in-JVM dispatcher drains this queue every few milliseconds, so a full queue means the client is briefly behind rather than gone. Refusing the message outright costs far more than the wait does: a dropped LeaseSet request spends a whole request timing out and then rebuilds the tunnel, for a message that would have been handed over milliseconds later.
- Overrides:
doSendWaitin classClientConnectionRunner- Parameters:
msg- the message to sendtimeoutMs- how long to wait for space in the client's queue- Throws:
I2CPMessageException- if the queue is still full after the wait, or on other errors
queueFull
The error for a client that is not draining its I2CP queue.Names the client's side of the queue rather than saying only that a write failed, because that is the fact the operator needs: the router's own writer is healthy and the client is the side that has stopped reading.
- Returns:
- a fresh exception carrying the pending and free-slot counts of the queue
setClientVersion
Does nothing. Client version is the core version.- Overrides:
setClientVersionin classClientConnectionRunner- Parameters:
version- the client version string
getClientVersion
The client version.- Overrides:
getClientVersionin classClientConnectionRunner- Returns:
- always the published core version; the client version is fixed and cannot be set