class ClientConnectionRunner extends Object
| Modifier and Type | Field and Description |
|---|---|
protected RouterContext | _contextrouter context |
protected Log | _loglogger for the runner |
protected ClientManager | _managerclient manager managing this runner |
protected I2CPMessageReader | _readerthingy that does stuff |
| Constructor and Description |
|---|
ClientConnectionRunner(RouterContext context,
ClientManager manager,
Socket socket)Create a new runner against the given socket |
| Modifier and Type | Method and Description |
|---|---|
(package private) void | ackSendMessage(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 if i2cp.messageReliability = "none"
or if the nonce is 0. |
protected I2CPMessageReader.I2CPMessageEventListener | createListener()Allow override for testing |
(package private) void | disconnectClient(String reason)Send a DisconnectMessage and log with level Log.ERROR. |
(package private) void | disconnectClient(String reason,
int logLevel)Disconnect the client with the given reason and log level. |
(package private) void | disconnected()The client was disconnected. |
(package private) MessageId | distributeMessage(SendMessageMessage message)Distribute the message. |
(package private) void | doSend(I2CPMessage msg)Actually send the I2CPMessage to the peer through the socket |
void | failLeaseRequest(LeaseRequestState req)Fail the given lease request. |
InetAddress | getAddress()The address of the client socket. |
String | getClientVersion()The client version. |
SessionConfig | getConfig(Hash h)Current client's config,
will be null if session not found
IS subsession aware. |
SessionConfig | getConfig(SessionId id)Current client's config,
will be null if session not found
IS subsession aware. |
Hash | getDestHash()Equivalent to getConfig().getDestination().calculateHash();
will be null before session is established
Not subsession aware. |
Hash | getDestHash(SessionId id)Return the hash for the given ID |
Destination | getDestination(SessionId id)Return the dest for the given ID |
(package private) List<Destination> | getDestinations()Subsession aware. |
FloodfillNetworkDatabaseFacade | getFloodfillNetworkDatabaseFacade()Get the FloodfillNetworkDatabaseFacade for this runner. |
(package private) boolean | getIsDead()Check if the runner is dead. |
(package private) LeaseRequestState | getLeaseRequest(Hash h)Data for the current leaseRequest, or null if there is no active leaseSet request. |
LeaseSet | getLeaseSet(Hash h)Currently allocated leaseSet. |
int | getNextMessageId()Get the next message id. |
(package private) Payload | getPayload(MessageId id)Only call if _dontSendMSMOnReceive is false, otherwise will always be null |
SessionConfig | getPrimaryConfig()Primary client's config,
will be null if session not set up |
(package private) SessionId | getSessionId(Hash h)Subsession aware. |
(package private) List<SessionId> | getSessionIds()Subsession aware. |
SessionKeyManager | getSessionKeyManager()The current client's SessionKeyManager. |
(package private) boolean | isDead()Already closed? |
(package private) void | leaseSetCreated(LeaseSet ls)called after a new leaseSet is granted by the client, the NetworkDb has been
updated. |
(package private) boolean | receiveMessage(Destination toDest,
Destination fromDest,
Payload payload)Synchronously deliver the message to the current runner
Failure indication is available as of 0.9.29. |
(package private) boolean | receiveMessage(Hash toHash,
Destination fromDest,
Payload payload)Synchronously deliver the message to the current runner
Failure indication is available as of 0.9.29. |
boolean | registerEncryptedLS(Hash hash)Call after destinationEstablished(),
when an encrypted leaseset is created, so we know it's local. |
(package private) void | removePayload(MessageId id)Only call if _dontSendMSMOnReceive is false |
(package private) void | removeSession(SessionId id)Kill the session. |
void | reportAbuse(Destination dest,
String reason,
int severity)Send async abuse message to the client |
(package private) void | requestLeaseSet(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. |
int | sessionEstablished(SessionConfig config)Caller must send a SessionStatusMessage to the client with the returned code. |
void | setClientVersion(String version)The client version. |
(package private) void | setPayload(MessageId id,
Payload payload)Only call if _dontSendMSMOnReceive is false |
(package private) void | setSessionId(Hash hash,
SessionId id)To be called only by ClientManager. |
void | startRunning()Actually run the connection - listen for I2CP messages and respond. |
void | stopRunning()Die a horrible death. |
(package private) void | updateMessageDeliveryStatus(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. |
(package private) void | writeMessage(I2CPMessage msg)Not thread-safe. |
protected final RouterContext _context
protected final Log _log
protected final ClientManager _manager
protected I2CPMessageReader _reader
public ClientConnectionRunner(RouterContext context, ClientManager manager, Socket socket)
context - the router contextmanager - the client managersocket - the I2CP socketvoid ackSendMessage(SessionId sid, MessageId id, long nonce)
sid - the session idid - OUR id for the messagenonce - HIS id for the messageprotected I2CPMessageReader.I2CPMessageEventListener createListener()
void disconnectClient(String reason)
reason - will be truncated to 255 bytesvoid disconnectClient(String reason, int logLevel)
reason - will be truncated to 255 byteslogLevel - e.g. Log.WARNvoid disconnected()
MessageId distributeMessage(SendMessageMessage message)
message - the message to distributevoid doSend(I2CPMessage msg) throws I2CPMessageException
msg - the message to sendI2CPMessageException - if the message could not be sentpublic void failLeaseRequest(LeaseRequestState req)
req - non-nullpublic InetAddress getAddress()
public String getClientVersion()
public SessionConfig getConfig(Hash h)
h - the session hashpublic SessionConfig getConfig(SessionId id)
id - the session idpublic Hash getDestHash()
public Hash getDestHash(SessionId id)
id - the session idpublic Destination getDestination(SessionId id)
id - the session idList<Destination> getDestinations()
public FloodfillNetworkDatabaseFacade getFloodfillNetworkDatabaseFacade()
boolean getIsDead()
LeaseRequestState getLeaseRequest(Hash h)
h - the session hashpublic LeaseSet getLeaseSet(Hash h)
h - the session hashpublic int getNextMessageId()
Payload getPayload(MessageId id)
id - the message idpublic SessionConfig getPrimaryConfig()
SessionId getSessionId(Hash h)
h - the local targetList<SessionId> getSessionIds()
public SessionKeyManager getSessionKeyManager()
boolean isDead()
void leaseSetCreated(LeaseSet ls)
ls - if encrypted, the encrypted LS, not the decrypted oneboolean receiveMessage(Destination toDest, Destination fromDest, Payload payload)
toDest - non-nullfromDest - generally null when from remote, non-null if from localpayload - the payload to deliverboolean receiveMessage(Hash toHash, Destination fromDest, Payload payload)
toHash - non-nullfromDest - generally null when from remote, non-null if from localpayload - the payload to deliverpublic boolean registerEncryptedLS(Hash hash)
hash - the location of the encrypted LS, will change every dayvoid removePayload(MessageId id)
id - the message id to removevoid removeSession(SessionId id)
id - the session id to removepublic void reportAbuse(Destination dest, String reason, int severity)
dest - the offending destinationreason - the reasonseverity - the severity levelvoid requestLeaseSet(Hash h, LeaseSet set, long expirationTime, Job onCreateJob, Job onFailedJob)
h - the Destination's hashset - 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.
Must be unique for this hash, do not reuse for subsessions.expirationTime - ms to wait before failingonCreateJob - Job to run after the LeaseSet is authorized, null OKonFailedJob - Job to run after the timeout passes without receiving authorization, null OKpublic int sessionEstablished(SessionConfig config)
config - the session configpublic void setClientVersion(String version)
version - the client version stringvoid setPayload(MessageId id, Payload payload)
id - the message idpayload - the payload to storevoid setSessionId(Hash hash, SessionId id)
hash - for the sessionid - the session id to setIllegalStateException - if already setpublic void startRunning()
throws IOExceptionI2CPMessageReaderIOException - if the socket I/O failspublic void stopRunning()
void updateMessageDeliveryStatus(Destination dest, MessageId id, long messageNonce, int status)
dest - the clientid - the router's ID for this messagemessageNonce - the client's ID for this message, greater than zerostatus - see I2CP MessageStatusMessage for success/failure codesvoid writeMessage(I2CPMessage msg)
msg - the message to write