Documentation
¶
Overview ¶
Package ddns publishes a node's public IP to DNS when it changes. It is dependency-free: the Cloudflare provider talks to the Cloudflare API v4 over the standard library and the webhook provider posts a templated request, so the server keeps its zero-dependency footprint (no libdns).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply pushes the node's current IPs to every domain in the profile, honoring EnableIPv4/EnableIPv6 and retrying each record up to MaxRetries times. It returns the joined error of all failed records (nil if all succeeded).
func GuardOutbound ¶
GuardOutbound rejects URLs that resolve to loopback, private, link-local, unspecified, or cloud-metadata addresses. This blunts SSRF via an admin-configured webhook URL. It performs a real DNS lookup; callers that must reach loopback (tests) construct the provider without this guard.
Types ¶
type Cloudflare ¶
type Cloudflare struct {
Token string
BaseURL string // defaults to cloudflareDefaultBase
Client *http.Client
// contains filtered or unexported fields
}
Cloudflare sets A/AAAA records through the Cloudflare API v4 using an API token. The token needs Zone:Read + DNS:Edit on the target zones.
func (*Cloudflare) Kind ¶
func (c *Cloudflare) Kind() string
type Provider ¶
Provider sets DNS records for one backend (Cloudflare, webhook, ...).
func NewProvider ¶
NewProvider builds the Provider described by a profile. The webhook provider is given the production SSRF guard; the Cloudflare provider targets the real API. Tests construct providers directly to bypass the guard / point at a mock.
type Record ¶
type Record struct {
Type string // "A" or "AAAA"
Name string // fully-qualified record name, e.g. node.example.com
IP string
TTL int
}
Record is a single DNS record to set.
type Webhook ¶
type Webhook struct {
URL string
Method string
Body string
Headers string // "Key: Value" per line
Client *http.Client
Guard func(rawURL string) error
}
Webhook delivers DNS updates to an arbitrary HTTP endpoint. The URL and body support the templates #ip#, #domain#, and #type#. Because the URL is operator-supplied, Guard (when set) is consulted before each request to block SSRF to internal addresses.