From acb3afbf2b3b67b4da299e40ff09b063967f12d1 Mon Sep 17 00:00:00 2001 From: YISH Date: Sat, 28 Dec 2024 14:18:08 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E2=AC=86=20Update=20HickoryDNS=20(#459)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 494 ++++++++++++++++++++++++++++-------- Cargo.toml | 20 +- src/app.rs | 7 +- src/config/domain.rs | 9 +- src/config/log.rs | 1 - src/config/parser/domain.rs | 2 +- src/config/parser/mod.rs | 2 +- src/dns.rs | 10 +- src/dns_client.rs | 43 +--- src/dns_error.rs | 5 +- src/dns_mw_cache.rs | 12 +- src/dns_mw_hosts.rs | 4 +- src/dns_mw_ns.rs | 1 + src/dnsmasq.rs | 15 +- src/ffi/nftset_sys.rs | 2 +- src/infra/ipset.rs | 8 +- src/resolver.rs | 23 +- src/rustls.rs | 9 +- src/server/udp.rs | 4 +- 19 files changed, 466 insertions(+), 205 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5f16f35f..e7bc2bca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,7 +136,7 @@ checksum = "29faa5d4d308266048bd7505ba55484315a890102f9345b9ff4b87de64201592" dependencies = [ "base64 0.13.1", "httparse", - "thiserror", + "thiserror 1.0.66", "tokio", ] @@ -156,7 +156,7 @@ name = "async-socks5" version = "0.6.0" source = "git+https://github.com/mokeyish/async-socks5.git?rev=f78eec5#f78eec58e8befd8b9615364b96e06fb2f20e009d" dependencies = [ - "thiserror", + "thiserror 1.0.66", "tokio", ] @@ -297,16 +297,14 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bindgen" -version = "0.69.5" +version = "0.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" dependencies = [ "bitflags", "cexpr", "clang-sys", "itertools", - "lazy_static", - "lazycell", "log", "prettyplease", "proc-macro2", @@ -315,7 +313,6 @@ dependencies = [ "rustc-hash 1.1.0", "shlex", "syn 2.0.87", - "which 4.4.2", ] [[package]] @@ -439,14 +436,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "190baaad529bcfbde9e1a19022c42781bdb6ff9de25721abdb8fd98c0807730b" dependencies = [ "libc", - "thiserror", + "thiserror 1.0.66", ] [[package]] name = "cc" -version = "1.1.34" +version = "1.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" +checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333" dependencies = [ "shlex", ] @@ -575,9 +572,9 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "core-foundation" -version = "0.9.4" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" dependencies = [ "core-foundation-sys", "libc", @@ -607,6 +604,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -808,6 +814,12 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "env_home" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe" + [[package]] name = "equivalent" version = "1.0.1" @@ -1094,8 +1106,8 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hickory-proto" -version = "0.25.0-alpha.2" -source = "git+https://github.com/mokeyish/hickory-dns.git?rev=0.25.0-smartdns.5#7887002d1198ed9faaaae531e0f9815c10589f7a" +version = "0.25.0-alpha.4" +source = "git+https://github.com/mokeyish/hickory-dns.git?rev=0.25.0-smartdns.6#45e44b904ef49004315a1fd8b546733b26ca1ce4" dependencies = [ "async-recursion", "async-trait", @@ -1119,9 +1131,9 @@ dependencies = [ "rand", "ring", "rustls", - "rustls-pemfile", + "rustls-pki-types", "serde", - "thiserror", + "thiserror 2.0.9", "time", "tinyvec", "tokio", @@ -1132,14 +1144,14 @@ dependencies = [ [[package]] name = "hickory-resolver" -version = "0.25.0-alpha.2" -source = "git+https://github.com/mokeyish/hickory-dns.git?rev=0.25.0-smartdns.5#7887002d1198ed9faaaae531e0f9815c10589f7a" +version = "0.25.0-alpha.4" +source = "git+https://github.com/mokeyish/hickory-dns.git?rev=0.25.0-smartdns.6#45e44b904ef49004315a1fd8b546733b26ca1ce4" dependencies = [ "cfg-if", "futures-util", "hickory-proto", "ipconfig", - "lru-cache", + "moka", "once_cell", "parking_lot", "quinn", @@ -1148,21 +1160,12 @@ dependencies = [ "rustls", "serde", "smallvec", - "thiserror", + "thiserror 2.0.9", "tokio", "tokio-rustls", "tracing", ] -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "hostname" version = "0.3.1" @@ -1300,14 +1303,143 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "icu_normalizer", + "icu_properties", ] [[package]] @@ -1396,12 +1528,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" version = "0.2.161" @@ -1429,18 +1555,18 @@ dependencies = [ "redox_syscall", ] -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - [[package]] name = "linux-raw-sys" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + [[package]] name = "local-ip-address" version = "0.6.3" @@ -1449,7 +1575,7 @@ checksum = "3669cf5561f8d27e8fc84cc15e58350e70f557d4d65f70e3154e54cd2f8e1782" dependencies = [ "libc", "neli", - "thiserror", + "thiserror 1.0.66", "windows-sys 0.59.0", ] @@ -1481,15 +1607,6 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" -[[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "matchers" version = "0.1.0" @@ -1544,6 +1661,26 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "moka" +version = "0.12.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32cf62eb4dd975d2dde76432fb1075c49e3ee2331cf36f1f8fd4b66550d32b6f" +dependencies = [ + "crossbeam-channel", + "crossbeam-epoch", + "crossbeam-utils", + "once_cell", + "parking_lot", + "quanta", + "rustc_version", + "smallvec", + "tagptr", + "thiserror 1.0.66", + "triomphe", + "uuid", +] + [[package]] name = "neli" version = "0.6.4" @@ -1857,6 +1994,21 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "quanta" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773ce68d0bb9bc7ef20be3536ffe94e223e1f365bd374108b2659fac0c65cfe6" +dependencies = [ + "crossbeam-utils", + "libc", + "once_cell", + "raw-cpuid", + "wasi", + "web-sys", + "winapi", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -1886,7 +2038,7 @@ dependencies = [ "rustc-hash 2.0.0", "rustls", "socket2", - "thiserror", + "thiserror 1.0.66", "tokio", "tracing", ] @@ -1903,7 +2055,7 @@ dependencies = [ "rustc-hash 2.0.0", "rustls", "slab", - "thiserror", + "thiserror 1.0.66", "tinyvec", "tracing", ] @@ -1967,6 +2119,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "raw-cpuid" +version = "11.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ab240315c661615f2ee9f0f2cd32d5a7343a84d5ebcccb99d46e6637565e7b0" +dependencies = [ + "bitflags", +] + [[package]] name = "rayon" version = "1.10.0" @@ -2219,12 +2380,11 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.3" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" dependencies = [ "openssl-probe", - "rustls-pemfile", "rustls-pki-types", "schannel", "security-framework", @@ -2241,8 +2401,8 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.9.0" -source = "git+https://github.com/mokeyish/pki-types.git?rev=1.9.0.smartdns.1#4ad51ec1f97ceb3809892396ef704d1d9485ef88" +version = "1.10.1" +source = "git+https://github.com/mokeyish/pki-types.git?rev=1.10.1.smartdns.1#0c808373af2cba8d1a406cf05953e36cb19917ed" [[package]] name = "rustls-webpki" @@ -2299,9 +2459,9 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "security-framework" -version = "2.11.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +checksum = "81d3f8c9bfcc3cbb6b0179eb57042d75b1582bdc65c3cb95f3fa999509c03cbc" dependencies = [ "bitflags", "core-foundation", @@ -2312,9 +2472,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.0" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" dependencies = [ "core-foundation-sys", "libc", @@ -2553,7 +2713,7 @@ dependencies = [ "socket2", "surge-ping", "sysinfo", - "thiserror", + "thiserror 2.0.9", "tokio", "tokio-rustls", "tokio-util", @@ -2562,7 +2722,7 @@ dependencies = [ "url", "uzers", "webpki-roots", - "which 6.0.3", + "which", "windows 0.58.0", "windows-service", ] @@ -2593,6 +2753,12 @@ dependencies = [ "der", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.11.1" @@ -2616,7 +2782,7 @@ dependencies = [ "pnet_packet", "rand", "socket2", - "thiserror", + "thiserror 1.0.66", "tokio", "tracing", ] @@ -2670,6 +2836,17 @@ dependencies = [ "futures-core", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "sysinfo" version = "0.32.0" @@ -2683,6 +2860,12 @@ dependencies = [ "windows 0.57.0", ] +[[package]] +name = "tagptr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" + [[package]] name = "tap" version = "1.0.1" @@ -2719,7 +2902,16 @@ version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d171f59dbaa811dbbb1aee1e73db92ec2b122911a48e1390dfe327a821ddede" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.66", +] + +[[package]] +name = "thiserror" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" +dependencies = [ + "thiserror-impl 2.0.9", ] [[package]] @@ -2733,6 +2925,17 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "thiserror-impl" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "thread_local" version = "1.1.8" @@ -2762,6 +2965,16 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -2952,6 +3165,12 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "triomphe" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" + [[package]] name = "try-lock" version = "0.2.5" @@ -2964,27 +3183,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "unicode-bidi" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" - [[package]] name = "unicode-ident" version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" -[[package]] -name = "unicode-normalization" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-width" version = "0.1.14" @@ -3005,9 +3209,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -3021,12 +3225,24 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + [[package]] name = "utf8-width" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -3038,6 +3254,9 @@ name = "uuid" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" +dependencies = [ + "getrandom", +] [[package]] name = "uzers" @@ -3163,24 +3382,12 @@ dependencies = [ [[package]] name = "which" -version = "4.4.2" +version = "7.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +checksum = "fb4a9e33648339dc1642b0e36e21b3385e6148e289226f657c809dee59df5028" dependencies = [ "either", - "home", - "once_cell", - "rustix", -] - -[[package]] -name = "which" -version = "6.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f" -dependencies = [ - "either", - "home", + "env_home", "rustix", "winsafe", ] @@ -3600,6 +3807,18 @@ version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "wyhash" version = "0.5.0" @@ -3629,6 +3848,30 @@ dependencies = [ "rustix", ] +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -3650,12 +3893,55 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "zip" version = "2.2.0" @@ -3669,7 +3955,7 @@ dependencies = [ "flate2", "indexmap", "memchr", - "thiserror", + "thiserror 1.0.66", "time", "zopfli", ] @@ -3682,7 +3968,7 @@ checksum = "6413a546ada9dbcd0b9a3e0b0880581279e35047bce9797e523b3408e1df607c" dependencies = [ "base64 0.22.1", "ed25519-dalek", - "thiserror", + "thiserror 1.0.66", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 8994c768..f5245748 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ service = [ nft = ["dep:which", "dep:either"] -dnssec = ["hickory-proto/dnssec", "hickory-proto/dnssec-ring", "rustls/ring"] +dnssec = [ "hickory-proto/dnssec-ring", "rustls/ring"] experimental = ["experimental-trie", "experimental-phf"] @@ -89,13 +89,13 @@ hostname = { git = "https://github.com/mokeyish/hostname.git", branch = "dev" } # enum_dispatch = { git = "https://gitlab.com/mokeyish/enum_dispatch.git", branch = "master"} # axum = { git = "https://github.com/tokio-rs/axum.git", rev = "8854e66" } # boomphf ={ path = "./target/patch/boomphf-0.6.0"} -rustls-pki-types = { git = "https://github.com/mokeyish/pki-types.git", rev = "1.9.0.smartdns.1" } +rustls-pki-types = { git = "https://github.com/mokeyish/pki-types.git", rev = "1.10.1.smartdns.1" } [dependencies] cfg-if = "1" clap = { version = "4.5", features = ["derive"] } clap-verbosity-flag = "2.2.2" -thiserror = "1.0" +thiserror = "2.0" anyhow = "1.0" once_cell = "1.16.0" nom = "7.1.3" @@ -143,8 +143,8 @@ 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.5", version = "0.25.0-alpha.2", features = ["serde"]} -hickory-resolver = { git = "https://github.com/mokeyish/hickory-dns.git", rev = "0.25.0-smartdns.5", version = "0.25.0-alpha.2", features = [ +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 = [ "serde", "system-config", ] } @@ -155,7 +155,7 @@ quinn = { version = "0.11.2", default-features = false } webpki-roots = "0.26" rustls = { version = "0.23", default-features = false, features = ["std", "tls12"] } rustls-pemfile = "2" -rustls-native-certs = "0.7" +rustls-native-certs = "0.8" lru = { version = "0.12", default-features = false } # time = "0.3" @@ -167,7 +167,7 @@ csv = "1.1" hostname = "0.3" byte-unit = { version = "5.0.3", features = ["serde"]} ipnet = "2.7" -which = { version = "6.0.1", optional = true } +which = { version = "7.0.1", optional = true } glob = "0.3.1" # process @@ -181,7 +181,7 @@ async-http-proxy = { version = "1.2.5", features = [ ] } num-traits = "0.2.19" -url = "2.5.2" +url = "2.5.4" # regex = "1" # rnp = "0.1" boomphf = { version = "0.6.0", optional = true } @@ -223,8 +223,8 @@ anyhow = "1.0" [target.'cfg(target_os = "linux")'.build-dependencies] -cc = "1.1" -bindgen = "0.69.4" +cc = "1.2" +bindgen = "0.70" # Dev-dependencies are not used when compiling a package for building, but are used for compiling tests, examples, and benchmarks. diff --git a/src/app.rs b/src/app.rs index 9c5ebecf..75f866c1 100644 --- a/src/app.rs +++ b/src/app.rs @@ -337,13 +337,13 @@ async fn process( message: SerialMessage, server_opts: ServerOpts, ) -> SerialMessage { - use crate::libdns::proto::error::ProtoError; use crate::libdns::proto::op::{Header, Message, MessageType, OpCode, ResponseCode}; + use crate::libdns::proto::ProtoError; let addr = message.addr(); let protocol = message.protocol(); - return match DnsRequest::try_from(message) { + match DnsRequest::try_from(message) { Ok(request) => { match request.message_type() { MessageType::Query => { @@ -408,6 +408,7 @@ async fn process( OpCode::Status => todo!(), OpCode::Notify => todo!(), OpCode::Update => todo!(), + OpCode::Unknown(_) => todo!(), } } MessageType::Response => todo!(), @@ -438,5 +439,5 @@ async fn process( SerialMessage::raw(response_message, addr, protocol) } _ => SerialMessage::raw(Default::default(), addr, protocol), - }; + } } diff --git a/src/config/domain.rs b/src/config/domain.rs index 7e0ff1fe..9b41c736 100644 --- a/src/config/domain.rs +++ b/src/config/domain.rs @@ -1,6 +1,5 @@ -use std::ops::Deref; - use crate::libdns::proto::rr::Name; +use std::ops::Deref; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum WildcardName { @@ -33,9 +32,9 @@ impl WildcardName { pub fn is_match(&self, name: &Name) -> bool { match self { WildcardName::Default(n) => n.zone_of(name), - WildcardName::Suffix(n) => n != name && n.zone_of(name), - WildcardName::Sub(n) => n == &name.base_name(), - WildcardName::Full(n) => n == name, + WildcardName::Suffix(n) => !n.eq_ignore_root_case(name) && n.zone_of(name), + WildcardName::Sub(n) => n.eq_ignore_root_case(&name.base_name()), + WildcardName::Full(n) => n.eq_ignore_root_case(name), } } } diff --git a/src/config/log.rs b/src/config/log.rs index a99443c3..ad54d9f5 100644 --- a/src/config/log.rs +++ b/src/config/log.rs @@ -26,7 +26,6 @@ pub struct LogConfig { pub num: Option, /// log file mode - #[serde(with = "serde_opt_str")] pub file_mode: Option, diff --git a/src/config/parser/domain.rs b/src/config/parser/domain.rs index e6106d74..259cc37c 100644 --- a/src/config/parser/domain.rs +++ b/src/config/parser/domain.rs @@ -3,7 +3,7 @@ use super::*; impl NomParser for Name { fn parse(input: &str) -> IResult<&str, Self> { let name = is_not(" \n\t\\/|\"#',!+<>"); - map_res(name, ::from_str)(input) + map_res(name, |s: &str| s.parse())(input) } } diff --git a/src/config/parser/mod.rs b/src/config/parser/mod.rs index 572470fa..3a4dd6b0 100644 --- a/src/config/parser/mod.rs +++ b/src/config/parser/mod.rs @@ -150,7 +150,7 @@ pub fn parse_config(input: &str) -> IResult<&str, OneConfig> { fn parse_item<'a, T: NomParser>( keyword: &'static str, - ) -> impl FnMut(&'a str) -> IResult<&str, T> { + ) -> impl FnMut(&'a str) -> IResult<&'a str, T> { preceded(tuple((space0, tag_no_case(keyword), space1)), T::parse) } diff --git a/src/dns.rs b/src/dns.rs index 1cfe0631..927ee8b7 100644 --- a/src/dns.rs +++ b/src/dns.rs @@ -14,17 +14,17 @@ use crate::dns_conf::RuntimeConfig; pub use crate::dns_rule::DomainRuleGetter; pub use crate::libdns::proto::{ - error::ProtoErrorKind, op, rr::{self, rdata::SOA, Name, RData, Record, RecordType}, + ProtoErrorKind, }; pub use crate::libdns::{ proto::xfer::Protocol, resolver::{ config::{NameServerConfig, NameServerConfigGroup}, - error::{ResolveError, ResolveErrorKind}, lookup::Lookup, + ResolveError, ResolveErrorKind, }, }; @@ -115,7 +115,7 @@ impl Default for LookupFrom { mod serial_message { use crate::dns_error::LookupError; - use crate::libdns::proto::error::ProtoError; + use crate::libdns::proto::ProtoError; use crate::libdns::Protocol; use crate::{config::ServerOpts, libdns::proto::op::Message}; use bytes::Bytes; @@ -214,9 +214,9 @@ mod request { use crate::libdns::{ proto::{ - error::ProtoError, op::{LowerQuery, Message, Query}, rr::{Name, RecordType}, + ProtoError, }, Protocol, }; @@ -293,7 +293,7 @@ mod request { let rtype = self.query().query_type(); self.extensions() .as_ref() - .map(|e| e.dnssec_ok()) + .map(|e| e.flags().dnssec_ok) .unwrap_or(rtype.is_dnssec()) } } diff --git a/src/dns_client.rs b/src/dns_client.rs index c69285e4..a18f3376 100644 --- a/src/dns_client.rs +++ b/src/dns_client.rs @@ -22,7 +22,6 @@ use crate::{ use crate::libdns::{ proto::{ - error::{ProtoError, ProtoErrorKind, ProtoResult}, op::{Edns, Message, MessageType, OpCode, Query}, rr::{ domain::{IntoName, Name}, @@ -30,12 +29,11 @@ use crate::libdns::{ Record, RecordType, }, xfer::{DnsRequest, DnsRequestOptions, FirstAnswer}, - DnsHandle, + DnsHandle, ProtoError, ProtoErrorKind, }, resolver::{ - config::{ResolverOpts, ServerOrderingStrategy, TlsClientConfig}, + config::{ResolverOpts, ServerOrderingStrategy}, name_server::GenericConnector, - TryParseIp, }, }; @@ -465,7 +463,7 @@ impl NameServer { tls_client_config.normal }; - (Some(url.host().to_string()), Some(TlsClientConfig(config))) + (Some(url.host().to_string()), Some(config)) } else { (None, None) }; @@ -631,7 +629,7 @@ impl GenericResolver for NameServer { name: N, options: O, ) -> Result { - use crate::libdns::proto::error::ProtoErrorKind; + use crate::libdns::proto::ProtoErrorKind; let name = name.into_name()?; let options: LookupOptions = options.into(); @@ -780,32 +778,13 @@ pub trait GenericResolver { #[async_trait::async_trait] pub trait GenericResolverExt { - /// Generic lookup for any RecordType - /// - /// # Arguments - /// - /// * `name` - name of the record to lookup, if name is not a valid domain name, an error will be returned - /// * `record_type` - type of record to lookup, all RecordData responses will be filtered to this type - /// - /// # Returns - /// - // A future for the returned Lookup RData - // async fn lookup( - // &self, - // name: N, - // record_type: RecordType, - // ) -> Result; - /// Performs a dual-stack DNS lookup for the IP for the given hostname. /// /// 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`. /// /// # Arguments /// * `host` - string hostname, if this is an invalid hostname, an error will be returned. - async fn lookup_ip( - &self, - host: N, - ) -> Result; + async fn lookup_ip(&self, host: N) -> Result; } #[async_trait::async_trait] @@ -814,18 +793,16 @@ where T: GenericResolver + Sync, { /// * `host` - string hostname, if this is an invalid hostname, an error will be returned. - async fn lookup_ip( - &self, - host: N, - ) -> Result { + async fn lookup_ip(&self, host: N) -> Result { let mut finally_ip_addr: Option = None; - let maybe_ip = host.try_parse_ip(); - let maybe_name: ProtoResult = host.into_name(); + let maybe_ip = host.to_ip(); + let maybe_name: Result = host.into_name(); // if host is a ip address, return directly. if let Some(ip_addr) = maybe_ip { + let ip_addr = ip_addr.into(); let name = maybe_name.clone().unwrap_or_default(); - let record = Record::from_rdata(name.clone(), MAX_TTL, ip_addr.clone()); + let record = Record::from_rdata(name.clone(), MAX_TTL, Clone::clone(&ip_addr)); // if ndots are greater than 4, then we can't assume the name is an IpAddr // this accepts IPv6 as well, b/c IPv6 can take the form: 2001:db8::198.51.100.35 diff --git a/src/dns_error.rs b/src/dns_error.rs index bf0a46b2..9f1549c6 100644 --- a/src/dns_error.rs +++ b/src/dns_error.rs @@ -1,10 +1,10 @@ use crate::dns::{DefaultSOA as _, DnsResponse}; use crate::libdns::proto::{ - error::{ProtoError, ProtoErrorKind}, op::{Query, ResponseCode}, rr::{rdata::SOA, Record}, + ProtoError, ProtoErrorKind, }; -use crate::libdns::resolver::error::{ResolveError, ResolveErrorKind}; +use crate::libdns::resolver::{ResolveError, ResolveErrorKind}; use std::{io, sync::Arc}; use thiserror::Error; @@ -79,6 +79,7 @@ impl LookupError { response_code: ResponseCode::ServFail, trusted: true, ns: None, + authorities: None, } .into() } diff --git a/src/dns_mw_cache.rs b/src/dns_mw_cache.rs index 721639db..0e102c1a 100644 --- a/src/dns_mw_cache.rs +++ b/src/dns_mw_cache.rs @@ -14,7 +14,7 @@ use std::time::Instant; use crate::config::ServerOpts; use crate::dns_conf::RuntimeConfig; -use crate::libdns::proto::error::ProtoResult; +use crate::libdns::proto::ProtoError; use crate::log; use crate::server::DnsHandle; use crate::{ @@ -649,7 +649,7 @@ use crate::libdns::proto::serialize::binary::{ }; impl BinEncodable for DnsCacheEntry { - fn emit(&self, encoder: &mut BinEncoder<'_>) -> ProtoResult<()> { + fn emit(&self, encoder: &mut BinEncoder<'_>) -> Result<(), ProtoError> { let res = &self.data; // message @@ -683,7 +683,7 @@ impl BinEncodable for DnsCacheEntry { } impl<'r> BinDecodable<'r> for DnsCacheEntry { - fn read(decoder: &mut BinDecoder<'r>) -> ProtoResult { + fn read(decoder: &mut BinDecoder<'r>) -> Result { // message if !decoder.read_u8()?.verify(|v| *v == 1).is_valid() { return Err(DecodeError::InsufficientBytes.into()); @@ -737,7 +737,7 @@ impl DnsCacheEntry { fn serialize_many<'a>( entries: impl Iterator, writer: &mut impl std::io::Write, - ) -> ProtoResult<()> { + ) -> Result<(), ProtoError> { let mut buf = vec![]; for entry in entries { @@ -750,7 +750,7 @@ impl DnsCacheEntry { Ok(()) } - fn deserialize_many(data: &[u8]) -> ProtoResult> { + fn deserialize_many(data: &[u8]) -> Result, ProtoError> { let mut entries = vec![]; let mut offset = 0; @@ -842,7 +842,7 @@ mod tests { fn test_lookup_serde() { let lookups = vec![ create_lookup( - "abc.exmample.com", + "abc.exmample.com.", RData::A("127.0.0.1".parse().unwrap()), 30, ), diff --git a/src/dns_mw_hosts.rs b/src/dns_mw_hosts.rs index 553dea01..12dae97e 100644 --- a/src/dns_mw_hosts.rs +++ b/src/dns_mw_hosts.rs @@ -159,7 +159,7 @@ mod tests { .iter() .flat_map(|r| r.data().as_ptr()) .collect::>(); - assert_eq!(hostnames, vec![&PTR("hi.a1.".parse().unwrap())]); + assert_eq!(hostnames, vec![&PTR("hi.a1".parse().unwrap())]); let lookup = mock .lookup("2.2.2.2.in-addr.arpa.", RecordType::PTR) @@ -169,7 +169,7 @@ mod tests { .iter() .flat_map(|r| r.data().as_ptr()) .collect::>(); - assert_eq!(hostnames, vec![&PTR("hi.a2.".parse().unwrap())]); + assert_eq!(hostnames, vec![&PTR("hi.a2".parse().unwrap())]); Ok(()) } diff --git a/src/dns_mw_ns.rs b/src/dns_mw_ns.rs index 9b776e7b..b4705f38 100644 --- a/src/dns_mw_ns.rs +++ b/src/dns_mw_ns.rs @@ -596,6 +596,7 @@ async fn per_nameserver_lookup_ip( negative_ttl: None, response_code: ResponseCode::NoError, trusted: false, + authorities: None, } .into()); } diff --git a/src/dnsmasq.rs b/src/dnsmasq.rs index ea4c9b84..04e1a226 100644 --- a/src/dnsmasq.rs +++ b/src/dnsmasq.rs @@ -179,7 +179,8 @@ fn read_lease_file>( #[cfg(test)] mod tests { - use crate::libdns::resolver::TryParseIp; + + use crate::libdns::resolver::IntoName; use super::*; @@ -229,7 +230,9 @@ mod tests { assert_eq!( store.lookup(&"iphone-abc".parse().unwrap(), RecordType::AAAA), - "2402:4e00:1013:e500:0:9671:f018:4947".try_parse_ip() + "2402:4e00:1013:e500:0:9671:f018:4947" + .to_ip() + .map(|s| s.into()) ); assert_eq!( @@ -244,7 +247,9 @@ mod tests { assert_eq!( store.lookup(&"iphone-abc.".parse().unwrap(), RecordType::AAAA), - "2402:4e00:1013:e500:0:9671:f018:4947".try_parse_ip() + "2402:4e00:1013:e500:0:9671:f018:4947" + .to_ip() + .map(|s| s.into()) ); assert_eq!( @@ -259,7 +264,9 @@ mod tests { assert_eq!( store.lookup(&"iphone-abc.xyz.".parse().unwrap(), RecordType::AAAA), - "2402:4e00:1013:e500:0:9671:f018:4947".try_parse_ip() + "2402:4e00:1013:e500:0:9671:f018:4947" + .to_ip() + .map(|s| s.into()) ); assert_eq!( diff --git a/src/ffi/nftset_sys.rs b/src/ffi/nftset_sys.rs index 063875f4..ad22269a 100644 --- a/src/ffi/nftset_sys.rs +++ b/src/ffi/nftset_sys.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.69.5 */ +/* automatically generated by rust-bindgen 0.70.1 */ extern "C" { pub fn nftset_add( diff --git a/src/infra/ipset.rs b/src/infra/ipset.rs index 2b83254c..142c9f60 100644 --- a/src/infra/ipset.rs +++ b/src/infra/ipset.rs @@ -94,25 +94,25 @@ pub trait Contains { fn contains(&self, other: T) -> bool; } -impl<'a> Contains<&'a IpNet> for IpSet { +impl Contains<&IpNet> for IpSet { fn contains(&self, other: &IpNet) -> bool { self.0.iter().any(|net| net.contains(other)) } } -impl<'a> Contains<&'a IpAddr> for IpSet { +impl Contains<&IpAddr> for IpSet { fn contains(&self, other: &IpAddr) -> bool { self.0.iter().any(|net| net.contains(other)) } } -impl<'a> Contains<&'a Ipv4Addr> for IpSet { +impl Contains<&Ipv4Addr> for IpSet { fn contains(&self, other: &Ipv4Addr) -> bool { self.contains(&IpAddr::V4(*other)) } } -impl<'a> Contains<&'a Ipv6Addr> for IpSet { +impl Contains<&Ipv6Addr> for IpSet { fn contains(&self, other: &Ipv6Addr) -> bool { self.contains(&IpAddr::V6(*other)) } diff --git a/src/resolver.rs b/src/resolver.rs index d2c34894..627fcac3 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -261,12 +261,7 @@ impl ResolveCommand { .map(Path::new) .and_then(|s| s.file_stem()) .and_then(|s| s.to_str()) - .map(|s| match s { - "dig" => true, - "nslookup" => true, - "resolve" => true, - _ => false, - }) + .map(|s| matches!(s, "dig" | "nslookup" | "resolve")) .unwrap_or_default() } @@ -364,8 +359,8 @@ impl FromStr for Variant { type Err = String; fn from_str(s: &str) -> Result { - if s.starts_with('@') { - return Ok(Self::Server(s[1..].to_string())); + if let Some(s) = s.strip_prefix('@') { + return Ok(Self::Server(s.to_string())); } let upper = s.to_uppercase(); @@ -477,7 +472,7 @@ mod tests { ResolveCommand::try_parse_from(["dig", "example.com", "a"]).unwrap(), ResolveCommand { domains: vec!["example.com".parse().unwrap()], - record_types: vec!["A"] + record_types: ["A"] .iter() .map(|s| s.parse()) .collect::, _>>() @@ -490,7 +485,7 @@ mod tests { ResolveCommand::try_parse_from(["dig", "example.com", "a+aaaa"]).unwrap(), ResolveCommand { domains: vec!["example.com".parse().unwrap()], - record_types: vec!["A", "AAAA"] + record_types: ["A", "AAAA"] .iter() .map(|s| s.parse()) .collect::, _>>() @@ -503,7 +498,7 @@ mod tests { ResolveCommand::try_parse_from(["dig", "example.com", "a", "aaaa", "TXT"]).unwrap(), ResolveCommand { domains: vec!["example.com".parse().unwrap()], - record_types: vec!["A", "AAAA", "TXT"] + record_types: ["A", "AAAA", "TXT"] .iter() .map(|s| s.parse()) .collect::, _>>() @@ -516,7 +511,7 @@ mod tests { ResolveCommand::try_parse_from(["dig", "example.com", "a", "aaaa", "in"]).unwrap(), ResolveCommand { domains: vec!["example.com".parse().unwrap()], - record_types: vec!["A", "AAAA"] + record_types: ["A", "AAAA"] .iter() .map(|s| s.parse()) .collect::, _>>() @@ -531,7 +526,7 @@ mod tests { .unwrap(), ResolveCommand { domains: vec!["example.com".parse().unwrap()], - record_types: vec!["A", "AAAA"] + record_types: ["A", "AAAA"] .iter() .map(|s| s.parse()) .collect::, _>>() @@ -547,7 +542,7 @@ mod tests { .unwrap(), ResolveCommand { domains: vec!["example.com".parse().unwrap()], - record_types: vec!["A", "AAAA"] + record_types: ["A", "AAAA"] .iter() .map(|s| s.parse()) .collect::, _>>() diff --git a/src/rustls.rs b/src/rustls.rs index 3fff3208..283945c2 100644 --- a/src/rustls.rs +++ b/src/rustls.rs @@ -64,10 +64,7 @@ impl TlsClientConfigBundle { }; let certs = { - let certs1 = rustls_native_certs::load_native_certs().unwrap_or_else(|err| { - warn!("load native certs failed.{}", err); - Default::default() - }); + let certs1 = rustls_native_certs::load_native_certs().certs; let certs2 = paths .iter() @@ -190,13 +187,13 @@ pub fn load_certificate_and_key( .certificate .as_deref() .or(cert_file) - .ok_or_else(|| Error::CertificatePathNotDefined(typ))?; + .ok_or(Error::CertificatePathNotDefined(typ))?; let certificate_key_path = ssl_config .certificate_key .as_deref() .or(key_file) - .ok_or_else(|| Error::CertificateKeyPathNotDefined(typ))?; + .ok_or(Error::CertificateKeyPathNotDefined(typ))?; if let Some(server_name) = ssl_config.server_name.as_deref() { log::info!( diff --git a/src/server/udp.rs b/src/server/udp.rs index 61427c59..566bb24c 100644 --- a/src/server/udp.rs +++ b/src/server/udp.rs @@ -2,9 +2,7 @@ use super::{reap_tasks, sanitize_src_address, DnsHandle}; use crate::{ dns::SerialMessage, libdns::{ - proto::{ - error::ProtoError, runtime::TokioRuntimeProvider, udp::UdpStream, DnsStreamHandle, - }, + proto::{runtime::TokioRuntimeProvider, udp::UdpStream, DnsStreamHandle, ProtoError}, Protocol, }, log, From 792f58236e60e7677beac7715f99600fa90b5d71 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 28 Dec 2024 07:24:11 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=94=96=20Bump=20version=20to=20v0.9.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e7bc2bca..329fb466 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2662,7 +2662,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smartdns" -version = "0.9.0" +version = "0.9.1" dependencies = [ "anyhow", "async-http-proxy", diff --git a/Cargo.toml b/Cargo.toml index f5245748..f107e955 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smartdns" -version = "0.9.0" +version = "0.9.1" authors = ["YISH "] edition = "2021" rust-version = "1.75.0" From 0e890ca1d579cd5da95f1c776f0cf084bfe1385a Mon Sep 17 00:00:00 2001 From: YISH Date: Sat, 28 Dec 2024 17:52:10 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=91=B7=20Add=20publishing=20crates.io?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/version.yml | 17 +++++++++++++++++ Cargo.toml | 4 ++-- README.md | 1 + README_zh-CN.md | 1 + justfile | 6 +++++- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index aafddf54..cc8f34e1 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -51,3 +51,20 @@ jobs: with: version: ${{ needs.bump.outputs.version }} prerelease: ${{ !contains('major, minor, patch', inputs.bump) }} + + publish: + needs: [ "bump", "build" ] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ needs.bump.outputs.version }} + + - name: Setup + uses: ./.github/actions/setup + + - name: Publish to crates.io + run: just publish + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index f107e955..1a5c7e27 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["YISH "] edition = "2021" rust-version = "1.75.0" -keywords = ["DNS", "BIND", "dig", "named", "dnssec", "SmartDNS", "Dnsmasq"] +keywords = ["DNS", "BIND", "dig", "SmartDNS", "Dnsmasq"] categories = ["network-programming"] description = """ @@ -14,7 +14,7 @@ A cross platform local DNS server written in rust to obtain the fastest website homepage = "https://github.com/mokeyish/smartdns-rs" repository = "https://github.com/mokeyish/smartdns-rs" -license = "GPL-v3.0" +license = "GPL-3.0-only" readme = "README.md" [lints.rust] diff --git a/README.md b/README.md index 573e8564..510ce51f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # SmartDNS-rs ![Test](https://github.com/mokeyish/smartdns-rs/actions/workflows/test.yml/badge.svg?branch=main) +[![Crates.io Version](https://img.shields.io/crates/v/smartdns.svg)](https://crates.io/crates/smartdns) [![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/mokeyish/smartdns-rs?display_name=tag&include_prereleases)](https://github.com/mokeyish/smartdns-rs/releases) [![homebrew version](https://img.shields.io/homebrew/v/smartdns)](https://formulae.brew.sh/formula/smartdns) ![OS](https://img.shields.io/badge/os-Windows%20%7C%20MacOS%20%7C%20Linux-blue) diff --git a/README_zh-CN.md b/README_zh-CN.md index 62305b1f..9c137adc 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -1,6 +1,7 @@ # SmartDNS-rs ![Test](https://github.com/mokeyish/smartdns-rs/actions/workflows/test.yml/badge.svg?branch=main) +[![Crates.io Version](https://img.shields.io/crates/v/smartdns.svg)](https://crates.io/crates/smartdns) [![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/mokeyish/smartdns-rs?display_name=tag&include_prereleases)](https://github.com/mokeyish/smartdns-rs/releases) [![homebrew version](https://img.shields.io/homebrew/v/smartdns)](https://formulae.brew.sh/formula/smartdns) ![OS](https://img.shields.io/badge/os-Windows%20%7C%20MacOS%20%7C%20Linux-blue) diff --git a/justfile b/justfile index 17ac1b1e..446cfeae 100644 --- a/justfile +++ b/justfile @@ -36,6 +36,10 @@ test *args: patch check *args: patch {{cargo}} check --workspace --tests --benches --examples {{args}} +# Publish +publish *args: patch + {{cargo}} publish --no-verify + # Run clippy fix clippy: patch @@ -73,4 +77,4 @@ setcap: [private] @require_set-version: - cargo set-version --version >/dev/null 2>&1 || cargo install cargo-edit > /dev/null \ No newline at end of file + cargo set-version --version >/dev/null 2>&1 || cargo install cargo-edit > /dev/null From 6b72708b342cc2564e7eecbf811627619e3d9a0f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 28 Dec 2024 10:39:07 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=94=96=20Bump=20version=20to=20v0.9.2?= =?UTF-8?q?-alpha.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 329fb466..d72720f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2662,7 +2662,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smartdns" -version = "0.9.1" +version = "0.9.2-alpha.1" dependencies = [ "anyhow", "async-http-proxy", diff --git a/Cargo.toml b/Cargo.toml index 1a5c7e27..f2827174 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "smartdns" -version = "0.9.1" +version = "0.9.2-alpha.1" authors = ["YISH "] edition = "2021" rust-version = "1.75.0"