pub struct ServerConfig {
pub transport: Arc<TransportConfig>,
pub crypto: Arc<dyn ServerConfig>,
pub validation_token: ValidationTokenConfig,
/* private fields */
}展开描述
控制入站连接的参数
默认值应该适合大多数互联网应用。
字段§
§transport: Arc<TransportConfig>用于入站连接的传输配置
crypto: Arc<dyn ServerConfig>用于入站连接的 TLS 配置
必须设置为仅使用 TLS 1.3。
validation_token: ValidationTokenConfig用于发送和处理验证令牌(validation token)的配置
实现§
源代码§impl ServerConfig
impl ServerConfig
源代码pub fn new(
crypto: Arc<dyn ServerConfig>,
token_key: Arc<dyn HandshakeTokenKey>,
) -> ServerConfig
pub fn new( crypto: Arc<dyn ServerConfig>, token_key: Arc<dyn HandshakeTokenKey>, ) -> ServerConfig
使用指定的握手令牌密钥创建一个默认配置
源代码pub fn transport_config(
&mut self,
transport: Arc<TransportConfig>,
) -> &mut ServerConfig
pub fn transport_config( &mut self, transport: Arc<TransportConfig>, ) -> &mut ServerConfig
设置自定义的 TransportConfig
源代码pub fn validation_token_config(
&mut self,
validation_token: ValidationTokenConfig,
) -> &mut ServerConfig
pub fn validation_token_config( &mut self, validation_token: ValidationTokenConfig, ) -> &mut ServerConfig
设置自定义的 ValidationTokenConfig
源代码pub fn token_key(
&mut self,
value: Arc<dyn HandshakeTokenKey>,
) -> &mut ServerConfig
pub fn token_key( &mut self, value: Arc<dyn HandshakeTokenKey>, ) -> &mut ServerConfig
用于认证握手令牌中所包含数据的私钥
源代码pub fn retry_token_lifetime(&mut self, value: Duration) -> &mut ServerConfig
pub fn retry_token_lifetime(&mut self, value: Duration) -> &mut ServerConfig
重试令牌在签发后被视为有效的时长
默认为 15 秒。
源代码pub fn migration(&mut self, value: bool) -> &mut ServerConfig
pub fn migration(&mut self, value: bool) -> &mut ServerConfig
是否允许客户端迁移到新的地址
可改善在切换网络连接或遭遇 NAT 重绑时客户端的行为。默认开启。
源代码pub fn preferred_address_v4(
&mut self,
address: Option<SocketAddrV4>,
) -> &mut ServerConfig
pub fn preferred_address_v4( &mut self, address: Option<SocketAddrV4>, ) -> &mut ServerConfig
在握手期间将向客户端通告的优先 IPv4 地址
若客户端能到达该地址,便会切换到该地址。
源代码pub fn preferred_address_v6(
&mut self,
address: Option<SocketAddrV6>,
) -> &mut ServerConfig
pub fn preferred_address_v6( &mut self, address: Option<SocketAddrV6>, ) -> &mut ServerConfig
在握手期间将向客户端通告的优先 IPv6 地址
若客户端能到达该地址,便会切换到该地址。
源代码pub fn max_incoming(&mut self, max_incoming: usize) -> &mut ServerConfig
pub fn max_incoming(&mut self, max_incoming: usize) -> &mut ServerConfig
源代码pub fn incoming_buffer_size(
&mut self,
incoming_buffer_size: u64,
) -> &mut ServerConfig
pub fn incoming_buffer_size( &mut self, incoming_buffer_size: u64, ) -> &mut ServerConfig
源代码pub fn incoming_buffer_size_total(
&mut self,
incoming_buffer_size_total: u64,
) -> &mut ServerConfig
pub fn incoming_buffer_size_total( &mut self, incoming_buffer_size_total: u64, ) -> &mut ServerConfig
源代码pub fn time_source(
&mut self,
time_source: Arc<dyn TimeSource>,
) -> &mut ServerConfig
pub fn time_source( &mut self, time_source: Arc<dyn TimeSource>, ) -> &mut ServerConfig
源代码§impl ServerConfig
impl ServerConfig
源代码pub fn with_single_cert(
cert_chain: Vec<CertificateDer<'static>>,
key: PrivateKeyDer<'static>,
) -> Result<ServerConfig, Error>
pub fn with_single_cert( cert_chain: Vec<CertificateDer<'static>>, key: PrivateKeyDer<'static>, ) -> Result<ServerConfig, Error>
使用给定的证书链创建一个服务器配置,该证书链将向客户端出示
使用一个随机生成的握手令牌密钥。
源代码§impl ServerConfig
impl ServerConfig
源代码pub fn with_crypto(crypto: Arc<dyn ServerConfig>) -> ServerConfig
pub fn with_crypto(crypto: Arc<dyn ServerConfig>) -> ServerConfig
使用给定的 crypto::ServerConfig 创建一个服务器配置
使用一个随机生成的握手令牌密钥。
trait 实现§
源代码§impl Clone for ServerConfig
impl Clone for ServerConfig
源代码§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
返回值的副本。 更多信息
1.0.0 · 源代码§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. 更多信息自动 trait 实现§
impl Freeze for ServerConfig
impl !RefUnwindSafe for ServerConfig
impl Send for ServerConfig
impl Sync for ServerConfig
impl Unpin for ServerConfig
impl UnsafeUnpin for ServerConfig
impl !UnwindSafe for ServerConfig
blanket 实现§
源代码§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
源代码§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. 更多信息