public abstract class I2PSessionImpl extends Object implements I2PSession, I2CPMessageReader.I2CPMessageEventListener
| Modifier and Type | Class and Description |
|---|---|
protected class |
I2PSessionImpl.AvailabilityNotifier
This notifies the client of payload messages.
|
protected static class |
I2PSessionImpl.State
Session state enumeration.
|
| Modifier and Type | Field and Description |
|---|---|
protected I2PSessionImpl.AvailabilityNotifier |
_availabilityNotifier
thread that we tell when new messages are available who then tells us
to fetch them.
|
protected Map<Long,MessagePayloadMessage> |
_availableMessages
map of Long --> MessagePayloadMessage
|
protected int[] |
_bwLimits |
protected Object |
_bwReceivedLock |
protected I2PAppContext |
_context
used to separate things out so we can get rid of singletons
|
protected I2PClientMessageHandlerMap |
_handlerMap |
protected String |
_hostname
hostname of router - will be null if in RouterContext
|
protected LeaseSet |
_leaseSet
currently granted lease set, or null
|
protected Object |
_leaseSetWait
monitor for waiting until a lease set has been granted
|
protected Log |
_log |
protected LinkedBlockingQueue<net.i2p.client.impl.I2PSessionImpl.LookupWaiter> |
_pendingLookups
hashes of lookups we are waiting for
|
protected int |
_portNum
port num to router - will be 0 if in RouterContext
|
protected I2CPMessageProducer |
_producer
class that generates new messages
|
protected I2CPMessageQueue |
_queue
Used for internal connections to the router.
|
protected I2CPMessageReader |
_reader
reader that always searches for messages
|
protected I2PSessionListener |
_sessionListener
who we send events to
|
protected Socket |
_socket
socket for comm
|
protected I2PSessionImpl.State |
_state |
protected Object |
_stateLock |
protected SigningPublicKey |
_transientSigningPublicKey |
protected ClientWriterRunner |
_writer
writer message queue
|
protected static int |
CACHE_MAX_SIZE |
(package private) static SessionId |
DUMMY_SESSION |
static int |
LISTEN_PORT |
protected static String |
PROP_DOMAIN_SOCKET
Use Unix domain socket (or similar) to connect to a router
|
PORT_ANY, PORT_UNSPECIFIED, PROTO_ANY, PROTO_DATAGRAM, PROTO_DATAGRAM_RAW, PROTO_DATAGRAM2, PROTO_DATAGRAM3, PROTO_STREAMING, PROTO_UNSPECIFIED| Modifier | Constructor and Description |
|---|---|
|
I2PSessionImpl(I2PAppContext context,
InputStream destKeyStream,
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
As of 0.9.19, defaults in options are honored.
|
protected |
I2PSessionImpl(I2PAppContext context,
Properties options,
I2PClientMessageHandlerMap handlerMap)
for extension by SimpleSession (no dest)
|
protected |
I2PSessionImpl(I2PSessionImpl primary,
InputStream destKeyStream,
Properties options) |
| Modifier and Type | Method and Description |
|---|---|
void |
addNewMessage(MessagePayloadMessage msg)
Recieve a payload message and let the app know its available
|
I2PSession |
addSubsession(InputStream privateKeyStream,
Properties opts)
Router must be connected or was connected...
|
int[] |
bandwidthLimits()
Blocking.
|
(package private) void |
bwReceived(int[] i)
called by the message handler
|
protected void |
changeState(I2PSessionImpl.State state) |
static void |
clearCache() |
void |
connect()
Connect to the router and establish a session.
|
(package private) void |
dateUpdated(String routerVersion) |
(package private) void |
destLookupFailed(Hash h)
Called by the message handler
on reception of DestReplyMessage
|
(package private) void |
destLookupFailed(long nonce,
int code)
Called by the message handler
on reception of HostReplyMessage
|
(package private) void |
destReceived(Destination d)
Called by the message handler
on reception of DestReplyMessage
|
(package private) void |
destReceived(long nonce,
Destination d)
Called by the message handler
on reception of HostReplyMessage
|
void |
destroySession()
Tear down the session, and do NOT reconnect.
|
void |
destroySession(boolean sendDisconnect)
Tear down the session, and do NOT reconnect.
|
protected void |
disconnect()
Will interrupt a connect in progress.
|
void |
disconnected(I2CPMessageReader reader)
The I2CPMessageEventListener callback.
|
(package private) I2PAppContext |
getContext()
For Subsessions
|
boolean |
getFastReceive() |
(package private) I2PClientMessageHandlerMap |
getHandlerMap()
For Subsessions
|
(package private) long |
getLastLS2SignTime()
The published timestamp of the last LS2 we signed
|
(package private) LeaseSet |
getLeaseSet() |
Destination |
getMyDestination()
Retrieve the destination of the session
|
protected String |
getName() |
long |
getOfflineExpiration()
Get the offline expiration
|
Signature |
getOfflineSignature() |
(package private) Properties |
getOptions()
Retrieve the configuration options, filtered.
|
protected String |
getPrefix()
try hard to make a decent identifier as this will appear in error logs
|
SigningPrivateKey |
getPrivateKey()
Retrieve the signing SigningPrivateKey.
|
(package private) I2CPMessageProducer |
getProducer()
Retrieve the helper that generates I2CP messages
|
String |
getRouterVersion()
Always valid in RouterContext.
|
(package private) SessionId |
getSessionId()
Retrieve the session's ID
|
List<I2PSession> |
getSubsessions() |
SigningPublicKey |
getTransientSigningPublicKey() |
boolean |
isClosed()
Has the session been closed (or not yet connected)?
False when open and during transitions.
|
boolean |
isOffline()
Does this session have offline and transient keys?
|
long |
lastActivity() |
Destination |
lookupDest(Hash h)
Blocking.
|
Destination |
lookupDest(Hash h,
long maxWait)
Blocking.
|
LookupResult |
lookupDest(Hash h,
long maxWait,
LookupCallback callback)
Lookup a Destination by hostname.
|
Destination |
lookupDest(String name)
Ask the router to lookup a Destination by host name.
|
Destination |
lookupDest(String name,
long maxWait)
Ask the router to lookup a Destination by host name.
|
LookupResult |
lookupDest(String name,
long maxWait,
LookupCallback callback)
Lookup a Destination by hash.
|
LookupResult |
lookupDest2(String name,
long maxWait)
Ask the router to lookup a Destination by host name.
|
void |
messageReceived(I2CPMessageReader reader,
I2CPMessage message)
The I2CPMessageEventListener callback.
|
(package private) void |
propagateError(String msg,
Throwable error)
Pass off the error to the listener
Misspelled, oh well.
|
void |
readError(I2CPMessageReader reader,
Exception error)
The I2CPMessageEventListener callback.
|
byte[] |
receiveMessage(int msgId)
Pull the unencrypted data from the message that we've already prefetched and
notified the user that its available.
|
abstract void |
receiveStatus(int msgId,
long nonce,
int status) |
protected boolean |
reconnect() |
void |
removeSubsession(I2PSession session) |
void |
reportAbuse(int msgId,
int severity)
Report abuse with regards to the given messageId
|
void |
sendBlindingInfo(BlindData bd) |
(package private) void |
sendMessage_unchecked(I2CPMessage message)
Deliver an I2CP message to the router.
|
(package private) void |
sendMessage(I2CPMessage message)
Deliver an I2CP message to the router
As of 0.9.3, may block for several seconds if the write queue to the router is full
|
(package private) void |
setLastLS2SignTime(long now)
The published timestamp of the last LS2 we signed
|
(package private) void |
setLeaseSet(LeaseSet ls) |
void |
setReduced() |
(package private) void |
setSessionId(SessionId id) |
void |
setSessionListener(I2PSessionListener lsnr)
configure the listener
|
protected boolean |
shouldReconnect() |
protected void |
startVerifyUsage()
Fire up a periodic task to check for unclaimed messages
|
boolean |
supportsLS2() |
String |
toString() |
protected void |
updateActivity() |
void |
updateOptions(Properties options)
Update the tunnel and bandwidth settings
|
protected void |
verifyOpen()
Throws I2PSessionException if uninitialized, closed or closing.
|
protected void |
waitForDate() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddMuxedSessionListener, addSessionListener, removeListener, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessageprotected I2PSessionImpl.AvailabilityNotifier _availabilityNotifier
protected Map<Long,MessagePayloadMessage> _availableMessages
protected volatile int[] _bwLimits
protected final Object _bwReceivedLock
protected final I2PAppContext _context
protected final I2PClientMessageHandlerMap _handlerMap
protected final String _hostname
protected volatile LeaseSet _leaseSet
protected final Object _leaseSetWait
protected final Log _log
protected final LinkedBlockingQueue<net.i2p.client.impl.I2PSessionImpl.LookupWaiter> _pendingLookups
protected final int _portNum
protected final I2CPMessageProducer _producer
protected I2CPMessageQueue _queue
protected I2CPMessageReader _reader
protected I2PSessionListener _sessionListener
protected Socket _socket
protected I2PSessionImpl.State _state
protected final Object _stateLock
protected SigningPublicKey _transientSigningPublicKey
protected ClientWriterRunner _writer
protected static final int CACHE_MAX_SIZE
static final SessionId DUMMY_SESSION
public static final int LISTEN_PORT
protected static final String PROP_DOMAIN_SOCKET
public I2PSessionImpl(I2PAppContext context, InputStream destKeyStream, Properties options) throws I2PSessionException
destKeyStream - stream containing the private key data,
format is specified in PrivateKeyFileoptions - set of options to configure the router with, if null will use System propertiesI2PSessionException - if there is a problem loading the private keysprotected I2PSessionImpl(I2PAppContext context, Properties options, I2PClientMessageHandlerMap handlerMap)
protected I2PSessionImpl(I2PSessionImpl primary, InputStream destKeyStream, Properties options) throws I2PSessionException
I2PSessionExceptionpublic void addNewMessage(MessagePayloadMessage msg)
public I2PSession addSubsession(InputStream privateKeyStream, Properties opts) throws I2PSessionException
addSubsession in interface I2PSessionprivateKeyStream - null for transient, if non-null must have same encryption keys as primary session
and different signing keysopts - subsession options if any, may be nullI2PSessionExceptionpublic int[] bandwidthLimits()
throws I2PSessionException
bandwidthLimits in interface I2PSessionI2PSessionExceptionvoid bwReceived(int[] i)
protected void changeState(I2PSessionImpl.State state)
public static void clearCache()
public void connect()
throws I2PSessionException
connect in interface I2PSessionI2PSessionException - if there is a configuration error or the router is
not reachablevoid dateUpdated(String routerVersion)
routerVersion - as rcvd in the SetDateMessage, may be null for very old routersvoid destLookupFailed(Hash h)
h - non-nullvoid destLookupFailed(long nonce,
int code)
void destReceived(Destination d)
d - non-nullvoid destReceived(long nonce,
Destination d)
d - non-nullpublic void destroySession()
destroySession in interface I2PSessionpublic void destroySession(boolean sendDisconnect)
protected void disconnect()
public void disconnected(I2CPMessageReader reader)
disconnected in interface I2CPMessageReader.I2CPMessageEventListenerreader - unusedI2PAppContext getContext()
public boolean getFastReceive()
I2PClientMessageHandlerMap getHandlerMap()
long getLastLS2SignTime()
LeaseSet getLeaseSet()
public Destination getMyDestination()
getMyDestination in interface I2PSessionprotected String getName()
public long getOfflineExpiration()
I2PSessiongetOfflineExpiration in interface I2PSessionpublic Signature getOfflineSignature()
getOfflineSignature in interface I2PSessionProperties getOptions()
protected String getPrefix()
public SigningPrivateKey getPrivateKey()
getPrivateKey in interface I2PSessionI2CPMessageProducer getProducer()
public String getRouterVersion()
getRouterVersion in interface I2PSessionSessionId getSessionId()
public List<I2PSession> getSubsessions()
getSubsessions in interface I2PSessionpublic SigningPublicKey getTransientSigningPublicKey()
getTransientSigningPublicKey in interface I2PSessionpublic boolean isClosed()
isClosed in interface I2PSessionpublic boolean isOffline()
isOffline in interface I2PSessionpublic long lastActivity()
public Destination lookupDest(Hash h) throws I2PSessionException
lookupDest in interface I2PSessionI2PSessionExceptionpublic Destination lookupDest(Hash h, long maxWait) throws I2PSessionException
lookupDest in interface I2PSessionmaxWait - msI2PSessionExceptionpublic LookupResult lookupDest(Hash h, long maxWait, LookupCallback callback) throws I2PSessionException
lookupDest in interface I2PSessionmaxWait - mscallback - to return the result, non-nullI2PSessionExceptionpublic Destination lookupDest(String name) throws I2PSessionException
lookupDest in interface I2PSessionI2PSessionExceptionpublic Destination lookupDest(String name, long maxWait) throws I2PSessionException
lookupDest in interface I2PSessionmaxWait - msI2PSessionExceptionpublic LookupResult lookupDest(String name, long maxWait, LookupCallback callback) throws I2PSessionException
lookupDest in interface I2PSessionmaxWait - mscallback - to return the result, non-nullI2PSessionExceptionpublic LookupResult lookupDest2(String name, long maxWait) throws I2PSessionException
lookupDest2 in interface I2PSessionmaxWait - msI2PSessionExceptionpublic void messageReceived(I2CPMessageReader reader, I2CPMessage message)
messageReceived in interface I2CPMessageReader.I2CPMessageEventListenerreader - unusedmessage - the I2CPMessagevoid propagateError(String msg, Throwable error)
error - non-nullpublic void readError(I2CPMessageReader reader, Exception error)
readError in interface I2CPMessageReader.I2CPMessageEventListenerreader - unusederror - non-nullpublic byte[] receiveMessage(int msgId)
throws I2PSessionException
receiveMessage in interface I2PSessionmsgId - message to fetchI2PSessionExceptionpublic abstract void receiveStatus(int msgId,
long nonce,
int status)
protected boolean reconnect()
public void removeSubsession(I2PSession session)
removeSubsession in interface I2PSessionpublic void reportAbuse(int msgId,
int severity)
throws I2PSessionException
reportAbuse in interface I2PSessionmsgId - message that was abusive (or -1 for not message related)severity - how abusiveI2PSessionExceptionpublic void sendBlindingInfo(BlindData bd) throws I2PSessionException
sendBlindingInfo in interface I2PSessionI2PSessionExceptionvoid sendMessage_unchecked(I2CPMessage message) throws I2PSessionException
I2PSessionException - if the message is malformed or there is an error writing it outvoid sendMessage(I2CPMessage message) throws I2PSessionException
I2PSessionException - if the message is malformed or there is an error writing it outvoid setLastLS2SignTime(long now)
void setLeaseSet(LeaseSet ls)
public void setReduced()
void setSessionId(SessionId id)
public void setSessionListener(I2PSessionListener lsnr)
setSessionListener in interface I2PSessionlsnr - listener to retrieve eventsprotected boolean shouldReconnect()
protected void startVerifyUsage()
public boolean supportsLS2()
protected void updateActivity()
public void updateOptions(Properties options)
updateOptions in interface I2PSessionoptions - non-nullprotected void verifyOpen()
throws I2PSessionException
I2PSessionExceptionprotected void waitForDate()
throws InterruptedException,
IOException
InterruptedExceptionIOException