This commit is contained in:
Mateusz Gruszczyński committed 2026-11-22 14:21:54 +01:00
commit fa432bebda
189 files changed
+26219

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
# syntax=docker/dockerfile:1
# Multi-stage build; final image runs as an unprivileged user.
FROM rust:1-bookworm AS build
WORKDIR /src
COPY . .
RUN cargo build --release --locked -p dns-cli -p dns-tools \
&& mkdir -p /out \
&& cp target/release/easydns /out/ \
&& for t in ed eh ens etrace ednssec eptr ezone econf ebench ewhois edoh edot ediff; do cp target/release/$t /out/; done
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates libcap2-bin && rm -rf /var/lib/apt/lists/* \
&& useradd --system --home /etc/easydns/data --shell /usr/sbin/nologin easydns \
&& mkdir -p /etc/easydns/zones.d /etc/easydns/keys.d /etc/easydns/data/zones && chown -R easydns:easydns /etc/easydns/data
COPY --from=build /out/ /usr/local/bin/
COPY config/root.hints /etc/easydns/root.hints
RUN setcap cap_net_bind_service=+ep /usr/local/bin/easydns
USER easydns
VOLUME ["/etc/easydns/data"]
EXPOSE 53/udp 53/tcp 853/tcp
HEALTHCHECK --interval=30s --timeout=3s CMD ["/usr/local/bin/ed", "@127.0.0.1", "+short", "+time=2", "+tries=1", "version.bind", "TXT", "CH"]
ENTRYPOINT ["/usr/local/bin/easydns"]
CMD ["run", "--config", "/etc/easydns/config.yaml"]
+49
View File
@@ -0,0 +1,49 @@
# syntax=docker/dockerfile:1
# Builds EasyDNS .deb packages inside Docker. Used by scripts/build-deb.sh:
# docker buildx build -f deploy/docker/Dockerfile.deb --platform linux/amd64 \
# --build-arg VERSION=0.1.0 --output type=local,dest=dist .
ARG DEBIAN_RELEASE=bookworm
FROM rust:1-${DEBIAN_RELEASE} AS build
ARG VERSION=0.1.0
ARG REVISION=1
ARG TARGETPLATFORM
WORKDIR /src
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/src/target,id=easydns-target-${TARGETPLATFORM} \
cargo build --release --locked -p dns-cli -p dns-tools \
&& mkdir -p /pkg/usr/bin /pkg/usr/share/man/man1 /pkg/usr/share/bash-completion/completions \
/pkg/usr/share/zsh/vendor-completions /pkg/usr/share/fish/vendor_completions.d \
/pkg/lib/systemd/system /pkg/usr/lib/sysusers.d /pkg/etc/easydns/zones.d /pkg/etc/easydns/keys.d /pkg/usr/share/doc/easydns \
&& install -m 0755 -s target/release/easydns /pkg/usr/bin/easydns \
&& for t in easydig easyhost easynslookup easytrace easydnssec easyptr easyzone easyconf easybench easywhois easydoh easydot easydiff; do \
install -m 0755 -s target/release/$t /pkg/usr/bin/$t; done \
&& target/release/easydns man > /pkg/usr/share/man/man1/easydns.1 && gzip -9n /pkg/usr/share/man/man1/easydns.1 \
&& target/release/easydns completions bash > /pkg/usr/share/bash-completion/completions/easydns \
&& target/release/easydns completions zsh > /pkg/usr/share/zsh/vendor-completions/_easydns \
&& target/release/easydns completions fish > /pkg/usr/share/fish/vendor_completions.d/easydns.fish \
&& install -m 0644 deploy/systemd/easydns.service deploy/systemd/easydns-blocklists.service deploy/systemd/easydns-blocklists.timer /pkg/lib/systemd/system/ \
&& install -m 0644 deploy/systemd/easydns.sysusers /pkg/usr/lib/sysusers.d/easydns.conf \
&& install -m 0640 config/config.yaml /pkg/etc/easydns/config.yaml \
&& install -m 0644 config/root.hints /pkg/etc/easydns/root.hints \
&& cp README.md CHANGELOG.md KNOWN_ISSUES.md LICENSE LICENSE-MIT /pkg/usr/share/doc/easydns/ \
&& cp -r docs config zones /pkg/usr/share/doc/easydns/
FROM debian:${DEBIAN_RELEASE}-slim AS package
ARG VERSION=0.1.0
ARG REVISION=1
COPY --from=build /pkg /pkg
COPY deploy/packaging/debian /debian-src
RUN apt-get update && apt-get install -y --no-install-recommends dpkg-dev >/dev/null && rm -rf /var/lib/apt/lists/* \
&& ARCH="$(dpkg --print-architecture)" \
&& mkdir -p /pkg/DEBIAN /out \
&& sed -e "s/@VERSION@/${VERSION}-${REVISION}/" -e "s/@ARCH@/${ARCH}/" \
-e "s/@SIZE@/$(du -sk /pkg | cut -f1)/" /debian-src/control > /pkg/DEBIAN/control \
&& install -m 0755 /debian-src/postinst /debian-src/prerm /debian-src/postrm /pkg/DEBIAN/ \
&& printf '/etc/easydns/config.yaml\n/etc/easydns/root.hints\n' > /pkg/DEBIAN/conffiles \
&& dpkg-deb --root-owner-group -Zxz --build /pkg "/out/easydns_${VERSION}-${REVISION}_${ARCH}.deb" \
&& dpkg-deb --info "/out/easydns_${VERSION}-${REVISION}_${ARCH}.deb" >/dev/null \
&& (cd /out && sha256sum *.deb > "easydns_${VERSION}-${REVISION}_${ARCH}.deb.sha256")
FROM scratch AS export
COPY --from=package /out/ /
+26
View File
@@ -0,0 +1,26 @@
{
"title": "EasyDNS",
"uid": "easydns",
"schemaVersion": 39,
"time": { "from": "now-6h", "to": "now" },
"templating": { "list": [ { "name": "DS", "type": "datasource", "query": "prometheus" } ] },
"panels": [
{ "type": "timeseries", "title": "Queries per second", "gridPos": {"x":0,"y":0,"w":12,"h":8},
"targets": [ { "expr": "sum by (transport) (rate(dns_queries_total[1m]))" } ] },
{ "type": "timeseries", "title": "Responses by RCODE", "gridPos": {"x":12,"y":0,"w":12,"h":8},
"targets": [ { "expr": "sum by (rcode) (rate(dns_responses_total[1m]))" } ] },
{ "type": "stat", "title": "Cache hit rate", "gridPos": {"x":0,"y":8,"w":6,"h":4},
"targets": [ { "expr": "rate(dns_cache_hits_total[5m]) / (rate(dns_cache_hits_total[5m]) + rate(dns_cache_misses_total[5m]))" } ] },
{ "type": "timeseries", "title": "Latency p50/p95/p99", "gridPos": {"x":6,"y":8,"w":18,"h":8},
"targets": [
{ "expr": "histogram_quantile(0.5, rate(dns_query_duration_seconds_bucket[5m]))", "legendFormat": "p50" },
{ "expr": "histogram_quantile(0.95, rate(dns_query_duration_seconds_bucket[5m]))", "legendFormat": "p95" },
{ "expr": "histogram_quantile(0.99, rate(dns_query_duration_seconds_bucket[5m]))", "legendFormat": "p99" } ] },
{ "type": "timeseries", "title": "Answer sources", "gridPos": {"x":0,"y":16,"w":12,"h":8},
"targets": [ { "expr": "sum by (source) (rate(dns_answers_by_source_total[1m]))" } ] },
{ "type": "table", "title": "Zones", "gridPos": {"x":12,"y":16,"w":12,"h":8},
"targets": [ { "expr": "dns_zone_serial" }, { "expr": "dns_zone_expired" } ] },
{ "type": "timeseries", "title": "Blocked / rate limited / DNSSEC bogus", "gridPos": {"x":0,"y":24,"w":24,"h":8},
"targets": [ { "expr": "rate(dns_blocked_total[5m])" }, { "expr": "rate(dns_rate_limited_total[5m])" }, { "expr": "rate(dns_dnssec_bogus_total[5m])" } ] }
]
}
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env sh
# Install EasyDNS binaries. Short tool names (ed, eh, ...) are only linked when they do
# not collide with existing commands (e.g. the classic `ed` editor); long names
# (easydig, easyhost, ...) are always installed.
# usage: deploy/install.sh [PREFIX] [--force-short-names]
set -eu
PREFIX="${1:-/usr/local}"
FORCE="${2:-}"
BIN="$PREFIX/bin"
SRC="${EASYDNS_BUILD_DIR:-target/release}"
mkdir -p "$BIN"
install -m 0755 "$SRC/easydns" "$BIN/easydns"
for pair in edns:easydns ed:easydig eh:easyhost ens:easynslookup etrace:easytrace ednssec:easydnssec eptr:easyptr \
ezone:easyzone econf:easyconf ebench:easybench ewhois:easywhois edoh:easydoh edot:easydot ediff:easydiff; do
short="${pair%%:*}"; long="${pair##*:}"
install -m 0755 "$SRC/$long" "$BIN/$long"
existing="$(command -v "$short" 2>/dev/null || true)"
if [ -n "$existing" ] && [ "$existing" != "$BIN/$short" ] && [ "$FORCE" != "--force-short-names" ]; then
echo "skip: '$short' already exists at $existing – use '$long' (or --force-short-names)"
continue
fi
ln -sf "$long" "$BIN/$short"
done
echo "installed into $BIN"
for sh in bash zsh fish; do
"$BIN/easydns" completions "$sh" > "easydns.$sh" 2>/dev/null && echo "completion: easydns.$sh" || true
done
+17
View File
@@ -0,0 +1,17 @@
Package: easydns
Version: @VERSION@
Architecture: @ARCH@
Maintainer: EasyDNS maintainers <maintainers@example.invalid>
Installed-Size: @SIZE@
Depends: libc6 (>= 2.34), ca-certificates, adduser
Section: net
Priority: optional
Homepage: https://example.invalid/easydns
Description: DNS server: primary, secondary, recursive, forwarder, hybrid
EasyDNS is an authoritative (primary/secondary with AXFR/IXFR, NOTIFY, TSIG,
DNSSEC signing), recursive (iterative, DNSSEC-validating), forwarding and hybrid
DNS server with DoT/DoH, REST API and Prometheus metrics.
.
Includes the EasyDNS Tools: easydig, easyhost, easynslookup, easytrace,
easydnssec, easyptr, easyzone, easyconf, easybench, easywhois, easydoh,
easydot and easydiff (short names ed, eh, ... are created when free).
+46
View File
@@ -0,0 +1,46 @@
#!/bin/sh
set -e
TOOLS="edns:easydns ed:easydig eh:easyhost ens:easynslookup etrace:easytrace ednssec:easydnssec eptr:easyptr ezone:easyzone econf:easyconf ebench:easybench ewhois:easywhois edoh:easydoh edot:easydot ediff:easydiff"
if [ "$1" = "configure" ]; then
if ! getent passwd easydns >/dev/null; then
adduser --system --group --home /etc/easydns/data --no-create-home --shell /usr/sbin/nologin easydns >/dev/null
fi
# /etc/easydns: config, zones.d/, keys.d/ (root:easydns, not world-readable – may hold keys)
install -d -o root -g easydns -m 0750 /etc/easydns /etc/easydns/zones.d /etc/easydns/keys.d
# data_dir: zone files (data/zones/), secondary copies, journals, control token
install -d -o easydns -g easydns -m 0750 /etc/easydns/data /etc/easydns/data/zones
chgrp easydns /etc/easydns/config.yaml 2>/dev/null || true
chmod 0640 /etc/easydns/config.yaml 2>/dev/null || true
# Short tool names only when the name is free (e.g. `ed` is often the line editor).
for pair in $TOOLS; do
s="${pair%%:*}"; l="${pair##*:}"
if [ ! -e "/usr/bin/$s" ] && ! command -v "$s" >/dev/null 2>&1; then
ln -s "$l" "/usr/bin/$s"
fi
done
if [ -d /run/systemd/system ]; then
systemctl daemon-reload >/dev/null || true
if [ -n "$2" ] && systemctl is-active --quiet easydns.service; then
# Upgrade of a running server: restart only if the new version accepts the
# configuration (checked as the service user); otherwise keep the old one running.
if command -v runuser >/dev/null 2>&1; then
CHECK="runuser -u easydns -- /usr/bin/easydns check-config --config /etc/easydns/config.yaml"
else
CHECK="/usr/bin/easydns check-config --config /etc/easydns/config.yaml"
fi
if $CHECK >/tmp/easydns-upgrade-check.log 2>&1; then
systemctl restart easydns.service && echo "EasyDNS upgraded from $2 and restarted."
rm -f /tmp/easydns-upgrade-check.log
else
echo "WARNING: the new EasyDNS rejects /etc/easydns/config.yaml; the previous version keeps running."
echo " details: /tmp/easydns-upgrade-check.log fix, then: systemctl restart easydns"
fi
elif [ -z "$2" ]; then
echo "EasyDNS installed (hybrid: authoritative + recursive for LAN)."
echo " config: /etc/easydns/config.yaml zones: /etc/easydns/data/zones/"
echo " new zone: easydns zone create example.com --ns ns1.example.com --ip 192.0.2.1"
echo " start: systemctl enable --now easydns then: easydns status"
fi
fi
fi
exit 0
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
set -e
TOOLS="edns:easydns ed:easydig eh:easyhost ens:easynslookup etrace:easytrace ednssec:easydnssec eptr:easyptr ezone:easyzone econf:easyconf ebench:easybench ewhois:easywhois edoh:easydoh edot:easydot ediff:easydiff"
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
# remove only symlinks we created
for pair in $TOOLS; do
s="${pair%%:*}"; l="${pair##*:}"
if [ -L "/usr/bin/$s" ] && [ "$(readlink "/usr/bin/$s")" = "$l" ]; then rm -f "/usr/bin/$s"; fi
done
fi
if [ "$1" = "purge" ]; then
# /etc/easydns holds your zone files and keys: never deleted automatically
rm -f /etc/easydns/data/control.token
echo "EasyDNS purged. /etc/easydns (zones, keys, data) was kept – remove it manually if no longer needed."
fi
[ -d /run/systemd/system ] && systemctl daemon-reload >/dev/null 2>&1 || true
exit 0
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
set -e
if [ "$1" = "remove" ] && [ -d /run/systemd/system ]; then
systemctl stop easydns.service easydns-blocklists.timer >/dev/null 2>&1 || true
fi
exit 0
+55
View File
@@ -0,0 +1,55 @@
# Build .deb and .rpm with nfpm (https://nfpm.goreleaser.com):
# ARCH=amd64 VERSION=0.1.0 nfpm pkg -f deploy/packaging/nfpm.yaml -p deb
# ARCH=arm64 VERSION=0.1.0 nfpm pkg -f deploy/packaging/nfpm.yaml -p rpm
name: easydns
arch: "${ARCH}"
platform: linux
version: "${VERSION}"
maintainer: "EasyDNS maintainers"
description: |
EasyDNS: authoritative (primary/secondary), recursive, forwarding and hybrid DNS
server with DoT/DoH, DNSSEC and the EasyDNS Tools (easydig, easyhost, ...).
license: MIT
contents:
- src: target/release/easydns
dst: /usr/bin/easydns
- src: target/release/easydig
dst: /usr/bin/easydig
- src: target/release/easyhost
dst: /usr/bin/easyhost
- src: target/release/easynslookup
dst: /usr/bin/easynslookup
- src: target/release/easytrace
dst: /usr/bin/easytrace
- src: target/release/easydnssec
dst: /usr/bin/easydnssec
- src: target/release/easyptr
dst: /usr/bin/easyptr
- src: target/release/easyzone
dst: /usr/bin/easyzone
- src: target/release/easyconf
dst: /usr/bin/easyconf
- src: target/release/easybench
dst: /usr/bin/easybench
- src: target/release/easywhois
dst: /usr/bin/easywhois
- src: target/release/easydoh
dst: /usr/bin/easydoh
- src: target/release/easydot
dst: /usr/bin/easydot
- src: target/release/easydiff
dst: /usr/bin/easydiff
- src: deploy/systemd/easydns.service
dst: /usr/lib/systemd/system/easydns.service
- src: deploy/systemd/easydns.sysusers
dst: /usr/lib/sysusers.d/easydns.conf
- src: config/config.yaml
dst: /etc/easydns/config.yaml
type: config|noreplace
- src: config/root.hints
dst: /etc/easydns/root.hints
type: config|noreplace
- src: target/man/easydns.1
dst: /usr/share/man/man1/easydns.1
scripts:
postinstall: deploy/packaging/postinstall.sh
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
# Create the service user and short tool names when they do not collide.
set -e
systemd-sysusers /usr/lib/sysusers.d/easydns.conf 2>/dev/null || true
mkdir -p /etc/easydns/zones.d /etc/easydns/keys.d /etc/easydns/data/zones
chown -R easydns:easydns /etc/easydns/data 2>/dev/null || true
chgrp easydns /etc/easydns /etc/easydns/zones.d /etc/easydns/keys.d /etc/easydns/config.yaml 2>/dev/null || true
chmod 0750 /etc/easydns /etc/easydns/zones.d /etc/easydns/keys.d /etc/easydns/data 2>/dev/null || true
for pair in edns:easydns ed:easydig eh:easyhost ens:easynslookup etrace:easytrace ednssec:easydnssec eptr:easyptr ezone:easyzone econf:easyconf ebench:easybench ewhois:easywhois edoh:easydoh edot:easydot ediff:easydiff; do
s="${pair%%:*}"; l="${pair##*:}"
if ! command -v "$s" >/dev/null 2>&1; then ln -s "/usr/bin/$l" "/usr/bin/$s"; fi
done
systemctl daemon-reload 2>/dev/null || true
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Build release archives + checksums for x86_64 and aarch64 (requires `cross` or native toolchains).
set -euo pipefail
VERSION="$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)"
mkdir -p dist target/man
for TARGET in x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu; do
if command -v cross >/dev/null; then B=cross; else B=cargo; fi
$B build --release --locked --target "$TARGET" -p dns-cli -p dns-tools
D="dist/easydns-$VERSION-$TARGET"; mkdir -p "$D"
cp target/$TARGET/release/{easydns,easydig,easyhost,easynslookup,easytrace,easydnssec,easyptr,easyzone,easyconf,easybench,easywhois,easydoh,easydot,easydiff} "$D/"
cp -r config README.md LICENSE* deploy/systemd deploy/install.sh "$D/"
tar -C dist -czf "$D.tar.gz" "$(basename "$D")"
done
target/release/easydns man > target/man/easydns.1 || true
(cd dist && sha256sum ./*.tar.gz > SHA256SUMS)
echo "artifacts in dist/"
@@ -0,0 +1,9 @@
[Unit]
Description=Update EasyDNS block lists
After=network-online.target
[Service]
Type=oneshot
User=easydns
EnvironmentFile=-/etc/easydns/easydns.env
ExecStart=/usr/bin/easydns blocklists update --config /etc/easydns/config.yaml
+10
View File
@@ -0,0 +1,10 @@
[Unit]
Description=Daily EasyDNS block list update
[Timer]
OnCalendar=daily
RandomizedDelaySec=1h
Persistent=true
[Install]
WantedBy=timers.target
+52
View File
@@ -0,0 +1,52 @@
[Unit]
Description=EasyDNS server
Documentation=https://example.invalid/easydns/docs
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=easydns
Group=easydns
ExecStartPre=/usr/bin/easydns check-config --config /etc/easydns/config.yaml
ExecStart=/usr/bin/easydns run --config /etc/easydns/config.yaml
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=2s
EnvironmentFile=-/etc/easydns/easydns.env
StateDirectory=easydns
StateDirectoryMode=0750
ConfigurationDirectory=easydns
LimitNOFILE=65536
TasksMax=4096
# Bind to port 53 without root
AmbientCapabilities=CAP_NET_BIND_SERVICE
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
NoNewPrivileges=yes
# Sandbox
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
LockPersonality=yes
MemoryDenyWriteExecute=yes
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallFilter=~@privileged @resources
UMask=0027
ReadWritePaths=/etc/easydns/data
[Install]
WantedBy=multi-user.target
+1
View File
@@ -0,0 +1 @@
u easydns - "EasyDNS server" /etc/easydns/data /usr/sbin/nologin