Skip to main content

AsyncControlClient

Struct AsyncControlClient 

Source
pub struct AsyncControlClient { /* private fields */ }
Expand description

A client to communicate with control.

Implementations§

Source§

impl AsyncControlClient

Source

pub async fn check_auth( config: &Config, node_keys: &NodeState, auth_key: Option<&str>, ) -> Result<(), Error>

Check whether it is possible to login with the given config, node keys, and auth key.

Source

pub async fn connect( config: &Config, node_keys: &NodeState, auth_key: Option<&str>, auth_url_tx: Sender<Option<Url>>, ) -> Result<(Self, impl Stream<Item = Arc<StateUpdate>> + Send + Sync + use<>), Error>

Connects to the control plane, registers this Tailscale node, and starts handling the message stream from control.

The second element of the return value is a netmap stream which started listening before the client connected, i.e. it will not miss any updates from control.

auth_url_tx is the embedder-owned “current pending re-auth URL” cell: if the live map-poll loop hits a mid-session re-auth (control returns MachineNotAuthorized on a re-register because the node key expired or was revoked), run publishes that URL here without tearing the loop down, so the embedder can prompt the user to re-authorize while registration keeps retrying. The caller creates the channel and keeps the Receiver (this crate must not depend on the embedder’s device-state types, so the cell carries a bare Option<Url>).

Source

pub async fn set_home_region<'c>( &mut self, region_id: RegionId, latencies: impl IntoIterator<Item = (&'c str, f64)>, )

Set the DERP home region for this node.

Source

pub async fn set_endpoints(&mut self, endpoints: Vec<Endpoint>)

Advertise this node’s magicsock UDP endpoints (ip:port candidates) to the control server so peers can learn where to attempt direct connections.

Source

pub async fn set_routable_ips(&mut self, routes: Vec<IpNet>)

Re-advertise this node’s routable IP prefixes (Hostinfo.RoutableIPs) to control mid-session — the wire half of a runtime set_advertise_routes. routes is the final advertised set (already filtered); it is sent on the live map-poll connection without tearing down the long-poll, exactly like set_endpoints.

Source

pub async fn set_hostname(&mut self, hostname: String)

Update this node’s Hostinfo.Hostname to hostname at control mid-session — the wire half of a runtime set_hostname. Sent on the live map-poll connection without tearing down the long-poll, exactly like set_routable_ips.

Source

pub fn map_url(&self) -> Url

Construct the URL that should be used to fetch the netmap.

Source

pub fn netmap_stream( &self, ) -> impl Stream<Item = Arc<StateUpdate>> + Send + Sync + use<>

Get a stream of all netmap updates.

Trait Implementations§

Source§

impl Debug for AsyncControlClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more