|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.client.I2PSessionImpl
net.i2p.client.I2PSessionImpl2
Thread safe implementation of an I2P session running over TCP.
Field Summary | |
(package private) java.util.Map |
_availableMessages
map of integer --> MessagePayloadMessage |
protected I2PAppContext |
_context
used to seperate things out so we can get rid of singletons |
protected I2PClientMessageHandlerMap |
_handlerMap
|
protected I2CPMessageProducer |
_producer
class that generates new messages |
static int |
LISTEN_PORT
|
Constructor Summary | |
I2PSessionImpl2(I2PAppContext ctx,
java.io.InputStream destKeyStream,
java.util.Properties options)
Create a new session, reading the Destination, PrivateKey, and SigningPrivateKey from the destKeyStream, and using the specified options to connect to the router |
Method Summary | |
void |
addNewMessage(MessagePayloadMessage msg)
Recieve a payload message and let the app know its available |
void |
connect()
Connect to the router and establish a session. |
protected static java.util.Set |
createNewTags(int num)
|
(package private) void |
dateUpdated()
|
void |
destroySession()
Tear down the session, and do NOT reconnect |
void |
destroySession(boolean sendDisconnect)
|
protected void |
disconnect()
|
void |
disconnected(I2CPMessageReader reader)
Recieve notification that the I2CP connection was disconnected |
PrivateKey |
getDecryptionKey()
Retrieve the decryption PrivateKey |
(package private) LeaseSet |
getLeaseSet()
|
Destination |
getMyDestination()
Retrieve the destination of the session |
(package private) java.util.Properties |
getOptions()
Retrieve the configuration options |
protected java.lang.String |
getPrefix()
|
SigningPrivateKey |
getPrivateKey()
Retrieve the signing SigningPrivateKey |
(package private) I2CPMessageProducer |
getProducer()
Retrieve the helper that generates I2CP messages |
(package private) SessionId |
getSessionId()
Retrieve the session's ID |
protected long |
getTimeout()
|
boolean |
isClosed()
has the session been closed (or not yet connected)? |
protected boolean |
isGuaranteed()
|
void |
messageReceived(I2CPMessageReader reader,
I2CPMessage message)
Recieve notification of some I2CP message and handle it if possible |
(package private) void |
propogateError(java.lang.String msg,
java.lang.Throwable error)
Pass off the error to the listener |
void |
readError(I2CPMessageReader reader,
java.lang.Exception error)
Recieve notifiation of an error reading the I2CP stream |
byte[] |
receiveMessage(int msgId)
pull the unencrypted AND DECOMPRESSED data |
void |
receiveStatus(int msgId,
long nonce,
int status)
|
protected boolean |
reconnect()
Called whenever we want to reconnect (used only in the superclass). |
void |
reportAbuse(int msgId,
int severity)
Report abuse with regards to the given messageId |
boolean |
sendMessage(Destination dest,
byte[] payload)
Send the data to the destination. |
boolean |
sendMessage(Destination dest,
byte[] payload,
int offset,
int size)
|
boolean |
sendMessage(Destination dest,
byte[] payload,
int offset,
int size,
SessionKey keyUsed,
java.util.Set tagsSent)
|
boolean |
sendMessage(Destination dest,
byte[] payload,
SessionKey keyUsed,
java.util.Set tagsSent)
Like sendMessage above, except the key used and the tags sent are exposed to the application. |
(package private) void |
sendMessage(I2CPMessage message)
Deliver an I2CP message to the router |
(package private) void |
setLeaseSet(LeaseSet ls)
|
(package private) void |
setSessionId(SessionId id)
|
void |
setSessionListener(I2PSessionListener lsnr)
configure the listener |
protected boolean |
shouldReconnect()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected I2CPMessageProducer _producer
java.util.Map _availableMessages
protected I2PClientMessageHandlerMap _handlerMap
protected I2PAppContext _context
public static final int LISTEN_PORT
Constructor Detail |
public I2PSessionImpl2(I2PAppContext ctx, java.io.InputStream destKeyStream, java.util.Properties options) throws I2PSessionException
I2PSessionException
- if there is a problem loading the private keys orMethod Detail |
protected long getTimeout()
public void destroySession(boolean sendDisconnect)
destroySession
in class I2PSessionImpl
public boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException
I2PSessionImpl
sendMessage
in interface I2PSession
sendMessage
in class I2PSessionImpl
I2PSessionException
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size) throws I2PSessionException
I2PSessionException
public boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed, java.util.Set tagsSent) throws I2PSessionException
I2PSession
SessionKeyManager.getInstance().tagsDelivered(dest.getPublicKey(), keyUsed, tagsSent);If an application is using guaranteed delivery mode, this is not useful, but for applications using best effort delivery mode, if they can know with certainty that a message was delivered and can update the SessionKeyManager appropriately, a significant performance boost will occur (subsequent message encryption and decryption will be done via AES and a SessionTag, rather than ElGamal+AES, which is 1000x slower).
sendMessage
in interface I2PSession
sendMessage
in class I2PSessionImpl
I2PSessionException
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, java.util.Set tagsSent) throws I2PSessionException
I2PSessionException
public byte[] receiveMessage(int msgId) throws I2PSessionException
receiveMessage
in interface I2PSession
receiveMessage
in class I2PSessionImpl
I2PSessionException
public void receiveStatus(int msgId, long nonce, int status)
receiveStatus
in class I2PSessionImpl
protected boolean reconnect()
reconnect
in class I2PSessionImpl
void dateUpdated()
void setLeaseSet(LeaseSet ls)
LeaseSet getLeaseSet()
public void connect() throws I2PSessionException
connect
in interface I2PSession
I2PSessionException
- if there is a configuration error or the router is
not reachablepublic void reportAbuse(int msgId, int severity) throws I2PSessionException
reportAbuse
in interface I2PSession
msgId
- message that was abusive (or -1 for not message related)severity
- how abusive
I2PSessionException
protected boolean isGuaranteed()
protected static final java.util.Set createNewTags(int num)
public void addNewMessage(MessagePayloadMessage msg)
public void messageReceived(I2CPMessageReader reader, I2CPMessage message)
messageReceived
in interface I2CPMessageReader.I2CPMessageEventListener
public void readError(I2CPMessageReader reader, java.lang.Exception error)
readError
in interface I2CPMessageReader.I2CPMessageEventListener
public Destination getMyDestination()
getMyDestination
in interface I2PSession
public PrivateKey getDecryptionKey()
getDecryptionKey
in interface I2PSession
public SigningPrivateKey getPrivateKey()
getPrivateKey
in interface I2PSession
I2CPMessageProducer getProducer()
java.util.Properties getOptions()
SessionId getSessionId()
void setSessionId(SessionId id)
public void setSessionListener(I2PSessionListener lsnr)
setSessionListener
in interface I2PSession
lsnr
- listener to retrieve eventspublic boolean isClosed()
isClosed
in interface I2PSession
void sendMessage(I2CPMessage message) throws I2PSessionException
I2PSessionException
- if the message is malformed or there is an error writing it outvoid propogateError(java.lang.String msg, java.lang.Throwable error)
public void destroySession()
destroySession
in interface I2PSession
public void disconnected(I2CPMessageReader reader)
disconnected
in interface I2CPMessageReader.I2CPMessageEventListener
protected void disconnect()
protected boolean shouldReconnect()
protected java.lang.String getPrefix()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |