From 0e66152987de3ccc55d6e0238448090acc5fc04d Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Fri, 20 Dec 2024 10:15:17 +0400 Subject: [PATCH] initial commit --- .gitignore | 2 ++ LICENSE | 7 ++++++ build_hr.sh | 27 +++++++++++++++++++++++ main.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ unbound.conf | 25 ++++++++++++++++++++++ 5 files changed, 121 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100755 build_hr.sh create mode 100755 main.sh create mode 100644 unbound.conf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c8474b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/hickory-dns +/unbound.log diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9dd6b0b --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2024 Andrey DarkCat09 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/build_hr.sh b/build_hr.sh new file mode 100755 index 0000000..477c756 --- /dev/null +++ b/build_hr.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +IFS=$'\n' +set -eu -o pipefail + +echo +echo '==> Checking deps' +which git +which cargo + +echo +echo '==> Cloning repo' +git clone --single-branch --depth 1 https://github.com/hickory-dns/hickory-dns.git hickory-dns + +echo +echo '==> Building resolve' +cd hickory-dns +cargo build \ + --release \ + --bin resolve \ + --features dnssec-ring \ + --config 'panic="abort"' \ + --config 'lto="fat"' +cd .. + +echo +echo '==> Done' diff --git a/main.sh b/main.sh new file mode 100755 index 0000000..070e023 --- /dev/null +++ b/main.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +IFS=$'\n' +set -eu -o pipefail + +cleanup () { + echo + echo '==> Stopping Unbound' + [ -v unbound_pid ] && kill -INT "$unbound_pid" + echo +} + +trap cleanup EXIT + +echo +echo '==> Checking deps' +echo 'Note: dig is installed from package usually named "bind-utils"' +echo ' drill -- package "ldns"' +echo " and hickory's resolve can be built with ./build_hr.sh" +echo ' (this script will find it in subdir, no need to install)' +which unbound +which hyperfine +which dig +which drill +hr="hickory-dns/target/release/resolve" +[ -e "$hr" ] || hr=$(which resolve) + +echo +echo '==> Starting Unbound' +unbound -c ./unbound.conf -dp 2>unbound.log & +unbound_pid=$! +sleep 2 + +echo +echo '==> Benchmarks for A domain.tld.' +hyperfine -N \ + "dig -p 2253 domain.tld @127.0.0.1" \ + "drill -p 2253 domain.tld @127.0.0.1" \ + "$hr -n 127.0.0.1:2253 domain.tld" + +echo +echo '==> Benchmarks for AAAA domain.tld.' +hyperfine -N \ + "dig -p 2253 aaaa domain.tld @127.0.0.1" \ + "drill -p 2253 aaaa domain.tld @127.0.0.1" \ + "$hr -n 127.0.0.1:2253 -t AAAA domain.tld" + +echo +echo '==> Benchmarks for MX domain.tld.' +hyperfine -N \ + "dig -p 2253 mx domain.tld @127.0.0.1" \ + "drill -p 2253 mx domain.tld @127.0.0.1" \ + "$hr -n 127.0.0.1:2253 -t MX domain.tld" + +echo +echo '==> Benchmarks for CNAME mail.domain.tld.' +hyperfine -N \ + "dig -p 2253 mail.domain.tld @127.0.0.1" \ + "drill -p 2253 mail.domain.tld @127.0.0.1" \ + "$hr -n 127.0.0.1:2253 mail.domain.tld" diff --git a/unbound.conf b/unbound.conf new file mode 100644 index 0000000..af7449d --- /dev/null +++ b/unbound.conf @@ -0,0 +1,25 @@ +server: + do-daemonize: no + username: "" + chroot: "" + logfile: "" + verbosity: 0 + + interface: 127.0.0.1 + port: 2253 + + num-threads: 4 + msg-cache-slabs: 4 + infra-cache-slabs: 4 + msg-cache-size: 32m + neg-cache-size: 32m + + outgoing-range: 4096 + num-queries-per-thread: 1024 + so-reuseport: yes + + local-zone: "domain.tld." static + local-data: "domain.tld. A 127.0.0.1" + local-data: "domain.tld. AAAA ::1" + local-data: "domain.tld. MX 10 mail.domain.tld." + local-data: "mail.domain.tld CNAME domain.tld."