Open
Conversation
Improve NS record handling with glue A-records for healthy targets Update DNS Authority feature with configuration options and conflict checks Add self-test functionality for DNS Authority server startup
6dff3f8 to
a0bb51f
Compare
Author
|
@oschwartz10612 When you get a chance, would love if you took a look |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fosrl/pangolin#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:
docker compose stop backend dig @localhost -p 5353 app.test.dev A +short # → secondary IP docker compose start backendAuth proxy:
See the testing README for the architecture diagram and all available test commands.
Option 2: Drop-in to an existing stack
Rollback:
sudo cp /usr/local/bin/newt.official /usr/local/bin/newt && sudo systemctl restart newtYou'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):