class ConnectionManager extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
ConnectionManager.PingNotifier
The callback interface for a pong.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
PROP_BLACKLIST |
(package private) static String |
PROP_MAX_PONG_DELAY |
| Constructor and Description |
|---|
ConnectionManager(I2PAppContext context,
I2PSession session,
ConnectionOptions defaultOptions,
IncomingConnectionFilter connectionFilter)
Manage all conns for this session
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
answerPings()
do we respond to pings that aren't on an existing connection?
|
Connection |
connect(Destination peer,
ConnectionOptions opts,
I2PSession session)
Build a new connection to the given peer.
|
void |
disconnectAllHard()
Something b0rked hard, so kill all of our connections without mercy.
|
boolean |
getAllowIncomingConnections() |
(package private) Connection |
getConnectionByInboundId(long id) |
(package private) Connection |
getConnectionByOutboundId(long id)
not guaranteed to be unique, but in case we receive more than one packet
on an inbound connection that we havent ack'ed yet...
|
ConnectionHandler |
getConnectionHandler() |
MessageHandler |
getMessageHandler() |
PacketHandler |
getPacketHandler() |
PacketQueue |
getPacketQueue() |
I2PSession |
getSession()
This is the primary session only
|
long |
getSoTimeout()
Get the socket accept() timeout.
|
Set<Connection> |
listConnections()
return a set of Connection objects
|
boolean |
ping(Destination peer,
int fromPort,
int toPort,
long timeoutMs)
blocking
|
boolean |
ping(Destination peer,
int fromPort,
int toPort,
long timeoutMs,
boolean blocking) |
boolean |
ping(Destination peer,
int fromPort,
int toPort,
long timeoutMs,
boolean blocking,
ConnectionManager.PingNotifier notifier) |
byte[] |
ping(Destination peer,
int fromPort,
int toPort,
long timeoutMs,
byte[] payload)
blocking
|
boolean |
ping(Destination peer,
long timeoutMs)
blocking
|
Connection |
receiveConnection(Packet synPacket)
Create a new connection based on the SYN packet we received.
|
boolean |
receivePing(Connection con,
Packet ping)
Process a ping by checking for throttling, etc., then sending a pong.
|
(package private) void |
receivePong(long pingId,
ByteArray payload) |
void |
removeConnection(Connection con)
Drop the (already closed) connection on the floor.
|
void |
setAllowIncomingConnections(boolean allow) |
void |
setSoTimeout(long x)
Set the socket accept() timeout.
|
void |
shutdown()
Kill all connections and the timers.
|
String |
toString() |
void |
updateOptions() |
void |
updateOptsFromShare(Connection con) |
void |
updateShareOpts(Connection con) |
boolean |
wasRecentlyClosed(long inboundID)
Was this conn recently closed?
|
public static final String PROP_BLACKLIST
static final String PROP_MAX_PONG_DELAY
public ConnectionManager(I2PAppContext context, I2PSession session, ConnectionOptions defaultOptions, IncomingConnectionFilter connectionFilter)
session - the primary session, packets may come in on subsessions alsopublic boolean answerPings()
public Connection connect(Destination peer, ConnectionOptions opts, I2PSession session)
peer - Destination to contact, non-nullopts - Connection's optionssession - generally the session from the constructor, but could be a subsessionpublic void disconnectAllHard()
public boolean getAllowIncomingConnections()
Connection getConnectionByInboundId(long id)
Connection getConnectionByOutboundId(long id)
public ConnectionHandler getConnectionHandler()
public MessageHandler getMessageHandler()
public PacketHandler getPacketHandler()
public PacketQueue getPacketQueue()
public I2PSession getSession()
public long getSoTimeout()
public Set<Connection> listConnections()
public boolean ping(Destination peer, int fromPort, int toPort, long timeoutMs)
timeoutMs - greater than zeropublic boolean ping(Destination peer, int fromPort, int toPort, long timeoutMs, boolean blocking)
timeoutMs - greater than zeropublic boolean ping(Destination peer, int fromPort, int toPort, long timeoutMs, boolean blocking, ConnectionManager.PingNotifier notifier)
timeoutMs - greater than zeronotifier - may be nullpublic byte[] ping(Destination peer, int fromPort, int toPort, long timeoutMs, byte[] payload)
timeoutMs - greater than zeropayload - non-null, include in packet, up to 32 bytes may be returned in pong
not copied, do not modifypublic boolean ping(Destination peer, long timeoutMs)
timeoutMs - greater than zeropublic Connection receiveConnection(Packet synPacket)
synPacket - SYN packet to processpublic boolean receivePing(Connection con, Packet ping)
con - null if unknownping - Ping packet to process, must have From and Sig fields,
with signature already verified, only if answerPings() returned truevoid receivePong(long pingId,
ByteArray payload)
payload - may be nullpublic void removeConnection(Connection con)
con - Connection to drop.public void setAllowIncomingConnections(boolean allow)
public void setSoTimeout(long x)
x - public void shutdown()
public void updateOptions()
public void updateOptsFromShare(Connection con)
public void updateShareOpts(Connection con)
public boolean wasRecentlyClosed(long inboundID)