dyndns

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: BSD-2-Clause Imports: 9 Imported by: 0

README

Dynamic DNS handler for Caddy

A caddy v2 plugin for dealing with dynamic DNS setups. See the documentation for DynDnsHandler for more details.

Installing

Build a custom Caddy:

$ go install github.com/caddyserver/xcaddy@latest
$ xcaddy build \
    --with github.com/nelsonxb/caddy-dyndns \
    --with github.com/caddy-dns/...

Setting up

This plugin was mainly developed to use with a FRITZ!Box. You might find a setup like the following useful:

{
    "apps": {
        "http": {
            "servers": {
                "default": {
                    "routes": [{
                        "match": [{
                            "remote_ip": { "ranges": ["192.168.178.1"] },
                            "path": ["/.ddns"]
                        }],
                        "handle": [
                            {
                                "handler": "authentication",
                                "providers": {
                                    "http_basic": {/*...*/}
                                }
                            },
                            {
                                "handler": "dyndns",
                                "domain": "my.domain.com",
                                "provider": {/* dns.providers.* */}
                            }
                        ]
                    }]
                }
            }
        }
    }
}

Then, in the FRITZ!Box, configure DynDNS using the User-defined provider:

Setting Value
Update URL http://192.168.178.x/.ddns?4=<ipaddr> http://192.168.178.x/.ddns?6=<ip6addr> (or <ip6addr> could be <ip6lanprefix>, also note the two space-separated URLs)
Domain name my.domain.com
User name As configured in Caddy
Password As configured in Caddy

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynDnsHandler

type DynDnsHandler struct {
	// The DNS provider module to use for updating the DNS records.
	// Note that providers that satisfy the requirements for ACME
	// don't necessarily work here.
	//
	// Providers that simply forward to libdns should be fine.
	ProviderRaw json.RawMessage `json:"provider" caddy:"namespace=dns.providers inline_key=name"`

	// The full domain name to get updated.
	Domain string `json:"domain"`

	// The DNS zone to update. This will likely be the root domain
	// that you purchased. If omitted, defaults to a suffix of the domain.
	// If specified, must be a suffix of the domain.
	//
	// Note that the suffix guesswork is currently very naïve -
	// the second-last component is considered to be the zone.
	// This doesn't always work - for example, the domain `sub.example.co.nz`
	// will produce a zone of `co.nz` (even though you would probably want
	// `example.co.nz`).
	Zone string `json:"zone,omitempty"`

	// An optional address to use, to override the local IPv6 address.
	// When specified, if a new IPv6 address only sets the high half
	// (i.e. the new address is a subnet range),
	// the low half will be filled with the matching low half
	// specified in this field.
	//
	// This can either be an IPv6 address,
	// or a domain name to look up
	// (may be useful within a Docker container).
	LanIPv6 string `json:"ipv6,omitempty"`

	Provider libdns.RecordSetter `json:"-"`
	// contains filtered or unexported fields
}

Handles a notification that an IP address has changed. On any request, checks the query parameters for IP addresses, then updates the domain given in the configuration.

When any HTTP request is submitted, it checks for query parameters "4" and "6". For example, `GET /?4=123.234.210.2&6=2000:80::52:3` - this then updates the configured DNS provider with corresponding A and AAAA records. Either one or both of these parameters may be specified in a request. If the IPv6 address is given as a CIDR prefix (e.g. `/?6=2000:80::/64`), then the unmasked space is filled based on the address specified in the ipv6 field.

func (*DynDnsHandler) CaddyModule

func (*DynDnsHandler) CaddyModule() caddy.ModuleInfo

func (*DynDnsHandler) Provision

func (ddns *DynDnsHandler) Provision(ctx caddy.Context) error

func (*DynDnsHandler) ServeHTTP

func (ddns *DynDnsHandler) ServeHTTP(w http.ResponseWriter, req *http.Request, _ caddyhttp.Handler) error

Jump to

Keyboard shortcuts

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