Package net.i2p.router.transport.udp
Class InboundEstablishState2
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.
- Since:
- 0.9.54
-
Nested Class Summary
Nested classes/interfaces inherited from class net.i2p.router.transport.udp.InboundEstablishState
InboundEstablishState.InboundState -
Field Summary
Fields inherited from class net.i2p.router.transport.udp.InboundEstablishState
_aliceIP, _alicePort, _bobIP, _bobPort, _context, _createdSentCount, _currentState, _establishBegin, _introductionRequested, _lastSend, _log, _nextSend, _receivedConfirmedIdentity, _receivedUnconfirmedIdentity, _remoteHostId, _rtt, _sentRelayTag, MAX_DELAY, RETRANSMIT_DELAY -
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 TypeMethodDescriptionvoidnote that we just sent a SessionCreated packetvoidnote that we just sent the SessionCreated packet and save it for retransmissionvoidfail()Overridden to destroy the handshake statevoidGenerates session key and mac key.longbyte[]byte[]longbyte[]byte[]longgetToken()intvoidgotACK(long ackThru, int acks, byte[] ranges) voidgotAddress(byte[] ip, int port) voidgotDateTime(long time) voidgotFragment(byte[] data, int off, int len, long messageID, int frag, boolean isLast) Data must be copied out in this method.voidgotI2NP(I2NPMessage msg) voidgotOptions(byte[] options, boolean isHandshake) voidgotPathChallenge(RemoteHostId from, byte[] data) voidgotPathResponse(RemoteHostId from, byte[] data) voidgotPeerTest(int msg, int status, Hash h, byte[] data) voidgotRelayIntro(Hash aliceHash, byte[] data) voidgotRelayRequest(byte[] data) voidgotRelayResponse(int status, byte[] data) voidgotRelayTag(long tag) voidvoidgotRI(RouterInfo ri, boolean isHandshake, boolean flood) voidgotRIFragment(byte[] data, boolean isHandshake, boolean flood, boolean isGzipped, int frag, int totalFrags) voidgotTermination(int reason, long count) voidgotToken(long token, long expires) voidqueuePossibleDataPacket(UDPPacket packet) 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 packettoString()Methods inherited from class net.i2p.router.transport.udp.InboundEstablishState
addMessage, complete, confirmedFullyReceived, getCipherKey, getConfirmedIdentity, getEstablishBeginTime, getLifetime, getMACKey, getNextQueuedMessage, getNextSendTime, getReceivedOurIP, getReceivedX, getRemoteHostId, getRTT, getSentIP, getSentPort, getSentRelayTag, getSentSignature, getSentSignedOnTime, getSentY, getState, isComplete, isIntroductionRequested, packetReceived, prepareSessionCreated, receiveSessionConfirmed, receiveSessionRequest, sessionRequestReceived, setSentRelayTag
-
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:
packet- with all header encryption removed, either a SessionRequest OR a TokenRequest.- Throws:
GeneralSecurityException
-
-
Method Details
-
getVersion
public int getVersion()- Overrides:
getVersionin classInboundEstablishState
-
gotDateTime
public void gotDateTime(long time) - Specified by:
gotDateTimein interfaceSSU2Payload.PayloadCallback
-
gotOptions
public void gotOptions(byte[] options, boolean isHandshake) - Specified by:
gotOptionsin interfaceSSU2Payload.PayloadCallback- Parameters:
isHandshake- true only for message 3 part 2
-
gotRI
- Specified by:
gotRIin interfaceSSU2Payload.PayloadCallback- Parameters:
ri- will already be validatedisHandshake- true only for message 3 part 2- Throws:
DataFormatException
-
gotRIFragment
public void gotRIFragment(byte[] data, boolean isHandshake, boolean flood, boolean isGzipped, int frag, int totalFrags) - Specified by:
gotRIFragmentin interfaceSSU2Payload.PayloadCallback- Parameters:
data- is first gzipped and then fragmentedisHandshake- true only for message 3 part 2
-
gotAddress
public void gotAddress(byte[] ip, int port) - Specified by:
gotAddressin interfaceSSU2Payload.PayloadCallback
-
gotRelayTagRequest
public void gotRelayTagRequest()- Specified by:
gotRelayTagRequestin interfaceSSU2Payload.PayloadCallback
-
gotRelayTag
public void gotRelayTag(long tag) - Specified by:
gotRelayTagin interfaceSSU2Payload.PayloadCallback
-
gotRelayRequest
public void gotRelayRequest(byte[] data) - Specified by:
gotRelayRequestin interfaceSSU2Payload.PayloadCallback- Parameters:
data- excludes flag, includes signature
-
gotRelayResponse
public void gotRelayResponse(int status, byte[] data) - Specified by:
gotRelayResponsein interfaceSSU2Payload.PayloadCallback- Parameters:
status- 0 = accept, 1-255 = rejectdata- excludes flag, includes signature
-
gotRelayIntro
- Specified by:
gotRelayIntroin interfaceSSU2Payload.PayloadCallback- Parameters:
data- excludes flag, includes signature
-
gotPeerTest
- 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) - Specified by:
gotTokenin interfaceSSU2Payload.PayloadCallback
-
gotI2NP
- Specified by:
gotI2NPin interfaceSSU2Payload.PayloadCallback
-
gotFragment
public void gotFragment(byte[] data, int off, int len, long messageID, int frag, boolean isLast) throws DataFormatException Description copied from interface:SSU2Payload.PayloadCallbackData must be copied out in this method. Data starts at the 9 byte header for fragment 0.- Specified by:
gotFragmentin interfaceSSU2Payload.PayloadCallback- Parameters:
off- offset in datalen- length of data to copy- Throws:
DataFormatException
-
gotACK
public void gotACK(long ackThru, int acks, byte[] ranges) - Specified by:
gotACKin interfaceSSU2Payload.PayloadCallback- Parameters:
ranges- null if none
-
gotTermination
public void gotTermination(int reason, long count) - Specified by:
gotTerminationin interfaceSSU2Payload.PayloadCallback- Parameters:
count- in theory could wrap around to negative, but very unlikely
-
gotPathChallenge
- Specified by:
gotPathChallengein interfaceSSU2Payload.PayloadCallback- Parameters:
from- null if unknown
-
gotPathResponse
- Specified by:
gotPathResponsein interfaceSSU2Payload.PayloadCallback- Parameters:
from- null if unknown
-
fail
public void fail()Overridden to destroy the handshake state- Overrides:
failin classInboundEstablishState- Since:
- 0.9.56
-
generateSessionKey
public void generateSessionKey()Description copied from class:InboundEstablishStateGenerates session key and mac key.- Overrides:
generateSessionKeyin classInboundEstablishState
-
getSendConnID
public long getSendConnID() -
getRcvConnID
public long getRcvConnID() -
getToken
public long getToken() -
getNextToken
-
getHandshakeState
-
getSendHeaderEncryptKey1
public byte[] getSendHeaderEncryptKey1() -
getRcvHeaderEncryptKey1
public byte[] getRcvHeaderEncryptKey1() -
getSendHeaderEncryptKey2
public byte[] getSendHeaderEncryptKey2() -
getRcvHeaderEncryptKey2
public byte[] getRcvHeaderEncryptKey2() -
getSentAddress
-
createdPacketSent
public void createdPacketSent()Description copied from class:InboundEstablishStatenote that we just sent a SessionCreated packet- Overrides:
createdPacketSentin classInboundEstablishState
-
retryPacketSent
public void retryPacketSent()note that we just sent a Retry packet -
receiveSessionRequestAfterRetry
All exceptions thrown from here will be fatal. fail() will be called before throwing.- Throws:
GeneralSecurityException
-
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.- Returns:
- the new PeerState2 if are done, may also be retrieved from getPeerState(), or null if more fragments to go
- Throws:
GeneralSecurityException
-
createdPacketSent
note that we just sent the SessionCreated packet and save it for retransmission -
getRetransmitSessionCreatedPacket
- Returns:
- null if not sent or already got the session confirmed
-
getPeerState
- Returns:
- null if we have not received the session confirmed
-
queuePossibleDataPacket
- Parameters:
packet- with header still encrypted
-
toString
- Overrides:
toStringin classInboundEstablishState
-