mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
make interval configurable
This commit is contained in:
parent
50c69bf548
commit
04134b20a4
@ -19,6 +19,7 @@
|
||||
}
|
||||
],
|
||||
"ip_url": "https://myip.biturl.top",
|
||||
"interval": 300,
|
||||
"ip_interface": "eth0",
|
||||
"socks5_proxy": "",
|
||||
"notify": {
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user