class InboundEstablishState2 extends InboundEstablishState implements SSU2Payload.PayloadCallback
InboundEstablishState.InboundState
_aliceIP, _alicePort, _bobIP, _bobPort, _context, _createdSentCount, _currentState, _establishBegin, _introductionRequested, _lastSend, _log, _nextSend, _receivedConfirmedIdentity, _receivedUnconfirmedIdentity, _remoteHostId, _rtt, _sentRelayTag, MAX_DELAY, RETRANSMIT_DELAY
Constructor and Description |
---|
InboundEstablishState2(RouterContext ctx,
UDPTransport transport,
UDPPacket packet)
Start a new handshake with the given incoming packet,
which must be a Session Request or Token Request.
|
Modifier and Type | Method and Description |
---|---|
void |
createdPacketSent()
note that we just sent a SessionCreated packet
|
void |
createdPacketSent(DatagramPacket pkt)
note that we just sent the SessionCreated packet
and save it for retransmission
|
void |
fail()
Overridden to destroy the handshake state
|
HandshakeState |
getHandshakeState() |
EstablishmentManager.Token |
getNextToken() |
PeerState2 |
getPeerState() |
long |
getRcvConnID() |
byte[] |
getRcvHeaderEncryptKey1() |
byte[] |
getRcvHeaderEncryptKey2() |
UDPPacket |
getRetransmitSessionCreatedPacket() |
long |
getSendConnID() |
byte[] |
getSendHeaderEncryptKey1() |
byte[] |
getSendHeaderEncryptKey2() |
InetSocketAddress |
getSentAddress() |
long |
getToken() |
int |
getVersion() |
void |
gotACK(long ackThru,
int acks,
byte[] ranges) |
void |
gotAddress(byte[] ip,
int port) |
void |
gotDateTime(long time) |
void |
gotFragment(byte[] data,
int off,
int len,
long messageID,
int frag,
boolean isLast)
Data must be copied out in this method.
|
void |
gotI2NP(I2NPMessage msg) |
void |
gotOptions(byte[] options,
boolean isHandshake) |
void |
gotPathChallenge(RemoteHostId from,
byte[] data) |
void |
gotPathResponse(RemoteHostId from,
byte[] data) |
void |
gotPeerTest(int msg,
int status,
Hash h,
byte[] data) |
void |
gotRelayIntro(Hash aliceHash,
byte[] data) |
void |
gotRelayRequest(byte[] data) |
void |
gotRelayResponse(int status,
byte[] data) |
void |
gotRelayTag(long tag) |
void |
gotRelayTagRequest() |
void |
gotRI(RouterInfo ri,
boolean isHandshake,
boolean flood)
For most errors here we throw a RIException with a reason code,
which is caught in processPayload() to create a PeerStateDestroyed
and send a termination with that reason.
|
void |
gotRIFragment(byte[] data,
boolean isHandshake,
boolean flood,
boolean isGzipped,
int frag,
int totalFrags) |
void |
gotTermination(int reason,
long count) |
void |
gotToken(long token,
long expires) |
void |
queuePossibleDataPacket(UDPPacket packet) |
PeerState2 |
receiveSessionConfirmed(UDPPacket packet)
Receive the last messages in the handshake, and create the PeerState.
|
void |
receiveSessionOrTokenRequestAfterRetry(UDPPacket packet)
All exceptions thrown from here will be fatal.
|
void |
retryPacketSent()
note that we just sent a Retry packet
|
String |
toString() |
addMessage, complete, confirmedFullyReceived, getConfirmedIdentity, getEstablishBeginTime, getLifetime, getLifetime, getNextQueuedMessage, getNextSendTime, getReceivedOurIP, getReceivedX, getRemoteHostId, getRTT, getSentIP, getSentPort, getSentRelayTag, getSentSignedOnTime, getState, isComplete, isIntroductionRequested, packetReceived, sessionRequestReceived, setSentRelayTag
public InboundEstablishState2(RouterContext ctx, UDPTransport transport, UDPPacket packet) throws GeneralSecurityException
packet
- with all header encryption removed,
either a SessionRequest OR a TokenRequest.GeneralSecurityException
public int getVersion()
getVersion
in class InboundEstablishState
public void gotDateTime(long time)
gotDateTime
in interface SSU2Payload.PayloadCallback
public void gotOptions(byte[] options, boolean isHandshake)
gotOptions
in interface SSU2Payload.PayloadCallback
isHandshake
- true only for message 3 part 2public void gotRI(RouterInfo ri, boolean isHandshake, boolean flood) throws DataFormatException
gotRI
in interface SSU2Payload.PayloadCallback
ri
- will already be validatedisHandshake
- true only for message 3 part 2DataFormatException
public void gotRIFragment(byte[] data, boolean isHandshake, boolean flood, boolean isGzipped, int frag, int totalFrags)
gotRIFragment
in interface SSU2Payload.PayloadCallback
data
- is first gzipped and then fragmentedisHandshake
- true only for message 3 part 2public void gotAddress(byte[] ip, int port)
gotAddress
in interface SSU2Payload.PayloadCallback
public void gotRelayTagRequest()
gotRelayTagRequest
in interface SSU2Payload.PayloadCallback
public void gotRelayTag(long tag)
gotRelayTag
in interface SSU2Payload.PayloadCallback
public void gotRelayRequest(byte[] data)
gotRelayRequest
in interface SSU2Payload.PayloadCallback
data
- excludes flag, includes signaturepublic void gotRelayResponse(int status, byte[] data)
gotRelayResponse
in interface SSU2Payload.PayloadCallback
status
- 0 = accept, 1-255 = rejectdata
- excludes flag, includes signaturepublic void gotRelayIntro(Hash aliceHash, byte[] data)
gotRelayIntro
in interface SSU2Payload.PayloadCallback
data
- excludes flag, includes signaturepublic void gotPeerTest(int msg, int status, Hash h, byte[] data)
gotPeerTest
in interface SSU2Payload.PayloadCallback
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 signaturepublic void gotToken(long token, long expires)
gotToken
in interface SSU2Payload.PayloadCallback
public void gotI2NP(I2NPMessage msg)
gotI2NP
in interface SSU2Payload.PayloadCallback
public void gotFragment(byte[] data, int off, int len, long messageID, int frag, boolean isLast) throws DataFormatException
SSU2Payload.PayloadCallback
gotFragment
in interface SSU2Payload.PayloadCallback
off
- offset in datalen
- length of data to copyDataFormatException
public void gotACK(long ackThru, int acks, byte[] ranges)
gotACK
in interface SSU2Payload.PayloadCallback
ranges
- null if nonepublic void gotTermination(int reason, long count)
gotTermination
in interface SSU2Payload.PayloadCallback
count
- in theory could wrap around to negative, but very unlikelypublic void gotPathChallenge(RemoteHostId from, byte[] data)
gotPathChallenge
in interface SSU2Payload.PayloadCallback
from
- null if unknownpublic void gotPathResponse(RemoteHostId from, byte[] data)
gotPathResponse
in interface SSU2Payload.PayloadCallback
from
- null if unknownpublic void fail()
fail
in class InboundEstablishState
public long getSendConnID()
public long getRcvConnID()
public long getToken()
public EstablishmentManager.Token getNextToken()
public HandshakeState getHandshakeState()
public byte[] getSendHeaderEncryptKey1()
public byte[] getRcvHeaderEncryptKey1()
public byte[] getSendHeaderEncryptKey2()
public byte[] getRcvHeaderEncryptKey2()
public InetSocketAddress getSentAddress()
public void createdPacketSent()
InboundEstablishState
createdPacketSent
in class InboundEstablishState
public void retryPacketSent()
public void receiveSessionOrTokenRequestAfterRetry(UDPPacket packet) throws GeneralSecurityException
GeneralSecurityException
public PeerState2 receiveSessionConfirmed(UDPPacket packet) throws GeneralSecurityException
GeneralSecurityException
public void createdPacketSent(DatagramPacket pkt)
public UDPPacket getRetransmitSessionCreatedPacket()
public PeerState2 getPeerState()
public void queuePossibleDataPacket(UDPPacket packet)
packet
- with header still encryptedpublic String toString()
toString
in class InboundEstablishState