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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
//! The HINFO record data type.
use Ordering;
use crate;
use crateParseMessageBytes;
use crate;
use crate;
//----------- HInfo ----------------------------------------------------------
/// Information about the host computer.
///
/// [`HInfo`] describes the hardware and software of the server associated
/// with the domain name. It is not commonly used for its original purpose,
/// given several issues:
///
/// 1. A domain name can be associated with multiple servers (due to having
/// multiple IP addresses or using IP anycast), but [`HInfo`] does not
/// provide a way to associate the information it provides with a specific
/// server (or at least IP address).
///
/// 2. The CPU and OS name are expected to be standardized, but given the
/// massive (and growing) number of both, it would be impossible to cover
/// every possibility. [RFC 1010] listed the initial set of names, and it
/// has evolved into the online lists of [operating system names] (last
/// updated in 2010) and [machine names] (last updated in 2001).
///
/// 3. As documented by [RFC 1035], the "main use" for [`HInfo`] records was
/// "for protocols such as FTP that can use special procedures when talking
/// between machines or operating systems of the same type". But given the
/// portabilitiy of most protocols across machines and operating systems,
/// [`HInfo`] is not very informative. Protocols typically provide
/// extension mechanisms in-band instead of relying on out-of-band DNS
/// information.
///
/// 4. [RFC 8482, section 6] states that "the HINFO RRTYPE is believed to be
/// rarely used in the DNS at the time of writing, based on observations
/// made in passive DNS and at recursive and authoritative DNS servers".
///
/// [RFC 1010]: https://datatracker.ietf.org/doc/html/rfc1010
/// [RFC 1035]: https://datatracker.ietf.org/doc/html/rfc1035
/// [RFC 8482, section 6]: https://datatracker.ietf.org/doc/html/rfc8482#section-6
/// [operating system names]: https://www.iana.org/assignments/operating-system-names/operating-system-names.xhtml
/// [machine names]: https://www.iana.org/assignments/machine-names/machine-names.xhtml
///
/// Recently, [`HInfo`] has gained new use, as a potential fallback response
/// for [`QType::ANY`] queries. [RFC 8482] specifies that name servers
/// wishing to avoid answering [`QType::ANY`] queries (which are expensive
/// to look up, have an amplifying network effect, and can be abused for DoS
/// attacks) can respond with a synthesized [`HInfo`] record instead.
///
/// [`QType::ANY`]: crate::new::base::QType::ANY
/// [RFC 8482]: https://datatracker.ietf.org/doc/html/rfc8482
///
/// [`HInfo`] is specified by [RFC 1035, section 3.3.2]. Its use as an
/// alternative response to [`QType::ANY`] queries is documented by [RFC 8482,
/// section 4.2].
///
/// [RFC 1035, section 3.3.2]: https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.2
/// [RFC 8482, section 4.2]: https://datatracker.ietf.org/doc/html/rfc8482#section-4.2
///
/// ## Wire Format
///
/// The wire format of an [`HInfo`] record is the concatenation of two
/// "character strings" (see [`CharStr`]). The first specifies the "machine
/// name" of the host computer, and the second specifies the name of the
/// operating system it is running.
///
/// ## Usage
///
/// Because [`HInfo`] is a record data type, it is usually handled within an
/// enum like [`RecordData`]. This section describes how to use it
/// independently (or when building new record data from scratch).
///
/// [`RecordData`]: crate::new::rdata::RecordData
///
/// There's a few ways to build an [`HInfo`]:
///
/// ```
/// # use domain::new::base::wire::{BuildBytes, ParseBytes};
/// # use domain::new::rdata::HInfo;
/// #
/// use domain::new::base::CharStrBuf;
///
/// // Build an 'HInfo' manually.
/// let cpu: CharStrBuf = "DEC-2060".parse().unwrap();
/// let os: CharStrBuf = "TOPS20".parse().unwrap();
/// let manual: HInfo<'_> = HInfo { cpu: &*cpu, os: &*os };
///
/// let bytes = b"\x08DEC-2060\x06TOPS20";
/// # let mut buffer = [0u8; 16];
/// # manual.build_bytes(&mut buffer).unwrap();
/// # assert_eq!(*bytes, buffer);
///
/// // Parse an 'HInfo' from the DNS wire format.
/// let from_wire: HInfo<'_> = HInfo::parse_bytes(bytes).unwrap();
/// # assert_eq!(manual, from_wire);
/// ```
///
/// Since [`HInfo`] is a sized type, and it implements [`Copy`] and [`Clone`],
/// it's straightforward to handle and move around. However, it is bound by
/// the lifetime of the borrowed character strings. At the moment, there is
/// no perfect way to own an [`HInfo`] without a lifetime restriction (largely
/// because it is not commonly used), however:
///
/// is capable of doing so, but it does not guarantee that it holds an
/// [`HInfo`] (it can hold any record data type).
///
/// - If [`bumpalo`] is being used,
/// can clone an [`HInfo`] over to a bump allocator. This may extend its
/// lifetime sufficiently for some use cases.
///
///
/// For debugging [`HInfo`] can be formatted using [`fmt::Debug`].
///
/// [`fmt::Debug`]: core::fmt::Debug
///
/// To serialize an [`HInfo`] in the wire format, use [`BuildBytes`]. It also
/// supports [`BuildInMessage`].
//--- Interaction
//--- Canonical operations
//--- Parsing from DNS messages
//--- Building into DNS messages
//--- Parsing record data