mhost 0.11.3

Fast, async DNS lookup library and CLI -- modern dig/host replacement with parallel multi-server queries, DoH, DoT, subdomain discovery, and zone verification
Documentation
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
// Copyright 2017-2021 Lukas Pustina <lukas@pustina.de>
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

pub use crate::app::common::record_type_info::{record_types, RecordTypeInfo};

#[derive(Debug)]
pub struct TxtSubTypeInfo {
    pub name: &'static str,
    pub prefix: &'static str,
    pub summary: &'static str,
    pub detail: &'static str,
    pub rfc: Option<&'static str>,
    pub rfc_url: Option<&'static str>,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Tier {
    Default,
    Extended,
}

#[derive(Debug)]
pub struct SubdomainInfo {
    pub subdomain: &'static str,
    pub record_type: &'static str,
    pub category: &'static str,
    pub summary: &'static str,
    pub detail: &'static str,
    pub rfc: Option<&'static str>,
    pub rfc_url: Option<&'static str>,
    pub tier: Tier,
}

#[derive(Debug)]
pub enum InfoEntry<'a> {
    RecordType(&'a RecordTypeInfo),
    TxtSubType(&'a TxtSubTypeInfo),
    Subdomain(&'a SubdomainInfo),
}

static TXT_SUB_TYPES: &[TxtSubTypeInfo] = &[
    TxtSubTypeInfo {
        name: "SPF",
        prefix: "v=spf1",
        summary: "Sender Policy Framework",
        detail: "Defines which mail servers are authorized to send email on behalf of a domain. \
                 The SPF policy lists allowed IP ranges, hostnames, and include directives. \
                 Receiving mail servers check SPF to detect forged sender addresses.",
        rfc: Some("RFC 7208"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc7208"),
    },
    TxtSubTypeInfo {
        name: "DMARC",
        prefix: "v=DMARC1",
        summary: "Domain-based Message Authentication",
        detail: "Builds on SPF and DKIM to give domain owners control over how unauthenticated \
                 mail is handled. Specifies policies (none/quarantine/reject) and reporting \
                 addresses. Published at _dmarc.<domain>.",
        rfc: Some("RFC 7489"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc7489"),
    },
    TxtSubTypeInfo {
        name: "MTA-STS",
        prefix: "v=STSv1",
        summary: "MTA Strict Transport Security",
        detail: "Tells sending mail servers that the domain requires TLS for SMTP connections. \
                 The TXT record provides a policy ID, while the full policy is hosted via HTTPS. \
                 Prevents downgrade attacks on mail transport.",
        rfc: Some("RFC 8461"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc8461"),
    },
    TxtSubTypeInfo {
        name: "TLS-RPT",
        prefix: "v=TLSRPTv1",
        summary: "SMTP TLS Reporting",
        detail: "Allows domains to request reports about TLS connection failures from sending \
                 mail servers. Specifies where failure reports should be sent. Helps domain \
                 operators detect email delivery issues.",
        rfc: Some("RFC 8460"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc8460"),
    },
    TxtSubTypeInfo {
        name: "BIMI",
        prefix: "v=BIMI1",
        summary: "Brand Indicators for Message Identification",
        detail: "Allows organizations to display their logo alongside authenticated emails in \
                 supported mail clients. Provides a URL to the brand's SVG logo and an optional \
                 VMC certificate.",
        rfc: None,
        rfc_url: Some("https://bimigroup.org/implementation-guide/"),
    },
    TxtSubTypeInfo {
        name: "Domain Verification",
        prefix: "<verifier>-<scope>-verification=<id>",
        summary: "Third-party domain ownership verification",
        detail: "Services like Google, Facebook, and others use these TXT records to verify that \
                 the person managing DNS also controls the domain. Each service provides a unique \
                 verification token.",
        rfc: None,
        rfc_url: None,
    },
];

static SUBDOMAINS: &[SubdomainInfo] = &[
    // Email Authentication — Default
    SubdomainInfo {
        subdomain: "_dmarc",
        record_type: "TXT",
        category: "Email Authentication",
        summary: "DMARC policy",
        detail: "DMARC policy record specifying how unauthenticated mail should be handled and \
                 where aggregate/forensic reports should be sent.",
        rfc: Some("RFC 7489"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc7489"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_mta-sts",
        record_type: "TXT",
        category: "Email Authentication",
        summary: "MTA-STS policy ID",
        detail: "MTA-STS policy ID record indicating the current version of the domain's \
                 MTA-STS policy hosted via HTTPS.",
        rfc: Some("RFC 8461"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc8461"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_smtp._tls",
        record_type: "TXT",
        category: "Email Authentication",
        summary: "TLS reporting",
        detail: "TLS-RPT reporting configuration telling senders where to submit reports about \
                 TLS connection failures during mail delivery.",
        rfc: Some("RFC 8460"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc8460"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "default._bimi",
        record_type: "TXT",
        category: "Email Authentication",
        summary: "Brand indicators",
        detail: "BIMI indicator record pointing to the organization's brand logo SVG and \
                 optional Verified Mark Certificate (VMC).",
        rfc: None,
        rfc_url: Some("https://bimigroup.org/implementation-guide/"),
        tier: Tier::Default,
    },
    // Email Services — Default
    SubdomainInfo {
        subdomain: "_submission._tcp",
        record_type: "SRV",
        category: "Email Services",
        summary: "Mail submission",
        detail: "Mail submission service (port 587), used by email clients to discover the \
                 outgoing mail server.",
        rfc: Some("RFC 6186"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6186"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_submissions._tcp",
        record_type: "SRV",
        category: "Email Services",
        summary: "Mail submission (TLS)",
        detail: "Mail submission over implicit TLS (port 465), the TLS-secured variant of mail \
                 submission.",
        rfc: Some("RFC 8314"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc8314"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_imap._tcp",
        record_type: "SRV",
        category: "Email Services",
        summary: "IMAP",
        detail: "IMAP mail access service, allowing email clients to discover the incoming mail \
                 server using IMAP with STARTTLS.",
        rfc: Some("RFC 6186"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6186"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_imaps._tcp",
        record_type: "SRV",
        category: "Email Services",
        summary: "IMAP (TLS)",
        detail: "IMAP over implicit TLS (port 993), the TLS-secured variant of IMAP access.",
        rfc: Some("RFC 8314"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc8314"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_pop3._tcp",
        record_type: "SRV",
        category: "Email Services",
        summary: "POP3",
        detail: "POP3 mail access service for clients that download and optionally delete mail \
                 from the server.",
        rfc: Some("RFC 6186"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6186"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_pop3s._tcp",
        record_type: "SRV",
        category: "Email Services",
        summary: "POP3 (TLS)",
        detail: "POP3 over implicit TLS (port 995), the TLS-secured variant of POP3.",
        rfc: Some("RFC 8314"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc8314"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_autodiscover._tcp",
        record_type: "SRV",
        category: "Email Services",
        summary: "Autodiscovery",
        detail: "Microsoft Exchange/Outlook autodiscovery service for automatic email client \
                 configuration.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Default,
    },
    // TLS / DANE — Default
    SubdomainInfo {
        subdomain: "_443._tcp",
        record_type: "TLSA",
        category: "TLS / DANE",
        summary: "HTTPS DANE",
        detail: "DANE record for HTTPS on port 443, pinning the TLS certificate or CA for the \
                 domain's web server.",
        rfc: Some("RFC 6698"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6698"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_25._tcp",
        record_type: "TLSA",
        category: "TLS / DANE",
        summary: "SMTP DANE",
        detail: "DANE record for SMTP on port 25, enabling authenticated TLS for mail \
                 server-to-server communication.",
        rfc: Some("RFC 7672"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc7672"),
        tier: Tier::Default,
    },
    // Communication — Default
    SubdomainInfo {
        subdomain: "_sip._tcp",
        record_type: "SRV",
        category: "Communication",
        summary: "SIP over TCP",
        detail: "Session Initiation Protocol endpoint for VoIP and video calling over TCP.",
        rfc: Some("RFC 3263"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc3263"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_sip._udp",
        record_type: "SRV",
        category: "Communication",
        summary: "SIP over UDP",
        detail: "Session Initiation Protocol endpoint for VoIP and video calling over UDP.",
        rfc: Some("RFC 3263"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc3263"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_sips._tcp",
        record_type: "SRV",
        category: "Communication",
        summary: "SIP over TLS",
        detail: "SIP over TLS for encrypted voice/video communication.",
        rfc: Some("RFC 3263"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc3263"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_xmpp-client._tcp",
        record_type: "SRV",
        category: "Communication",
        summary: "XMPP client",
        detail: "XMPP (Jabber) client connection endpoint for instant messaging.",
        rfc: Some("RFC 6120"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6120"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_xmpp-server._tcp",
        record_type: "SRV",
        category: "Communication",
        summary: "XMPP server",
        detail: "XMPP server-to-server federation endpoint.",
        rfc: Some("RFC 6120"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6120"),
        tier: Tier::Default,
    },
    // Calendar / Contacts — Default
    SubdomainInfo {
        subdomain: "_caldavs._tcp",
        record_type: "SRV",
        category: "Calendar / Contacts",
        summary: "CalDAV (TLS)",
        detail: "CalDAV over TLS, allowing calendar applications to discover the calendar server.",
        rfc: Some("RFC 6764"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6764"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_carddavs._tcp",
        record_type: "SRV",
        category: "Calendar / Contacts",
        summary: "CardDAV (TLS)",
        detail: "CardDAV over TLS, allowing contact applications to discover the address book \
                 server.",
        rfc: Some("RFC 6764"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6764"),
        tier: Tier::Default,
    },
    // Infrastructure — Default
    SubdomainInfo {
        subdomain: "_ldap._tcp",
        record_type: "SRV",
        category: "Infrastructure",
        summary: "LDAP",
        detail: "LDAP directory service, used for user authentication and directory lookups in \
                 enterprise environments.",
        rfc: Some("RFC 2782"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc2782"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_kerberos._tcp",
        record_type: "SRV",
        category: "Infrastructure",
        summary: "Kerberos TCP",
        detail: "Kerberos authentication service endpoint for single sign-on in enterprise \
                 networks.",
        rfc: Some("RFC 4120"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc4120"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_kerberos._udp",
        record_type: "SRV",
        category: "Infrastructure",
        summary: "Kerberos UDP",
        detail: "Kerberos authentication service endpoint over UDP.",
        rfc: Some("RFC 4120"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc4120"),
        tier: Tier::Default,
    },
    // Modern Protocols — Default
    SubdomainInfo {
        subdomain: "_matrix-fed._tcp",
        record_type: "SRV",
        category: "Modern Protocols",
        summary: "Matrix federation",
        detail: "Matrix federation endpoint for decentralized communication (chat, VoIP).",
        rfc: None,
        rfc_url: None,
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_stun._udp",
        record_type: "SRV",
        category: "Modern Protocols",
        summary: "STUN",
        detail: "STUN (Session Traversal Utilities for NAT) service for NAT traversal in WebRTC \
                 and VoIP.",
        rfc: Some("RFC 5389"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc5389"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_turn._udp",
        record_type: "SRV",
        category: "Modern Protocols",
        summary: "TURN",
        detail: "TURN relay service for media relay when direct peer-to-peer connections fail.",
        rfc: Some("RFC 5766"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc5766"),
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_turns._tcp",
        record_type: "SRV",
        category: "Modern Protocols",
        summary: "TURN (TLS)",
        detail: "TURN relay service over TLS for secure media relay.",
        rfc: Some("RFC 5766"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc5766"),
        tier: Tier::Default,
    },
    // Verification / Metadata — Default
    SubdomainInfo {
        subdomain: "_atproto",
        record_type: "TXT",
        category: "Verification / Metadata",
        summary: "Bluesky verification",
        detail: "AT Protocol (Bluesky) domain verification, proving ownership of a domain as a \
                 decentralized identifier.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_dnslink",
        record_type: "TXT",
        category: "Verification / Metadata",
        summary: "IPFS / content addressing",
        detail: "DNSLink record pointing to IPFS or other content-addressed resources, enabling \
                 human-readable names for distributed content.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Default,
    },
    SubdomainInfo {
        subdomain: "_domainconnect",
        record_type: "TXT",
        category: "Verification / Metadata",
        summary: "Domain Connect protocol",
        detail: "Domain Connect protocol endpoint enabling one-click DNS configuration by \
                 service providers.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Default,
    },
    // --- Extended entries ---
    // TLS / DANE — Extended
    SubdomainInfo {
        subdomain: "_dane._tcp",
        record_type: "TLSA",
        category: "TLS / DANE",
        summary: "Generic DANE",
        detail: "Generic DANE record for services not on a specific well-known port.",
        rfc: Some("RFC 6698"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6698"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_465._tcp",
        record_type: "TLSA",
        category: "TLS / DANE",
        summary: "SMTPS DANE",
        detail: "DANE record for SMTPS (implicit TLS SMTP) on port 465.",
        rfc: Some("RFC 6698"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6698"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_993._tcp",
        record_type: "TLSA",
        category: "TLS / DANE",
        summary: "IMAPS DANE",
        detail: "DANE record for IMAPS on port 993.",
        rfc: Some("RFC 6698"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6698"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_995._tcp",
        record_type: "TLSA",
        category: "TLS / DANE",
        summary: "POP3S DANE",
        detail: "DANE record for POP3S on port 995.",
        rfc: Some("RFC 6698"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6698"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_587._tcp",
        record_type: "TLSA",
        category: "TLS / DANE",
        summary: "Submission DANE",
        detail: "DANE record for mail submission on port 587.",
        rfc: Some("RFC 6698"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6698"),
        tier: Tier::Extended,
    },
    // Communication — Extended
    SubdomainInfo {
        subdomain: "_h323cs._tcp",
        record_type: "SRV",
        category: "Communication",
        summary: "H.323",
        detail: "H.323 call signaling for legacy video conferencing systems.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_h323ls._udp",
        record_type: "SRV",
        category: "Communication",
        summary: "H.323 location",
        detail: "H.323 location service for gatekeeper discovery.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Extended,
    },
    // Calendar / Contacts — Extended
    SubdomainInfo {
        subdomain: "_caldav._tcp",
        record_type: "SRV",
        category: "Calendar / Contacts",
        summary: "CalDAV (plain)",
        detail: "CalDAV without TLS (plain HTTP), the unencrypted variant.",
        rfc: Some("RFC 6764"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6764"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_carddav._tcp",
        record_type: "SRV",
        category: "Calendar / Contacts",
        summary: "CardDAV (plain)",
        detail: "CardDAV without TLS (plain HTTP), the unencrypted variant.",
        rfc: Some("RFC 6764"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc6764"),
        tier: Tier::Extended,
    },
    // Infrastructure — Extended
    SubdomainInfo {
        subdomain: "_kpasswd._tcp",
        record_type: "SRV",
        category: "Infrastructure",
        summary: "Kerberos password",
        detail: "Kerberos password change service over TCP.",
        rfc: Some("RFC 4120"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc4120"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_kpasswd._udp",
        record_type: "SRV",
        category: "Infrastructure",
        summary: "Kerberos password",
        detail: "Kerberos password change service over UDP.",
        rfc: Some("RFC 4120"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc4120"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_ntp._udp",
        record_type: "SRV",
        category: "Infrastructure",
        summary: "NTP",
        detail: "Network Time Protocol service for time synchronization.",
        rfc: Some("RFC 5905"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc5905"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_http._tcp",
        record_type: "SRV",
        category: "Infrastructure",
        summary: "HTTP service",
        detail: "Generic HTTP service discovery.",
        rfc: Some("RFC 2782"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc2782"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_https._tcp",
        record_type: "SRV",
        category: "Infrastructure",
        summary: "HTTPS service",
        detail: "Generic HTTPS service discovery.",
        rfc: Some("RFC 2782"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc2782"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_vlmcs._tcp",
        record_type: "SRV",
        category: "Infrastructure",
        summary: "KMS activation",
        detail: "Microsoft Key Management Service (KMS) for volume license activation.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Extended,
    },
    // Legacy — Extended
    SubdomainInfo {
        subdomain: "_finger._tcp",
        record_type: "SRV",
        category: "Legacy",
        summary: "Finger protocol",
        detail: "Finger protocol service for user information lookup (largely obsolete).",
        rfc: Some("RFC 1288"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc1288"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_nicname._tcp",
        record_type: "SRV",
        category: "Legacy",
        summary: "WHOIS",
        detail: "WHOIS service for domain registration information lookup.",
        rfc: Some("RFC 3912"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc3912"),
        tier: Tier::Extended,
    },
    // Gaming — Extended
    SubdomainInfo {
        subdomain: "_ts3._udp",
        record_type: "SRV",
        category: "Gaming",
        summary: "TeamSpeak 3",
        detail: "TeamSpeak 3 voice communication server discovery.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_minecraft._tcp",
        record_type: "SRV",
        category: "Gaming",
        summary: "Minecraft",
        detail: "Minecraft Java Edition server discovery.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Extended,
    },
    // Email Authentication — Extended
    SubdomainInfo {
        subdomain: "_adsp._domainkey",
        record_type: "TXT",
        category: "Email Authentication",
        summary: "ADSP (deprecated)",
        detail: "Author Domain Signing Practices, a deprecated extension to DKIM that specified \
                 signing policy. Superseded by DMARC.",
        rfc: Some("RFC 5617"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc5617"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_mta-sts",
        record_type: "CNAME",
        category: "Email Authentication",
        summary: "MTA-STS alias check",
        detail: "Checks for a CNAME alias on the MTA-STS subdomain, which may indicate delegated \
                 MTA-STS hosting.",
        rfc: Some("RFC 8461"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc8461"),
        tier: Tier::Extended,
    },
    // Verification / Metadata — Extended
    SubdomainInfo {
        subdomain: "_acme-challenge",
        record_type: "TXT",
        category: "Verification / Metadata",
        summary: "ACME DNS-01",
        detail: "ACME DNS-01 challenge records used by Let's Encrypt and other CAs to verify \
                 domain ownership during certificate issuance.",
        rfc: Some("RFC 8555"),
        rfc_url: Some("https://datatracker.ietf.org/doc/html/rfc8555"),
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_dnsauth",
        record_type: "TXT",
        category: "Verification / Metadata",
        summary: "DNS auth tokens",
        detail: "DNS authorization tokens used by various services for domain verification.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_amazonses",
        record_type: "TXT",
        category: "Verification / Metadata",
        summary: "Amazon SES",
        detail: "Amazon Simple Email Service domain verification token.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_github-pages-challenge",
        record_type: "TXT",
        category: "Verification / Metadata",
        summary: "GitHub Pages",
        detail: "GitHub Pages domain verification token.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Extended,
    },
    SubdomainInfo {
        subdomain: "_google",
        record_type: "TXT",
        category: "Verification / Metadata",
        summary: "Google Workspace",
        detail: "Google Workspace domain verification token.",
        rfc: None,
        rfc_url: None,
        tier: Tier::Extended,
    },
];

pub fn txt_sub_types() -> &'static [TxtSubTypeInfo] {
    TXT_SUB_TYPES
}

pub fn subdomains() -> &'static [SubdomainInfo] {
    SUBDOMAINS
}

pub fn find(topic: &str) -> Option<InfoEntry<'_>> {
    let topic_lower = topic.to_lowercase();

    // Search record types (case-insensitive) — delegated to common
    if let Some(rt) = crate::app::common::record_type_info::find(&topic_lower) {
        return Some(InfoEntry::RecordType(rt));
    }

    // Search TXT sub-types (case-insensitive)
    if let Some(txt) = TXT_SUB_TYPES.iter().find(|t| t.name.to_lowercase() == topic_lower) {
        return Some(InfoEntry::TxtSubType(txt));
    }

    // Search subdomains (case-insensitive, exact match)
    if let Some(sub) = SUBDOMAINS.iter().find(|s| s.subdomain.to_lowercase() == topic_lower) {
        return Some(InfoEntry::Subdomain(sub));
    }

    None
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn find_record_type_a() {
        let entry = find("A").unwrap();
        assert!(matches!(entry, InfoEntry::RecordType(info) if info.name == "A"));
    }

    #[test]
    fn find_record_type_case_insensitive() {
        let entry = find("a").unwrap();
        assert!(matches!(entry, InfoEntry::RecordType(info) if info.name == "A"));
    }

    #[test]
    fn find_record_type_sshfp() {
        let entry = find("SSHFP").unwrap();
        assert!(matches!(entry, InfoEntry::RecordType(info) if info.name == "SSHFP"));
    }

    #[test]
    fn find_txt_sub_type_spf() {
        let entry = find("SPF").unwrap();
        assert!(matches!(entry, InfoEntry::TxtSubType(info) if info.name == "SPF"));
    }

    #[test]
    fn find_txt_sub_type_case_insensitive() {
        let entry = find("dmarc").unwrap();
        assert!(matches!(entry, InfoEntry::TxtSubType(info) if info.name == "DMARC"));
    }

    #[test]
    fn find_subdomain_dmarc() {
        let entry = find("_dmarc").unwrap();
        assert!(matches!(entry, InfoEntry::Subdomain(info) if info.subdomain == "_dmarc"));
    }

    #[test]
    fn find_nonexistent() {
        assert!(find("nonexistent").is_none());
    }

    #[test]
    fn record_types_not_empty() {
        assert!(!record_types().is_empty());
        // Should contain all SUPPORTED_RECORD_TYPES from cli_parser (minus ANY)
        let names: Vec<&str> = record_types().iter().map(|r| r.name).collect();
        assert!(names.contains(&"A"));
        assert!(names.contains(&"AAAA"));
        assert!(names.contains(&"MX"));
        assert!(names.contains(&"TXT"));
        assert!(names.contains(&"SSHFP"));
        assert!(names.contains(&"TLSA"));
        assert!(names.contains(&"CAA"));
    }

    #[test]
    fn txt_sub_types_not_empty() {
        assert!(!txt_sub_types().is_empty());
        let names: Vec<&str> = txt_sub_types().iter().map(|t| t.name).collect();
        assert!(names.contains(&"SPF"));
        assert!(names.contains(&"DMARC"));
    }

    #[test]
    fn subdomains_not_empty() {
        assert!(!subdomains().is_empty());
        let subs: Vec<&str> = subdomains().iter().map(|s| s.subdomain).collect();
        assert!(subs.contains(&"_dmarc"));
        assert!(subs.contains(&"_443._tcp"));
    }

    #[test]
    fn all_supported_record_types_have_info() {
        // These are the SUPPORTED_RECORD_TYPES from cli_parser.rs minus ANY (which is a
        // meta-type, not a real record type to document)
        let supported = [
            "A",
            "AAAA",
            "ANAME",
            "CAA",
            "CNAME",
            "DNSKEY",
            "DS",
            "HINFO",
            "HTTPS",
            "MX",
            "NAPTR",
            "NSEC",
            "NSEC3",
            "NSEC3PARAM",
            "NULL",
            "NS",
            "OPENPGPKEY",
            "PTR",
            "RRSIG",
            "SOA",
            "SRV",
            "SSHFP",
            "SVCB",
            "TLSA",
            "TXT",
        ];
        let info_names: Vec<&str> = record_types().iter().map(|r| r.name).collect();
        for name in &supported {
            assert!(
                info_names.contains(name),
                "Missing reference data for record type {name}"
            );
        }
    }

    #[test]
    fn subdomains_match_subdomain_spec_count() {
        // Our reference data should cover all non-apex entries from subdomain_spec
        use crate::app::common::subdomain_spec;
        let spec_entries: Vec<_> = subdomain_spec::all_entries()
            .into_iter()
            .filter(|e| !e.subdomain.is_empty())
            .collect();
        let ref_subdomains: Vec<(&str, &str)> = subdomains().iter().map(|s| (s.subdomain, s.record_type)).collect();
        for entry in &spec_entries {
            let rt_str: &str = entry.record_type.into();
            assert!(
                ref_subdomains.contains(&(entry.subdomain, rt_str)),
                "Missing reference data for subdomain {} ({})",
                entry.subdomain,
                rt_str
            );
        }
    }

    #[test]
    fn all_record_type_info_has_detail() {
        for rt in record_types() {
            assert!(!rt.detail.is_empty(), "Record type {} has empty detail", rt.name);
            assert!(!rt.summary.is_empty(), "Record type {} has empty summary", rt.name);
        }
    }

    #[test]
    fn all_subdomain_info_has_detail() {
        for sub in subdomains() {
            assert!(!sub.detail.is_empty(), "Subdomain {} has empty detail", sub.subdomain);
            assert!(!sub.summary.is_empty(), "Subdomain {} has empty summary", sub.subdomain);
        }
    }
}