summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2017-11-22 04:12:04 +0000
committerFelix Hanley <felix@userspace.com.au>2017-11-22 04:17:40 +0000
commitf18488df5291dafe59b53585715f025d5c3c29b2 (patch)
treea3b4053c2bd1a291fdf11a0215b32f5233568651
downloaddyndnsd-f18488df5291dafe59b53585715f025d5c3c29b2.tar.gz
dyndnsd-f18488df5291dafe59b53585715f025d5c3c29b2.tar.bz2
Add initial configuration structure
-rw-r--r--Makefile23
-rw-r--r--config.go34
-rw-r--r--config.toml.sample48
3 files changed, 105 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..c93b411
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,23 @@
+
+BINARY=dyndnsd
+VERSION=$(shell git describe --tags --always)
+SRC=$(shell find . -type f -name '*.go')
+
+build: $(BINARY)
+
+$(BINARY): $(SRC)
+ cd cmd && go build -ldflags "-w -s \
+ -X main.version=$(VERSION)" \
+ -o ../$(BINARY)
+test:
+ go test -short -coverprofile=coverage.out
+ go tool cover -html=coverage.out -o coverage.html
+
+lint:
+ @for file in $$(find . -name 'vendor' -prune -o -type f -name '*.go'); do golint $$file; done
+
+clean:
+ rm -f $(BINARY)
+ rm -rf coverage*
+
+.PHONY: install build test lint clean
diff --git a/config.go b/config.go
new file mode 100644
index 0000000..7e08e77
--- /dev/null
+++ b/config.go
@@ -0,0 +1,34 @@
+package dyndns
+
+// Config stores the server configuration
+type Config struct {
+ Verbose bool `toml:"verbose"`
+ Port int `toml:"port"`
+ Strict bool `toml:"strict"`
+ PublishMethod string `toml:"publish_method"`
+ MinimumTime int `toml:"minimum_time"`
+ Domains []Domain `toml:"domain"`
+ RRs []RR `toml:"record"`
+ Accounts []Account `toml:"account"`
+}
+
+// Account stores the account details
+type Account struct {
+ Username string `toml:"username"`
+ Password string `toml:"password"`
+ Hostnames []string `toml:"hostnames"`
+}
+
+// Domain stores settings for zones
+type Domain struct {
+ FQDN string `toml:"fqdn"`
+ TTL int `toml:"ttl"`
+}
+
+// RR defines resource records, must contain a Domain
+type RR struct {
+ FQDN string `toml:"fqdn"`
+ Type string `toml:"type"`
+ TTL int `toml:"ttl"`
+ Data string `toml:"data"`
+}
diff --git a/config.toml.sample b/config.toml.sample
new file mode 100644
index 0000000..7e3101e
--- /dev/null
+++ b/config.toml.sample
@@ -0,0 +1,48 @@
+# Example dyndnsd config file, defaults are commented out
+
+# Be verbose in logging
+#verbose = false
+
+# Port to listen for HTTP requests
+#port = 80
+
+# Publish method: bind, djbdns, axfr or daemon
+#publish_method = 'bind'
+
+# Minimum allowed time in seconds between client updates
+#minimum_time = 600
+
+# Match the dyn.com API strictly
+#strict = false
+
+# The following are examples for which there are no defaults
+
+[[domain]]
+# All records and hostnames must belong to a domain
+fqdn = 'au.example.com'
+# Default TTL for this domain
+ttl = 60
+
+[[domain]]
+fqdn = 'au.example.org'
+ttl = 60
+
+# Additional resource records for domains
+[[record]]
+fqdn = 'www.au.example.org'
+type = 'CNAME'
+ttl = 60
+data = 'www.au.example.com'
+
+[[account]]
+# Username required in request
+username = 'johnny'
+# Password required in request
+password = 'asdf02jfas092wefs'
+# Hostnames available for updating
+hostnames = ['one.example.com', 'two.example.org']
+
+[[account]]
+username = 'sally'
+password = '9mf9md92j2dkfhgjd'
+hostnames = ['three.example.com', 'four.example.org']