跳到主要内容

EndpointConfig

搜索

结构体 EndpointConfig 

源代码
pub struct EndpointConfig { /* private fields */ }
展开描述

端点的全局配置,会影响所有连接

默认值应该适合大多数互联网应用。

实现§

源代码§

impl EndpointConfig

源代码

pub fn new(reset_key: Arc<dyn HmacKey>) -> EndpointConfig

使用指定的 reset_key 创建一个默认配置

源代码

pub fn cid_generator<F>(&mut self, factory: F) -> &mut EndpointConfig
where F: Fn() -> Box<dyn ConnectionIdGenerator> + Send + Sync + 'static,

提供一个自定义的连接 ID 生成器工厂

每个由本配置构造的 Endpoint 都会调用一次该工厂,以获取 CID 生成器,用于为该 Endpoint 所涉及的所有连接的入站包生成 CID。自定义 CID 生成器允许应用程序在本地连接 ID 中嵌入信息,例如支持无状态的数据包级负载均衡器。

默认为 HashedConnectionIdGenerator

源代码

pub fn reset_key(&mut self, key: Arc<dyn HmacKey>) -> &mut EndpointConfig

用于向与本端点上一实例通信的对端发送已认证的连接重置所用的私钥。

源代码

pub fn max_udp_payload_size( &mut self, value: u16, ) -> Result<&mut EndpointConfig, ConfigError>

接受来自对端的最大 UDP 有效负载大小(不含 UDP 与 IP 头部开销)。

必须大于或等于 1200。

默认为 1472,这是可在典型 1500 字节以太网 MTU 中传输的最大 UDP 有效负载。在具有更大 MTU 的链路上(例如回环或使用巨型帧的以太网),可以增大该值以提升性能,代价是数据报接收缓冲区大小线性增长。

源代码

pub fn get_max_udp_payload_size(&self) -> u64

获取 max_udp_payload_size 的当前值

源代码

pub fn supported_versions( &mut self, supported_versions: Vec<u32>, ) -> &mut EndpointConfig

覆盖所支持的 QUIC 版本

源代码

pub fn grease_quic_bit(&mut self, value: bool) -> &mut EndpointConfig

是否接受 QUIC 包头中 fixed bit 为任意取值的包

默认开启。有助于防止协议僵化,并降低流量对观察者的可识别度。若希望让观察者能够将本流量识别为 QUIC,可关闭该选项。

源代码

pub fn min_reset_interval(&mut self, value: Duration) -> &mut EndpointConfig

两条外发无状态重置包之间的最小间隔

默认为 20ms。用于限制向端点发送垃圾包的攻击(例如 ISAKMP/IKE amplification)所造成的影响。较大的值能提供更强的防御,但可能延迟客户端对某些错误情况的检测。使用在 validate 中具有较低误报率的 ConnectionIdGenerator,可以降低使用较小最小重置间隔所带来的风险。

源代码

pub fn rng_seed(&mut self, seed: Option<[u8; 32]>) -> &mut EndpointConfig

供内部随机数生成使用的可选种子

默认情况下,quinn 使用平台熵源初始化端点的随机数生成器。但你也可以通过本方法自行设定种子(例如需要确定性运行 quinn,或在无可用熵源的环境中运行)。

trait 实现§

源代码§

impl Clone for EndpointConfig

源代码§

fn clone(&self) -> EndpointConfig

返回值的副本。 更多信息
1.0.0 · 源代码§

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

Performs copy-assignment from source. 更多信息
源代码§

impl Debug for EndpointConfig

源代码§

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

使用给定的格式化器格式化此值。 更多信息
源代码§

impl Default for EndpointConfig

Available on crate features aws-lc-rs or ring only.
源代码§

fn default() -> EndpointConfig

Returns the “default value” for a type. 更多信息

自动 trait 实现§

blanket 实现§

源代码§

impl<T> Any for T
where T: 'static + ?Sized,

源代码§

fn type_id(&self) -> TypeId

Gets the TypeId of self. 更多信息
源代码§

impl<T> Borrow<T> for T
where T: ?Sized,

源代码§

fn borrow(&self) -> &T

Immutably borrows from an owned value. 更多信息
源代码§

impl<T> BorrowMut<T> for T
where T: ?Sized,

源代码§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 更多信息
源代码§

impl<T> CloneToUninit for T
where T: Clone,

源代码§

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. 更多信息
源代码§

impl<T> From<T> for T

源代码§

fn from(t: T) -> T

原样返回该参数。

源代码§

impl<T> Instrument for T

源代码§

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

Instruments this type with the provided Span, returning an Instrumented wrapper. 更多信息
源代码§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. 更多信息
源代码§

impl<T, U> Into<U> for T
where U: From<T>,

源代码§

fn into(self) -> U

调用 U::from(self)

也就是说,此转换行为完全由 From<T> for U 的实现决定。

源代码§

impl<T> ToOwned for T
where T: Clone,

源代码§

type Owned = T

The resulting type after obtaining ownership.
源代码§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. 更多信息
源代码§

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

Uses borrowed data to replace owned data, usually by cloning. 更多信息
源代码§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

源代码§

type Error = Infallible

The type returned in the event of a conversion error.
源代码§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

执行转换。
源代码§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

源代码§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
源代码§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

执行转换。
源代码§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

源代码§

fn vzip(self) -> V

源代码§

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. 更多信息
源代码§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. 更多信息
源代码§

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

源代码§

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

源代码§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,