- Added configuration management using Viper in internal/config/config.go - Implemented ClientConfig, ServerConfig, TLSConfig, HetznerConfig, UpstreamConfig, and main Config struct. - Created LoadConfig function to read and validate configuration files. - Developed Hetzner DNS provider in internal/provider/hetzner/hetzner.go with methods for updating DNS records. - Added comprehensive unit tests for configuration loading and Hetzner provider functionality. - Established HTTP server with metrics and update endpoint in internal/server/server.go. - Implemented request handling, authorization, and error management in the server. - Created integration tests for the Hetzner provider API interactions. - Removed legacy dynamic DNS integration tests in favor of the new API-based approach.
4.0 KiB
4.0 KiB
Development Plan for UpDNS
A step-by-step roadmap to build, test, and evolve the Go‑based DynDNS proxy—including support for both exact hostnames and wildcard domains.
Phase 1: Project Setup (Week 1)
-
Repository Initialization
go mod init git.cloonar.com/cloonar/updns- Create directory structure:
cmd/updns internal/config internal/server internal/provider test/
-
Configuration Loader
- Use [spf13/viper] to parse YAML/JSON/TOML.
- Define
Configstruct with:type ClientConfig struct { Secret string `mapstructure:"secret"` Exact []string `mapstructure:"exact"` Wildcard []string `mapstructure:"wildcard"` } type Config struct { Server ServerConfig `mapstructure:"server"` Upstream UpstreamConfig `mapstructure:"upstream"` Clients map[string]ClientConfig `mapstructure:"clients"` } - Validate that at least one of
ExactorWildcardis set per client.
-
Main & CLI
- Parse
--configflag. - Load config, handle errors, and pass into server setup.
- Parse
Phase 2: HTTP API & Authentication (Week 2)
-
Server Implementation
- Choose router:
net/httporgin-gonic/gin. - Define route
POST /update.
- Choose router:
-
Authentication & Authorization
- Middleware to:
- Lookup client by
key. - Verify
secretmatches stored token. - Check that requested
hostis allowed by matching either:- An entry in
Exact(full string equality), or - A wildcard base domain in
Wildcard, e.g.example.commatchesfoo.example.comandexample.com.
- An entry in
- Lookup client by
- Reject requests with clear error if host not authorized.
- Middleware to:
-
Request Validation
- Validate JSON payload:
key,secret,host, optionalip. - Default
ipto requestor’s IP if omitted.
- Validate JSON payload:
Phase 3: Hetzner Provider Integration (Week 3)
-
Provider Interface
type Provider interface { UpdateRecord(ctx context.Context, domain, ip string) error } -
Hetzner Implementation
- On startup, fetch or cache record IDs by domain.
- Use Hetzner’s DDNS API to PATCH IP on update.
-
Error Handling & Retries
- Retry transient errors with exponential backoff.
- Surface permanent errors in response.
Phase 4: Testing & CI (Week 4)
-
Unit Tests
- Config parsing, ensuring
ExactandWildcardfields load correctly. - Authorization logic: hosts matching exact list vs. wildcard list.
- Secret validation.
- Config parsing, ensuring
-
Integration Tests
- Use
httptest.Serverto simulate upstream. - Test success and failure for:
- Exact hostname updates.
- Subdomain updates via wildcard rules.
- Unauthorized host attempts.
- Use
-
CI Pipeline
- GitHub Actions to run
go fmt,go vet,go test. - Build artifacts for Linux/macOS.
- GitHub Actions to run
Phase 5: TLS, Logging & Metrics (Week 5)
-
TLS Support
- Enable HTTPS when
tls.enabledin config. - Load cert/key files.
- Enable HTTPS when
-
Structured Logging
- Integrate
uber/zaporsirupsen/logrus. - Log requests, responses, errors, and authorization decisions (with no secrets).
- Integrate
-
Metrics
- Expose Prometheus
/metricsendpoint. - Track:
- Total updates.
- Successes vs. failures.
- Requests authorized via exact vs. wildcard.
- Expose Prometheus
Phase 6: Extensibility & Additional Providers (Week 6)
-
Provider Factory
- Map
upstream.providerstring to constructor.
- Map
-
Cloudflare & AWS Stubs
- Scaffold
cloudflareandawsprovider packages. - Document config for each.
- Scaffold
-
Documentation Update
- Update README to reflect exact + wildcard support and new provider instructions.
Phase 7: Deployment & Release (Week 7)
-
Dockerization
- Write
Dockerfileand exampledocker-compose.yml.
- Write
-
Optional Helm Chart
- Package for Kubernetes.
-
Release v1.0.0
- Tag in GitHub, attach binaries, update changelog.