go-ddns-client/main.go

40 lines
641 B
Go
Raw Normal View History

2019-05-07 09:48:58 +00:00
package main
2019-05-08 10:01:06 +00:00
import (
"log"
"git.trj.tw/golang/go-ddns-client/module/config"
2019-05-09 08:13:25 +00:00
"git.trj.tw/golang/go-ddns-client/module/ddns"
2019-05-08 10:01:06 +00:00
"git.trj.tw/golang/go-ddns-client/module/option"
)
func init() {
option.RegOptions()
}
2019-05-07 09:48:58 +00:00
func main() {
2019-05-08 10:01:06 +00:00
var err error
opts := option.GetOptions()
err = config.LoadConfig(opts.Config)
if err != nil {
log.Fatal(err)
}
2019-05-09 08:13:25 +00:00
data, err := ddns.GetDNSSetting()
if err != nil {
log.Fatal(err)
}
if len(data.V4) > 0 {
if err = ddns.SendRequest(true, data.V4); err != nil {
log.Fatal(err)
}
}
if len(data.V6) > 0 {
if err = ddns.SendRequest(false, data.V6); err != nil {
log.Fatal(err)
}
}
2019-05-07 09:48:58 +00:00
}