Skip to main content

Listener

Struct Listener 

Source
pub struct Listener {
    pub kind: ListenerKind,
    pub access: Option<Arc<AccessValidator>>,
    pub policy: ToolPolicy,
    pub allow_unauthenticated: bool,
    pub tailnet: bool,
    pub routes: Option<Routes>,
    pub public_routes: Option<Routes>,
    pub preview: Option<Routes>,
    pub hooks: Hooks,
}
Expand description

One address the server answers on, with its own gate and tool policy.

Fields§

§kind: ListenerKind§access: Option<Arc<AccessValidator>>

Required on TCP unless allow_unauthenticated; refused on unix.

§policy: ToolPolicy§allow_unauthenticated: bool

Serve TCP with no Access validation, trusting whatever reaches the port.

§tailnet: bool

A TCP listener on a tailnet address rather than loopback.

§routes: Option<Routes>

Paths other than /healthz and /mcp.

§public_routes: Option<Routes>

Routes that authenticate every request themselves and are served even with Access configured (webhooks, signed by their sender).

§preview: Option<Routes>

Requests for preview hosts, by Host, ahead of everything else.

§hooks: Hooks

Authentication and authorization the embedder supplies.

Implementations§

Source§

impl Listener

Source

pub fn tcp(addr: impl Into<String>) -> Self

Source

pub fn unix(path: impl Into<PathBuf>) -> Self

Source

pub fn mtls(addr: impl Into<String>, tls: TlsConfig) -> Self

TLS on any address, admitting only clients whose certificate tls verifies.

Source

pub fn hooks(self, h: Hooks) -> Self

Serve routes on this listener too.

Source

pub fn routes(self, r: Routes) -> Self

Source

pub fn public_routes(self, r: Routes) -> Self

Serve r ahead of Access: only for routes whose every request carries its own credential.

Source

pub fn preview(self, r: Routes) -> Self

Let r take requests by their Host before anything else: it answers only for hosts that are its own.

Source

pub fn access(self, v: AccessValidator) -> Self

Source

pub fn access_shared(self, v: Arc<AccessValidator>) -> Self

Self::access, sharing a validator (and its key cache).

Source

pub fn tailnet(self, yes: bool) -> Self

Bind a tailnet address instead of loopback (no Access: only tailnet peers reach it).

Source

pub fn policy(self, p: ToolPolicy) -> Self

Source

pub fn allow_unauthenticated(self, yes: bool) -> Self

Source

pub fn is_trusted(&self) -> bool

The unix socket is trusted as itself; a TCP caller is trusted only as a superadmin, per request.

Trait Implementations§

Source§

impl Clone for Listener

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Listener

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V