Class OutboundEstablishState2

    • 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 unknown
        remoteHostId - non-null, == claimedAddress if direct, or a hash-based one if indirect
        remotePeer - must have supported sig type
        needIntroduction - should we ask Bob to be an introducer for us? ignored unless allowExtendedOptions is true
        introKey - Bob's introduction key, as published in the netdb
        addr - non-null
        Throws:
        IllegalArgumentException
    • Method Detail

      • introduced

        public void introduced​(byte[] ip,
                               int port,
                               long token)
        After introduction
        Since:
        0.9.55
      • gotOptions

        public void gotOptions​(byte[] options,
                               boolean isHandshake)
        Specified by:
        gotOptions in interface SSU2Payload.PayloadCallback
        isHandshake - true only for message 3 part 2
      • gotRIFragment

        public void gotRIFragment​(byte[] data,
                                  boolean isHandshake,
                                  boolean flood,
                                  boolean isGzipped,
                                  int frag,
                                  int totalFrags)
        Specified by:
        gotRIFragment in interface SSU2Payload.PayloadCallback
        Parameters:
        data - is first gzipped and then fragmented
        isHandshake - true only for message 3 part 2
      • gotRelayResponse

        public void gotRelayResponse​(int status,
                                     byte[] data)
        Specified by:
        gotRelayResponse in interface SSU2Payload.PayloadCallback
        Parameters:
        status - 0 = accept, 1-255 = reject
        data - excludes flag, includes signature
      • gotPeerTest

        public void gotPeerTest​(int msg,
                                int status,
                                Hash h,
                                byte[] data)
        Specified by:
        gotPeerTest in interface SSU2Payload.PayloadCallback
        Parameters:
        msg - 1-7
        status - 0 = accept, 1-255 = reject
        h - Alice or Charlie hash for msg 2 and 4, null for msg 1, 3, 5-7
        data - excludes flag, includes signature
      • gotTermination

        public void gotTermination​(int reason,
                                   long count)
        Specified by:
        gotTermination in interface SSU2Payload.PayloadCallback
        count - in theory could wrap around to negative, but very unlikely
      • fail

        public void fail()
        Overridden to destroy the handshake state
        Overrides:
        fail in class OutboundEstablishState
        Since:
        0.9.56
      • validateSessionCreated

        public boolean validateSessionCreated()
        Description copied from class: OutboundEstablishState
        Blocking 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:
        validateSessionCreated in class OutboundEstablishState
        Returns:
        true if valid
      • receiveHolePunch

        boolean receiveHolePunch()
        Overridden because we don't have to wait for Relay Response first.
        Overrides:
        receiveHolePunch in class OutboundEstablishState
        Returns:
        true if we should send the SessionRequest now
        Since:
        0.9.55
      • getSendConnID

        public long getSendConnID()
      • getRcvConnID

        public long getRcvConnID()
      • getToken

        public long getToken()
      • 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()
      • 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.
      • 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
      • introSent

        public void introSent​(Hash h)
        A relay request was sent to the SSU2 introducer specified
        Since:
        0.9.55