secure_dns

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 13 Imported by: 0

README

secure_dns

secure_dns is a secure, decentralized DNS-over-QUIC (DoQ) implementation tailored for zero-trust mesh networks. It enforces strict mutual TLS (mTLS) authentication for all peer connections, frames DNS traffic over stream-oriented QUIC transport using a 2-byte length prefix (compliant with stream-based DNS standards), and integrates with a cryptographic data verification engine to protect against domain spoofing and malicious ingress.


Features

  • DNS-over-QUIC (DoQ): Replaces traditional untrusted UDP communication with robust, stream-oriented QUIC connections.
  • Strict Mutual TLS (mTLS): Enforces peer identity verification via x509 client certificates, ensuring only pre-authorized nodes can query or inject zone records.
  • Decentralized Swarm Mesh Resolution: Coordinates local zone file resolution with network-wide peer broadcasts using a custom peer routing layer.
  • Cryptographic Data Lineage Verification: Leverages a secure data validation engine to audit the authenticity and configuration validity of resource records.
  • Authoritative Persistence Layer: Plugs into atomic, fast, local memory-page persistence for quick lookups and secure transactions.

Architecture & Transport Framing

Unlike UDP-based DNS alternatives, secure_dns relies on reliable, ordered stream byte delivery via quic-go. To handle query boundaries over continuous streams accurately, all packet transactions prepend a 2-byte big-endian length prefix.

When a query is received, the node evaluates the peer's certificate, establishes the streaming context, parses the structural DNS labels sequentially, and checks local tables. If an entry is missing or expired, it falls back to a network broadcast to find the record within the trusted swarm mesh.


Prerequisites

Ensure your environment includes a modern version of quic-go which manages connection handlers via the concrete pointer (*quic.Conn) architecture.

go get github.com/quic-go/quic-go


General Application Server Integration

To integrate secure_dns into a modular application server architecture or framework, instantiate the coordinator during your platform's startup lifecycle once the database and network layers are operational.

Implementation Template
package main

import (
	"crypto/tls"
	"log"

	"github.com/0TrustCloud/secure_dns"
)

// Assume your environment has pre-existing components for storage and networking
type ApplicationServer struct {
	DB        *YourDatabaseType
	Router    *YourRouterType
	Engine    *YourCryptoEngineType
	PublicKey []byte
}

func (s *ApplicationServer) StartDNSWorker(bindAddr string, tlsConf *tls.Config) {
	// 1. Initialize the SecureDNS instance with your platform's core dependencies
	sdns := secure_dns.NewSecureDNS(s.Router, s.Engine, s.PublicKey, s.DB)

	// 2. Ensure the TLS configuration enforces strict peer verification
	tlsConf.ClientAuth = tls.RequireAndVerifyClientCert
	tlsConf.NextProtos = []string{"doq"}

	// 3. Spin up the listener loop inside a background execution routine
	go func() {
		log.Printf("[DNS Core] Launching mTLS DNS-over-QUIC loop on %s...", bindAddr)
		if err := sdns.ServeWireProtocol(bindAddr, tlsConf); err != nil {
			log.Printf("[DNS Core] Listener closed or exited: %v", err)
		}
	}()
}

Managing Domain Zone Modifications

You can manage authoritative domain bindings programmatically by executing zone registration commands through your application handlers or administrative API endpoints:

// Bind an authoritative A record to the underlying database page
err := sdns.RegisterDomain("node-alpha.mesh", "A", "10.0.0.5", 3600)
if err != nil {
    log.Printf("Failed to bind domain authority: %v", err)
}


Running Tests

The test suite validates connection streams, mTLS handshake constraints, and proper packet framing by generating ephemeral in-memory Certificate Authorities and cross-signing connection endpoints at runtime.

To execute the unit tests, use:

go test -v ./...

Documentation

Index

Constants

View Source
const (
	DNSPageID ultimate_db.PageID = 53
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DNSQueryPayload

type DNSQueryPayload struct {
	QueryID string `json:"query_id"`
	Domain  string `json:"domain"`
	Type    string `json:"type"`
}

type DNSRecord

type DNSRecord struct {
	Domain string    `json:"domain"`
	Type   string    `json:"type"` // "A", "AAAA", "PTR", "TXT"
	Value  string    `json:"value"`
	TTL    int       `json:"ttl"`
	Expiry time.Time `json:"expiry"`
}

type DNSResponsePayload

type DNSResponsePayload struct {
	QueryID  string      `json:"query_id"`
	Records  []DNSRecord `json:"records"`
	SdfProof string      `json:"sdf_proof"`
}

type SecureDNS

type SecureDNS struct {
	// contains filtered or unexported fields
}

func NewSecureDNS

func NewSecureDNS(pr *secure_network.PeerRoute, sdf *secure_data_format.SecureDataEngine, localPub []byte, database *ultimate_db.DB) *SecureDNS

func (*SecureDNS) RegisterDomain

func (s *SecureDNS) RegisterDomain(domain, recordType, value string, ttl int) error

func (*SecureDNS) ResolveLocal

func (s *SecureDNS) ResolveLocal(domain, recordType string) ([]DNSRecord, error)

func (*SecureDNS) ResolveMesh

func (s *SecureDNS) ResolveMesh(ctx context.Context, domain, recordType string, timeout time.Duration) ([]DNSRecord, error)

func (*SecureDNS) ServeWireProtocol

func (s *SecureDNS) ServeWireProtocol(bindAddr string) error

func (*SecureDNS) Shutdown

func (s *SecureDNS) Shutdown()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL