java.lang.Object
net.i2p.router.transport.udp.InboundEstablishState
net.i2p.router.transport.udp.InboundEstablishState2
- All Implemented Interfaces:
SSU2Payload.PayloadCallback
Data for a new connection being established, where the remote peer has initiated the connection with us. In other words, they are Alice and we are Bob.
SSU2 only.
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classResult ofselectSessionAddress(List, boolean, byte[]): the chosen RouterInfo address and, when the peer advertises a different IP than the sender's source address, an explanatory mismatch message.(package private) static classFor throwing out of gotRI().Nested classes/interfaces inherited from class InboundEstablishState
InboundEstablishState.InboundStateModifier and TypeClassDescriptionstatic enumStates for inbound SSU session establishment.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final InetSocketAddressAlice's socket address.private final BanLoggerRecords why routers were banned.private final HandshakeStateHandshake state for the ratchet keys.private intThe MTU agreed for the new peer.private PeerState2The peer state being built, once created.Data packets queued before the handshake finished.private final longConnection id we receive with.private byte[]Second header encryption key for receiving.private final longConnection id we send with.private byte[]First header encryption key for sending.private byte[]Second header encryption key for sending.private byte[][]Session Confirmed fragments for retransmission.private byte[]Session Created packet held for retransmission.private longOur clock skew to Alice, in ms.private longWhen the handshake started.private final longThe handshake token echoed to Alice.private final UDPTransportThe SSU transport we serve.private final intVersion of the handshake.private static final booleanTrue to enforce the handshake token.(package private) static final intDrop it: a temporary sent port or no introduction support on the peer's family.(package private) static final intKeep the introduction request;createPeerState()sends the relay tag with ACK 0.(package private) static final intDrop it: the peer advertises itself reachable; relaying is not required.(package private) static final intDrop it: the peer's version is too old to relay to.private static final intBytes of the source IPv6 prefix that identify an address as this router's own.private static final longMaximum clock skew accepted in a handshake.private static final StringFirst version supporting SSU2 relays.private static final longA RouterInfo published more than 2 minutes in the future is clock-skewed.private static final longA RouterInfo published more than 1 hour in the past is clock-skewed.private static final intSSU 1.0 mtu option value that maps to MIN_MTU; workaround for a bug in 1.9.0.private static final intFirst byte of the Yggdrasil protocol.private static final intA yggdrasil IPv6 address starts with 0x02 or 0x03 (first byte 0b0000001x).Fields inherited from class InboundEstablishState
_aliceIP, _alicePort, _bobIP, _bobPort, _context, _createdSentCount, _currentState, _establishBegin, _introductionRequested, _lastSend, _log, _nextSend, _receivedConfirmedIdentity, _receivedUnconfirmedIdentity, _remoteHostId, _rtt, _sentRelayTag, RETRANSMIT_DELAYModifier and TypeFieldDescriptionprotected final byte[]Alice's IP address from the SessionCreated message.protected final intAlice's port number.protected byte[]Our IP address as seen by Alice.protected final intOur port number as seen by Alice.protected final RouterContextRouter context.protected intCount of SessionCreated packets sent (for exponential backoff).protected InboundEstablishState.InboundStateCurrent state in the inbound establishment protocol.protected final longTimestamp when establishment began.protected booleanWhether Alice requested introduction (default true for SSU 1, false for SSU 2).protected longLast packet send time.protected final LogLogger.protected longNext scheduled send time.protected RouterIdentityIdentity after successful signature verification.protected RouterIdentityIdentity before signature verification.protected final RemoteHostIdRemote host identifier for uniqueness.protected intEstimated round-trip time.protected longRelay tag we sent to Alice.protected static final longBasic delay before backoff Transmissions at 0, 1, 3, 7 sec.Constructor Summary
ConstructorsConstructorDescriptionInboundEstablishState2(RouterContext ctx, UDPTransport transport, UDPPacket packet) Start a new handshake with the given incoming packet, which must be a Session Request or Token Request.Method Summary
Modifier and TypeMethodDescriptionvoidRecord that we sent the SessionCreated packet.voidNote that we just sent the SessionCreated packet, and save it for retransmission.private voidCreates the PeerState and stores in _pstate.private PeerStateDestroyedcreatePeerStateDestroyed(int reason) Creates a PeerStateDestroyed after msg 3 failure, so we can send a termination and deal with subsequent in-session messages.(package private) static intdecideIntroduction(String version, String caps, boolean sentPortOk, boolean canIntroduce, boolean randomKeep) Decide whether a deferred relay-tag request survives once the peer's RouterInfo is known.voidfail()Overridden from SSU1 to destroy the handshake state.Read the handshake progress for this session.intgetMTU()The MTU to use for packets to this peer: his MTU, as learned from his address options or from the size of the request he sent, capped by our own when we know it.Look up the next inbound establishment token for this session's peer.The completed PeerState, or null if we have not received the session confirmed.longThe rcv conn ID.byte[]First header encryption key for packets received from the peer.byte[]Second header encryption key for packets received from the peer.The retransmitted SessionCreated packet, or null if not sent or already got the session confirmed.longThe SSU2 send connection ID.byte[]First header encryption key for packets sent to the peer.byte[]Second header encryption key for packets sent to the peer.Read the peer address this session is talking to.longgetToken()Read the token this session presented to the peer.intReport the SSU 2 version negotiated with the peer.voidgotACK(long ackThru, int acks, byte[] ranges) Got an ACK block.voidgotAddress(byte[] ip, int port) Got an Address block.voidgotDateTime(long time) Payload callback: got a DateTime block.voidgotFragment(byte[] data, int off, int len, long messageID, int frag, boolean isLast) Got a Fragment block.voidgotI2NP(I2NPMessage msg) Got an I2NP block.voidgotOptions(byte[] options, boolean isHandshake) Got an Options block.voidgotPathChallenge(RemoteHostId from, byte[] data) Got a PathChallenge block.voidgotPathResponse(RemoteHostId from, byte[] data) Got a PathResponse block.voidgotPeerTest(int msg, int status, Hash h, byte[] data) Got a PeerTest block.voidgotRelayIntro(Hash aliceHash, byte[] data) Got a RelayIntro block.voidgotRelayRequest(byte[] data) Got a RelayRequest block.voidgotRelayResponse(int status, byte[] data) Got a RelayResponse block.voidgotRelayTag(long tag) Got a RelayTag block.voidGot a RelayTagRequest block.voidgotRI(RouterInfo ri, boolean isHandshake, boolean flood) For most errors here we throw a RIException with a reason code, which is caught inprocessPayload(byte[], int, int, boolean)to create a PeerStateDestroyed and send a termination with that reason.voidgotRIFragment(byte[] data, boolean isHandshake, boolean flood, boolean isGzipped, int frag, int totalFrags) Got an RI fragment block.voidgotTermination(int reason, long count) Got a Termination block.voidgotToken(long token, long expires) Got a Token block.private PeerState2Process SessionConfirmed and create the peer state, with the lock held.private voidProcess a session or token request after a retry, with the lock held.(package private) static intparseMTU(RouterAddress ra, boolean isIPv6) Resolve the session MTU from the peer's "mtu" option.(package private) static byte[]parseSessionKeys(RouterAddress ra, byte[] publicKey) Decode and verify the SSU2 IKey/S options of the negotiated RouterInfo address and verify that the peer's S key matches the X25519 public key already derived from the handshake.private voidprocessPayload(byte[] payload, int offset, int length, boolean isHandshake) Processes one handshake payload.voidqueuePossibleDataPacket(UDPPacket packet) Queue a data packet received before the session completed.receiveSessionConfirmed(UDPPacket packet) Receive the last messages in the handshake, and create the PeerState.voidAll exceptions thrown from here will be fatal.voidNote that we just sent a Retry packet.(package private) static InboundEstablishState2.AddressSelectionselectSessionAddress(List<RouterAddress> addrs, boolean isIPv6, byte[] aliceIP) Choose the RouterInfo address this session negotiates with, given the sender's IP family, so the caller can determine the MTU and keys.private booleanDetermines whether the given Throwable (or any of its causes) contains a message that should be suppressed from logging.(package private) static intstoreFailureReason(long now, long published) Classify a RouterInfo store failure - generally an expired or future-dated RouterInfo that the netDb rejected - into a termination reason.(package private) StringCompact one-line establish-state identifier for log output: alice address and current state.toString()A string summary of this state.private voidvalidateRouterInfo(RouterInfo ri, RouterAddress ra, String mismatchMessage) Validates the RouterInfo for banning conditions and throws RIException if any issue is found.Methods inherited from class InboundEstablishState
addMessage, complete, confirmedFullyReceived, getConfirmedIdentity, getEstablishBeginTime, getLifetime, getLifetime, getMaxDelay, getNextQueuedMessage, getNextSendTime, getReceivedOurIP, getReceivedX, getRemoteHostId, getRTT, getSentIP, getSentPort, getSentRelayTag, getSentSignedOnTime, getState, isComplete, isIntroductionRequested, packetReceived, sessionRequestReceived, setSentRelayTagModifier and TypeMethodDescriptionvoidaddMessage(OutNetMessage msg) Queue a message to be sent after the session is established.voidcomplete()Notify successful completion of the inbound session establishment.protected booleanHave we fully received the SessionConfirmed messages from Alice? Caller must synchronize on this.The confirmed identity of Alice (null if forged/unknown).longThe wall clock time when this establishment attempt began.longHow long have we been trying to establish this session?longgetLifetime(long now) How long have we been trying to establish this session, using the given time.protected static longMax delay including backoff.Pull from the message queue.longThe next time at which we should send a packet for this establishment.byte[]Our IP address as reported by Alice in the SessionRequest.byte[]The received X value from Alice's SessionRequest message.(package private) RemoteHostIdThe RemoteHostId that uniquely identifies this establishment attempt.(package private) intgetRTT()The estimated round-trip time for this establishment.byte[]Alice's apparent IP address.intAlice's apparent port number.longThe relay tag we sent to Alice in the SessionCreated message.longThe signed-on time we sent to Alice.getState()Current state of the inbound session establishment.booleanCheck if the inbound establish state is complete.booleanWhether Alice requested an introduction.protected voidUpdate the next send time to now, as we just received a packet.booleanWhether the SessionRequest message has been received from Alice.voidsetSentRelayTag(long tag) Set the relay tag to include in the SessionCreated message.
Field Details
_banLogger
Records why routers were banned._transport
The SSU transport we serve._aliceSocketAddress
Alice's socket address._rcvConnID
private final long _rcvConnIDConnection id we receive with._sendConnID
private final long _sendConnIDConnection id we send with._token
private final long _tokenThe handshake token echoed to Alice._handshakeState
Handshake state for the ratchet keys._version
private final int _versionVersion of the handshake._sendHeaderEncryptKey1
private byte[] _sendHeaderEncryptKey1First header encryption key for sending._sendHeaderEncryptKey2
private byte[] _sendHeaderEncryptKey2Second header encryption key for sending._rcvHeaderEncryptKey2
private byte[] _rcvHeaderEncryptKey2Second header encryption key for receiving._sessCrForReTX
private byte[] _sessCrForReTXSession Created packet held for retransmission._sessConfFragments
private byte[][] _sessConfFragmentsSession Confirmed fragments for retransmission._timeReceived
private long _timeReceivedWhen the handshake started._skew
private long _skewOur clock skew to Alice, in ms._mtu
private int _mtuThe MTU agreed for the new peer._pstate
The peer state being built, once created._queuedDataPackets
ENFORCE_TOKEN
private static final boolean ENFORCE_TOKENTrue to enforce the handshake token.- See Also:
MAX_SKEW
private static final long MAX_SKEWMaximum clock skew accepted in a handshake.- See Also:
MIN_RELAY_VERSION
First version supporting SSU2 relays.- See Also:
YGGDRASIL_FIRST_BYTE_MASK
private static final int YGGDRASIL_FIRST_BYTE_MASKA yggdrasil IPv6 address starts with 0x02 or 0x03 (first byte 0b0000001x).- See Also:
YGGDRASIL_FIRST_BYTE
private static final int YGGDRASIL_FIRST_BYTEFirst byte of the Yggdrasil protocol.- See Also:
IPV6_SELF_PREFIX_BYTES
private static final int IPV6_SELF_PREFIX_BYTESBytes of the source IPv6 prefix that identify an address as this router's own.- See Also:
SSU_V1_MTU_19_BUG
private static final int SSU_V1_MTU_19_BUGSSU 1.0 mtu option value that maps to MIN_MTU; workaround for a bug in 1.9.0.- See Also:
RI_SKEW_FUTURE_WINDOW
private static final long RI_SKEW_FUTURE_WINDOWA RouterInfo published more than 2 minutes in the future is clock-skewed.- See Also:
RI_SKEW_PAST_WINDOW
private static final long RI_SKEW_PAST_WINDOWA RouterInfo published more than 1 hour in the past is clock-skewed.- See Also:
INTRO_KEEP
static final int INTRO_KEEPKeep the introduction request;createPeerState()sends the relay tag with ACK 0.- See Also:
INTRO_BLOCKED
static final int INTRO_BLOCKEDDrop it: a temporary sent port or no introduction support on the peer's family.- See Also:
INTRO_VERSION
static final int INTRO_VERSIONDrop it: the peer's version is too old to relay to.- See Also:
INTRO_OPPORTUNISTIC
static final int INTRO_OPPORTUNISTICDrop it: the peer advertises itself reachable; relaying is not required.- See Also:
Constructor Details
InboundEstablishState2
public InboundEstablishState2(RouterContext ctx, UDPTransport transport, UDPPacket packet) throws GeneralSecurityException Start a new handshake with the given incoming packet, which must be a Session Request or Token Request.Caller must then check getState() and build a Retry or Session Created in response.
- Parameters:
ctx- the router contexttransport- the UDP transport this inbound handshake belongs topacket- with all header encryption removed, either a SessionRequest OR a TokenRequest.- Throws:
GeneralSecurityException- if the connection IDs in the packet are identical
Method Details
getVersion
public int getVersion()Report the SSU 2 version negotiated with the peer.- Overrides:
getVersionin classInboundEstablishState- Returns:
- the negotiated protocol version number
getMTU
public int getMTU()The MTU to use for packets to this peer: his MTU, as learned from his address options or from the size of the request he sent, capped by our own when we know it. The version 4 handshake needs an MTU ofPeerState2.MIN_MLKEM768_IPV4_MTUorPeerState2.MIN_MLKEM768_IPV6_MTU, and the padding in a session created is sized from this.- Returns:
- the MTU in bytes, 0 if unknown
processPayload
private void processPayload(byte[] payload, int offset, int length, boolean isHandshake) throws GeneralSecurityException Processes one handshake payload.- Parameters:
payload- the packet payloadoffset- where the handshake data startslength- the handshake data lengthisHandshake- true for a handshake packet- Throws:
GeneralSecurityException- if the decryption or MAC fails
gotDateTime
public void gotDateTime(long time) Payload callback: got a DateTime block.- Specified by:
gotDateTimein interfaceSSU2Payload.PayloadCallback- Parameters:
time- time in milliseconds since epoch
gotOptions
public void gotOptions(byte[] options, boolean isHandshake) Got an Options block.- Specified by:
gotOptionsin interfaceSSU2Payload.PayloadCallback- Parameters:
options- the option dataisHandshake- true only for message 3 part 2
gotRI
For most errors here we throw a RIException with a reason code, which is caught inprocessPayload(byte[], int, int, boolean)to create a PeerStateDestroyed and send a termination with that reason.Plain DataFormatExceptions indicate you may not respond in-session.
- Specified by:
gotRIin interfaceSSU2Payload.PayloadCallback- Parameters:
ri- will already be validatedisHandshake- true only for message 3 part 2flood- true if this is a floodfill router- Throws:
DataFormatException- if the RouterInfo block is malformed
selectSessionAddress
static InboundEstablishState2.AddressSelection selectSessionAddress(List<RouterAddress> addrs, boolean isIPv6, byte[] aliceIP) Choose the RouterInfo address this session negotiates with, given the sender's IP family, so the caller can determine the MTU and keys. The rules mirror the SSU2 handshake:- with several addresses, a pure SSU 1 address (no "s" option) is skipped
- an address is skipped when its host is not compatible with the sender's IP family, unless the capacity bit marks it usable
- an address is skipped when it advertises the sender's own IP (yggdrasil addresses and a matching IPv6 source prefix cannot be ourselves)
- an address that advertises a different IP than the sender's source address is selected but flagged, so the caller can ban it after the signature is verified
- Parameters:
addrs- the addresses from the peer's RouterInfo, in preference orderisIPv6- true if the sender connected over IPv6aliceIP- the sender's source IP bytes (4 for IPv4, 16 for IPv6)- Returns:
- the selection;
rais null when no address qualified
parseMTU
Resolve the session MTU from the peer's "mtu" option. Pure decision logic: a missing or unparsable value falls back to the per-style/family default, the 1.9.0 workaround maps 1276 to MIN_MTU for SSU 1, and any other value is clamped into the legal range for the negotiated style and IP family. A declared MTU below MIN_MTU (other than the workaround) is rejected.- Parameters:
ra- the negotiated SSU2/SSU addressisIPv6- true for an IPv6 session- Returns:
- the effective MTU
- Throws:
InboundEstablishState2.RIException- with REASON_OPTIONS if a declared MTU is below MIN_MTU
storeFailureReason
static int storeFailureReason(long now, long published) Classify a RouterInfo store failure - generally an expired or future-dated RouterInfo that the netDb rejected - into a termination reason.- Parameters:
now- current clock timepublished- the RI's publication date- Returns:
- REASON_SKEW when the publication date is outside the accepted skew window, otherwise REASON_MSG3
parseSessionKeys
Decode and verify the SSU2 IKey/S options of the negotiated RouterInfo address and verify that the peer's S key matches the X25519 public key already derived from the handshake. Throws before any session state is modified, so a malformed or dishonest RouterInfo cannot corrupt the established keys.- Parameters:
ra- the negotiated address; must carry the "i" and "s" optionspublicKey- the X25519 public key from_handshakeState- Returns:
- the verified IKey, to install as the send header key
- Throws:
DataFormatException- with a type-specific message on any bad key or an S/public-key mismatch
decideIntroduction
static int decideIntroduction(String version, String caps, boolean sentPortOk, boolean canIntroduce, boolean randomKeep) Decide whether a deferred relay-tag request survives once the peer's RouterInfo is known. Pure decision logic so the branch table is testable:- we cannot relay while our sent port is a temporary one or the transport does not support introduction on the peer's IP family
- we do not relay to routers running older than
MIN_RELAY_VERSION - when the peer already advertises itself reachable we only relay on a 1-in-4 draw - the peer is likely starting up and simply unaware of its reachability
- Parameters:
version- the peer's RouterInfo version stringcaps- the peer's RouterInfo capabilities, or nullsentPortOk- true if our sent port is a real, stable port (at least 1024)canIntroduce- true if the transport can introduce on the peer's IP familyrandomKeep- the pre-rolled 1-in-4 opportunistic keep draw- Returns:
INTRO_KEEP,INTRO_BLOCKED,INTRO_VERSIONorINTRO_OPPORTUNISTIC
validateRouterInfo
private void validateRouterInfo(RouterInfo ri, RouterAddress ra, String mismatchMessage) throws InboundEstablishState2.RIException Validates the RouterInfo for banning conditions and throws RIException if any issue is found. Checks: - Valid publication date - Banned status - Network ID match - IP match - SSU2 version - Old/slow router status.- Parameters:
ri- the received RouterInfo to validatera- the peer's selected RouterAddress for this sessionmismatchMessage- address mismatch warning from the address selection, null if none- Throws:
InboundEstablishState2.RIException- if the RouterInfo fails any of the checks above
gotRIFragment
public void gotRIFragment(byte[] data, boolean isHandshake, boolean flood, boolean isGzipped, int frag, int totalFrags) Got an RI fragment block.- Specified by:
gotRIFragmentin interfaceSSU2Payload.PayloadCallback- Parameters:
data- is first gzipped and then fragmentedisHandshake- true only for message 3 part 2flood- true if this is a floodfill routerisGzipped- true if the data is gzippedfrag- fragment number (0-based)totalFrags- total number of fragments
gotAddress
public void gotAddress(byte[] ip, int port) Got an Address block.- Specified by:
gotAddressin interfaceSSU2Payload.PayloadCallback- Parameters:
ip- IP address bytesport- the port number to send
gotRelayTagRequest
public void gotRelayTagRequest()Got a RelayTagRequest block.- Specified by:
gotRelayTagRequestin interfaceSSU2Payload.PayloadCallback
gotRelayTag
public void gotRelayTag(long tag) Got a RelayTag block.- Specified by:
gotRelayTagin interfaceSSU2Payload.PayloadCallback- Parameters:
tag- the relay tag
gotRelayRequest
public void gotRelayRequest(byte[] data) Got a RelayRequest block.- Specified by:
gotRelayRequestin interfaceSSU2Payload.PayloadCallback- Parameters:
data- excludes flag, includes signature
gotRelayResponse
public void gotRelayResponse(int status, byte[] data) Got a RelayResponse block.- Specified by:
gotRelayResponsein interfaceSSU2Payload.PayloadCallback- Parameters:
status- 0 = accept, 1-255 = rejectdata- excludes flag, includes signature
gotRelayIntro
Got a RelayIntro block.- Specified by:
gotRelayIntroin interfaceSSU2Payload.PayloadCallback- Parameters:
aliceHash- hash of the introducerdata- excludes flag, includes signature
gotPeerTest
Got a PeerTest block.- Specified by:
gotPeerTestin interfaceSSU2Payload.PayloadCallback- Parameters:
msg- 1-7status- 0 = accept, 1-255 = rejecth- Alice or Charlie hash for msg 2 and 4, null for msg 1, 3, 5-7data- excludes flag, includes signature
gotToken
public void gotToken(long token, long expires) Got a Token block.- Specified by:
gotTokenin interfaceSSU2Payload.PayloadCallback- Parameters:
token- the session token to attach to the next peer testexpires- token expiration time in milliseconds
gotI2NP
Got an I2NP block.- Specified by:
gotI2NPin interfaceSSU2Payload.PayloadCallback- Parameters:
msg- the parsed I2NP message
gotFragment
public void gotFragment(byte[] data, int off, int len, long messageID, int frag, boolean isLast) throws DataFormatException Got a Fragment block.- Specified by:
gotFragmentin interfaceSSU2Payload.PayloadCallback- Parameters:
data- buffer containing fragment dataoff- offset in datalen- length of data to copymessageID- unique message identifierfrag- fragment number (0-based)isLast- whether this is the last fragment- Throws:
DataFormatException- if the fragment is malformed
gotACK
public void gotACK(long ackThru, int acks, byte[] ranges) Got an ACK block.- Specified by:
gotACKin interfaceSSU2Payload.PayloadCallback- Parameters:
ackThru- highest contiguous sequence number acknowledgedacks- number of additional acknowledgments beyond ackThruranges- null if none
gotTermination
public void gotTermination(int reason, long count) Got a Termination block.- Specified by:
gotTerminationin interfaceSSU2Payload.PayloadCallback- Parameters:
reason- termination reason codecount- in theory could wrap around to negative, but very unlikely
gotPathChallenge
Got a PathChallenge block.- Specified by:
gotPathChallengein interfaceSSU2Payload.PayloadCallback- Parameters:
from- null if unknowndata- the challenge bytes, which must be copied out
gotPathResponse
Got a PathResponse block.- Specified by:
gotPathResponsein interfaceSSU2Payload.PayloadCallback- Parameters:
from- null if unknowndata- the response bytes, which must be copied out
fail
public void fail()Overridden from SSU1 to destroy the handshake state.- Overrides:
failin classInboundEstablishState
getSendConnID
public long getSendConnID()The SSU2 send connection ID.- Returns:
- the 64-bit connection ID used on our outbound packets
getRcvConnID
public long getRcvConnID()The rcv conn ID.- Returns:
- the 64-bit connection ID used by the peer on its packets
getToken
public long getToken()Read the token this session presented to the peer.- Returns:
- the SessionRequest token value
getNextToken
Look up the next inbound establishment token for this session's peer.- Returns:
- the token, or null for an IPv4 peer behind a symmetric NAT, where a fresh token cannot be attributed to the correct session
getHandshakeState
Read the handshake progress for this session.- Returns:
- the current handshake state
getSendHeaderEncryptKey1
public byte[] getSendHeaderEncryptKey1()First header encryption key for packets sent to the peer.- Returns:
- the key bytes
getRcvHeaderEncryptKey1
public byte[] getRcvHeaderEncryptKey1()First header encryption key for packets received from the peer.- Returns:
- the key bytes
getSendHeaderEncryptKey2
public byte[] getSendHeaderEncryptKey2()Second header encryption key for packets sent to the peer.- Returns:
- the key bytes
getRcvHeaderEncryptKey2
public byte[] getRcvHeaderEncryptKey2()Second header encryption key for packets received from the peer.- Returns:
- the key bytes
getSentAddress
Read the peer address this session is talking to.- Returns:
- the address the peer connected from
createdPacketSent
public void createdPacketSent()Record that we sent the SessionCreated packet.- Overrides:
createdPacketSentin classInboundEstablishState
retryPacketSent
public void retryPacketSent()Note that we just sent a Retry packet.receiveSessionOrTokenRequestAfterRetry
public void receiveSessionOrTokenRequestAfterRetry(UDPPacket packet) throws GeneralSecurityException All exceptions thrown from here will be fatal.fail()will be called before throwing.- Parameters:
packet- the retried Session Request or Token Request, header encryption removed- Throws:
GeneralSecurityException- if the packet fails address, connection ID, token, version or clock-skew validation; fail() has already been called
locked_receiveSessionOrTokenRequestAfterRetry
private void locked_receiveSessionOrTokenRequestAfterRetry(UDPPacket packet) throws GeneralSecurityException Process a session or token request after a retry, with the lock held.- Parameters:
packet- the repeated SessionRequest or TokenRequest packet from the peer- Throws:
GeneralSecurityException- if the source address does not match the initiator's, or decrypting or validating the request fails
receiveSessionConfirmed
Receive the last messages in the handshake, and create the PeerState. If the message is fragmented, store the data for reassembly and return, unless this was the last one.Exceptions thrown from here are fatal.
- Parameters:
packet- the SessionConfirmed message, header encryption removed- Returns:
- the new PeerState2 if are done, may also be retrieved from
getPeerState(), or null if more fragments to go
locked_receiveSessionConfirmed
Process SessionConfirmed and create the peer state, with the lock held.- Parameters:
packet- the SessionConfirmed packet from the peer- Returns:
- the newly created peer state for the established session
- Throws:
GeneralSecurityException- if the state is wrong for a confirmation, the source address does not match, or decrypting or validating the confirmation fails
createPeerState
private void createPeerState()Creates the PeerState and stores in _pstate. Called fromgotRI(RouterInfo, boolean, boolean)so that we can pass any I2NP messages or fragments immediately to the PeerState.createPeerStateDestroyed
Creates a PeerStateDestroyed after msg 3 failure, so we can send a termination and deal with subsequent in-session messages.- Parameters:
reason- the SSU2 termination reason code recorded in the destroyed state- Returns:
- the destroyed peer state holding the session's chaining keys
createdPacketSent
Note that we just sent the SessionCreated packet, and save it for retransmission.- Parameters:
pkt- the SessionCreated datagram that was just sent, saved for retransmission
getRetransmitSessionCreatedPacket
The retransmitted SessionCreated packet, or null if not sent or already got the session confirmed.- Returns:
- null if not sent or already got the session confirmed
getPeerState
The completed PeerState, or null if we have not received the session confirmed.- Returns:
- null if we have not received the session confirmed
queuePossibleDataPacket
Queue a data packet received before the session completed.- Parameters:
packet- with header still encrypted
shouldSuppressException
Determines whether the given Throwable (or any of its causes) contains a message that should be suppressed from logging.- Parameters:
t- the Throwable to check- Returns:
- true if the exception should be suppressed, false otherwise
toShortString
String toShortString()Compact one-line establish-state identifier for log output: alice address and current state. No lifetime or IDs, no newlines.- Returns:
- the alice address and state, on one line
toString
A string summary of this state.- Overrides:
toStringin classInboundEstablishState- Returns:
- debug string with peer address, lifetime, relay tag, and state