Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Sync upstream hickory-dns #511

Merged
merged 1 commit into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
422 changes: 245 additions & 177 deletions Cargo.lock

Large diffs are not rendered by default.

39 changes: 17 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name = "smartdns"
version = "0.9.2-alpha.1"
authors = ["YISH <[email protected]>"]
edition = "2021"
rust-version = "1.75.0"
edition = "2024"
rust-version = "1.85.0"

keywords = ["DNS", "BIND", "dig", "SmartDNS", "Dnsmasq"]
categories = ["network-programming"]
Expand Down Expand Up @@ -45,27 +45,23 @@ self-update = ["dep:self_update"]

resolve-cli = ["dep:console"]

dns-over-tls = []
dns-over-https = ["dns-over-https-rustls"]
dns-over-tls = [
"hickory-proto/tls-ring",
"hickory-resolver/tls-ring",
]
dns-over-https = [
"hickory-proto/https-ring",
"hickory-resolver/https-ring"
]
dns-over-quic = [
"dns-over-rustls",
"hickory-proto/dns-over-quic",
"hickory-resolver/dns-over-quic",
"hickory-proto/quic-ring",
"hickory-resolver/quic-ring",
]
dns-over-h3 = [
"dns-over-rustls",
"hickory-proto/dns-over-h3",
"hickory-resolver/dns-over-h3"
"hickory-proto/h3-ring",
"hickory-resolver/h3-ring"
]

dns-over-https-rustls = [
"dns-over-rustls",
"hickory-proto/dns-over-https-rustls",
"hickory-resolver/dns-over-https-rustls",
]

dns-over-rustls = []

mdns = []

