Back to Site
Loading...
Searching...
No Matches
librats::NatStatus Class Referencefinal

#include <nat_status.h>

Inheritance diagram for librats::NatStatus:
[legend]
Collaboration diagram for librats::NatStatus:
[legend]

Public Member Functions

void record_udp_observation (const PeerId &reporter, const Address &external, bool is_own_address)
 Record that reporter observed our datagram socket at external.
 
void forget (const PeerId &reporter)
 Forget a reporter's observation — its link is gone and what it saw may have been a mapping that died with it.
 
void reset ()
 Drop everything.
 
size_t observation_count () const
 How many distinct peers have reported an endpoint.
 
std::vector< Addressexternal_udp_endpoints () const override
 Endpoints peers have reported observing our shared datagram socket at, most recently confirmed first.
 
NatMapping udp_mapping () const override
 What the observations so far say about the mapping.
 
- Public Member Functions inherited from librats::ExternalAddressService
virtual ~ExternalAddressService ()=default
 

Static Public Attributes

static constexpr size_t kMaxObservers = 32
 Observations kept.
 

Detailed Description

Definition at line 77 of file nat_status.h.

Member Function Documentation

◆ external_udp_endpoints()

std::vector< Address > librats::NatStatus::external_udp_endpoints ( ) const
overridevirtual

Endpoints peers have reported observing our shared datagram socket at, most recently confirmed first.

Empty until at least one peer has said so over a datagram link. These are what a hole punch advertises to its target.

Implements librats::ExternalAddressService.

◆ forget()

void librats::NatStatus::forget ( const PeerId reporter)

Forget a reporter's observation — its link is gone and what it saw may have been a mapping that died with it.

◆ observation_count()

size_t librats::NatStatus::observation_count ( ) const

How many distinct peers have reported an endpoint.

◆ record_udp_observation()

void librats::NatStatus::record_udp_observation ( const PeerId reporter,
const Address external,
bool  is_own_address 
)

Record that reporter observed our datagram socket at external.

Parameters
is_own_addresswhether that endpoint is one this node holds locally (the caller knows its interfaces; this class does not) — the signal that there is no NAT in the path.

◆ reset()

void librats::NatStatus::reset ( )

Drop everything.

The node is restarting, or the host's network changed and every mapping learned under the old one is now a guess.

◆ udp_mapping()

NatMapping librats::NatStatus::udp_mapping ( ) const
overridevirtual

What the observations so far say about the mapping.

Implements librats::ExternalAddressService.

Member Data Documentation

◆ kMaxObservers

constexpr size_t librats::NatStatus::kMaxObservers = 32
staticconstexpr

Observations kept.

One per reporting peer, so a node with many peers does not grow this without bound and a single peer cannot flood it either — a second report from the same peer replaces its first rather than adding to it.

Definition at line 82 of file nat_status.h.


The documentation for this class was generated from the following file: