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
//! `openmoat-proxy`: the default-deny egress proxy behind `moat proxy` (ADR-020).
//!
//! It serves HTTP `CONNECT` tunnels and absolute-form plain-HTTP requests on a
//! loopback port:
//!
//! - Hosts are decided by openmoat-core's [`CompiledPolicy`](openmoat_core::CompiledPolicy)
//! as `moat guard` decides a fetch tool's URL: only an `allow` passes. A host
//! is reached on 443 and 80 unless a rule names `host:port` ([`port_policy`]).
//! - Cloud metadata and link-local addresses are refused whatever the policy
//! says, by name and on every address the proxy resolves. Private and CGNAT
//! addresses are refused unless an allow rule names the address.
//! - A tunnel's TLS `ClientHello` must name the CONNECT host (SNI). Nothing is
//! decrypted except, with [`Tls`] set, a tunnel to the host of a secret that
//! says `tls: terminate` (ADR-043): its one request is checked against the
//! leak check and the secret's `allow` rules, given the value, sent over the
//! proxy's own verified TLS, and its answer searched for every value. A
//! host with [`Requests`] rules (`requests:`, ADR-062) is terminated the
//! same way for a session that trusts the CA ([`Trust`]), and a request its
//! rules refuse is refused; a session it cannot terminate is refused or
//! relayed as the policy's `requests_untrusted` says, and after a secret read
//! only reads without a body pass there.
//! - A request that carries a brokered secret's placeholder or value to a host
//! other than the secret's own is refused ([`Broker`]).
//! - Every decision is recorded through a [`Recorder`]; a failed record is a
//! refused connection.
//! - In session mode ([`Sessions`], ADR-027, ADR-044) every request must
//! carry its session's credential: one the proxy holds ([`Credential`]) or
//! one a [`Verify`] accepts. The session's audit id goes on each row, a
//! session that read secret material reaches only that secret's host, and
//! no session holds more than half the connections.
//! - A connection that starts with a [`LocalService`]'s prefix goes to that
//! service of the proxy's own process (ADR-028), not upstream.
//! - Apart from the proxy, [`Poster`] makes live audit delivery's one `POST`
//! (ADR-081) with the same upstream TLS and address checks.
//!
//! Plain `std::net` and one thread per connection, capped by [`Limits`]; the
//! choice is explained in `docs/ARCHITECTURE.md` ยง12.
// A library reports to its caller; only the `moat` binary prints.
pub use ;
pub use ;
pub use ;
pub use LocalService;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;