pub enum NetAddress {
    IPv4 {
        addr: [u8; 4],
        port: u16,
    },
    IPv6 {
        addr: [u8; 16],
        port: u16,
    },
    OnionV2([u8; 12]),
    OnionV3 {
        ed25519_pubkey: [u8; 32],
        checksum: u16,
        version: u8,
        port: u16,
    },
}
Expand description

An address which can be used to connect to a remote peer

Variants

IPv4

Fields

addr: [u8; 4]

The 4-byte IPv4 address

port: u16

The port on which the node is listening

An IPv4 address/port on which the peer is listening.

IPv6

Fields

addr: [u8; 16]

The 16-byte IPv6 address

port: u16

The port on which the node is listening

An IPv6 address/port on which the peer is listening.

OnionV2([u8; 12])

An old-style Tor onion address/port on which the peer is listening.

This field is deprecated and the Tor network generally no longer supports V2 Onion addresses. Thus, the details are not parsed here.

OnionV3

Fields

ed25519_pubkey: [u8; 32]

The ed25519 long-term public key of the peer

checksum: u16

The checksum of the pubkey and version, as included in the onion address

version: u8

The version byte, as defined by the Tor Onion v3 spec.

port: u16

The port on which the node is listening

A new-style Tor onion address/port on which the peer is listening. To create the human-readable “hostname”, concatenate ed25519_pubkey, checksum, and version, wrap as base32 and append “.onion”.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Reads a Self in from the given Read

Writes self out to the given Writer

Writes self out to a Vec

Writes self out to a Vec

Gets the length of this object after it has been serialized. This can be overridden to optimize cases where we prepend an object with its length. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Reads a Self in from the given Read

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.