1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! The peer of one connection, seen from the engine's side (bl-4263): who it
//! is, how its silence is read, and how it is hung up on. Split from
//! [`server`](super) at §12's cap when the punched wire gave a connection a
//! second way to be quiet.
//!
//! **A held connection is quiet on purpose** (REMOTE §13.4). A dialled seat
//! asks and hangs up, so two minutes of nothing is a peer that vanished; a
//! punched stream is *held* between asks, and the two NATs it crosses forget
//! a mapping that carries nothing. So the engine writes a ping frame into the
//! silence at a 25-second cadence — a frame, because std exposes no keepalive
//! and a frame is what a test can read — and the two-minute bound still says
//! when the peer is gone. The frame is `{"ping":true}` and never the start of
//! a reply stream: a client reading a held connection discards it.
use frame;
use crate;
use CertificateDer;
use ;
use ;
use ;
use ;
use Duration;
/// How a connection's silence is read.
pub
/// The frame a held connection carries through its silence.
pub
/// Write one ping; a peer the write cannot reach is gone.
pub
/// **A refusal is only a refusal if the peer can read it** (bl-e4c8).
///
/// A refused peer is the one connection the engine hangs up on *first*:
/// everywhere else the peer closes and the engine reads the EOF. Closing a
/// socket that still holds unread bytes — or that the peer writes to just after
/// — makes the kernel answer RST, and an RST **discards what the peer had
/// already received**. So the seat whose refusal was sitting in its receive
/// buffer reads a transport error instead, having been told nothing: exactly
/// the outcome [`hello`](super::super::hello) refused ALPN to avoid, arriving
/// by a different door. It is a race and it reads as silence, which is the
/// worst pair of properties a refusal can have.
///
/// The engine therefore half-closes and reads to EOF. `close_notify` and a FIN
/// say there is nothing more coming; the read side stays open until the peer
/// has said its own last word, so nothing it wrote is ever unread at the close.
/// The wait is [`serve`](super::serve)'s quiet bound and not a new one — a
/// peer that will not hang up is a peer saying nothing, which is the case that
/// clock is for.
pub
/// The peer a presented chain names (REMOTE §2, §4.2): the **leaf's** subject
/// common name, and the grade the same subject carries. The leaf is the first
/// certificate — TLS sends the end entity first and the chain toward the anchor
/// after it, so the issuer's own common name is never mistaken for the peer's,
/// and an `OU` on the CA is never mistaken for a grade on the client.
pub