fix: Fix the problem that ip cache time is one less (#712)

This commit is contained in:
feranwq
2023-05-26 18:49:31 +08:00
committed by GitHub
parent d69bbe6e0f
commit 89166e69e6
2 changed files with 3 additions and 3 deletions

View File

@ -27,7 +27,7 @@ var listen = flag.String("l", ":9876", "监听地址")
var every = flag.Int("f", 300, "同步间隔时间(秒)")
// 缓存次数
var ipCacheTimes = flag.Int("cacheTimes", 6, "间隔N次与服务商比对")
var ipCacheTimes = flag.Int("cacheTimes", 5, "间隔N次与服务商比对")
// 服务管理
var serviceType = flag.String("s", "", "服务管理, 支持install, uninstall")

View File

@ -24,10 +24,10 @@ func (d *IpCache) Check(newAddr string) bool {
if d.Addr != newAddr || d.Times <= 1 {
IPCacheTimes, err := strconv.Atoi(os.Getenv(IPCacheTimesENV))
if err != nil {
IPCacheTimes = 6
IPCacheTimes = 5
}
d.Addr = newAddr
d.Times = IPCacheTimes
d.Times = IPCacheTimes + 1
return true
}
d.Addr = newAddr