[][src]Enum tox_core::net_crypto::ConnectionStatus

pub enum ConnectionStatus {
    CookieRequesting {
        cookie_request_id: u64,
        packet: StatusPacketWithTime,
    },
    HandshakeSending {
        sent_nonce: Nonce,
        packet: StatusPacketWithTime,
    },
    NotConfirmed {
        sent_nonce: Nonce,
        received_nonce: Nonce,
        session_precomputed_key: PrecomputedKey,
        packet: StatusPacketWithTime,
    },
    Established {
        sent_nonce: Nonce,
        received_nonce: Nonce,
        session_precomputed_key: PrecomputedKey,
    },
}

Status of crypto connection.

Initial state is CookieRequesting. In this status we send up to 8 CookieRequest packets every second and waiting for a CookieResponse packet. After receiving a CookieResponse packet we change the status to HandshakeSending in which we send up to 8 CryptoHandshake packets every second and waiting for CryptoHandshake packet from the other side. When we received CryptoHandshake packet we change the status to NotConfirmed and continue sending CryptoHandshake packets because we don't know if the other side received our CryptoHandshake packet. Only after receiving first CryptoData packet we change status to Established and stop sending CryptoHandshake packets. In this status connection is considered as fully established.

It's also possible that we received CryptoHandshake packet but didn't create crypto connection yet. This means that we should skip first two states and use NotConfirmed state as initial. We can do it because CryptoHandshake contains Cookie that we can use to send our CryptoHandshake.

Variants

CookieRequesting

We are sending cookie request packets and haven't received cookie response yet.

Fields of CookieRequesting

cookie_request_id: u64

ID used in the cookie request packets for this connection

packet: StatusPacketWithTime

Packet that should be sent every second

HandshakeSending

We are sending handshake packets and haven't received handshake from the other side yet.

Fields of HandshakeSending

sent_nonce: Nonce

Nonce that should be used to encrypt outgoing packets

packet: StatusPacketWithTime

Packet that should be sent every second

NotConfirmed

A handshake packet has been received from the other side but no encrypted packets. Continue sending handshake packets because we can't know if the other side has received them.

Fields of NotConfirmed

sent_nonce: Nonce

Nonce that should be used to encrypt outgoing packets

received_nonce: Nonce

Nonce that should be used to decrypt incoming packets

session_precomputed_key: PrecomputedKey

PrecomputedKey for this session that is used to encrypt and decrypt data packets

packet: StatusPacketWithTime

Packet that should be sent every second

Established

A valid encrypted packet has been received from the other side. Connection is fully established.

Fields of Established

sent_nonce: Nonce

Nonce that should be used to encrypt outgoing packets

received_nonce: Nonce

Nonce that should be used to decrypt incoming packets

session_precomputed_key: PrecomputedKey

PrecomputedKey for this session that is used to encrypt and decrypt data packets

Trait Implementations

impl Clone for ConnectionStatus[src]

impl Debug for ConnectionStatus[src]

impl Eq for ConnectionStatus[src]

impl PartialEq<ConnectionStatus> for ConnectionStatus[src]

impl StructuralEq for ConnectionStatus[src]

impl StructuralPartialEq for ConnectionStatus[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.