initial commit

This commit is contained in:
DarkCat09 2024-12-20 10:15:17 +04:00
commit 0e66152987
Signed by: DarkCat09
GPG key ID: BD3CE9B65916CD82
5 changed files with 121 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/hickory-dns
/unbound.log

7
LICENSE Normal file
View file

@ -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.

27
build_hr.sh Executable file
View file

@ -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'

60
main.sh Executable file
View file

@ -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"

25
unbound.conf Normal file
View file

@ -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."