public class EstablishmentManager extends Object
| Modifier and Type | Class and Description |
|---|---|
static class | EstablishmentManager.TokenToken used for SSU2 session establishment and validation. |
| Modifier and Type | Field and Description |
|---|---|
(package private) static AtomicLong | DATA_MESSAGE_TIMEOUTfor the DSM and or netdb store |
static long | IB_TOKEN_EXPIRATIONIB_TOKEN_EXPIRATION. |
(package private) static AtomicLong | MAX_IB_ESTABLISH_TIMEKill any inbound that takes more than this. |
(package private) static AtomicLong | MAX_OB_ESTABLISH_TIMEKill any outbound that takes more than this. |
static long | MAX_TAG_VALUEthe relay tag is a 4-byte field in the protocol |
static long | OB_MESSAGE_TIMEOUTMax wait before receiving a response to a single message during outbound establishment |
| Constructor and Description |
|---|
EstablishmentManager(RouterContext ctx,
UDPTransport transport)EstablishmentManager. |
| Modifier and Type | Method and Description |
|---|---|
void | addOutboundToken(RemoteHostId peer,
long token,
long expires)Remember a token that can be used later to connect to the peer |
void | establish(OutNetMessage msg)Send the message to its specified recipient by establishing a connection
with them and sending it off. |
static int | getDefaultHighMaxConcurrentEstablish()Get the default high max concurrent establish |
static int | getDefaultLowMaxConcurrentEstablish()Get the default low max concurrent establish |
(package private) InboundEstablishState | getInboundState(RemoteHostId from)Grab the active establishing state |
EstablishmentManager.Token | getInboundToken(RemoteHostId peer)Get a token that can be used later for the peer to connect to us |
EstablishmentManager.Token | getInboundToken(RemoteHostId peer,
long expiration)Get a token that can be used later for the peer to connect to us. |
static int | getMaxQueuedOutbound() |
DatabaseStoreMessage | getOurInfo()A database store message with our router info |
(package private) OutboundEstablishState | getOutboundState(RemoteHostId from)Grab the active establishing state |
long | getOutboundToken(RemoteHostId peer)Get a token to connect to the peer |
void | ipChanged(boolean isIPv6)Remove our tokens for this length |
boolean | isConnecting(Hash dest)Check if an outbound SSU handshake is in progress for the given peer. |
boolean | isInboundTokenValid(RemoteHostId peer,
long token)Is the token from this peer valid? |
(package private) boolean | isValid(byte[] ip,
int port)Are IP and port valid? This is only for checking the relay response. |
static String | parseReason(int reasonCode)parseReason. |
void | portChanged()Remove all tokens |
(package private) PeerState | receiveData(OutboundEstablishState state)A data packet arrived on an outbound connection being established, which
means its complete (yay!). |
(package private) void | receiveHolePunch(RemoteHostId id,
UDPPacket packet)Called from PacketHandler. |
(package private) void | receiveRelayResponse(PeerState2 bob,
long nonce,
int code,
byte[] data)We are Alice, we sent a RelayRequest to Bob and got a RelayResponse back. |
(package private) void | receiveRetry(OutboundEstablishState2 state,
UDPPacket packet)Got a Retry (in response to our outbound SessionRequest or TokenRequest)
SSU 2 only. |
(package private) void | receiveSessionConfirmed(InboundEstablishState2 state,
UDPPacket packet)got a SessionConfirmed (should only happen as part of an inbound
establishment)
SSU 2 only. |
(package private) void | receiveSessionCreated(OutboundEstablishState2 state,
UDPPacket packet)Got a SessionCreated (in response to our outbound SessionRequest)
SSU 2 only. |
(package private) void | receiveSessionDestroy(RemoteHostId from)Got a SessionDestroy - maybe during an inbound establish?
TODO - PacketHandler won't look up inbound establishes
As this packet was essentially unauthenticated (i.e. |
(package private) void | receiveSessionDestroy(RemoteHostId from,
OutboundEstablishState state)Got a SessionDestroy during outbound establish
SSU 2 |
(package private) void | receiveSessionDestroy(RemoteHostId from,
PeerState state)Got a SessionDestroy on an established conn
SSU 2 |
(package private) void | receiveSessionOrTokenRequest(RemoteHostId from,
InboundEstablishState2 state,
UDPPacket packet)Got a SessionRequest OR a TokenRequest (initiates an inbound establishment)
SSU 2 only. |
static void | setDefaultHighMaxConcurrentEstablish(int val)Set the default high max concurrent establish, bounded 64-8192 |
static void | setDefaultLowMaxConcurrentEstablish(int val)Set the default low max concurrent establish, bounded 32-4096 |
static void | setMaxQueuedOutbound(int max)Set the max queued outbound connections (called by Tuner). |
boolean | shouldAllowInboundEstablishment()Should we allow another inbound establishment? |
void | shutdown()shutdown. |
void | startup()startup. |
static final AtomicLong DATA_MESSAGE_TIMEOUT
public static final long IB_TOKEN_EXPIRATION
static final AtomicLong MAX_IB_ESTABLISH_TIME
static final AtomicLong MAX_OB_ESTABLISH_TIME
public static final long MAX_TAG_VALUE
public static final long OB_MESSAGE_TIMEOUT
public EstablishmentManager(RouterContext ctx, UDPTransport transport)
public void addOutboundToken(RemoteHostId peer, long token, long expires)
token - nonzeroexpires - absolute timepublic void establish(OutNetMessage msg)
public static int getDefaultHighMaxConcurrentEstablish()
public static int getDefaultLowMaxConcurrentEstablish()
InboundEstablishState getInboundState(RemoteHostId from)
public EstablishmentManager.Token getInboundToken(RemoteHostId peer)
public EstablishmentManager.Token getInboundToken(RemoteHostId peer, long expiration)
expiration - time from now, will be reduced if necessary based on cache eviction time.public static int getMaxQueuedOutbound()
public DatabaseStoreMessage getOurInfo()
OutboundEstablishState getOutboundState(RemoteHostId from)
public long getOutboundToken(RemoteHostId peer)
public void ipChanged(boolean isIPv6)
public boolean isConnecting(Hash dest)
dest - router hashpublic boolean isInboundTokenValid(RemoteHostId peer, long token)
boolean isValid(byte[] ip,
int port)public static String parseReason(int reasonCode)
public void portChanged()
PeerState receiveData(OutboundEstablishState state)
void receiveHolePunch(RemoteHostId id, UDPPacket packet)
id - non-nullpacket - header already decryptedvoid receiveRelayResponse(PeerState2 bob, long nonce, int code, byte[] data)
data - including nonce, including token if code == 0void receiveRetry(OutboundEstablishState2 state, UDPPacket packet)
void receiveSessionConfirmed(InboundEstablishState2 state, UDPPacket packet)
state - non-nullpacket - header decrypted onlyvoid receiveSessionCreated(OutboundEstablishState2 state, UDPPacket packet)
state - non-nullpacket - header decrypted onlyvoid receiveSessionDestroy(RemoteHostId from)
void receiveSessionDestroy(RemoteHostId from, OutboundEstablishState state)
void receiveSessionDestroy(RemoteHostId from, PeerState state)
void receiveSessionOrTokenRequest(RemoteHostId from, InboundEstablishState2 state, UDPPacket packet)
state - as looked up in PacketHandler, but null unless retransmitted or retry sentpacket - header decrypted onlypublic static void setDefaultHighMaxConcurrentEstablish(int val)
public static void setDefaultLowMaxConcurrentEstablish(int val)
public static void setMaxQueuedOutbound(int max)
public boolean shouldAllowInboundEstablishment()
public void shutdown()
public void startup()