Skip to content

Commit acb3afb

Browse files
authored
⬆ Update HickoryDNS (#459)
1 parent 70162f9 commit acb3afb

File tree

19 files changed

+466
-205
lines changed

19 files changed

+466
-205
lines changed

Cargo.lock

Lines changed: 390 additions & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ service = [
6868

6969
nft = ["dep:which", "dep:either"]
7070

71-
dnssec = ["hickory-proto/dnssec", "hickory-proto/dnssec-ring", "rustls/ring"]
71+
dnssec = [ "hickory-proto/dnssec-ring", "rustls/ring"]
7272

7373
experimental = ["experimental-trie", "experimental-phf"]
7474

@@ -89,13 +89,13 @@ hostname = { git = "https://github.com/mokeyish/hostname.git", branch = "dev" }
8989
# enum_dispatch = { git = "https://gitlab.com/mokeyish/enum_dispatch.git", branch = "master"}
9090
# axum = { git = "https://github.com/tokio-rs/axum.git", rev = "8854e66" }
9191
# boomphf ={ path = "./target/patch/boomphf-0.6.0"}
92-
rustls-pki-types = { git = "https://github.com/mokeyish/pki-types.git", rev = "1.9.0.smartdns.1" }
92+
rustls-pki-types = { git = "https://github.com/mokeyish/pki-types.git", rev = "1.10.1.smartdns.1" }
9393

9494
[dependencies]
9595
cfg-if = "1"
9696
clap = { version = "4.5", features = ["derive"] }
9797
clap-verbosity-flag = "2.2.2"
98-
thiserror = "1.0"
98+
thiserror = "2.0"
9999
anyhow = "1.0"
100100
once_cell = "1.16.0"
101101
nom = "7.1.3"
@@ -143,8 +143,8 @@ tracing-subscriber = { version = "0.3", features = [
143143
# tracing-appender = "0.2"
144144

145145
# hickory dns
146-
hickory-proto = { git = "https://github.com/mokeyish/hickory-dns.git", rev = "0.25.0-smartdns.5", version = "0.25.0-alpha.2", features = ["serde"]}
147-
hickory-resolver = { git = "https://github.com/mokeyish/hickory-dns.git", rev = "0.25.0-smartdns.5", version = "0.25.0-alpha.2", features = [
146+
hickory-proto = { git = "https://github.com/mokeyish/hickory-dns.git", rev = "0.25.0-smartdns.6", version = "0.25.0-alpha.4", features = ["serde"]}
147+
hickory-resolver = { git = "https://github.com/mokeyish/hickory-dns.git", rev = "0.25.0-smartdns.6", version = "0.25.0-alpha.4", features = [
148148
"serde",
149149
"system-config",
150150
] }
@@ -155,7 +155,7 @@ quinn = { version = "0.11.2", default-features = false }
155155
webpki-roots = "0.26"
156156
rustls = { version = "0.23", default-features = false, features = ["std", "tls12"] }
157157
rustls-pemfile = "2"
158-
rustls-native-certs = "0.7"
158+
rustls-native-certs = "0.8"
159159

160160
lru = { version = "0.12", default-features = false }
161161
# time = "0.3"
@@ -167,7 +167,7 @@ csv = "1.1"
167167
hostname = "0.3"
168168
byte-unit = { version = "5.0.3", features = ["serde"]}
169169
ipnet = "2.7"
170-
which = { version = "6.0.1", optional = true }
170+
which = { version = "7.0.1", optional = true }
171171
glob = "0.3.1"
172172

173173
# process
@@ -181,7 +181,7 @@ async-http-proxy = { version = "1.2.5", features = [
181181
] }
182182

183183
num-traits = "0.2.19"
184-
url = "2.5.2"
184+
url = "2.5.4"
185185
# regex = "1"
186186
# rnp = "0.1"
187187
boomphf = { version = "0.6.0", optional = true }
@@ -223,8 +223,8 @@ anyhow = "1.0"
223223

224224

225225
[target.'cfg(target_os = "linux")'.build-dependencies]
226-
cc = "1.1"
227-
bindgen = "0.69.4"
226+
cc = "1.2"
227+
bindgen = "0.70"
228228

229229

230230
# Dev-dependencies are not used when compiling a package for building, but are used for compiling tests, examples, and benchmarks.

src/app.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,13 @@ async fn process(
337337
message: SerialMessage,
338338
server_opts: ServerOpts,
339339
) -> SerialMessage {
340-
use crate::libdns::proto::error::ProtoError;
341340
use crate::libdns::proto::op::{Header, Message, MessageType, OpCode, ResponseCode};
341+
use crate::libdns::proto::ProtoError;
342342

343343
let addr = message.addr();
344344
let protocol = message.protocol();
345345

346-
return match DnsRequest::try_from(message) {
346+
match DnsRequest::try_from(message) {
347347
Ok(request) => {
348348
match request.message_type() {
349349
MessageType::Query => {
@@ -408,6 +408,7 @@ async fn process(
408408
OpCode::Status => todo!(),
409409
OpCode::Notify => todo!(),
410410
OpCode::Update => todo!(),
411+
OpCode::Unknown(_) => todo!(),
411412
}
412413
}
413414
MessageType::Response => todo!(),
@@ -438,5 +439,5 @@ async fn process(
438439
SerialMessage::raw(response_message, addr, protocol)
439440
}
440441
_ => SerialMessage::raw(Default::default(), addr, protocol),
441-
};
442+
}
442443
}

src/config/domain.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::ops::Deref;
2-
31
use crate::libdns::proto::rr::Name;
2+
use std::ops::Deref;
43

54
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
65
pub enum WildcardName {
@@ -33,9 +32,9 @@ impl WildcardName {
3332
pub fn is_match(&self, name: &Name) -> bool {
3433
match self {
3534
WildcardName::Default(n) => n.zone_of(name),
36-
WildcardName::Suffix(n) => n != name && n.zone_of(name),
37-
WildcardName::Sub(n) => n == &name.base_name(),
38-
WildcardName::Full(n) => n == name,
35+
WildcardName::Suffix(n) => !n.eq_ignore_root_case(name) && n.zone_of(name),
36+
WildcardName::Sub(n) => n.eq_ignore_root_case(&name.base_name()),
37+
WildcardName::Full(n) => n.eq_ignore_root_case(name),
3938
}
4039
}
4140
}

src/config/log.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub struct LogConfig {
2626
pub num: Option<u64>,
2727

2828
/// log file mode
29-
3029
#[serde(with = "serde_opt_str")]
3130
pub file_mode: Option<FileMode>,
3231

src/config/parser/domain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
impl NomParser for Name {
44
fn parse(input: &str) -> IResult<&str, Self> {
55
let name = is_not(" \n\t\\/|\"#',!+<>");
6-
map_res(name, <Name as std::str::FromStr>::from_str)(input)
6+
map_res(name, |s: &str| s.parse())(input)
77
}
88
}
99

src/config/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub fn parse_config(input: &str) -> IResult<&str, OneConfig> {
150150

151151
fn parse_item<'a, T: NomParser>(
152152
keyword: &'static str,
153-
) -> impl FnMut(&'a str) -> IResult<&str, T> {
153+
) -> impl FnMut(&'a str) -> IResult<&'a str, T> {
154154
preceded(tuple((space0, tag_no_case(keyword), space1)), T::parse)
155155
}
156156

src/dns.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ use crate::dns_conf::RuntimeConfig;
1414
pub use crate::dns_rule::DomainRuleGetter;
1515

1616
pub use crate::libdns::proto::{
17-
error::ProtoErrorKind,
1817
op,
1918
rr::{self, rdata::SOA, Name, RData, Record, RecordType},
19+
ProtoErrorKind,
2020
};
2121

2222
pub use crate::libdns::{
2323
proto::xfer::Protocol,
2424
resolver::{
2525
config::{NameServerConfig, NameServerConfigGroup},
26-
error::{ResolveError, ResolveErrorKind},
2726
lookup::Lookup,
27+
ResolveError, ResolveErrorKind,
2828
},
2929
};
3030

@@ -115,7 +115,7 @@ impl Default for LookupFrom {
115115
mod serial_message {
116116

117117
use crate::dns_error::LookupError;
118-
use crate::libdns::proto::error::ProtoError;
118+
use crate::libdns::proto::ProtoError;
119119
use crate::libdns::Protocol;
120120
use crate::{config::ServerOpts, libdns::proto::op::Message};
121121
use bytes::Bytes;
@@ -214,9 +214,9 @@ mod request {
214214

215215
use crate::libdns::{
216216
proto::{
217-
error::ProtoError,
218217
op::{LowerQuery, Message, Query},
219218
rr::{Name, RecordType},
219+
ProtoError,
220220
},
221221
Protocol,
222222
};
@@ -293,7 +293,7 @@ mod request {
293293
let rtype = self.query().query_type();
294294
self.extensions()
295295
.as_ref()
296-
.map(|e| e.dnssec_ok())
296+
.map(|e| e.flags().dnssec_ok)
297297
.unwrap_or(rtype.is_dnssec())
298298
}
299299
}

src/dns_client.rs

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,18 @@ use crate::{
2222

2323
use crate::libdns::{
2424
proto::{
25-
error::{ProtoError, ProtoErrorKind, ProtoResult},
2625
op::{Edns, Message, MessageType, OpCode, Query},
2726
rr::{
2827
domain::{IntoName, Name},
2928
rdata::opt::{ClientSubnet, EdnsOption},
3029
Record, RecordType,
3130
},
3231
xfer::{DnsRequest, DnsRequestOptions, FirstAnswer},
33-
DnsHandle,
32+
DnsHandle, ProtoError, ProtoErrorKind,
3433
},
3534
resolver::{
36-
config::{ResolverOpts, ServerOrderingStrategy, TlsClientConfig},
35+
config::{ResolverOpts, ServerOrderingStrategy},
3736
name_server::GenericConnector,
38-
TryParseIp,
3937
},
4038
};
4139

@@ -465,7 +463,7 @@ impl NameServer {
465463
tls_client_config.normal
466464
};
467465

468-
(Some(url.host().to_string()), Some(TlsClientConfig(config)))
466+
(Some(url.host().to_string()), Some(config))
469467
} else {
470468
(None, None)
471469
};
@@ -631,7 +629,7 @@ impl GenericResolver for NameServer {
631629
name: N,
632630
options: O,
633631
) -> Result<DnsResponse, LookupError> {
634-
use crate::libdns::proto::error::ProtoErrorKind;
632+
use crate::libdns::proto::ProtoErrorKind;
635633
let name = name.into_name()?;
636634
let options: LookupOptions = options.into();
637635

@@ -780,32 +778,13 @@ pub trait GenericResolver {
780778

781779
#[async_trait::async_trait]
782780
pub trait GenericResolverExt {
783-
/// Generic lookup for any RecordType
784-
///
785-
/// # Arguments
786-
///
787-
/// * `name` - name of the record to lookup, if name is not a valid domain name, an error will be returned
788-
/// * `record_type` - type of record to lookup, all RecordData responses will be filtered to this type
789-
///
790-
/// # Returns
791-
///
792-
// A future for the returned Lookup RData
793-
// async fn lookup<N: IntoName + Send>(
794-
// &self,
795-
// name: N,
796-
// record_type: RecordType,
797-
// ) -> Result<Lookup, ResolveError>;
798-
799781
/// Performs a dual-stack DNS lookup for the IP for the given hostname.
800782
///
801783
/// See the configuration and options parameters for controlling the way in which A(Ipv4) and AAAA(Ipv6) lookups will be performed. For the least expensive query a fully-qualified-domain-name, FQDN, which ends in a final `.`, e.g. `www.example.com.`, will only issue one query. Anything else will always incur the cost of querying the `ResolverConfig::domain` and `ResolverConfig::search`.
802784
///
803785
/// # Arguments
804786
/// * `host` - string hostname, if this is an invalid hostname, an error will be returned.
805-
async fn lookup_ip<N: IntoName + TryParseIp + Send>(
806-
&self,
807-
host: N,
808-
) -> Result<DnsResponse, LookupError>;
787+
async fn lookup_ip<N: IntoName + Send>(&self, host: N) -> Result<DnsResponse, LookupError>;
809788
}
810789

811790
#[async_trait::async_trait]
@@ -814,18 +793,16 @@ where
814793
T: GenericResolver + Sync,
815794
{
816795
/// * `host` - string hostname, if this is an invalid hostname, an error will be returned.
817-
async fn lookup_ip<N: IntoName + TryParseIp + Send>(
818-
&self,
819-
host: N,
820-
) -> Result<DnsResponse, LookupError> {
796+
async fn lookup_ip<N: IntoName + Send>(&self, host: N) -> Result<DnsResponse, LookupError> {
821797
let mut finally_ip_addr: Option<Record> = None;
822-
let maybe_ip = host.try_parse_ip();
823-
let maybe_name: ProtoResult<Name> = host.into_name();
798+
let maybe_ip = host.to_ip();
799+
let maybe_name: Result<Name, ProtoError> = host.into_name();
824800

825801
// if host is a ip address, return directly.
826802
if let Some(ip_addr) = maybe_ip {
803+
let ip_addr = ip_addr.into();
827804
let name = maybe_name.clone().unwrap_or_default();
828-
let record = Record::from_rdata(name.clone(), MAX_TTL, ip_addr.clone());
805+
let record = Record::from_rdata(name.clone(), MAX_TTL, Clone::clone(&ip_addr));
829806

830807
// if ndots are greater than 4, then we can't assume the name is an IpAddr
831808
// this accepts IPv6 as well, b/c IPv6 can take the form: 2001:db8::198.51.100.35

src/dns_error.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::dns::{DefaultSOA as _, DnsResponse};
22
use crate::libdns::proto::{
3-
error::{ProtoError, ProtoErrorKind},
43
op::{Query, ResponseCode},
54
rr::{rdata::SOA, Record},
5+
ProtoError, ProtoErrorKind,
66
};
7-
use crate::libdns::resolver::error::{ResolveError, ResolveErrorKind};
7+
use crate::libdns::resolver::{ResolveError, ResolveErrorKind};
88
use std::{io, sync::Arc};
99
use thiserror::Error;
1010

@@ -79,6 +79,7 @@ impl LookupError {
7979
response_code: ResponseCode::ServFail,
8080
trusted: true,
8181
ns: None,
82+
authorities: None,
8283
}
8384
.into()
8485
}

0 commit comments

Comments
 (0)