跳到主要内容

Connecting

搜索

结构体 Connecting 

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

正在进行的连接尝试的 Future

实现§

源代码§

impl Connecting

源代码

pub fn into_0rtt(self) -> Result<(Connection, ZeroRttAccepted), Self>

以牺牲一定的安全性为代价,转换为一个 0-RTT 或 0.5-RTT 连接

若本地端点能够尝试发送 0/0.5-RTT 数据,本方法会立即返回 Ok。返回的 Connection 可用于在握手完成之前发送应用数据,代价是密码学安全保证被削弱。返回的 ZeroRttAccepted future 在握手完成时求解,此后新打开的流与新写入的数据将获得完整的密码学保护。

§出站连接

对于出站连接,若 crypto::ClientConfig 尝试恢复之前的 TLS 会话,则初次将连接转换为发送 0-RTT 数据的 Connection 的尝试会进行下去。然而,远端实际可能并不会接受这些 0-RTT 数据,但仍会接受此次连接尝试。这种可能性通过 ZeroRttAccepted future 表达——握手完成时,若 0-RTT 数据被接受则解析为 true,被拒绝则解析为 false。若被拒绝,在握手完成之前已打开的流与已发送的应用数据不会传达给远端应用,且本地的相关操作将返回 ZeroRttRejected 错误。

服务器可以自行决定是否拒绝 0-RTT 数据;而接受 0-RTT 数据则要求服务器保存相应的恢复状态,服务器可能出于各种原因对恢复状态进行限制或丢失,包括不跨服务器重启持久化恢复状态。

若自行提供 crypto::ClientConfig,请查阅其实现文档中关于 0-RTT 的注意事项。

§入站连接

对于入站连接,转换为 0.5-RTT 总能完全成功。into_0rtt 始终返回 Ok,且 ZeroRttAccepted 始终解析为 true。

若自行提供 crypto::ServerConfig,请查阅其实现文档中关于 0-RTT 的注意事项。

§安全性

对于出站连接,此方法启用 0-RTT 数据的发送,而 0-RTT 数据容易遭受重放攻击,因此永远不应触发非幂等操作。

对于入站连接,此方法启用 0.5-RTT 数据的发送,这类数据可能在 TLS 客户端认证完成之前就已发出,因此不应发送依赖客户端认证才可信的数据。

源代码

pub async fn handshake_data(&mut self) -> Result<Box<dyn Any>, ConnectionError>

握手期间协商出的参数

返回值的动态类型由所配置的 Session 决定。对于默认的 rustls 会话,返回值可以 downcastcrypto::rustls::HandshakeData

源代码

pub fn local_ip(&self) -> Option<IpAddr>

对端建立连接时所使用的本地 IP 地址

当端点绑定到通配地址(如 0.0.0.0::)时,该地址可能与端点所绑定的地址不同。

对客户端或当平台未暴露此信息时返回 None。使用 quinn_udp(默认)作为 I/O 时,支持的平台列表请参阅 quinn_udp::RecvMeta::dst_ip

若在 poll 返回 Ready 之后调用会 panic。

源代码

pub fn remote_address(&self) -> SocketAddr

对端的 UDP 地址

若在 poll 返回 Ready 之后调用会 panic。

trait 实现§

源代码§

impl Debug for Connecting

源代码§

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

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

impl Future for Connecting

源代码§

type Output = Result<Connection, ConnectionError>

Future 完成时产生的值的类型。
源代码§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. 更多信息

自动 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> 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<F> IntoFuture for F
where F: Future,

源代码§

type Output = <F as Future>::Output

Future 完成时产生的输出。
源代码§

type IntoFuture = F

我们将要把此值转变成哪种 future?
源代码§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. 更多信息
源代码§

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

源代码§

type Error = Infallible

转换出错时返回的类型。
源代码§

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

转换出错时返回的类型。
源代码§

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,