Package net.i2p.router.transport.udp
Class EstablishmentManager
java.lang.Object
net.i2p.router.transport.udp.EstablishmentManager
class EstablishmentManager extends Object
Coordinate the establishment of new sessions - both inbound and outbound.
This has its own thread to add packets to the packet queue when necessary,
as well as to drop any failed establishment attempts.
-
Field Summary
Fields Modifier and Type Field Description static long
MAX_TAG_VALUE
the relay tag is a 4-byte field in the protocolstatic int
OB_MESSAGE_TIMEOUT
max before receiving a response to a single message during outbound establishment -
Constructor Summary
Constructors Constructor Description EstablishmentManager(RouterContext ctx, UDPTransport transport)
-
Method Summary
Modifier and Type Method Description void
establish(OutNetMessage msg)
Send the message to its specified recipient by establishing a connection with them and sending it off.(package private) InboundEstablishState
getInboundState(RemoteHostId from)
Grab the active establishing state(package private) OutboundEstablishState
getOutboundState(RemoteHostId from)
Grab the active establishing state(package private) boolean
isValid(byte[] ip, int port)
Are IP and port valid? This is only for checking the relay response.(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(InetAddress from, int fromPort)
Called from UDPReceiver.(package private) void
receiveRelayResponse(RemoteHostId bob, UDPPacketReader reader)
We are Alice, we sent a RelayRequest to Bob and got a response back.(package private) void
receiveSessionConfirmed(RemoteHostId from, UDPPacketReader reader)
got a SessionConfirmed (should only happen as part of an inbound establishment)(package private) void
receiveSessionCreated(RemoteHostId from, UDPPacketReader reader)
Got a SessionCreated (in response to our outbound SessionRequest)(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(package private) void
receiveSessionDestroy(RemoteHostId from, PeerState state)
Got a SessionDestroy on an established conn(package private) void
receiveSessionRequest(RemoteHostId from, UDPPacketReader reader)
Got a SessionRequest (initiates an inbound establishment)boolean
shouldAllowInboundEstablishment()
Should we allow another inbound establishment? Used to throttle outbound hole punches.void
shutdown()
void
startup()
-
Field Details
-
OB_MESSAGE_TIMEOUT
public static final int OB_MESSAGE_TIMEOUTmax before receiving a response to a single message during outbound establishment- See Also:
- Constant Field Values
-
MAX_TAG_VALUE
public static final long MAX_TAG_VALUEthe relay tag is a 4-byte field in the protocol- See Also:
- Constant Field Values
-
-
Constructor Details
-
Method Details
-
startup
public void startup() -
shutdown
public void shutdown() -
getInboundState
Grab the active establishing state- Returns:
- null if none
-
getOutboundState
Grab the active establishing state- Returns:
- null if none
-
establish
Send the message to its specified recipient by establishing a connection with them and sending it off. This call does not block, and on failure, the message is failed. Note - if we go back to multiple PacketHandler threads, this may need more locking. -
shouldAllowInboundEstablishment
public boolean shouldAllowInboundEstablishment()Should we allow another inbound establishment? Used to throttle outbound hole punches.- Since:
- 0.9.2
-
receiveSessionRequest
Got a SessionRequest (initiates an inbound establishment) -
receiveSessionConfirmed
got a SessionConfirmed (should only happen as part of an inbound establishment) -
receiveSessionCreated
Got a SessionCreated (in response to our outbound SessionRequest) -
receiveSessionDestroy
Got a SessionDestroy on an established conn- Since:
- 0.8.1
-
receiveSessionDestroy
Got a SessionDestroy during outbound establish- Since:
- 0.8.1
-
receiveSessionDestroy
Got a SessionDestroy - maybe during an inbound establish? TODO - PacketHandler won't look up inbound establishes As this packet was essentially unauthenticated (i.e. intro key, not session key) we just log it as it could be spoofed.- Since:
- 0.8.1
-
receiveData
A data packet arrived on an outbound connection being established, which means its complete (yay!). This is a blocking call, more than I'd like...- Returns:
- the new PeerState
-
receiveRelayResponse
We are Alice, we sent a RelayRequest to Bob and got a response back. -
receiveHolePunch
Called from UDPReceiver. Accelerate response to RelayResponse if we haven't sent it yet.- Since:
- 0.9.15
-
isValid
boolean isValid(byte[] ip, int port)Are IP and port valid? This is only for checking the relay response. Allow IPv6 as of 0.9.50. Refuse anybody in the same /16- Since:
- 0.9.3, pkg private since 0.9.45 for PacketBuider
-