1
0
mirror of https://github.com/taigrr/godns synced 2025-01-18 04:03:25 -08:00

make interval configurable

This commit is contained in:
TimothyYe 2019-04-21 17:18:05 +08:00
parent 50c69bf548
commit 04134b20a4
7 changed files with 19 additions and 14 deletions

View File

@ -19,6 +19,7 @@
}
],
"ip_url": "https://myip.biturl.top",
"interval": 300,
"ip_interface": "eth0",
"socks5_proxy": "",
"notify": {

View File

@ -71,9 +71,9 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns.
}
}
}
// Interval is 5 minutes
log.Printf("Going to sleep, will start next checking in %d minutes...\r\n", godns.INTERVAL)
time.Sleep(time.Minute * godns.INTERVAL)
// Sleep with interval
log.Printf("Going to sleep, will start next checking in %d seconds...\r\n", handler.Configuration.Interval)
time.Sleep(time.Second * time.Duration(handler.Configuration.Interval))
}
}

View File

@ -119,9 +119,9 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns.
log.Println("Failed to find zone for domain:", domain.DomainName)
}
}
// Interval is 5 minutes
log.Printf("Going to sleep, will start next checking in %d minutes...\r\n", godns.INTERVAL)
time.Sleep(time.Minute * godns.INTERVAL)
// Sleep with interval
log.Printf("Going to sleep, will start next checking in %d seconds...\r\n", handler.Configuration.Interval)
time.Sleep(time.Second * time.Duration(handler.Configuration.Interval))
}
}

View File

@ -86,9 +86,9 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns.
}
}
}
// Interval is 5 minutes
log.Printf("Going to sleep, will start next checking in %d minutes...\r\n", godns.INTERVAL)
time.Sleep(time.Minute * godns.INTERVAL)
// Sleep with interval
log.Printf("Going to sleep, will start next checking in %d seconds...\r\n", handler.Configuration.Interval)
time.Sleep(time.Second * time.Duration(handler.Configuration.Interval))
}
}

View File

@ -68,9 +68,9 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns.
}
}
}
// Interval is 5 minutes
log.Printf("Going to sleep, will start next checking in %d minutes...\r\n", godns.INTERVAL)
time.Sleep(time.Minute * godns.INTERVAL)
// Sleep with interval
log.Printf("Going to sleep, will start next checking in %d seconds...\r\n", handler.Configuration.Interval)
time.Sleep(time.Second * time.Duration(handler.Configuration.Interval))
}
}

View File

@ -30,6 +30,7 @@ type Settings struct {
LoginToken string `json:"login_token"`
Domains []Domain `json:"domains"`
IPUrl string `json:"ip_url"`
Interval int `json:"interval"`
LogPath string `json:"log_path"`
Socks5Proxy string `json:"socks5_proxy"`
Notify Notify `json:"notify"`
@ -53,5 +54,10 @@ func LoadSettings(configPath string, settings *Settings) error {
return err
}
if settings.Interval == 0 {
// set default interval as 5 minutes if interval is 0
settings.Interval = 5 * 60
}
return nil
}

View File

@ -34,8 +34,6 @@ https://github.com/TimothyYe/godns
const (
// PanicMax is the max allowed panic times
PanicMax = 5
// INTERVAL is minute
INTERVAL = 5
// DNSPOD for dnspod.cn
DNSPOD = "DNSPod"
// HE for he.net