diff options
-rw-r--r-- | config.go | 25 | ||||
-rw-r--r-- | dyndns.go | 31 | ||||
-rw-r--r-- | log.go | 5 |
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) +} @@ -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 + } + } +} @@ -0,0 +1,5 @@ +package main + +import "log" + +var logger = log.Default() |