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
//! The DNS relay on the node (#1049): the services a node announces at `<did>.<zone>`, and the
//! relay a node may run for its zones.
//!
//! The relay itself, its DNS authority, address map and ingress, is the overlay-free crate
//! `rings_dns_relay`. This module is what ties it to Rings:
//!
//! - `descriptor`: the signed service descriptor a node publishes in the DHT, on the topic of its
//! own DID, built with the node's signed-descriptor machinery.
//! - `registration`: the heartbeat that publishes it, one of the node's registration tasks.
//! - `directory`: the relay's [`Directory`](rings_dns_relay::Directory): an owner's latest valid
//! descriptor, read from the DHT.
//! - `forward`: the relay's [`Forward`](rings_dns_relay::Forward): the TCP relay to the owner's
//! node, which dials only the services it registered, a PROXY protocol header first where the
//! owner asks for one.
//! - `config`: the node's `services` section.
//! - `open`: what `rings run` starts: the served ports, and the relay the node runs.
//!
//! ```text
//! node d: services ─▶ register tcp relay services "dns-relay/<p>" ─▶ publish σ(d) every I
//! relay: DNS label(d).z ─▶ σ(d) from the DHT ─▶ AAAA addr(d), MX, TXT
//! TCP (addr(d), p) ─▶ tcp relay ─▶ d's "dns-relay/<p>" ─▶ d's local target
//! ```
use fmt;
pub use ServedPortConfig;
pub use ServedTxtConfig;
pub use ServicesConfig;
pub use service_topic;
pub use ServedPort;
pub use ServedTxt;
pub use ServiceDescriptor;
pub use ServiceDescriptorBody;
pub use DhtDirectory;
pub use DirectoryError;
pub use ForwardError;
pub use RelayForward;
pub use open;
pub use NodeDnsRelay;
pub use OpenError;
pub use ServiceOffer;
pub use ServiceRegistration;
pub use DnsRelay;
pub use DnsRelayConfig;
use Owner;
use crateDid;
/// A DID as the owner of a relayed name: its label is the DID's canonical text, `0x` and 40
/// lowercase hex digits.
///
/// ```text
/// label(DidOwner(d)) = d.to_string()
/// from_label(l) = Some(DidOwner(d)) ⇔ l parses as d ∧ d.to_string() = l
/// ```
///
/// The second law makes the parse canonical: a label without `0x`, or with fewer digits, names
/// no owner, so a DID has one name per zone.
;
/// The TCP relay service a node serves `port` under: what the relay's ingress asks the node to
/// dial for a connection to that port of its address.
///
/// Law: injective in `port`, and disjoint from every service name an operator registers that
/// does not start with `dns-relay/`.