class ClientConnectionRunner extends Object
Modifier and Type | Field and Description |
---|---|
protected RouterContext |
_context |
protected Log |
_log |
protected ClientManager |
_manager |
protected I2CPMessageReader |
_reader
thingy 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(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) |
(package private) void |
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) |
String |
getClientVersion()
The client version.
|
SessionConfig |
getConfig()
Current client's config,
will be null before session is established
|
Hash |
getDestHash()
Equivalent to getConfig().getDestination().calculateHash();
will be null before session is established
|
(package private) boolean |
getIsDead() |
(package private) LeaseRequestState |
getLeaseRequest()
data for the current leaseRequest, or null if there is no active leaseSet request
|
LeaseSet |
getLeaseSet()
currently allocated leaseSet
|
int |
getNextMessageId() |
(package private) Payload |
getPayload(MessageId id)
Only call if _dontSendMSMOnReceive is false, otherwise will always be null
|
(package private) SessionId |
getSessionId() |
SessionKeyManager |
getSessionKeyManager()
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) void |
receiveMessage(Destination toDest,
Destination fromDest,
Payload payload)
Asynchronously deliver the message to the current runner
|
(package private) void |
removePayload(MessageId id)
Only call if _dontSendMSMOnReceive is false
|
void |
reportAbuse(String reason,
int severity)
Send async abuse message to the client
|
(package private) void |
requestLeaseSet(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 |
setLeaseSet(LeaseSet ls) |
(package private) void |
setPayload(MessageId id,
Payload payload)
Only call if _dontSendMSMOnReceive is false
|
(package private) void |
setSessionId(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(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 Log _log
protected final RouterContext _context
protected final ClientManager _manager
protected I2CPMessageReader _reader
public ClientConnectionRunner(RouterContext context, ClientManager manager, Socket socket)
public void startRunning() throws IOException
I2CPMessageReader
IOException
protected I2CPMessageReader.I2CPMessageEventListener createListener()
public void stopRunning()
public SessionConfig getConfig()
public void setClientVersion(String version)
public String getClientVersion()
public SessionKeyManager getSessionKeyManager()
public LeaseSet getLeaseSet()
void setLeaseSet(LeaseSet ls)
public Hash getDestHash()
SessionId getSessionId()
void setSessionId(SessionId id)
IllegalStateException
- if already setLeaseRequestState getLeaseRequest()
public void failLeaseRequest(LeaseRequestState req)
req
- non-nullboolean isDead()
Payload getPayload(MessageId id)
void setPayload(MessageId id, Payload payload)
void removePayload(MessageId id)
public int sessionEstablished(SessionConfig config)
void updateMessageDeliveryStatus(MessageId id, long messageNonce, int status)
id
- the router's ID for this messagemessageNonce
- the client's ID for this messagestatus
- see I2CP MessageStatusMessage for success/failure codesvoid leaseSetCreated(LeaseSet ls)
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.WARNMessageId distributeMessage(SendMessageMessage message)
void ackSendMessage(MessageId id, long nonce)
id
- OUR id for the messagenonce
- HIS id for the messagevoid receiveMessage(Destination toDest, Destination fromDest, Payload payload)
public void reportAbuse(String reason, int severity)
void requestLeaseSet(LeaseSet set, long expirationTime, Job onCreateJob, Job onFailedJob)
set
- LeaseSet with requested leases - this object must be updated to contain the
signed version (as well as any changed/added/removed Leases)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 OKvoid disconnected()
boolean getIsDead()
void writeMessage(I2CPMessage msg)
void doSend(I2CPMessage msg) throws I2CPMessageException
I2CPMessageException
public int getNextMessageId()