I2PSession
, I2CPMessageReader.I2CPMessageEventListener
I2PSessionImpl2
public abstract class I2PSessionImpl extends java.lang.Object implements I2PSession, I2CPMessageReader.I2CPMessageEventListener
修飾子とタイプ | クラス | 説明 |
---|---|---|
protected class |
I2PSessionImpl.AvailabilityNotifier |
This notifies the client of payload messages.
|
protected static class |
I2PSessionImpl.State |
修飾子とタイプ | フィールド | 説明 |
---|---|---|
protected I2PSessionImpl.AvailabilityNotifier |
_availabilityNotifier |
thread that we tell when new messages are available who then tells us
to fetch them.
|
protected java.util.Map<java.lang.Long,MessagePayloadMessage> |
_availableMessages |
map of Long --> MessagePayloadMessage
|
protected int[] |
_bwLimits |
|
protected java.lang.Object |
_bwReceivedLock |
|
protected I2PAppContext |
_context |
used to separate things out so we can get rid of singletons
|
protected I2PClientMessageHandlerMap |
_handlerMap |
|
protected java.lang.String |
_hostname |
hostname of router - will be null if in RouterContext
|
protected LeaseSet |
_leaseSet |
currently granted lease set, or null
|
protected java.lang.Object |
_leaseSetWait |
monitor for waiting until a lease set has been granted
|
protected Log |
_log |
|
protected java.util.concurrent.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 java.net.Socket |
_socket |
socket for comm
|
protected I2PSessionImpl.State |
_state |
|
protected java.lang.Object |
_stateLock |
|
protected ClientWriterRunner |
_writer |
writer message queue
|
protected static int |
CACHE_MAX_SIZE |
|
static int |
LISTEN_PORT |
|
protected static java.lang.String |
PROP_DOMAIN_SOCKET |
Use Unix domain socket (or similar) to connect to a router
|
protected static java.lang.String |
PROP_ENABLE_SSL |
SSL interface (only) @since 0.8.3
|
protected static java.lang.String |
PROP_PW |
|
protected static java.lang.String |
PROP_USER |
PORT_ANY, PORT_UNSPECIFIED, PROTO_ANY, PROTO_DATAGRAM, PROTO_DATAGRAM_RAW, PROTO_STREAMING, PROTO_UNSPECIFIED
修飾子 | コンストラクタ | 説明 |
---|---|---|
protected |
I2PSessionImpl(I2PSessionImpl primary,
java.io.InputStream destKeyStream,
java.util.Properties options) |
|
|
I2PSessionImpl(I2PAppContext context,
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
As of 0.9.19, defaults in options are honored.
|
protected |
I2PSessionImpl(I2PAppContext context,
java.util.Properties options,
I2PClientMessageHandlerMap handlerMap) |
for extension by SimpleSession (no dest)
|
修飾子とタイプ | メソッド | 説明 |
---|---|---|
void |
addNewMessage(MessagePayloadMessage msg) |
Recieve a payload message and let the app know its available
|
I2PSession |
addSubsession(java.io.InputStream privateKeyStream,
java.util.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(java.lang.String routerVersion) |
|
(package private) void |
destLookupFailed(long nonce) |
Called by the message handler
on reception of HostReplyMessage
|
(package private) void |
destLookupFailed(Hash h) |
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
|
(package private) void |
destReceived(Destination d) |
Called by the message handler
on reception of DestReplyMessage
|
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
|
PrivateKey |
getDecryptionKey() |
Retrieve the decryption PrivateKey
|
boolean |
getFastReceive() |
|
(package private) I2PClientMessageHandlerMap |
getHandlerMap() |
For Subsessions
|
(package private) LeaseSet |
getLeaseSet() |
|
Destination |
getMyDestination() |
Retrieve the destination of the session
|
(package private) java.util.Properties |
getOptions() |
Retrieve the configuration options, filtered.
|
protected java.lang.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
|
(package private) SessionId |
getSessionId() |
Retrieve the session's ID
|
java.util.List<I2PSession> |
getSubsessions() |
|
boolean |
isClosed() |
Has the session been closed (or not yet connected)?
False when open and during transitions.
|
long |
lastActivity() |
|
Destination |
lookupDest(java.lang.String name) |
Ask the router to lookup a Destination by host name.
|
Destination |
lookupDest(java.lang.String name,
long maxWait) |
Ask the router to lookup a Destination by host name.
|
Destination |
lookupDest(Hash h) |
Blocking.
|
Destination |
lookupDest(Hash h,
long maxWait) |
Blocking.
|
void |
messageReceived(I2CPMessageReader reader,
I2CPMessage message) |
The I2CPMessageEventListener callback.
|
(package private) void |
propogateError(java.lang.String msg,
java.lang.Throwable error) |
Pass off the error to the listener
Misspelled, oh well.
|
void |
readError(I2CPMessageReader reader,
java.lang.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
|
(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 |
sendMessage_unchecked(I2CPMessage message) |
Deliver an I2CP message to the router.
|
(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
|
java.lang.String |
toString() |
|
protected void |
updateActivity() |
|
void |
updateOptions(java.util.Properties options) |
Update the tunnel and bandwidth settings
|
protected void |
verifyOpen() |
Throws I2PSessionException if uninitialized, closed or closing.
|
protected void |
waitForDate() |
addMuxedSessionListener, addSessionListener, removeListener, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage
protected final Log _log
protected volatile LeaseSet _leaseSet
protected final java.lang.String _hostname
protected final int _portNum
protected java.net.Socket _socket
protected I2CPMessageReader _reader
protected ClientWriterRunner _writer
protected I2CPMessageQueue _queue
protected I2PSessionListener _sessionListener
protected final I2CPMessageProducer _producer
protected java.util.Map<java.lang.Long,MessagePayloadMessage> _availableMessages
protected final java.util.concurrent.LinkedBlockingQueue<net.i2p.client.impl.I2PSessionImpl.LookupWaiter> _pendingLookups
protected final java.lang.Object _bwReceivedLock
protected volatile int[] _bwLimits
protected final I2PClientMessageHandlerMap _handlerMap
protected final I2PAppContext _context
protected final java.lang.Object _leaseSetWait
protected I2PSessionImpl.State _state
protected final java.lang.Object _stateLock
protected I2PSessionImpl.AvailabilityNotifier _availabilityNotifier
protected static final int CACHE_MAX_SIZE
protected static final java.lang.String PROP_ENABLE_SSL
protected static final java.lang.String PROP_USER
protected static final java.lang.String PROP_PW
protected static final java.lang.String PROP_DOMAIN_SOCKET
public static final int LISTEN_PORT
protected I2PSessionImpl(I2PAppContext context, java.util.Properties options, I2PClientMessageHandlerMap handlerMap)
protected I2PSessionImpl(I2PSessionImpl primary, java.io.InputStream destKeyStream, java.util.Properties options) throws I2PSessionException
public I2PSessionImpl(I2PAppContext context, java.io.InputStream destKeyStream, java.util.Properties options) throws I2PSessionException
destKeyStream
- stream containing the private key data,
format is specified in PrivateKeyFile
options
- set of options to configure the router with, if null will use System propertiesI2PSessionException
- if there is a problem loading the private keysvoid dateUpdated(java.lang.String routerVersion)
routerVersion
- as rcvd in the SetDateMessage, may be null for very old routerspublic I2PSession addSubsession(java.io.InputStream privateKeyStream, java.util.Properties opts) throws I2PSessionException
addSubsession
インタフェース内 I2PSession
privateKeyStream
- null for transient, if non-null must have same encryption keys as primary session
and different signing keysopts
- subsession options if any, may be nullI2PSessionException
public void removeSubsession(I2PSession session)
removeSubsession
インタフェース内 I2PSession
public java.util.List<I2PSession> getSubsessions()
getSubsessions
インタフェース内 I2PSession
public void updateOptions(java.util.Properties options)
updateOptions
インタフェース内 I2PSession
options
- non-nullpublic boolean getFastReceive()
void setLeaseSet(LeaseSet ls)
LeaseSet getLeaseSet()
protected void changeState(I2PSessionImpl.State state)
public void connect() throws I2PSessionException
connect
インタフェース内 I2PSession
I2PSessionException
- if there is a configuration error or the router is
not reachableprotected void waitForDate() throws java.lang.InterruptedException, java.io.IOException
java.lang.InterruptedException
java.io.IOException
public byte[] receiveMessage(int msgId) throws I2PSessionException
receiveMessage
インタフェース内 I2PSession
msgId
- message to fetchI2PSessionException
public void reportAbuse(int msgId, int severity) throws I2PSessionException
reportAbuse
インタフェース内 I2PSession
msgId
- message that was abusive (or -1 for not message related)severity
- how abusiveI2PSessionException
public abstract void receiveStatus(int msgId, long nonce, int status)
public void addNewMessage(MessagePayloadMessage msg)
protected void startVerifyUsage()
public void messageReceived(I2CPMessageReader reader, I2CPMessage message)
messageReceived
インタフェース内 I2CPMessageReader.I2CPMessageEventListener
reader
- unusedmessage
- the I2CPMessagepublic void readError(I2CPMessageReader reader, java.lang.Exception error)
readError
インタフェース内 I2CPMessageReader.I2CPMessageEventListener
reader
- unusederror
- non-nullpublic Destination getMyDestination()
getMyDestination
インタフェース内 I2PSession
public PrivateKey getDecryptionKey()
getDecryptionKey
インタフェース内 I2PSession
public SigningPrivateKey getPrivateKey()
getPrivateKey
インタフェース内 I2PSession
I2CPMessageProducer getProducer()
I2PClientMessageHandlerMap getHandlerMap()
I2PAppContext getContext()
java.util.Properties getOptions()
SessionId getSessionId()
void setSessionId(SessionId id)
public void setSessionListener(I2PSessionListener lsnr)
setSessionListener
インタフェース内 I2PSession
lsnr
- listener to retrieve eventspublic boolean isClosed()
isClosed
インタフェース内 I2PSession
protected void verifyOpen() throws I2PSessionException
I2PSessionException
void sendMessage(I2CPMessage message) throws I2PSessionException
I2PSessionException
- if the message is malformed or there is an error writing it outvoid sendMessage_unchecked(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)
error
- non-nullpublic void destroySession()
destroySession
インタフェース内 I2PSession
public void destroySession(boolean sendDisconnect)
public void disconnected(I2CPMessageReader reader)
disconnected
インタフェース内 I2CPMessageReader.I2CPMessageEventListener
reader
- unusedprotected void disconnect()
protected boolean shouldReconnect()
protected boolean reconnect()
protected java.lang.String getPrefix()
void destReceived(Destination d)
d
- non-nullvoid destLookupFailed(Hash h)
h
- non-nullvoid destReceived(long nonce, Destination d)
d
- non-nullvoid destLookupFailed(long nonce)
void bwReceived(int[] i)
public static void clearCache()
public Destination lookupDest(Hash h) throws I2PSessionException
lookupDest
インタフェース内 I2PSession
I2PSessionException
public Destination lookupDest(Hash h, long maxWait) throws I2PSessionException
lookupDest
インタフェース内 I2PSession
maxWait
- msI2PSessionException
public Destination lookupDest(java.lang.String name) throws I2PSessionException
lookupDest
インタフェース内 I2PSession
I2PSessionException
public Destination lookupDest(java.lang.String name, long maxWait) throws I2PSessionException
lookupDest
インタフェース内 I2PSession
maxWait
- msI2PSessionException
public int[] bandwidthLimits() throws I2PSessionException
bandwidthLimits
インタフェース内 I2PSession
I2PSessionException
protected void updateActivity()
public long lastActivity()
public void setReduced()
public java.lang.String toString()
toString
クラス内 java.lang.Object