Package net.i2p.router.transport.udp
Class OutboundEstablishState2
- java.lang.Object
-
- net.i2p.router.transport.udp.OutboundEstablishState
-
- net.i2p.router.transport.udp.OutboundEstablishState2
-
- All Implemented Interfaces:
SSU2Payload.PayloadCallback
class OutboundEstablishState2 extends OutboundEstablishState implements SSU2Payload.PayloadCallback
Data for a new connection being established, where we initiated the connection with a remote peer. In other words, we are Alice and they are Bob. SSU2 only.- Since:
- 0.9.54
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOutboundEstablishState2.IntroStatePer-introducer introduction states-
Nested classes/interfaces inherited from class net.i2p.router.transport.udp.OutboundEstablishState
OutboundEstablishState.OutboundState
-
-
Field Summary
-
Fields inherited from class net.i2p.router.transport.udp.OutboundEstablishState
_aliceIP, _alicePort, _bobIP, _bobPort, _context, _currentState, _establishBegin, _lastSend, _log, _nextSend, _receivedRelayTag, _remoteHostId, _remotePeer, _requestSentCount, _requestSentTime, _rtt, RETRANSMIT_DELAY
-
-
Constructor Summary
Constructors Constructor Description OutboundEstablishState2(RouterContext ctx, UDPTransport transport, RemoteHostId claimedAddress, RemoteHostId remoteHostId, RouterIdentity remotePeer, boolean needIntroduction, SessionKey introKey, RouterAddress ra, UDPAddress addr)Prepare to start a new handshake with the given peer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PeerState2confirmedPacketsSent(UDPPacket[] packets)note that we just sent the SessionConfirmed packets and save them for retransmissionvoidfail()Overridden to destroy the handshake stateHandshakeStategetHandshakeState()OutboundEstablishState2.IntroStategetIntroState(Hash h)intgetMTU()What is the largest packet we can send to the peer? Only used for Session Confirmed packets.EstablishmentManager.TokengetNextToken()PeerState2getPeerState()longgetRcvConnID()byte[]getRcvHeaderEncryptKey1()byte[]getRcvHeaderEncryptKey2()byte[]getRcvRetryHeaderEncryptKey2()UDPPacketgetRetransmitSessionRequestPacket()longgetSendConnID()byte[]getSendHeaderEncryptKey1()byte[]getSendHeaderEncryptKey2()InetSocketAddressgetSentAddress()longgetToken()intgetVersion()voidgotACK(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)voidgotRelayTagRequest()voidgotRI(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)voidintroduced(byte[] ip, int port, long token)After introductionvoidintroSent(Hash h)A relay request was sent to the SSU2 introducer specified(package private) booleanreceiveHolePunch()Overridden because we don't have to wait for Relay Response first.voidreceiveRetry(UDPPacket packet)voidreceiveSessionCreated(UDPPacket packet)voidrequestSent(DatagramPacket pkt)note that we just sent the SessionRequest packet and save it for retransmissionvoidsetIntroState(Hash h, OutboundEstablishState2.IntroState state)Set the current state for the SSU2 introducer specifiedvoidtokenRequestSent(DatagramPacket packet)Note that we just sent a token request packet.StringtoString()booleanvalidateSessionCreated()Blocking call (run in the establisher thread) to determine if the session was created properly.-
Methods inherited from class net.i2p.router.transport.udp.OutboundEstablishState
addMessage, complete, confirmedPacketsSent, dataReceived, getCipherKey, getClaimedAddress, getConfirmedSentTime, getEstablishBeginTime, getIntroKey, getIntroNonce, getIntroSentTime, getLifetime, getLifetime, getMACKey, getNextQueuedMessage, getNextSendTime, getReceivedIP, getReceivedPort, getReceivedRelayTag, getReceivedSignedOnTime, getRemoteAddress, getRemoteHostId, getRemoteIdentity, getRequestSentTime, getRTT, getSentIP, getSentPort, getSentSignature, getSentSignedOnTime, getSentX, getState, introduced, introductionFailed, introSent, isExtendedOptionsAllowed, isFirstMessageOurDSM, needIntroduction, packetReceived, prepareSessionConfirmed, receiveSessionCreated, requestSent, setIntroNonce
-
-
-
-
Constructor Detail
-
OutboundEstablishState2
public OutboundEstablishState2(RouterContext ctx, UDPTransport transport, RemoteHostId claimedAddress, RemoteHostId remoteHostId, RouterIdentity remotePeer, boolean needIntroduction, SessionKey introKey, RouterAddress ra, UDPAddress addr) throws IllegalArgumentException
Prepare to start a new handshake with the given peer. Caller must then check getState() and build a Token Request or Session Request to send to the peer.- Parameters:
claimedAddress- an IP/port based RemoteHostId, or null if unknownremoteHostId- non-null, == claimedAddress if direct, or a hash-based one if indirectremotePeer- must have supported sig typeneedIntroduction- should we ask Bob to be an introducer for us? ignored unless allowExtendedOptions is trueintroKey- Bob's introduction key, as published in the netdbaddr- non-null- Throws:
IllegalArgumentException
-
-
Method Detail
-
introduced
public void introduced(byte[] ip, int port, long token)After introduction- Since:
- 0.9.55
-
gotDateTime
public void gotDateTime(long time)
- Specified by:
gotDateTimein interfaceSSU2Payload.PayloadCallback
-
gotOptions
public void gotOptions(byte[] options, boolean isHandshake)- Specified by:
gotOptionsin interfaceSSU2Payload.PayloadCallbackisHandshake- true only for message 3 part 2
-
gotRI
public void gotRI(RouterInfo ri, boolean isHandshake, boolean flood) throws DataFormatException
- 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
public void gotRelayIntro(Hash aliceHash, byte[] data)
- Specified by:
gotRelayIntroin interfaceSSU2Payload.PayloadCallbackdata- excludes flag, includes signature
-
gotPeerTest
public void gotPeerTest(int msg, int status, Hash h, byte[] data)- 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
public void gotI2NP(I2NPMessage msg)
- Specified by:
gotI2NPin interfaceSSU2Payload.PayloadCallback
-
gotFragment
public void gotFragment(byte[] data, int off, int len, long messageId, int frag, boolean isLast) throws DataFormatExceptionDescription 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.PayloadCallbackoff- offset in datalen- length of data to copy- Throws:
DataFormatException
-
gotACK
public void gotACK(long ackThru, int acks, byte[] ranges)- Specified by:
gotACKin interfaceSSU2Payload.PayloadCallbackranges- null if none
-
gotTermination
public void gotTermination(int reason, long count)- Specified by:
gotTerminationin interfaceSSU2Payload.PayloadCallbackcount- in theory could wrap around to negative, but very unlikely
-
gotPathChallenge
public void gotPathChallenge(RemoteHostId from, byte[] data)
- Specified by:
gotPathChallengein interfaceSSU2Payload.PayloadCallback- Parameters:
from- null if unknown
-
gotPathResponse
public void gotPathResponse(RemoteHostId from, byte[] data)
- Specified by:
gotPathResponsein interfaceSSU2Payload.PayloadCallback- Parameters:
from- null if unknown
-
fail
public void fail()
Overridden to destroy the handshake state- Overrides:
failin classOutboundEstablishState- Since:
- 0.9.56
-
validateSessionCreated
public boolean validateSessionCreated()
Description copied from class:OutboundEstablishStateBlocking call (run in the establisher thread) to determine if the session was created properly. If it wasn't, all the SessionCreated remnants are dropped (perhaps they were spoofed, etc) so that we can receive another one Generates session key and mac key.- Overrides:
validateSessionCreatedin classOutboundEstablishState- Returns:
- true if valid
-
receiveHolePunch
boolean receiveHolePunch()
Overridden because we don't have to wait for Relay Response first.- Overrides:
receiveHolePunchin classOutboundEstablishState- Returns:
- true if we should send the SessionRequest now
- Since:
- 0.9.55
-
getVersion
public int getVersion()
- Overrides:
getVersionin classOutboundEstablishState
-
getSendConnID
public long getSendConnID()
-
getRcvConnID
public long getRcvConnID()
-
getToken
public long getToken()
-
getNextToken
public EstablishmentManager.Token getNextToken()
- Returns:
- may be null
-
getHandshakeState
public HandshakeState getHandshakeState()
-
getSendHeaderEncryptKey1
public byte[] getSendHeaderEncryptKey1()
-
getRcvHeaderEncryptKey1
public byte[] getRcvHeaderEncryptKey1()
-
getSendHeaderEncryptKey2
public byte[] getSendHeaderEncryptKey2()
-
getRcvHeaderEncryptKey2
public byte[] getRcvHeaderEncryptKey2()
- Returns:
- null before Session Request is sent (i.e. we sent a Token Request first)
-
getRcvRetryHeaderEncryptKey2
public byte[] getRcvRetryHeaderEncryptKey2()
-
getSentAddress
public InetSocketAddress getSentAddress()
-
getMTU
public int getMTU()
What is the largest packet we can send to the peer? Only used for Session Confirmed packets. Session Request is very small.
-
receiveRetry
public void receiveRetry(UDPPacket packet) throws GeneralSecurityException
- Throws:
GeneralSecurityException
-
receiveSessionCreated
public void receiveSessionCreated(UDPPacket packet) throws GeneralSecurityException
- Throws:
GeneralSecurityException
-
tokenRequestSent
public void tokenRequestSent(DatagramPacket packet)
Note that we just sent a token request packet. and save them for retransmission
-
requestSent
public void requestSent(DatagramPacket pkt)
note that we just sent the SessionRequest packet and save it for retransmission
-
confirmedPacketsSent
public PeerState2 confirmedPacketsSent(UDPPacket[] packets)
note that we just sent the SessionConfirmed packets and save them for retransmission- Returns:
- the new PeerState2, may also be retrieved from getPeerState()
-
getRetransmitSessionRequestPacket
public UDPPacket getRetransmitSessionRequestPacket()
- Returns:
- null if not sent or already got the session created
-
getPeerState
public PeerState2 getPeerState()
- Returns:
- null if we have not sent the session confirmed
-
getIntroState
public OutboundEstablishState2.IntroState getIntroState(Hash h)
- Returns:
- non-null current state for the SSU2 introducer specified, or INTRO_STATE_INVALID if peer is not an SSU2 introducer
- Since:
- 0.9.55
-
setIntroState
public void setIntroState(Hash h, OutboundEstablishState2.IntroState state)
Set the current state for the SSU2 introducer specified- Since:
- 0.9.55
-
introSent
public void introSent(Hash h)
A relay request was sent to the SSU2 introducer specified- Since:
- 0.9.55
-
toString
public String toString()
- Overrides:
toStringin classOutboundEstablishState
-
-