Skip to main content

GuardConfig

Struct GuardConfig 

Source
pub struct GuardConfig {
    pub egress_limit_bps: u64,
    pub per_ip_media: u32,
    pub accept_rate: f64,
    pub accept_rate_per_ip: f64,
    pub whep_rate_per_ip: f64,
    pub whep_per_ip_max: u32,
    pub ban_window: Duration,
    pub ban_strikes: u32,
    pub ban: Duration,
    pub disabled: bool,
}
Expand description

准入参数。默认值与 C 版一致。

Fields§

§egress_limit_bps: u64

出口码率阈值(字节/秒);0 = 关闭码率准入。

§per_ip_media: u32

单 IP 媒体并发上限。

§accept_rate: f64

全局媒体建连速率(每秒)与突发(2 倍)。

§accept_rate_per_ip: f64

单 IP 媒体建连速率(每秒)与突发(2 倍)。

§whep_rate_per_ip: f64

单 IP WHEP 建连速率(每秒)。WHEP 是「一次 POST 建一个会话」,浏览器刷新/ 多标签页会瞬间连开几条,与 RTSP 长连接共用 10/s 必然误伤(实测两块浏览器就触发封禁)。

§whep_per_ip_max: u32

单 IP WHEP 并发会话上限。

§ban_window: Duration

只有「窗口内累计超限多少次」才封禁(单次超限只拒这一条)。

§ban_strikes: u32

连续超速多少次触发封禁。

§ban: Duration

封禁时长。

§disabled: bool

是否整体关闭(调试用)。

Implementations§

Source§

impl GuardConfig

Source

pub fn from_env() -> Self

从环境变量读取(缺省用默认值)。

Trait Implementations§

Source§

impl Clone for GuardConfig

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 Copy for GuardConfig

Source§

impl Debug for GuardConfig

Source§

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

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

impl Default for GuardConfig

Source§

fn default() -> Self

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.

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> 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<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