pub struct NetAddr {
    pub addr: PreVector<u8, ADDR_IPV6_SIZE>,
    pub net: Network,
    pub scope_id: u32,
}
Expand description

| Network address. |

Fields§

§addr: PreVector<u8, ADDR_IPV6_SIZE>

| Raw representation of the network address. | | In network byte order (big endian) for | IPv4 and IPv6. |

§net: Network

| Network to which this address belongs. |

§scope_id: u32

| Scope id if scoped/link-local IPV6 | address. | | See https://tools.ietf.org/html/rfc4007 |

Implementations§

| Whether this address should be relayed | to other peers even if we can’t reach | it ourselves. |

| Serialize to a stream. |

| Unserialize from a stream. |

| Serialize in pre-ADDRv2/BIP155 format | to an array. |

| Serialize in pre-ADDRv2/BIP155 format | to a stream. |

| Serialize as ADDRv2 / BIP155. |

| Unserialize from a pre-ADDRv2/BIP155 | format from an array. |

| Unserialize from a pre-ADDRv2/BIP155 | format from a stream. |

| Unserialize from a ADDRv2 / BIP155 format. |

| Get the BIP155 network id of this address. | | Must not be called for IsInternal() | objects. | | | ———– | @return | | BIP155 network id, except TORV2 which | is no longer supported. |

| Set m_net from the provided BIP155 | network id and size after validation. | | ———– | @return | | true the network was recognized, is | valid and m_net was set | ––––– | @return | | false not recognised (from future?) | and should be silently ignored @throws | std::ios_base::failure if the network | is one of the BIP155 founding networks | (id 1..6) with wrong address size. |

| Set from a legacy IPv6 address. | | Legacy IPv6 address may be a normal IPv6 | address, or another address (e.g. IPv4) | disguised as IPv6. | | This encoding is used in the legacy addr | encoding. |

| Create an “internal” address that represents | a name or FQDN. AddrMan uses these fake | addresses to keep track of which DNS | seeds were used. | | | ———– | @return | | Whether or not the operation was successful. | @see NET_INTERNAL, INTERNAL_IN_IPV6_PREFIX, | CNetAddr::IsInternal(), CNetAddr::IsRFC4193() |

| Parse a Tor or I2P address and set this | object to it. | | ———– | @param[in] addr | | Address to parse, for example pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion | or ukeu3k5oycgaauneqgtnvselmt4yemvoilkln7jpvamvfx7dnkdq.b32.i2p. | | ———– | @return | | Whether the operation was successful. | @see CNetAddr::IsTor(), CNetAddr::IsI2P() |

| Parse a Tor address and set this object | to it. | | ———– | @param[in] addr | | Address to parse, must be a valid C string, | for example pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion. | | ———– | @return | | Whether the operation was successful. | @see CNetAddr::IsTor() |

| Parse an I2P address and set this object | to it. | | ———– | @param[in] addr | | Address to parse, must be a valid C string, | for example ukeu3k5oycgaauneqgtnvselmt4yemvoilkln7jpvamvfx7dnkdq.b32.i2p. | | ———– | @return | | Whether the operation was successful. | @see CNetAddr::IsI2P() |

| INADDR_ANY equivalent |

| IPv4 mapped address (::FFFF:0:0/96, | 0.0.0.0/0) |

| IPv6 address (not mapped IPv4, not Tor) |

| IPv4 private networks (10.0.0.0/8, | 192.168.0.0/16, 172.16.0.0/12) |

| IPv4 inter-network communications | (198.18.0.0/15) |

| IPv4 autoconfig (169.254.0.0/16) |

| IPv4 ISP-level NAT (100.64.0.0/10) |

| IPv4 documentation addresses (192.0.2.0/24, | 198.51.100.0/24, 203.0.113.0/24) |

| IPv6 documentation address (2001:0DB8::/32) |

| IPv6 6to4 tunnelling (2002::/16) |

| IPv6 well-known prefix for IPv4-embedded | address (64:FF9B::/96) |

| IPv6 Teredo tunnelling (2001::/32) |

| IPv6 autoconfig (FE80::/64) |

| IPv6 unique local (FC00::/7) |

| IPv6 IPv4-translated address (::FFFF:0:0:0/96) | (actually defined in RFC2765) |

| IPv6 ORCHID (deprecated) (2001:10::/28) |

| IPv6 ORCHIDv2 (2001:20::/28) |

| IPv6 Hurricane Electric - https://he.net | (2001:0470::/36) |

| Check whether this object represents | a TOR address. @see CNetAddr::SetSpecial(const | std::string &) |

| Check whether this object represents | an I2P address. |

| Check whether this object represents | a CJDNS address. |

| @note | | A valid address may or may not be publicly | routable on the global internet. As | in, the set of valid addresses is a superset | of the set of publicly routable addresses. | @see CNetAddr::IsRoutable() | | ———– | @return | | Whether or not this network address | is a valid address that @a could be used | to refer to an actual host. |

| @note | | A routable address is always valid. | As in, the set of routable addresses | is a subset of the set of valid addresses. | @see CNetAddr::IsValid() | | ———– | @return | | Whether or not this network address | is publicly routable on the global internet. |

| @return | | Whether or not this is a dummy address | that represents a name. @see CNetAddr::SetInternal(const | std::string &) |

| Check if the current object can be serialized | in pre-ADDRv2/BIP155 format. |

| Try to get our IPv4 address. | | ———– | @param[out] pipv4Addr | | The in_addr struct to which to copy. | | ———– | @return | | Whether or not the operation was successful, | in particular, whether or not our address | was an IPv4 address. @see CNetAddr::IsIPv4() |

| Try to get our IPv6 address. | | ———– | @param[out] pipv6Addr | | The in6_addr struct to which to copy. | | ———– | @return | | Whether or not the operation was successful, | in particular, whether or not our address | was an IPv6 address. @see CNetAddr::IsIPv6() |

| Whether this address has a linked IPv4 | address (see GetLinkedIPv4()). |

| For IPv4, mapped IPv4, SIIT translated | | IPv4, Teredo, 6to4 tunneled addresses, | return the relevant IPv4 address as | a uint32. |

| The AS on the BGP path to the node we use | to diversify peers in AddrMan bucketing | based on the AS infrastructure. | | The ip->AS mapping depends on how asmap is | constructed.

| Get the canonical identifier of our | network group | | The groups are assigned in a way where | it should be costly for an attacker to | obtain addresses with many different | group identifiers, even if it is cheap | to obtain addresses with the same identifier. | | ———– | @note | | No two connections will be attempted | to addresses with the same network group. |

| Calculates a metric for how reachable | (*this) is from a given partner |

Trait Implementations§

| @return | | true if the address is in a reachable | network, false otherwise |

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

| Construct an unspecified IPv6 network | address (::/128). | | ———– | @note | | This address is considered invalid | by | | CNetAddr::IsValid() |

Deserialize this value from the given Serde deserializer. Read more
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Serialize this value into the given Serde serializer. 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
Performs the conversion. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Convert type of a const pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.