mirror of
https://github.com/fosrl/newt.git
synced 2026-05-06 07:59:04 -05:00
[PR #236] (feat) DNS Authority #1592
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fosrl/newt/pull/236
Author: @mattv8
Created: 2/17/2026
Status: 🔄 Open
Base:
dev← Head:dns-authority📝 Commits (7)
0db25c2DNS authority management and features0d1c29bAdd support for updating TLS certificates in auth proxy705f4e0Add multi-target, path routing, and proxy settings to auth configd031126Add backward compatibility for single target URL in resource auth configef8755bfeat(dns): add sticky session affinity896abb1feat(dns): blend intelligent scoring with health latencyd9f1ec4fix(healthcheck): publish status every check for latency telemetry📊 Changes
8 files changed (+2450 additions, -16 deletions)
View changed files
📝
README.md(+26 -0)➕
auth/auth.go(+1160 -0)➕
dns/authority.go(+868 -0)📝
get-newt.sh(+75 -12)📝
go.mod(+2 -0)📝
go.sum(+4 -0)📝
healthcheck/healthcheck.go(+11 -4)📝
main.go(+304 -0)📄 Description
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Description
This adds DNS Authority and Auth Proxy capabilities to Newt. The companion Pangolin PR is https://github.com/fosrl/pangolin/pull/2490. More context is in the discussion.
What this does
DNS Authority (
dns/authority.go): An authoritative DNS server built onmiekg/dns. Listens on port 53 (UDP + TCP), serves A/NS/SOA records for zones pushed from Pangolin. Supports three routing policies:Zones are held in memory and fully repopulated on each Newt reconnect. Wildcard matching is supported (
*.example.commatches any subdomain). If no healthy targets exist, falls back to returning all targets (best effort). The server performs a pre-flight port 53 bind check with clear error messages (systemd-resolved, dnsmasq, etc.) and a self-test query after startup.Auth Proxy (
auth/auth.go): An HTTP reverse proxy that enforces SSO at the edge. Uses a hybrid validation model: first tries local JWT verification using an RSA public key fetched from Pangolin (sub-ms latency), then falls back to calling Pangolin's/auth/session/validateAPI. Supports per-resource SSO toggle, access blocking, email whitelist, and injectsX-Auth-User/X-Auth-User-IDheaders for the backend.WebSocket handlers (in
main.go): Handlesnewt/dns/authority/configandnewt/auth/proxy/configmessages from Pangolin with actions: start, stop, update, remove. Reports DNS server status back to Pangolin vianewt/dns/status.Configuration
--dns-bind/DNS_BIND_ADDR0.0.0.0--disable-dns-authority/DISABLE_DNS_AUTHORITYfalseNEWT_AUTH_PROXY_BIND:80Backward compatibility
DNS Authority and Auth Proxy only activate when Pangolin pushes configuration. If Pangolin doesn't have the feature enabled, Newt behaves exactly as before. The
--disable-dns-authorityflag lets operators explicitly opt out even if the server-side is enabled.Port 53 notes
Port 53 requires root on Linux. If
systemd-resolvedis occupying port 53, either disable it (sudo systemctl disable --now systemd-resolved) or bind Newt to a specific IP via--dns-bind.New dependencies
miekg/dns: DNS librarygolang-jwt/jwt/v5: JWT parsing for auth proxyHow to test?
Option 1: Full local test stack
There's a complete end-to-end test stack in
mattv8/pangolin-testing. It spins up a PostgreSQL, Pangolin, Gerbil, two Newt instances, two backends, and a test client on a Docker bridge network.Verify:
Failover:
Auth proxy:
See the testing README for the architecture diagram and all available test commands.
Option 2: Drop-in to an existing stack
Rollback:
You'll also need the companion Pangolin build (see the Pangolin PR) to actually push zone configs.
See it in action
Run this command and watch it rotate between my public IP's (please don't DOS me):
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.