feat: add interval between DNS updates
This commit is contained in:
parent
5f94658e1f
commit
8634f4f569
2 changed files with 11 additions and 2 deletions
|
@ -22,6 +22,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
@ -184,8 +185,16 @@ func init() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
config = loadConfig(configPath)
|
config = loadConfig(configPath)
|
||||||
|
|
||||||
|
if config.UpdateInterval <= 0 {
|
||||||
|
log.Fatal("\"updateInterval\" has to be greater than 0")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config.updateIp()
|
for {
|
||||||
|
config.updateIp()
|
||||||
|
log.Print("Sleeping for " + fmt.Sprint(config.UpdateInterval) + " seconds")
|
||||||
|
time.Sleep(time.Duration(config.UpdateInterval) * time.Second)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"interval:": 60,
|
"updateInterval": 60,
|
||||||
"dnsServer": "1.1.1.1:53",
|
"dnsServer": "1.1.1.1:53",
|
||||||
"provider": "porkbun",
|
"provider": "porkbun",
|
||||||
"porkbun": {
|
"porkbun": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue