From 20f46c4aefd8739c62812531f5fae15eea8f739d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Mon, 25 Sep 2023 11:21:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=84=E7=90=86=E7=9F=AD=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=86=85=E5=8F=8D=E5=A4=8D=E5=88=87=E6=8D=A2=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/watch/record.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/watch/record.go b/internal/watch/record.go index b825bc1..245dfdb 100644 --- a/internal/watch/record.go +++ b/internal/watch/record.go @@ -36,6 +36,7 @@ func newRecord(w *watch, r *dnspod.RecordListItem, domain, value string) *record // watch 每分钟检查ip是否可以访问, 无法访问自动暂停记录 func (r *record) watch(ctx context.Context) { t := time.NewTicker(time.Minute) + lastSwitch := time.Now() count := 0 for { select { @@ -70,6 +71,13 @@ func (r *record) watch(ctx context.Context) { } } } else if r.isDisable && count > 3 { + // 上次切换时间超过30分钟才能再次切换 + if time.Since(lastSwitch) < time.Minute*30 { + r.logger.Ctx(ctx).Info("ip可以访问,但是上次切换时间不足30分钟") + continue + } + lastSwitch = time.Now() + // 检查连续成功3次,开启记录 count = 0 request := dnspod.NewModifyRecordStatusRequest()