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
//! Putting the local port on `*.trycloudflare.com`.
//!
//! A quick tunnel needs no Cloudflare account and no DNS: the client asks
//! `api.trycloudflare.com` for a hostname and a secret, dials the argotunnel
//! edge, and registers. It stops existing when the process does. That is the
//! right shape for "let me look at this from my phone for ten minutes" and the
//! wrong shape for anything permanent — the URL changes every run, which is also
//! why it is not a substitute for the token.
//!
//! The client is [`cloudflare_quick_tunnel`], which speaks that protocol itself —
//! QUIC to the edge and capnp-RPC over it — rather than shelling out to
//! `cloudflared` and reading a URL off its stderr. So `--tunnel` needs nothing
//! installed and cctop stays one binary, which is the whole reason it ships as
//! one.
//!
//! The consequence worth knowing: the tunnel's data path is *inside this
//! process*. Every request from the internet arrives as a QUIC stream, gets
//! proxied to the loopback listener by a task on the runtime below, and lands on
//! the same socket a local browser would use. So the connection cap, the token
//! check and the deadlines in [`super::http`] all still apply — the tunnel adds
//! a route in, not a second server.
//!
//! # What it does not do
//!
//! Cloudflare terminates the TLS. The traffic is encrypted from the browser to
//! the edge and from the edge to here, and readable in between by the party
//! carrying it — which is worth saying because the opposite is easy to assume of
//! anything with a `https://` URL. A quick tunnel is a way to reach your own
//! machine from a phone, not a private channel, and the announcement in
//! [`super::announce`] says so where someone will actually read it.
use ;
/// A live tunnel, reachable at [`url`](Tunnel::url) until it is dropped.
/// Register a tunnel to `port` and return it, or say why not.
///
/// Blocking, and deliberately so: there is nothing to serve over a tunnel that
/// does not exist yet, and a URL printed before the edge has the registration is
/// a link that 404s for whoever opens it first.
///
/// Silent, also deliberately. This is called with the dashboard on screen as
/// often as from the command line, and a line written to stderr under a TUI is
/// painted straight over it — `cctop: opening a trycloudflare tunnel…` sat
/// across somebody's session list for exactly as long as the registration took.
/// Whoever called says so on the surface they own: the command line prints it,
/// and the dashboard spins.