跳到主要内容

ServerConnection

结构体 ServerConnection 

Source
pub struct ServerConnection { /* private fields */ }
展开描述

QUIC 服务器连接。

实现§

Source§

impl ServerConnection

Source

pub fn new( config: Arc<ServerConfig>, quic_version: Version, params: Vec<u8>, ) -> Result<Self, Error>

创建一个新的 QUIC ServerConnection.

This differs 从 ServerConnection::new() in that it takes an extra params argument, which contains the TLS-encoded transport parameters 到 send.

Source

pub fn reject_early_data(&mut self)

明示弃用早期数据,并通知客户端

Useful if invariants encoded in received_resumption_data() cannot be respected.

Must be called while is_handshaking is true.

Source

pub fn server_name(&self) -> Option<&str>

Retrieves 服务器名, if any, 用 到 select 证书 并 私钥.

This returns None until some time after the client’s server name indication (SNI) extension value is processed during the handshake. It will never be None when the connection is ready 到 send 或 process application data, unless the client does not support SNI.

This is useful 用于 application protocols that need 到 enforce that the server name matches an application layer protocol hostname. For example, HTTP/1.1 servers commonly expect the Host: header field of every request on 一个 connection 到 match the hostname in the SNI extension when the client provides the SNI extension.

此 server 名称是 also 用 到 match sessions during session resumption.

Methods from Deref<Target = ConnectionCommon<ServerConnectionData>>§

Source

pub fn quic_transport_parameters(&self) -> Option<&[u8]>

返回该会话的 TLS 编码传输参数’s peer.

While the transport parameters are technically available prior 到 the completion of the handshake, they cannot be fully trusted until the handshake completes, 并 reliance on them should be minimized. However, any tampering with the parameters will cause the handshake 到 fail.

Source

pub fn zero_rtt_keys(&self) -> Option<DirectionalKeys>

如果可用,计算用于加密/解密 0-RTT 数据包的密钥

Source

pub fn read_hs(&mut self, plaintext: &[u8]) -> Result<(), Error>

Consume unencrypted TLS handshake data.

Handshake data obtained 从 separate encryption levels should be supplied in separate calls.

Source

pub fn write_hs(&mut self, buf: &mut Vec<u8>) -> Option<KeyChange>

输出未加密的 TLS 握手数据

When this returns Some(_), the new keys must be 用 用于 future handshake data.

Source

pub fn alert(&self) -> Option<AlertDescription>

如果已产生致命警报,则输出其 TLS 描述码

Check after read_hs returns Err(_)

Methods from Deref<Target = CommonState>§

Source

pub fn wants_write(&self) -> bool

如果调用者应尽快调用以下方法,则返回 true: Connection::write_tls 尽快。

Source

pub fn is_handshaking(&self) -> bool

如果连接当前正在执行 TLS 握手,则返回 true。

During this time 明文 written 到 the connection is buffered in memory. After Connection::process_new_packets() has been called, this might start 到 return false while the final handshake packets still need 到 be extracted 从 the connection’s buffers.

Source

pub fn peer_certificates(&self) -> Option<&[CertificateDer<'static>]>

检索对等方用于身份验证的证书链或原始公钥。

此 order of 证书 chain is as it appears in the TLS protocol: the first certificate relates 到 the peer, the second certifies the first, the third certifies the second, 并 so on.

When using raw public keys, the first 并 only element 是 raw 公钥.

This is made available 用于 both full 并 resumed handshakes.

For clients, this 是 certificate chain 或 the raw 公钥 of the server.

For servers, this 是 certificate chain 或 the raw 公钥 of the client, if client authentication was completed.

此 return value is None until this value is available.

Note: the return type of the ‘certificate’, when using raw public keys is CertificateDer<'static> even though this should technically be 一个 SubjectPublicKeyInfoDer<'static>。 This choice simplifies the API 并 ensures backwards compatibility.

Source

pub fn alpn_protocol(&self) -> Option<&[u8]>

检索通过 ALPN 与对等方协商的协议。

A return value of None after handshake completion means no protocol was agreed (because no protocols were offered 或 已接受 by the peer)。

Source

pub fn negotiated_cipher_suite(&self) -> Option<SupportedCipherSuite>

检索与对等方协商的密码套件。

在密码套件协商一致之前返回 None。

Source

pub fn negotiated_key_exchange_group( &self, ) -> Option<&'static dyn SupportedKxGroup>

检索与对等方协商的密钥交换组。

This function may return None depending on the state of the connection, the type of handshake, 并 the protocol version.

If CommonState::is_handshaking() 为 true,此函数将返回 None。 Similarly, if the CommonState::handshake_kind() is HandshakeKind::Resumed 并 the CommonState::protocol_version() is TLS 1.2, then no key exchange will have occurred 并 此函数将返回 None

Source

pub fn protocol_version(&self) -> Option<ProtocolVersion>

检索与对等方协商的协议版本。

This returns None until the version is agreed.

Source

pub fn handshake_kind(&self) -> Option<HandshakeKind>

执行的握手类型。

它会告知握手是否为恢复握手。

This 将返回 None before it is known which sort of handshake occurred.

Source

pub fn send_close_notify(&mut self)

Queues 一个 close_notify warning alert 到 be sent in the next Connection::write_tls 调用。 This informs the peer that the connection is being closed.

Does nothing if any close_notify 或 fatal alert was already sent.

Source

pub fn wants_read(&self) -> bool

如果调用者应尽快调用以下方法,则返回 true: Connection::read_tls as soon as possible.

如果有要读取的待处理明文数据,请使用 Connection::reader, this returns false. If your application respects this mechanism, only one full TLS message , buffered by rustls.

Trait 实现§

Source§

impl Debug for ServerConnection

Source§

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

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

impl Deref for ServerConnection

Source§

type Target = ConnectionCommon<ServerConnectionData>

解引用后得到的类型。
Source§

fn deref(&self) -> &Self::Target

解引用此值。
Source§

impl DerefMut for ServerConnection

Source§

fn deref_mut(&mut self) -> &mut Self::Target

以可变方式解引用此值。
Source§

impl From<ServerConnection> for Connection

Source§

fn from(c: ServerConnection) -> Self

从输入类型转换为此类型。

自动 Trait 实现§

Blanket 实现§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. 更多信息
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows 从 an owned value. 更多信息
Source§

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

Source§

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

Mutably borrows 从 an owned value. 更多信息
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

原样返回传入的参数。

Source§

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

Source§

fn into(self) -> U

Calls U::从(self)

That is, this conversion is whatever the implementation of From<T> 用于 U 的实现方式。

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
此 target type on which the method may be called.
Source§

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

Source§

type Error = Infallible

转换出错时返回的类型。
Source§

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

执行转换。
Source§

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

Source§

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

转换出错时返回的类型。
Source§

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

执行转换。