1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

refactor(ext/net): Use hickory dns instead of unmaintained trust-dns (#26741)

This PR replaces the unmaintained and rebranded `trust-dns` to `hickory`
for resolver in `deno_net`.
This commit is contained in:
Kaveh 2024-11-07 03:19:32 +03:30 committed by Divy Srivastava
parent faed1d8e59
commit 3b37162c46
5 changed files with 133 additions and 195 deletions

248
Cargo.lock generated
View file

@ -765,6 +765,8 @@ dependencies = [
"fastwebsockets",
"file_test_runner",
"flaky_test",
"hickory-client",
"hickory-server",
"http 1.1.0",
"http-body-util",
"hyper 1.4.1",
@ -778,8 +780,6 @@ dependencies = [
"serde",
"test_server",
"tokio",
"trust-dns-client",
"trust-dns-server",
"url",
"uuid",
"zeromq",
@ -1800,14 +1800,14 @@ dependencies = [
"deno_core",
"deno_permissions",
"deno_tls",
"hickory-proto",
"hickory-resolver",
"pin-project",
"rustls-tokio-stream",
"serde",
"socket2",
"thiserror",
"tokio",
"trust-dns-proto",
"trust-dns-resolver",
]
[[package]]
@ -2639,15 +2639,6 @@ dependencies = [
"text_lines",
]
[[package]]
name = "drain"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d105028bd2b5dfcb33318fd79a445001ead36004dd8dffef1bdd7e493d8bc1e"
dependencies = [
"tokio",
]
[[package]]
name = "dsa"
version = "0.6.3"
@ -3545,6 +3536,92 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "hickory-client"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab9683b08d8f8957a857b0236455d80e1886eaa8c6178af556aa7871fb61b55"
dependencies = [
"cfg-if",
"data-encoding",
"futures-channel",
"futures-util",
"hickory-proto",
"once_cell",
"radix_trie",
"rand",
"thiserror",
"tokio",
"tracing",
]
[[package]]
name = "hickory-proto"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07698b8420e2f0d6447a436ba999ec85d8fbf2a398bbd737b82cac4a2e96e512"
dependencies = [
"async-trait",
"cfg-if",
"data-encoding",
"enum-as-inner",
"futures-channel",
"futures-io",
"futures-util",
"idna 0.4.0",
"ipnet",
"once_cell",
"rand",
"serde",
"thiserror",
"tinyvec",
"tokio",
"tracing",
"url",
]
[[package]]
name = "hickory-resolver"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28757f23aa75c98f254cf0405e6d8c25b831b32921b050a66692427679b1f243"
dependencies = [
"cfg-if",
"futures-util",
"hickory-proto",
"ipconfig",
"lru-cache",
"once_cell",
"parking_lot",
"rand",
"resolv-conf",
"serde",
"smallvec",
"thiserror",
"tokio",
"tracing",
]
[[package]]
name = "hickory-server"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9be0e43c556b9b3fdb6c7c71a9a32153a2275d02419e3de809e520bfcfe40c37"
dependencies = [
"async-trait",
"bytes",
"cfg-if",
"enum-as-inner",
"futures-util",
"hickory-proto",
"serde",
"thiserror",
"time",
"tokio",
"tokio-util",
"tracing",
]
[[package]]
name = "hkdf"
version = "0.12.4"
@ -6147,15 +6224,6 @@ dependencies = [
"syn 2.0.72",
]
[[package]]
name = "serde_spanned"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0"
dependencies = [
"serde",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@ -7369,40 +7437,6 @@ dependencies = [
"serde",
]
[[package]]
name = "toml"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
]
[[package]]
name = "toml_datetime"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"winnow 0.5.40",
]
[[package]]
name = "tower"
version = "0.4.13"
@ -7492,95 +7526,6 @@ dependencies = [
"stable_deref_trait",
]
[[package]]
name = "trust-dns-client"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14135e72c7e6d4c9b6902d4437881a8598f0145dbb2e3f86f92dbad845b61e63"
dependencies = [
"cfg-if",
"data-encoding",
"futures-channel",
"futures-util",
"once_cell",
"radix_trie",
"rand",
"thiserror",
"tokio",
"tracing",
"trust-dns-proto",
]
[[package]]
name = "trust-dns-proto"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3119112651c157f4488931a01e586aa459736e9d6046d3bd9105ffb69352d374"
dependencies = [
"async-trait",
"cfg-if",
"data-encoding",
"enum-as-inner",
"futures-channel",
"futures-io",
"futures-util",
"idna 0.4.0",
"ipnet",
"once_cell",
"rand",
"serde",
"smallvec",
"thiserror",
"tinyvec",
"tokio",
"tracing",
"url",
]
[[package]]
name = "trust-dns-resolver"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a3e6c3aff1718b3c73e395d1f35202ba2ffa847c6a62eea0db8fb4cfe30be6"
dependencies = [
"cfg-if",
"futures-util",
"ipconfig",
"lru-cache",
"once_cell",
"parking_lot",
"rand",
"resolv-conf",
"serde",
"smallvec",
"thiserror",
"tokio",
"tracing",
"trust-dns-proto",
]
[[package]]
name = "trust-dns-server"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c540f73c2b2ec2f6c54eabd0900e7aafb747a820224b742f556e8faabb461bc7"
dependencies = [
"async-trait",
"bytes",
"cfg-if",
"drain",
"enum-as-inner",
"futures-executor",
"futures-util",
"serde",
"thiserror",
"time",
"tokio",
"toml 0.7.8",
"tracing",
"trust-dns-proto",
]
[[package]]
name = "try-lock"
version = "0.2.5"
@ -8330,15 +8275,6 @@ version = "0.52.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8"
[[package]]
name = "winnow"
version = "0.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
dependencies = [
"memchr",
]
[[package]]
name = "winnow"
version = "0.6.15"
@ -8374,7 +8310,7 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c"
dependencies = [
"toml 0.5.11",
"toml",
]
[[package]]
@ -8451,7 +8387,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a6a39b6b5ba0d02c910d05d7fbc366a4befb8901ea107dcde9c1c97acb8a366"
dependencies = [
"rowan",
"winnow 0.6.15",
"winnow",
]
[[package]]

View file

@ -17,11 +17,11 @@ path = "lib.rs"
deno_core.workspace = true
deno_permissions.workspace = true
deno_tls.workspace = true
hickory-proto = "0.24"
hickory-resolver = { version = "0.24", features = ["tokio-runtime", "serde-config"] }
pin-project.workspace = true
rustls-tokio-stream.workspace = true
serde.workspace = true
socket2.workspace = true
thiserror.workspace = true
tokio.workspace = true
trust-dns-proto = "0.23"
trust-dns-resolver = { version = "0.23", features = ["tokio-runtime", "serde-config"] }

View file

@ -18,6 +18,16 @@ use deno_core::OpState;
use deno_core::RcRef;
use deno_core::Resource;
use deno_core::ResourceId;
use hickory_proto::rr::rdata::caa::Value;
use hickory_proto::rr::record_data::RData;
use hickory_proto::rr::record_type::RecordType;
use hickory_resolver::config::NameServerConfigGroup;
use hickory_resolver::config::ResolverConfig;
use hickory_resolver::config::ResolverOpts;
use hickory_resolver::error::ResolveError;
use hickory_resolver::error::ResolveErrorKind;
use hickory_resolver::system_conf;
use hickory_resolver::AsyncResolver;
use serde::Deserialize;
use serde::Serialize;
use socket2::Domain;
@ -33,16 +43,6 @@ use std::rc::Rc;
use std::str::FromStr;
use tokio::net::TcpStream;
use tokio::net::UdpSocket;
use trust_dns_proto::rr::rdata::caa::Value;
use trust_dns_proto::rr::record_data::RData;
use trust_dns_proto::rr::record_type::RecordType;
use trust_dns_resolver::config::NameServerConfigGroup;
use trust_dns_resolver::config::ResolverConfig;
use trust_dns_resolver::config::ResolverOpts;
use trust_dns_resolver::error::ResolveError;
use trust_dns_resolver::error::ResolveErrorKind;
use trust_dns_resolver::system_conf;
use trust_dns_resolver::AsyncResolver;
#[derive(Serialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
@ -828,6 +828,21 @@ mod tests {
use deno_core::JsRuntime;
use deno_core::RuntimeOptions;
use deno_permissions::PermissionCheckError;
use hickory_proto::rr::rdata::a::A;
use hickory_proto::rr::rdata::aaaa::AAAA;
use hickory_proto::rr::rdata::caa::KeyValue;
use hickory_proto::rr::rdata::caa::CAA;
use hickory_proto::rr::rdata::mx::MX;
use hickory_proto::rr::rdata::name::ANAME;
use hickory_proto::rr::rdata::name::CNAME;
use hickory_proto::rr::rdata::name::NS;
use hickory_proto::rr::rdata::name::PTR;
use hickory_proto::rr::rdata::naptr::NAPTR;
use hickory_proto::rr::rdata::srv::SRV;
use hickory_proto::rr::rdata::txt::TXT;
use hickory_proto::rr::rdata::SOA;
use hickory_proto::rr::record_data::RData;
use hickory_proto::rr::Name;
use socket2::SockRef;
use std::net::Ipv4Addr;
use std::net::Ipv6Addr;
@ -836,21 +851,6 @@ mod tests {
use std::path::PathBuf;
use std::sync::Arc;
use std::sync::Mutex;
use trust_dns_proto::rr::rdata::a::A;
use trust_dns_proto::rr::rdata::aaaa::AAAA;
use trust_dns_proto::rr::rdata::caa::KeyValue;
use trust_dns_proto::rr::rdata::caa::CAA;
use trust_dns_proto::rr::rdata::mx::MX;
use trust_dns_proto::rr::rdata::name::ANAME;
use trust_dns_proto::rr::rdata::name::CNAME;
use trust_dns_proto::rr::rdata::name::NS;
use trust_dns_proto::rr::rdata::name::PTR;
use trust_dns_proto::rr::rdata::naptr::NAPTR;
use trust_dns_proto::rr::rdata::srv::SRV;
use trust_dns_proto::rr::rdata::txt::TXT;
use trust_dns_proto::rr::rdata::SOA;
use trust_dns_proto::rr::record_data::RData;
use trust_dns_proto::rr::Name;
#[test]
fn rdata_to_return_record_a() {

View file

@ -47,6 +47,8 @@ deno_tls.workspace = true
fastwebsockets = { workspace = true, features = ["upgrade", "unstable-split"] }
file_test_runner = "0.7.2"
flaky_test = "=0.2.2"
hickory-client = "=0.24"
hickory-server = "=0.24"
http.workspace = true
http-body-util.workspace = true
hyper.workspace = true
@ -60,8 +62,6 @@ serde.workspace = true
test_util.workspace = true
tokio.workspace = true
tower-lsp.workspace = true
trust-dns-client = "=0.23.2"
trust-dns-server = "=0.23.2"
url.workspace = true
uuid = { workspace = true, features = ["serde"] }
zeromq.workspace = true

View file

@ -16,12 +16,11 @@ use deno_tls::rustls;
use deno_tls::rustls::ClientConnection;
use deno_tls::rustls_pemfile;
use deno_tls::TlsStream;
use hickory_client::serialize::txt::Parser;
use pretty_assertions::assert_eq;
use test_util as util;
use test_util::itest;
use test_util::TempDir;
use trust_dns_client::serialize::txt::Lexer;
use trust_dns_client::serialize::txt::Parser;
use util::assert_contains;
use util::assert_not_contains;
use util::PathRef;
@ -2175,6 +2174,11 @@ fn basic_auth_tokens() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_resolve_dns() {
use hickory_server::authority::Catalog;
use hickory_server::authority::ZoneType;
use hickory_server::proto::rr::Name;
use hickory_server::store::in_memory::InMemoryAuthority;
use hickory_server::ServerFuture;
use std::net::SocketAddr;
use std::str::FromStr;
use std::sync::Arc;
@ -2182,11 +2186,6 @@ async fn test_resolve_dns() {
use tokio::net::TcpListener;
use tokio::net::UdpSocket;
use tokio::sync::oneshot;
use trust_dns_server::authority::Catalog;
use trust_dns_server::authority::ZoneType;
use trust_dns_server::proto::rr::Name;
use trust_dns_server::store::in_memory::InMemoryAuthority;
use trust_dns_server::ServerFuture;
const DNS_PORT: u16 = 4553;
@ -2196,9 +2195,12 @@ async fn test_resolve_dns() {
util::testdata_path().join("run/resolve_dns.zone.in"),
)
.unwrap();
let lexer = Lexer::new(&zone_file);
let records =
Parser::new().parse(lexer, Some(Name::from_str("example.com").unwrap()));
let records = Parser::new(
&zone_file,
None,
Some(Name::from_str("example.com").unwrap()),
)
.parse();
if records.is_err() {
panic!("failed to parse: {:?}", records.err())
}