AuthClient

Struct AuthClient 

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

DPlus TCP authentication client.

Performs the mandatory TCP auth step against auth.dstargateway.org and returns the [HostList] cached by the auth server. Caller then hands the host list to the sans-io session to transition the typestate to [dstar_gateway_core::session::client::Authenticated].

Implementations§

Source§

impl AuthClient

Source

pub const fn new() -> Self

Create a new auth client with defaults.

The endpoint is None (resolve auth.dstargateway.org:20001 via DNS at call time), the connect timeout is 10 s, and the per-read timeout is 5 s.

Source

pub const fn with_endpoint(self, endpoint: SocketAddr) -> Self

Override the TCP auth endpoint.

Used by integration tests to point the client at a local fake auth server on an ephemeral port.

Source

pub const fn with_connect_timeout(self, dur: Duration) -> Self

Override the TCP connect timeout.

Source

pub const fn with_read_timeout(self, dur: Duration) -> Self

Override the per-read timeout while draining the response.

Source

pub const fn endpoint(&self) -> Option<SocketAddr>

Current endpoint override, if any.

Source

pub async fn authenticate( &self, callsign: Callsign, ) -> Result<HostList, AuthError>

Perform the TCP auth against the configured endpoint.

Builds the 56-byte auth packet per ircDDBGateway/Common/DPlusAuthenticator.cpp:111-143, sends it over a fresh TCP connection, and accumulates the framed response until the server closes the socket. The accumulated bytes are then parsed via [dstar_gateway_core::codec::dplus::parse_auth_response] with a [NullSink] for diagnostics.

§Errors
§Cancellation safety

This method is not cancel-safe. Cancelling the future may leave a half-written request on the wire or an auth TCP session dangling from the upstream host list server’s perspective. The method owns a transient [tokio::net::TcpStream] internally and relies on drop-on-cancel to close it, but the upstream server may briefly see the partial packet. Callers should either await the future to completion or apply an outer [tokio::time::timeout] that matches the configured connect_timeout.

§Example
use dstar_gateway::auth::AuthClient;
use dstar_gateway_core::types::Callsign;

let client = AuthClient::new();
let hosts = client.authenticate(Callsign::try_from_str("W1AW")?).await?;
println!("{} known REF hosts", hosts.len());
§See also

ircDDBGateway/Common/DPlusAuthenticator.cpp:111-143 — the reference 56-byte packet layout this client mirrors.

Trait Implementations§

Source§

impl Clone for AuthClient

Source§

fn clone(&self) -> AuthClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AuthClient

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for AuthClient

Source§

fn default() -> AuthClient

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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