Trait CmdChecker

Source
pub(crate) trait CmdChecker: Debug {
    // Required methods
    fn check_msg(&mut self, msg: &UnparsedRelayMsg) -> Result<StreamStatus>;
    fn consume_checked_msg(&mut self, msg: UnparsedRelayMsg) -> Result<()>;
}
Expand description

An object that checks incoming commands before they are sent to a stream.

These checks are called from the circuit reactor code, which runs in its own task. The reactor code continues calling these checks we have sent our own END cell on the stream. See crate::tunnel::circuit::halfstream for more information.

NOTE: The checking DOES NOT take SENDME messages into account; those are handled separately. Neither of the methods on this trait will ever be passed a SENDME message.

See circuit::reactor for more information on how these checks relate to other checks performed on incoming messages.

Required Methods§

Source

fn check_msg(&mut self, msg: &UnparsedRelayMsg) -> Result<StreamStatus>

Look at a message msg and decide whether it can be handled on this stream.

If msg is invalid, return an error, indicating that the protocol has been violated and the corresponding circuit should be closed.

If msg is invalid, update the state of this checker, and return a StreamStatus indicating whether the last message closed.

Source

fn consume_checked_msg(&mut self, msg: UnparsedRelayMsg) -> Result<()>

Consume msg and make sure it can be parsed correctly.

This is an additional check, beyond check_msg(), performed for half-open streams. It should only be called if check_msg() succeeds. It shouldn’t be called on open streams: for those, the stream itself parses the message and consumes it.

Implementors§

Source§

impl CmdChecker for DataCmdChecker

Source§

impl CmdChecker for IncomingCmdChecker

Available on crate feature hs-service only.
Source§

impl CmdChecker for ResolveCmdChecker