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
//! TCP keepalive applied on `QsshClient::connect` (issue #1).
//!
//! Without `SO_KEEPALIVE`, a silently-half-open forward tunnel leaves
//! `transport.receive_message().await` blocked indefinitely and the
//! outer reconnect loop in `qssh-node` never runs. The fix sets the
//! socket option in `apply_tcp_keepalive` — this test exercises the
//! same code path against a loopback listener and reads the kernel
//! options back through `socket2` to confirm they took effect.
use Socket;
use Duration;
use ;
/// Re-implementation of `apply_tcp_keepalive` mirroring the production
/// helper in `src/client.rs`. We can't import it directly (it's a
/// private free function and qssh's `client` module is large), so the
/// test asserts on the *behaviour* the production code is required to
/// implement: an `SO_KEEPALIVE`-enabled socket with sane probe params.
/// Helper: bring up a loopback listener + connect a single client to
/// it, returning the *client* side. Uses tokio I/O end-to-end so the
/// test never blocks the runtime.
async
async
async