service = [
Expand Down Expand Up @@ -162,12 +158,11 @@ tracing-subscriber = { version = "0.3", features = [
# tracing-appender = "0.2"

# hickory dns
hickory-proto = { git = "https://github.com/mokeyish/hickory-dns.git", rev = "0.25.0-smartdns.6", version = "0.25.0-alpha.4", features = ["serde"]}
hickory-resolver = { git = "https://github.com/mokeyish/hickory-dns.git", rev = "0.25.0-smartdns.6", version = "0.25.0-alpha.4", features = [
hickory-proto = { git = "https://github.com/mokeyish/hickory-dns.git", rev = "0.25.0-smartdns.7", features = ["serde"]}
hickory-resolver = { git = "https://github.com/mokeyish/hickory-dns.git", rev = "0.25.0-smartdns.7", features = [
"serde",
"system-config",
] }
# hickory-server = { git = "https://github.com/mokeyish/hickory-dns.git", rev = "0.25.0-smartdns.5", version = "0.25.0-alpha.2", features = ["resolver"], optional = true }
quinn = { version = "0.11.2", default-features = false }

# ssl
Expand Down Expand Up @@ -244,7 +239,7 @@ anyhow = "1.0"

[target.'cfg(target_os = "linux")'.build-dependencies]
cc = "1.2"
bindgen = "0.70"
bindgen = "0.71"


# Dev-dependencies are not used when compiling a package for building, but are used for compiling tests, examples, and benchmarks.
Expand Down
4 changes: 2 additions & 2 deletions src/api/address.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use super::openapi::{http::get, routes, IntoRouter};
use super::openapi::{IntoRouter, http::get, routes};
use super::{IntoDataListPayload, ServeState, StatefulRouter};
use axum::{extract::State, response::IntoResponse, Json};
use axum::{Json, extract::State, response::IntoResponse};

pub fn routes() -> StatefulRouter {
routes![addresses].into_router()
Expand Down
4 changes: 2 additions & 2 deletions src/api/audit.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use super::openapi::{http::get, routes, IntoRouter};
use axum::{extract::State, response::IntoResponse, Json};
use super::openapi::{IntoRouter, http::get, routes};
use axum::{Json, extract::State, response::IntoResponse};

use super::{ServeState, StatefulRouter};

Expand Down
5 changes: 3 additions & 2 deletions src/api/cache.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::sync::Arc;

use super::openapi::{
IntoRouter,
http::{get, post},
routes, IntoRouter,
routes,
};
use super::{IntoDataListPayload, ServeState, StatefulRouter};
use crate::log;
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json};
use axum::{Json, extract::State, http::StatusCode, response::IntoResponse};

pub fn routes() -> StatefulRouter {
let route1 = routes![flush_cache, caches].into_router();
Expand Down
4 changes: 2 additions & 2 deletions src/api/forward.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use axum::{extract::State, response::IntoResponse, Json};
use axum::{Json, extract::State, response::IntoResponse};

use super::openapi::{http::get, routes, IntoRouter};
use super::openapi::{IntoRouter, http::get, routes};
use super::{IntoDataListPayload, ServeState, StatefulRouter};

pub fn routes() -> StatefulRouter {
Expand Down
4 changes: 2 additions & 2 deletions src/api/listener.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use axum::{extract::State, response::IntoResponse, Json};
use axum::{Json, extract::State, response::IntoResponse};

use super::openapi::{http::get, routes, IntoRouter};
use super::openapi::{IntoRouter, http::get, routes};
use super::{IntoDataListPayload, ServeState, StatefulRouter};

pub fn routes() -> StatefulRouter {
Expand Down
4 changes: 2 additions & 2 deletions src/api/log.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use super::openapi::{http::get, routes, IntoRouter};
use super::openapi::{IntoRouter, http::get, routes};
use super::{ServeState, StatefulRouter};
use axum::{extract::State, response::IntoResponse, Json};
use axum::{Json, extract::State, response::IntoResponse};

pub fn routes() -> StatefulRouter {
routes![log_config].into_router()
Expand Down
2 changes: 1 addition & 1 deletion src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use axum::{
Json,
http::StatusCode,
response::{IntoResponse, Response},
routing::get,
Json,
};
use cfg_if::cfg_if;
use openapi::Router;
Expand Down
4 changes: 2 additions & 2 deletions src/api/nameserver.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use axum::{extract::State, response::IntoResponse, Json};
use axum::{Json, extract::State, response::IntoResponse};

use super::openapi::{http::get, routes, IntoRouter};
use super::openapi::{IntoRouter, http::get, routes};
use super::{IntoDataListPayload, ServeState, StatefulRouter};

pub fn routes() -> StatefulRouter {
Expand Down
4 changes: 2 additions & 2 deletions src/api/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use axum::routing::MethodRouter;
use utoipa::{
openapi::{Paths, RefOr, Schema},
OpenApi,
openapi::{Paths, RefOr, Schema},
};

pub use utoipa::{IntoParams, ToSchema};
Expand Down Expand Up @@ -33,10 +33,10 @@ pub fn swagger_cdn<S: Clone + Send + Sync + 'static>(
cdn: Option<&str>,
) -> axum::Router<S> {
use axum::{
Router,
extract::State,
response::{Html, Json},
routing::get,
Router,
};
use std::sync::Arc;
use utoipa::openapi::OpenApi;
Expand Down
5 changes: 3 additions & 2 deletions src/api/serve_dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;

use axum::body::Body;
use axum::extract::Query;
use axum::http::{header, HeaderValue, StatusCode};
use axum::http::{HeaderValue, StatusCode, header};
use axum::response::{IntoResponse, Response};
use axum::{
body::Bytes,
Expand All @@ -12,8 +12,9 @@ use axum::{
use serde::{Deserialize, Serialize};

use super::openapi::{
IntoParams, IntoRouter, ToSchema,
http::{get, post},
routes, IntoParams, IntoRouter, ToSchema,
routes,
};
use super::{ServeState, StatefulRouter};
use crate::{dns::SerialMessage, libdns::Protocol, log};
Expand Down
4 changes: 2 additions & 2 deletions src/api/settings.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use super::openapi::{http::get, routes, IntoRouter};
use super::openapi::{IntoRouter, http::get, routes};
use super::{ServeState, StatefulRouter};
use axum::{extract::State, response::IntoResponse, Json};
use axum::{Json, extract::State, response::IntoResponse};

pub fn routes() -> StatefulRouter {
routes![server_name].into_router()
Expand Down
20 changes: 16 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ async fn process(
message: SerialMessage,
server_opts: ServerOpts,
) -> SerialMessage {
use crate::libdns::proto::op::{Header, Message, MessageType, OpCode, ResponseCode};
use crate::libdns::proto::ProtoError;
use crate::libdns::proto::op::{Header, Message, MessageType, OpCode, ResponseCode};

let addr = message.addr();
let protocol = message.protocol();
Expand Down Expand Up @@ -380,7 +380,15 @@ async fn process(
}
Err(e) => {
if e.is_nx_domain() {
log::debug!("{}Response: error resolving: NXDomain, Duration: {:?}", if server_opts.is_background { "Background"} else { "" }, start.elapsed());
log::debug!(
"{}Response: error resolving: NXDomain, Duration: {:?}",
if server_opts.is_background {
"Background"
} else {
""
},
start.elapsed()
);
response_header
.set_response_code(ResponseCode::NXDomain);
}
Expand All @@ -390,7 +398,11 @@ async fn process(
None => {
log::debug!(
"{}Response: error resolving: {}, Duration: {:?}",
if server_opts.is_background { "Background"} else { "" },
if server_opts.is_background {
"Background"
} else {
""
},
e,
start.elapsed()
);
Expand Down Expand Up @@ -432,7 +444,7 @@ async fn process(
proto = protocol,
addr = addr.ip(),
port = addr.port(),
message_type= request_header.message_type(),
message_type = request_header.message_type(),
op = request_header.op_code(),
error = error,
);
Expand Down
4 changes: 2 additions & 2 deletions src/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl FromIterator<WildcardName> for DomainSet {
mod trie {
use crate::third_ext::AsSlice;
use std::{
collections::{hash_map::RandomState, HashMap},
collections::{HashMap, hash_map::RandomState},
hash::{BuildHasher, Hash},
};

Expand Down Expand Up @@ -555,7 +555,7 @@ mod benchmark {
for name in domain_list.iter() {
set.insert(name.clone());
}
let set = phf::create_from_hashmap(set.0 .0);
let set = phf::create_from_hashmap(set.0.0);
let set = &set;

let domain_list = &domain_list;
Expand Down
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::{
use crate::{
infra::file_mode::FileMode,
libdns::proto::rr::{
rdata::{HTTPS, SRV},
Name, RecordType,
rdata::{HTTPS, SRV},
},
log::Level,
proxy::ProxyConfig,
Expand Down
2 changes: 1 addition & 1 deletion src/config/parser/https_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl NomParser for HttpsRecordRule {
#[cfg(test)]
mod tests {
use super::*;
use crate::libdns::proto::rr::rdata::svcb::{Alpn, IpHint, SvcParamKey, SvcParamValue, SVCB};
use crate::libdns::proto::rr::rdata::svcb::{Alpn, IpHint, SVCB, SvcParamKey, SvcParamValue};

#[test]
fn test_parse() {
Expand Down
4 changes: 2 additions & 2 deletions src/config/parser/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use nom::{
branch::*, bytes::complete::*, character::complete::*, combinator::*, multi::*, sequence::*,
IResult,
IResult, branch::*, bytes::complete::*, character::complete::*, combinator::*, multi::*,
sequence::*,
};

mod address_rule;
Expand Down
2 changes: 1 addition & 1 deletion src/config/parser/nom_recipes/ip.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::net::IpAddr;

use super::{ipv4, ipv6};
use nom::{branch::alt, combinator::map, IResult};
use nom::{IResult, branch::alt, combinator::map};

pub fn ip(input: &str) -> IResult<&str, IpAddr> {
alt((map(ipv4, IpAddr::from), map(ipv6, IpAddr::from)))(input)
Expand Down
2 changes: 1 addition & 1 deletion src/config/parser/nom_recipes/ipv4.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::net::Ipv4Addr;

use nom::{
IResult,
character::complete::{char, digit1},
combinator::{map, map_res, recognize},
error::context,
multi::many_m_n,
sequence::{preceded, tuple},
IResult,
};

pub fn ipv4(input: &str) -> IResult<&str, Ipv4Addr> {
Expand Down
2 changes: 1 addition & 1 deletion src/config/parser/nom_recipes/ipv6.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::net::Ipv6Addr;

use nom::{
IResult,
branch::alt,
bytes::complete::tag,
character::complete::{char, hex_digit1},
combinator::{map, map_res, opt, recognize, verify},
error::context,
multi::{many_m_n, separated_list0},
sequence::{pair, preceded},
IResult,
};

use super::ipv4;
Expand Down
2 changes: 1 addition & 1 deletion src/config/parser/svcb.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use crate::libdns::proto::rr::rdata::svcb::{
Alpn, EchConfigList, IpHint, SvcParamKey, SvcParamValue, SVCB,
Alpn, EchConfigList, IpHint, SVCB, SvcParamKey, SvcParamValue,
};
use crate::libdns::proto::rr::rdata::{A, AAAA};

Expand Down
Loading