aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.go25
-rw-r--r--dyndns.go31
-rw-r--r--log.go5
3 files changed, 61 insertions, 0 deletions
diff --git a/config.go b/config.go
new file mode 100644
index 0000000..8a11d58
--- /dev/null
+++ b/config.go
@@ -0,0 +1,25 @@
+package main
+
+import (
+ "encoding/json"
+ "os"
+)
+
+type config struct {
+ User string
+ Passwd string
+ Link string
+ PrefixLen int
+ Records4 []int
+ Records6 []int
+}
+
+func (c *config) parse(location string) error {
+ f, err := os.Open(location)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ return json.NewDecoder(f).Decode(c)
+}
diff --git a/dyndns.go b/dyndns.go
index 47f8513..c6f2c79 100644
--- a/dyndns.go
+++ b/dyndns.go
@@ -1,2 +1,33 @@
// dyndns is a dual-stack DynDNS client that uses the INWX JSON-RPC API.
package main
+
+import (
+ "flag"
+ "log"
+ "net"
+)
+
+func main() {
+ const usage = "override the default config path"
+ configFile := flag.String("config", "/etc/dyndns.conf", usage)
+
+ config := &config{}
+ if err := config.parse(*configFile); err != nil {
+ log.Fatal(err)
+ }
+
+ update4 := make(chan net.IPAddr)
+ update6 := make(chan net.IPNet)
+
+ go monitorIf4(update4)
+ go monitorIf6(update6)
+
+ for {
+ select {
+ case newAddr := <-update4:
+ // TODO
+ case newPrefix := <-update6:
+ // TODO
+ }
+ }
+}
diff --git a/log.go b/log.go
new file mode 100644
index 0000000..e7aca57
--- /dev/null
+++ b/log.go
@@ -0,0 +1,5 @@
+package main
+
+import "log"
+
+var logger = log.Default()