pub struct Guard { /* private fields */ }Expand description
Everything the checks need, built once at startup.
Implementations§
Source§impl Guard
impl Guard
Sourcepub fn for_session(
settings: &HttpConfig,
identity: &SelfIdentity,
peers: HashMap<IpAddr, String>,
) -> Self
pub fn for_session( settings: &HttpConfig, identity: &SelfIdentity, peers: HashMap<IpAddr, String>, ) -> Self
Everything the checks need, from the settings and what status said.
The settings are one argument rather than three so that the token, the hosts and the origins travel as what they are — one operator’s answer about one transport — rather than as three lists a caller could pass in the wrong order.
Sourcepub fn new(
token: Option<Secret>,
extra_hosts: &[String],
origins: &[String],
identity: &SelfIdentity,
peers: HashMap<IpAddr, String>,
) -> Self
pub fn new( token: Option<Secret>, extra_hosts: &[String], origins: &[String], identity: &SelfIdentity, peers: HashMap<IpAddr, String>, ) -> Self
Build the checks from what the operator asked for and what status said.
The allow-list always contains loopback and localhost and this node’s
own names; an operator adding to it is adding, never replacing, because
a list that could be narrowed to nothing is one an operator can lock
themselves out with.
Sourcepub fn hosts(&self) -> Vec<&str>
pub fn hosts(&self) -> Vec<&str>
The hosts this server answers for, so that rmcp’s own transport can be given the same list and the two cannot disagree.
Sourcepub fn admit(
&self,
headers: &HeaderMap,
address: IpAddr,
now: Instant,
) -> Result<(), Refusal>
pub fn admit( &self, headers: &HeaderMap, address: IpAddr, now: Instant, ) -> Result<(), Refusal>
Ask every question, in order, and answer the first that says no.
The order matters: a request from the wrong host is refused before its token is looked at, so a page probing for a valid token learns nothing from the timing of the refusal.