Documentation
¶
Overview ¶
Package cfdyndns provides a dynamic DNS (DDNS) service for domains managed by Cloudflare.
This package allows users to automatically update DNS records for their Cloudflare-managed domains to point to the current public IP address of the machine running the code. It supports both IPv4 (A records) and IPv6 (AAAA records) addresses.
Key features:
- One-time updates of DNS records to the current public IP (Set method)
- Scheduled automatic updates using cron jobs (Auto method)
- Support for both proxied and unproxied DNS records
- Handles subdomains and zone apex updates
This package is particularly useful for maintaining up-to-date DNS records for machines with dynamic IP addresses, effectively turning a Cloudflare-managed domain into a dynamic DNS service.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates a new instance of cfdyndns with the provided Cloudflare API token.
It initializes the Cloudflare API client, detects the current IP address, and sets up a cron scheduler for automatic updates.
Parameters:
- token: A string containing the Cloudflare API token.
Returns:
- *cfdyndns: A pointer to the newly created cfdyndns instance.
- error: An error if any issues occur during initialization.
Example ¶
token := os.Getenv("CF_API_TOKEN") if token == "" { log.Fatal("CF_API_TOKEN environment variable is not set") } cfdyndns, err := New(token) if err != nil { log.Fatal("Error creating cfdyndns instance", "error", err) } // use cfdyndns cfdyndns.Set("example.com", "www", false)
Output:
Types ¶
This section is empty.