java.lang.Object
net.i2p.client.impl.I2PSessionImpl
net.i2p.client.impl.I2PSessionImpl2
net.i2p.client.impl.I2PSimpleSession
- All Implemented Interfaces:
I2PSession, I2CPMessageReader.I2CPMessageEventListener
Create a new session for doing naming and bandwidth queries only. Do not create a Destination. Don't create a producer. Do not send/receive messages to other Destinations. Cannot handle multiple simultaneous queries atm. Could be expanded to ask the router other things.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classOnly map message handlers that we will use.Nested classes/interfaces inherited from class I2PSessionImpl
I2PSessionImpl.AvailabilityNotifier, I2PSessionImpl.StateModifier and TypeClassDescriptionprotected classThis notifies the client of payload messages.protected static enumSession state enumeration.Nested classes/interfaces inherited from interface I2PSession
I2PSession.TunnelPairModifier and TypeInterfaceDescriptionstatic classSimple holder for tunnel pair information.Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intSize of the stream copy buffer, in bytes.Fields inherited from class I2PSessionImpl2
_noEffort, _sendingStates, _sendMessageNonceModifier and TypeFieldDescriptionprotected booleanDon't expect any MSMs from the router for outbound traffic.protected final Map<Long, MessageState> One MessageState object per message in the process of being sent.protected final AtomicLongSource of the per-message replay nonces sent to the router.Fields inherited from class I2PSessionImpl
_availabilityNotifier, _availableMessages, _bwLimits, _bwReceivedLock, _context, _handlerMap, _hostname, _leaseSet, _leaseSetWait, _log, _pendingLookups, _portNum, _producer, _queue, _reader, _sessionListener, _socket, _state, _stateLock, _transientSigningPublicKey, _tunnelStatusListeners, _writer, CACHE_MAX_SIZE, DUMMY_SESSION, LISTEN_PORT, PROP_DOMAIN_SOCKETModifier and TypeFieldDescriptionprotected I2PSessionImpl.AvailabilityNotifierThread that we tell when new messages are available, who then tells us to fetch them.protected Map<Long, MessagePayloadMessage> Map of Long--> MessagePayloadMessage.protected int[]Current bandwidth limits.protected final ObjectLock for bandwidth limit updates.protected final I2PAppContextApp context, kept separate so we can get rid of singletons.protected final I2PClientMessageHandlerMapHandler map for I2CP message types.protected final StringHostname of router - will be null if in RouterContext.protected LeaseSetCurrently granted lease set, or null.protected final ObjectMonitor for waiting until a lease set has been granted.protected final LogLogger for this session.protected final LinkedBlockingQueue<I2PSessionImpl.LookupWaiter> Hashes of lookups we are waiting for.protected final intPort number of router - will be 0 if in RouterContext.protected final I2CPMessageProducerClass that generates new messages.protected I2CPMessageQueueUsed for internal connections to the router.protected I2CPMessageReaderReader that always searches for messages.protected I2PSessionListenerWhere session events are sent.protected SocketSocket for communication.protected I2PSessionImpl.StateCurrent session state.protected final ObjectLock for state transitions.protected SigningPublicKeyTransient signing public key for offline signatures.protected final Set<TunnelStatusListener> Listeners for tunnel status changes (tunnel failures and removals).protected ClientWriterRunnerWriter message queue.protected static final intMaximum size of the lookup cache.(package private) static final SessionIdDummy session ID for messages before a real session is established.static final intDefault I2CP listen port.protected static final StringUse Unix domain socket (or similar) to connect to a router.Fields inherited from interface I2PSession
PORT_ANY, PORT_UNSPECIFIED, PROTO_ANY, PROTO_DATAGRAM, PROTO_DATAGRAM_RAW, PROTO_DATAGRAM2, PROTO_DATAGRAM3, PROTO_STREAMING, PROTO_UNSPECIFIEDModifier and TypeFieldDescriptionstatic final intAny port.static final intUnspecified port.static final intAny protocol.static final intA repliable and signed datagram.static final intA raw (unsigned, unrepliable) datagram.static final intA repliable and signed datagram.static final intA repliable but unsigned datagram.static final intStreaming protocol.static final intUnspecified protocol.Constructor Summary
ConstructorsConstructorDescriptionI2PSimpleSession(I2PAppContext context, Properties options) Create a new session for doing naming and bandwidth queries only.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidconnect()Connect to the router and establish a session.voidupdateOptions(Properties options) Ignore, does nothing.Methods inherited from class I2PSessionImpl2
addMuxedSessionListener, addSessionListener, addTunnelStatusListener, destroySession, getCurrentTunnelPair, getTimeout, notifyPoolShuttingDown, notifyTunnelFailed, notifyTunnelRemoved, rebuildTunnels, receiveMessage, receiveStatus, reconnect, removeListener, removeTunnelStatusListener, sendBestEffort, sendBestEffort, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendNoEffort, setCurrentTunnelPair, shouldCompress, startVerifyUsage, switchToNewTunnelModifier and TypeMethodDescriptionvoidaddMuxedSessionListener(I2PSessionMuxedListener l, int proto, int port) Register a muxed session listener.voidaddSessionListener(I2PSessionListener lsnr, int proto, int port) Register a session listener.voidRegister a tunnel status listener.voiddestroySession(boolean sendDisconnect) Destroy the I2P session, after clearing the message send states.Return the current tunnel pair.protected longWait this long for the router to accept a sent message, in ms.protected voidnotifyPoolShuttingDown(String poolName, boolean isInbound) Notify all tunnel status listeners of pool shutdown.protected voidnotifyTunnelFailed(String poolName, boolean isInbound) Notify all tunnel status listeners of a tunnel failure.protected voidNotify all tunnel status listeners of a tunnel removal.voidRebuild the tunnel set.byte[]receiveMessage(int msgId) Receive a message from the router, decompressing it unless it was sent uncompressed.voidreceiveStatus(int msgId, long nonce, int status) Only call this with nonzero status, i.e.protected booleanReconnect the I2CP session.voidremoveListener(int proto, int port) Remove a registered listener.voidRemove a tunnel status listener.protected booleansendBestEffort(Destination dest, byte[] payload, long expires, int flags) Send a best-effort message with the given flags.protected booleansendBestEffort(Destination dest, byte[] payload, SessionKey keyUsed, Set<SessionTag> tagsSent, long expires) Send a message with best effort delivery.booleansendMessage(Destination dest, byte[] payload) Unused, see MuxedImpl override.booleansendMessage(Destination dest, byte[] payload, int offset, int size) Send an I2CP message.booleansendMessage(Destination dest, byte[] payload, int proto, int fromport, int toport) Send an I2CP message.booleansendMessage(Destination dest, byte[] payload, int offset, int size, int proto, int fromport, int toport, SendMessageOptions options) Send an I2CP message.longsendMessage(Destination dest, byte[] payload, int offset, int size, int proto, int fromport, int toport, SendMessageOptions options, SendMessageStatusListener listener) Send an I2CP message.booleansendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent) Send a message with session key and tags.booleansendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, int proto, int fromport, int toport) Send an I2CP message.booleansendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expires) Unused? See the MuxedImpl override.booleansendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expire, int proto, int fromport, int toport) Send an I2CP message.booleansendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expire, int proto, int fromport, int toport, int flags) Send an I2CP message.booleansendMessage(Destination dest, byte[] payload, SessionKey keyUsed, Set<SessionTag> tagsSent) Send a message with session key and tags.protected booleansendNoEffort(Destination dest, byte[] payload, long expires, int flags) Same asI2PSessionImpl2.sendBestEffort(Destination, byte[], SessionKey, Set, long), except we do not expect any MessageStatusMessage responses - not for accepted, or success, or failure.voidCurrent tunnel pair in use.protected booleanshouldCompress(int size) Return whether compression should be used.protected voidFire up a periodic task to check for unclaimed messages.booleanSwitch to the new tunnel set.Methods inherited from class I2PSessionImpl
addNewMessage, addSubsession, bandwidthLimits, bwReceived, changeState, clearCache, dateUpdated, destLookupFailed, destLookupFailed, destReceived, destReceived, destroySession, discardMessage, disconnect, disconnected, getContext, getFastReceive, getHandlerMap, getLastLS2SignTime, getLeaseSet, getMyDestination, getName, getOfflineExpiration, getOfflineSignature, getOptions, getPrefix, getPrivateKey, getProducer, getRouterVersion, getSessionId, getSubsessions, getTransientSigningPublicKey, getTunnelBuildTimeout, isClosed, isOffline, lastActivity, lookupDest, lookupDest, lookupDest, lookupDest, lookupDest, lookupDest, lookupDest2, messageReceived, propagateError, readError, removeSubsession, reportAbuse, sendBlindingInfo, sendMessage, sendMessage_unchecked, setLastLS2SignTime, setLeaseSet, setReduced, setSessionId, setSessionListener, shouldReconnect, supportsLS2, toString, updateActivity, verifyOpen, waitForDateModifier and TypeMethodDescriptionvoidReceive a payload message and let the app know its available.addSubsession(InputStream privateKeyStream, Properties opts) Router must be connected or was connected...int[]Blocking.(package private) voidbwReceived(int[] limits) Called by the message handler.protected voidchangeState(I2PSessionImpl.State state) Change the session state.static voidClear the lookup cache.(package private) voiddateUpdated(String routerVersion) Update the router version and related feature support flags.(package private) voiddestLookupFailed(long nonce, int code) Called by the message handler on reception of HostReplyMessage.(package private) voidCalled by the message handler on reception of DestReplyMessage.(package private) voiddestReceived(long nonce, Destination d) Called by the message handler on reception of HostReplyMessage.(package private) voidCalled by the message handler on reception of DestReplyMessage.voidTear down the session, and do NOT reconnect.voiddiscardMessage(int msgId) Throw away the received message, we don't want it.protected voidWill interrupt a connect in progress.voiddisconnected(I2CPMessageReader reader) The I2CPMessageEventListener callback.(package private) I2PAppContextFor Subsessions.booleanDoes this session support fast receive?(package private) I2PClientMessageHandlerMapFor Subsessions.(package private) longThe published timestamp of the last LS2 we signed.Current lease set published by this session.Retrieve the destination of the session.protected StringgetName()Session name for logging.longJava time (ms) or 0 if not initialized or does not have offline keys.Null on error or if not initialized or does not have offline keys.Retrieve the configuration options, filtered.protected final StringTry hard to make a decent identifier as this will appear in error logs.Retrieve the signing SigningPrivateKey.(package private) I2CPMessageProducerRetrieve the helper that generates I2CP messages.Always valid in RouterContext.(package private) SessionIdRetrieve the session's ID.List of subsessions, non-null, does not include the primary session.Null on error or if not initialized or does not have offline keys.(package private) static intgetTunnelBuildTimeout(String sessionValue, String contextValue) Parse the tunnel build timeout, shared with the instance method and tests.booleanisClosed()Has the session been closed (or not yet connected)? False when open and during transitions.booleanDoes this session have offline and transient keys?longTime of last session activity in milliseconds.lookupDest(String name) Ask the router to lookup a Destination by host name.lookupDest(String name, long maxWait) Ask the router to lookup a Destination by host name.lookupDest(String name, long maxWait, LookupCallback callback) Lookup a Destination by hash.lookupDest(Hash h) Blocking.lookupDest(Hash h, long maxWait) Blocking.lookupDest(Hash h, long maxWait, LookupCallback callback) Lookup a Destination by hostname.lookupDest2(String name, long maxWait) Ask the router to lookup a Destination by host name.voidmessageReceived(I2CPMessageReader reader, I2CPMessage message) The I2CPMessageEventListener callback.(package private) voidpropagateError(String msg, Throwable error) Pass off the error to the listener Misspelled, oh well.voidreadError(I2CPMessageReader reader, Exception error) The I2CPMessageEventListener callback.voidremoveSubsession(I2PSession session) No-op, this session has no subsessions.voidreportAbuse(int msgId, int severity) Report abuse with regards to the given messageId.voidSend blinding info to a peer.(package private) voidsendMessage(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) voidsendMessage_unchecked(I2CPMessage message) Deliver an I2CP message to the router.(package private) voidsetLastLS2SignTime(long now) The published timestamp of the last LS2 we signed.(package private) voidsetLeaseSet(LeaseSet ls) Lease set published by this session.voidMark the session as reduced.(package private) voidSession ID assigned by the router.voidConfigure the listener.protected booleanWhether the session should attempt reconnection on disconnect.booleanDoes this session support LS2?toString()protected voidUpdate the last activity timestamp.protected voidThrows I2PSessionException if uninitialized, closed or closing.protected voidWait for a SetDate response from the router.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface I2PSession
getDecryptionKeyModifier and TypeMethodDescriptionRetrieve the decryption PrivateKey associated with the Destination.
Field Details
BUF_SIZE
private static final int BUF_SIZESize of the stream copy buffer, in bytes.- See Also:
Constructor Details
I2PSimpleSession
Create a new session for doing naming and bandwidth queries only. Do not create a destination.- Parameters:
context- the application context the session and its message handlers are built aroundoptions- set of options to configure the router with, if null will use System properties- Throws:
I2PSessionException- if there is a problem
Method Details
connect
Connect to the router and establish a session. This call blocks until a session is granted.NOT threadsafe, do not call from multiple threads.
- Specified by:
connectin interfaceI2PSession- Overrides:
connectin classI2PSessionImpl- Throws:
I2PSessionException- if there is a configuration error or the router is not reachable
updateOptions
Ignore, does nothing.- Specified by:
updateOptionsin interfaceI2PSession- Overrides:
updateOptionsin classI2PSessionImpl- Parameters:
options- non-null