feat(question): name SVCB/LOC/NAPTR record types in logs #120
11
src/ctx.rs
11
src/ctx.rs
@@ -511,13 +511,12 @@ fn strip_dnssec_records(pkt: &mut DnsPacket) {
|
|||||||
pkt.resources.retain(|r| !is_dnssec_record(r));
|
pkt.resources.retain(|r| !is_dnssec_record(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
const SVCB_QTYPE: u16 = 64;
|
|
||||||
|
|
||||||
fn strip_svcb_ipv6_hints(pkt: &mut DnsPacket) {
|
fn strip_svcb_ipv6_hints(pkt: &mut DnsPacket) {
|
||||||
let https_qtype = QueryType::HTTPS.to_num();
|
let https_qtype = QueryType::HTTPS.to_num();
|
||||||
|
let svcb_qtype = QueryType::SVCB.to_num();
|
||||||
pkt.for_each_record_mut(|rec| {
|
pkt.for_each_record_mut(|rec| {
|
||||||
if let DnsRecord::UNKNOWN { qtype, data, .. } = rec {
|
if let DnsRecord::UNKNOWN { qtype, data, .. } = rec {
|
||||||
if *qtype == https_qtype || *qtype == SVCB_QTYPE {
|
if *qtype == https_qtype || *qtype == svcb_qtype {
|
||||||
if let Some(new_data) = crate::svcb::strip_ipv6hint(data) {
|
if let Some(new_data) = crate::svcb::strip_ipv6hint(data) {
|
||||||
*data = new_data;
|
*data = new_data;
|
||||||
}
|
}
|
||||||
@@ -1307,7 +1306,7 @@ mod tests {
|
|||||||
|
|
||||||
let mut svcb_pkt = pkt.clone();
|
let mut svcb_pkt = pkt.clone();
|
||||||
svcb_pkt.questions[0].name = "svc.test".to_string();
|
svcb_pkt.questions[0].name = "svc.test".to_string();
|
||||||
svcb_pkt.questions[0].qtype = QueryType::UNKNOWN(64);
|
svcb_pkt.questions[0].qtype = QueryType::SVCB;
|
||||||
if let DnsRecord::UNKNOWN { domain, qtype, .. } = &mut svcb_pkt.answers[0] {
|
if let DnsRecord::UNKNOWN { domain, qtype, .. } = &mut svcb_pkt.answers[0] {
|
||||||
*domain = "svc.test".to_string();
|
*domain = "svc.test".to_string();
|
||||||
*qtype = 64;
|
*qtype = 64;
|
||||||
@@ -1322,12 +1321,12 @@ mod tests {
|
|||||||
ctx.cache
|
ctx.cache
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert("svc.test", QueryType::UNKNOWN(64), &svcb_pkt);
|
.insert("svc.test", QueryType::SVCB, &svcb_pkt);
|
||||||
let ctx = Arc::new(ctx);
|
let ctx = Arc::new(ctx);
|
||||||
|
|
||||||
for (name, qtype, label) in [
|
for (name, qtype, label) in [
|
||||||
("hints.test", QueryType::HTTPS, "HTTPS"),
|
("hints.test", QueryType::HTTPS, "HTTPS"),
|
||||||
("svc.test", QueryType::UNKNOWN(64), "SVCB"),
|
("svc.test", QueryType::SVCB, "SVCB"),
|
||||||
] {
|
] {
|
||||||
let (resp, path) = resolve_in_test(&ctx, name, qtype).await;
|
let (resp, path) = resolve_in_test(&ctx, name, qtype).await;
|
||||||
assert_eq!(path, QueryPath::Cached, "{label}");
|
assert_eq!(path, QueryPath::Cached, "{label}");
|
||||||
|
|||||||
@@ -12,13 +12,16 @@ pub enum QueryType {
|
|||||||
MX, // 15
|
MX, // 15
|
||||||
TXT, // 16
|
TXT, // 16
|
||||||
AAAA, // 28
|
AAAA, // 28
|
||||||
|
LOC, // 29
|
||||||
SRV, // 33
|
SRV, // 33
|
||||||
|
NAPTR, // 35
|
||||||
DS, // 43
|
DS, // 43
|
||||||
RRSIG, // 46
|
RRSIG, // 46
|
||||||
NSEC, // 47
|
NSEC, // 47
|
||||||
DNSKEY, // 48
|
DNSKEY, // 48
|
||||||
NSEC3, // 50
|
NSEC3, // 50
|
||||||
OPT, // 41 (EDNS0 pseudo-type)
|
OPT, // 41 (EDNS0 pseudo-type)
|
||||||
|
SVCB, // 64
|
||||||
HTTPS, // 65
|
HTTPS, // 65
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,13 +37,16 @@ impl QueryType {
|
|||||||
QueryType::MX => 15,
|
QueryType::MX => 15,
|
||||||
QueryType::TXT => 16,
|
QueryType::TXT => 16,
|
||||||
QueryType::AAAA => 28,
|
QueryType::AAAA => 28,
|
||||||
|
QueryType::LOC => 29,
|
||||||
QueryType::SRV => 33,
|
QueryType::SRV => 33,
|
||||||
|
QueryType::NAPTR => 35,
|
||||||
QueryType::OPT => 41,
|
QueryType::OPT => 41,
|
||||||
QueryType::DS => 43,
|
QueryType::DS => 43,
|
||||||
QueryType::RRSIG => 46,
|
QueryType::RRSIG => 46,
|
||||||
QueryType::NSEC => 47,
|
QueryType::NSEC => 47,
|
||||||
QueryType::DNSKEY => 48,
|
QueryType::DNSKEY => 48,
|
||||||
QueryType::NSEC3 => 50,
|
QueryType::NSEC3 => 50,
|
||||||
|
QueryType::SVCB => 64,
|
||||||
QueryType::HTTPS => 65,
|
QueryType::HTTPS => 65,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,13 +61,16 @@ impl QueryType {
|
|||||||
15 => QueryType::MX,
|
15 => QueryType::MX,
|
||||||
16 => QueryType::TXT,
|
16 => QueryType::TXT,
|
||||||
28 => QueryType::AAAA,
|
28 => QueryType::AAAA,
|
||||||
|
29 => QueryType::LOC,
|
||||||
33 => QueryType::SRV,
|
33 => QueryType::SRV,
|
||||||
|
35 => QueryType::NAPTR,
|
||||||
41 => QueryType::OPT,
|
41 => QueryType::OPT,
|
||||||
43 => QueryType::DS,
|
43 => QueryType::DS,
|
||||||
46 => QueryType::RRSIG,
|
46 => QueryType::RRSIG,
|
||||||
47 => QueryType::NSEC,
|
47 => QueryType::NSEC,
|
||||||
48 => QueryType::DNSKEY,
|
48 => QueryType::DNSKEY,
|
||||||
50 => QueryType::NSEC3,
|
50 => QueryType::NSEC3,
|
||||||
|
64 => QueryType::SVCB,
|
||||||
65 => QueryType::HTTPS,
|
65 => QueryType::HTTPS,
|
||||||
_ => QueryType::UNKNOWN(num),
|
_ => QueryType::UNKNOWN(num),
|
||||||
}
|
}
|
||||||
@@ -77,13 +86,16 @@ impl QueryType {
|
|||||||
QueryType::MX => "MX",
|
QueryType::MX => "MX",
|
||||||
QueryType::TXT => "TXT",
|
QueryType::TXT => "TXT",
|
||||||
QueryType::AAAA => "AAAA",
|
QueryType::AAAA => "AAAA",
|
||||||
|
QueryType::LOC => "LOC",
|
||||||
QueryType::SRV => "SRV",
|
QueryType::SRV => "SRV",
|
||||||
|
QueryType::NAPTR => "NAPTR",
|
||||||
QueryType::OPT => "OPT",
|
QueryType::OPT => "OPT",
|
||||||
QueryType::DS => "DS",
|
QueryType::DS => "DS",
|
||||||
QueryType::RRSIG => "RRSIG",
|
QueryType::RRSIG => "RRSIG",
|
||||||
QueryType::NSEC => "NSEC",
|
QueryType::NSEC => "NSEC",
|
||||||
QueryType::DNSKEY => "DNSKEY",
|
QueryType::DNSKEY => "DNSKEY",
|
||||||
QueryType::NSEC3 => "NSEC3",
|
QueryType::NSEC3 => "NSEC3",
|
||||||
|
QueryType::SVCB => "SVCB",
|
||||||
QueryType::HTTPS => "HTTPS",
|
QueryType::HTTPS => "HTTPS",
|
||||||
QueryType::UNKNOWN(_) => "UNKNOWN",
|
QueryType::UNKNOWN(_) => "UNKNOWN",
|
||||||
}
|
}
|
||||||
@@ -99,12 +111,15 @@ impl QueryType {
|
|||||||
"MX" => Some(QueryType::MX),
|
"MX" => Some(QueryType::MX),
|
||||||
"TXT" => Some(QueryType::TXT),
|
"TXT" => Some(QueryType::TXT),
|
||||||
"AAAA" => Some(QueryType::AAAA),
|
"AAAA" => Some(QueryType::AAAA),
|
||||||
|
"LOC" => Some(QueryType::LOC),
|
||||||
"SRV" => Some(QueryType::SRV),
|
"SRV" => Some(QueryType::SRV),
|
||||||
|
"NAPTR" => Some(QueryType::NAPTR),
|
||||||
"DS" => Some(QueryType::DS),
|
"DS" => Some(QueryType::DS),
|
||||||
"RRSIG" => Some(QueryType::RRSIG),
|
"RRSIG" => Some(QueryType::RRSIG),
|
||||||
"DNSKEY" => Some(QueryType::DNSKEY),
|
"DNSKEY" => Some(QueryType::DNSKEY),
|
||||||
"NSEC" => Some(QueryType::NSEC),
|
"NSEC" => Some(QueryType::NSEC),
|
||||||
"NSEC3" => Some(QueryType::NSEC3),
|
"NSEC3" => Some(QueryType::NSEC3),
|
||||||
|
"SVCB" => Some(QueryType::SVCB),
|
||||||
"HTTPS" => Some(QueryType::HTTPS),
|
"HTTPS" => Some(QueryType::HTTPS),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user