-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ip cache time configable #708
Conversation
8c32d38
to
cde1c10
Compare
util/ip_cache.go
Outdated
@@ -13,10 +20,14 @@ func (d *IpCache) Check(newAddr string) bool { | |||
if newAddr == "" { | |||
return true | |||
} | |||
IPCacheTimes, err := strconv.Atoi(os.Getenv(IPCacheTimesENV)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IPCacheTimes获取可以放在28行的if里面
main.go
Outdated
@@ -26,6 +26,9 @@ var listen = flag.String("l", ":9876", "监听地址") | |||
// 更新频率(秒) | |||
var every = flag.Int("f", 300, "同步间隔时间(秒)") | |||
|
|||
// 缓存次数 | |||
var ipCacheTimes = flag.Int("t", 6, "IP缓存次数") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不用简写t。换个类似noweb的单词
README.md
Outdated
@@ -59,10 +59,10 @@ | |||
docker run -d --name ddns-go --restart=always --net=host -v /opt/ddns-go:/root ghcr.io/jeessy2/ddns-go | |||
``` | |||
|
|||
- [可选] 支持启动带参数 `-l`监听地址 `-f`间隔时间(秒) | |||
- [可选] 支持启动带参数 `-l`监听地址 `-f`间隔时间(秒) `-t`缓存触发更新次数 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缓存触发更新次数
这个不好理解,想个更加容易理解的,如:间隔多少次与服务商比对?或想下有没有更好的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,我看下一起改下
35fb976
to
f5f55ae
Compare
@jeessy2 已更新, flag 改为 -cacheTimes , 说明没改, 下面举例说了一下用法, 默认示例里不再体现此参数 |
|
间隔N次与服务商比对 怎么样 |
可以 |
@jeessy2 done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @feranwq
还有一个转换问题,比如:输入的6,实际等待了5次,感觉有点不对呢 |
我试下,逻辑跟之前应该是没区别的 |
以前没暴露给用户看,所以不存在这个问题。现在让用户设置了,我设置的6,怎么间隔了5次 |
@jeessy2 去服务商比对也算作一次,所以实际间隔次数确实需要加一
这样可以达到预期效果,你看如何 |
-cacheTimes间隔N次与服务商比对 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得应该这么改?
@@ -15,8 +22,12 @@ func (d *IpCache) Check(newAddr string) bool { | |||
} | |||
// 地址改变 或 达到剩余次数 | |||
if d.Addr != newAddr || d.Times <= 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该为d.Times <= 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样改虽然实际执行是正确的,log显示不友好, 例如设置为 3 次
2023/05/26 00:07:27 IPv6未改变,将等待 2 次后与DNS服务商进行比对
2023/05/26 00:07:32 IPv6未改变,将等待 1 次后与DNS服务商进行比对
2023/05/26 00:07:37 IPv6未改变,将等待 0 次后与DNS服务商进行比对
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那按你的来,默认5次
@@ -26,6 +26,9 @@ var listen = flag.String("l", ":9876", "监听地址") | |||
// 更新频率(秒) | |||
var every = flag.Int("f", 300, "同步间隔时间(秒)") | |||
|
|||
// 缓存次数 | |||
var ipCacheTimes = flag.Int("cacheTimes", 6, "间隔N次与服务商比对") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
默认5次
What does this PR do?
#706
Motivation
可配置 IP 缓存次数,增加本地IP 检查频率, 且不会被服务商限流
Additional Notes