Package net.i2p.client.impl
Class SubSession
java.lang.Object
net.i2p.client.impl.I2PSessionImpl
net.i2p.client.impl.I2PSessionImpl2
net.i2p.client.impl.I2PSessionMuxedImpl
net.i2p.client.impl.SubSession
- All Implemented Interfaces:
I2PSession,I2CPMessageReader.I2CPMessageEventListener
class SubSession extends I2PSessionMuxedImpl
An additional session using another session's connection.
A subsession uses the same connection to the router as the primary session,
but has a different Destination. It uses the same tunnels as the primary
but has its own leaseset. It must use the same encryption keys as the primary
so that garlic encryption/decryption works.
The message handler map and message producer are reused from primary.
Does NOT reuse the session listener ????
While the I2CP protocol, in theory, allows for fully independent sessions
over the same I2CP connection, this is not currently supported by the router.
- Since:
- 0.9.21
-
Nested Class Summary
Nested classes/interfaces inherited from class net.i2p.client.impl.I2PSessionMuxedImpl
I2PSessionMuxedImpl.MuxedAvailabilityNotifierNested classes/interfaces inherited from class net.i2p.client.impl.I2PSessionImpl
I2PSessionImpl.AvailabilityNotifier, I2PSessionImpl.State -
Field Summary
Fields inherited from class net.i2p.client.impl.I2PSessionImpl2
_noEffort, _sendingStates, _sendMessageNonceFields inherited from class net.i2p.client.impl.I2PSessionImpl
_availabilityNotifier, _availableMessages, _bwLimits, _bwReceivedLock, _context, _handlerMap, _hostname, _leaseSet, _leaseSetWait, _log, _pendingLookups, _portNum, _producer, _queue, _reader, _sessionListener, _socket, _state, _stateLock, _transientSigningPublicKey, _writer, CACHE_MAX_SIZE, LISTEN_PORT, PROP_DOMAIN_SOCKETFields inherited from interface net.i2p.client.I2PSession
PORT_ANY, PORT_UNSPECIFIED, PROTO_ANY, PROTO_DATAGRAM, PROTO_DATAGRAM_RAW, PROTO_STREAMING, PROTO_UNSPECIFIED -
Constructor Summary
Constructors Constructor Description SubSession(I2PSession primary, InputStream destKeyStream, Properties options) -
Method Summary
Modifier and Type Method Description I2PSessionaddSubsession(InputStream destKeyStream, Properties opts)Unsupported in a subsession.int[]bandwidthLimits()This won't be called, as the reply does not contain a session ID, so it won't be routed back to us(package private) voidbwReceived(int[] i)Called by the message handler.voidconnect()Connect to the router and establish a session.(package private) voiddestLookupFailed(long nonce, int code)Called by the message handler on reception of HostReplyMessage(package private) voiddestLookupFailed(Hash h)Called by the message handler on reception of DestReplyMessage This will never happen, as the dest reply message does not contain a session ID.(package private) voiddestReceived(long nonce, Destination d)Called by the message handler on reception of HostReplyMessage(package private) voiddestReceived(Destination d)Called by the message handler on reception of DestReplyMessage This will never happen, as the dest reply message does not contain a session ID.voiddestroySession()Tear down the session, and do NOT reconnect.protected voiddisconnect()Will interrupt a connect in progress.PropertiesgetPrimaryOptions()List<I2PSession>getSubsessions()Unsupported in a subsession.booleanisClosed()Has the session been closed (or not yet connected)? False when open and during transitions.longlastActivity()DestinationlookupDest(String name)Ask the router to lookup a Destination by host name.DestinationlookupDest(String name, long maxWait)Ask the router to lookup a Destination by host name.DestinationlookupDest(Hash h)Blocking.DestinationlookupDest(Hash h, long maxWait)Blocking.(package private) voidpropogateError(String msg, Throwable error)Pass off the error to the listener Misspelled, oh well.protected booleanreconnect()Called whenever we want to reconnect (used only in the superclass).voidremoveSubsession(I2PSession session)Unsupported in a subsession.(package private) voidsendMessage(I2CPMessage message)Deliver an I2CP message to the router May block for several seconds if the write queue to the router is full(package private) voidsendMessage_unchecked(I2CPMessage message)Deliver an I2CP message to the router.voidsetReduced()protected voidupdateActivity()voidupdateOptions(Properties options)Does nothing for nowMethods inherited from class net.i2p.client.impl.I2PSessionMuxedImpl
addMuxedSessionListener, addNewMessage, addSessionListener, removeListener, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, setSessionListenerMethods inherited from class net.i2p.client.impl.I2PSessionImpl2
destroySession, getTimeout, receiveMessage, receiveStatus, sendBestEffort, sendBestEffort, sendMessage, sendMessage, sendMessage, sendNoEffort, shouldCompress, startVerifyUsageMethods inherited from class net.i2p.client.impl.I2PSessionImpl
changeState, clearCache, dateUpdated, disconnected, getContext, getDecryptionKey, getFastReceive, getHandlerMap, getLeaseSet, getMyDestination, getName, getOfflineExpiration, getOfflineSignature, getOptions, getPrefix, getPrivateKey, getProducer, getRouterVersion, getSessionId, getTransientSigningPublicKey, isOffline, lookupDest2, messageReceived, readError, reportAbuse, sendBlindingInfo, setLeaseSet, setSessionId, shouldReconnect, supportsLS2, toString, verifyOpen, waitForDate
-
Constructor Details
-
SubSession
public SubSession(I2PSession primary, InputStream destKeyStream, Properties options) throws I2PSessionException- Parameters:
primary- must be a I2PSessionMuxedImpl- Throws:
I2PSessionException
-
-
Method Details
-
addSubsession
public I2PSession addSubsession(InputStream destKeyStream, Properties opts) throws I2PSessionExceptionUnsupported in a subsession.- Specified by:
addSubsessionin interfaceI2PSession- Overrides:
addSubsessionin classI2PSessionImpl- Parameters:
destKeyStream- null for transient, if non-null must have same encryption keys as primary session and different signing keysopts- subsession options if any, may be null- Returns:
- a new subsession, non-null
- Throws:
UnsupportedOperationException- alwaysI2PSessionException
-
removeSubsession
Unsupported in a subsession. Does nothing.- Specified by:
removeSubsessionin interfaceI2PSession- Overrides:
removeSubsessionin classI2PSessionImpl
-
getSubsessions
Unsupported in a subsession.- Specified by:
getSubsessionsin interfaceI2PSession- Overrides:
getSubsessionsin classI2PSessionImpl- Returns:
- empty list always
-
updateOptions
Does nothing for now- Specified by:
updateOptionsin interfaceI2PSession- Overrides:
updateOptionsin classI2PSessionImpl- Parameters:
options- non-null
-
getPrimaryOptions
- Since:
- 0.9.33
-
connect
Connect to the router and establish a session. This call blocks until a session is granted. Should be threadsafe, other threads will block until complete. Disconnect / destroy from another thread may be called simultaneously and will (should?) interrupt the connect. Connecting a subsession will automatically connect the primary session if not previously connected.- Specified by:
connectin interfaceI2PSession- Overrides:
connectin classI2PSessionImpl- Throws:
I2PSessionException- if there is a configuration error or the router is not reachable
-
isClosed
public boolean isClosed()Has the session been closed (or not yet connected)? False when open and during transitions.- Specified by:
isClosedin interfaceI2PSession- Overrides:
isClosedin classI2PSessionImpl- Returns:
- true if the session is closed, OR connect() has not been called yet
-
sendMessage
Deliver an I2CP message to the router May block for several seconds if the write queue to the router is full- Overrides:
sendMessagein classI2PSessionImpl- Throws:
I2PSessionException- if the message is malformed or there is an error writing it out
-
sendMessage_unchecked
Deliver an I2CP message to the router. Does NOT check state. Call only from connect() or other methods that need to send messages when not in OPEN state.- Overrides:
sendMessage_uncheckedin classI2PSessionImpl- Throws:
I2PSessionException- if the message is malformed or there is an error writing it out- Since:
- 0.9.23
-
propogateError
Pass off the error to the listener Misspelled, oh well.- Overrides:
propogateErrorin classI2PSessionImpl- Parameters:
error- non-null
-
destroySession
public void destroySession()Tear down the session, and do NOT reconnect. Blocks if session has not been fully started.- Specified by:
destroySessionin interfaceI2PSession- Overrides:
destroySessionin classI2PSessionImpl
-
disconnect
protected void disconnect()Will interrupt a connect in progress.- Overrides:
disconnectin classI2PSessionImpl
-
reconnect
protected boolean reconnect()Description copied from class:I2PSessionImpl2Called whenever we want to reconnect (used only in the superclass). We need to override this to clear out the message state- Overrides:
reconnectin classI2PSessionImpl2
-
destReceived
Called by the message handler on reception of DestReplyMessage This will never happen, as the dest reply message does not contain a session ID.- Overrides:
destReceivedin classI2PSessionImpl- Parameters:
d- non-null
-
destLookupFailed
Called by the message handler on reception of DestReplyMessage This will never happen, as the dest reply message does not contain a session ID.- Overrides:
destLookupFailedin classI2PSessionImpl- Parameters:
h- non-null
-
destReceived
Called by the message handler on reception of HostReplyMessage- Overrides:
destReceivedin classI2PSessionImpl- Parameters:
d- non-null
-
destLookupFailed
void destLookupFailed(long nonce, int code)Called by the message handler on reception of HostReplyMessage- Overrides:
destLookupFailedin classI2PSessionImpl
-
bwReceived
void bwReceived(int[] i)Called by the message handler. This will never happen, as the bw limits message does not contain a session ID.- Overrides:
bwReceivedin classI2PSessionImpl
-
lookupDest
Blocking. Waits a max of 10 seconds by default. See lookupDest with maxWait parameter to change. Implemented in 0.8.3 in I2PSessionImpl; previously was available only in I2PSimpleSession. Multiple outstanding lookups are now allowed.- Specified by:
lookupDestin interfaceI2PSession- Overrides:
lookupDestin classI2PSessionImpl- Returns:
- null on failure
- Throws:
I2PSessionException
-
lookupDest
Blocking.- Specified by:
lookupDestin interfaceI2PSession- Overrides:
lookupDestin classI2PSessionImpl- Parameters:
maxWait- ms- Returns:
- null on failure
- Throws:
I2PSessionException
-
lookupDest
Ask the router to lookup a Destination by host name. Blocking. Waits a max of 10 seconds by default. This only makes sense for a b32 hostname, OR outside router context. Inside router context, just query the naming service. Outside router context, this does NOT query the context naming service. Do that first if you expect a local addressbook. This will log a warning for non-b32 in router context. See interface for suggested implementation. Requires router side to be 0.9.11 or higher. If the router is older, this will return null immediately.- Specified by:
lookupDestin interfaceI2PSession- Overrides:
lookupDestin classI2PSessionImpl- Throws:
I2PSessionException
-
lookupDest
Ask the router to lookup a Destination by host name. Blocking. See above for details.- Specified by:
lookupDestin interfaceI2PSession- Overrides:
lookupDestin classI2PSessionImpl- Parameters:
maxWait- ms- Returns:
- null on failure
- Throws:
I2PSessionException
-
bandwidthLimits
This won't be called, as the reply does not contain a session ID, so it won't be routed back to us- Specified by:
bandwidthLimitsin interfaceI2PSession- Overrides:
bandwidthLimitsin classI2PSessionImpl- Returns:
- null on failure
- Throws:
I2PSessionException
-
updateActivity
protected void updateActivity()- Overrides:
updateActivityin classI2PSessionImpl
-
lastActivity
public long lastActivity()- Overrides:
lastActivityin classI2PSessionImpl
-
setReduced
public void setReduced()- Overrides:
setReducedin classI2PSessionImpl
-