Struct iroh_net_report::Client
source · pub struct Client { /* private fields */ }
Expand description
Client to run net_reports.
Creating this creates a net_report actor which runs in the background. Most of the time
it is idle unless Client::get_report
is called, which is the main interface.
The Client
struct can be cloned and results multiple handles to the running actor.
If all Client
s are dropped the actor stops running.
While running the net_report actor expects to be passed all received stun packets using
Addr::receive_stun_packet
.
Implementations§
source§impl Client
impl Client
sourcepub fn new(
port_mapper: Option<Client>,
dns_resolver: DnsResolver
) -> Result<Self>
pub fn new( port_mapper: Option<Client>, dns_resolver: DnsResolver ) -> Result<Self>
Creates a new net_report client.
This starts a connected actor in the background. Once the client is dropped it will stop running.
sourcepub fn addr(&self) -> Addr
pub fn addr(&self) -> Addr
Returns a new address to send messages to this actor.
Unlike the client itself the returned Addr
does not own the actor task, it only
allows sending messages to the actor.
sourcepub async fn get_report(
&mut self,
dm: RelayMap,
stun_conn4: Option<Arc<UdpSocket>>,
stun_conn6: Option<Arc<UdpSocket>>
) -> Result<Arc<Report>>
pub async fn get_report( &mut self, dm: RelayMap, stun_conn4: Option<Arc<UdpSocket>>, stun_conn6: Option<Arc<UdpSocket>> ) -> Result<Arc<Report>>
Runs a net_report, returning the report.
It may not be called concurrently with itself, &mut self
takes care of that.
The stun_conn4 and stun_conn6 endpoints are bound UDP sockets to use to send out
STUN packets. This function will not read from the sockets, as they may be
receiving other traffic as well, normally they are the sockets carrying the real
traffic. Thus all stun packets received on those sockets should be passed to
Addr::receive_stun_packet
in order for this function to receive the stun
responses and function correctly.
If these are not passed in this will bind sockets for STUN itself, though results may not be as reliable.