diff --git a/config/webhook.go b/config/webhook.go index 1b237b351..470b2f522 100644 --- a/config/webhook.go +++ b/config/webhook.go @@ -13,6 +13,7 @@ import ( // Webhook Webhook type Webhook struct { + WebhookDisable bool WebhookURL string WebhookRequestBody string } @@ -34,7 +35,7 @@ func ExecWebhook(domains *Domains, conf *Config) (v4Status updateStatusType, v6S v4Status = getDomainsStatus(domains.Ipv4Domains) v6Status = getDomainsStatus(domains.Ipv6Domains) - if conf.WebhookURL != "" && (v4Status != UpdatedNothing || v6Status != UpdatedNothing) { + if !conf.WebhookDisable && conf.WebhookURL != "" && (v4Status != UpdatedNothing || v6Status != UpdatedNothing) { // 成功和失败都要触发webhook method := "GET" postPara := "" diff --git a/web/save.go b/web/save.go index f06dc29b0..191759efe 100755 --- a/web/save.go +++ b/web/save.go @@ -42,6 +42,7 @@ func checkAndSave(request *http.Request) string { conf.NotAllowWanAccess = request.FormValue("NotAllowWanAccess") == "on" conf.Username = strings.TrimSpace(request.FormValue("Username")) conf.Password = request.FormValue("Password") + conf.WebhookDisable = request.FormValue("WebhookDisable") == "on" conf.WebhookURL = strings.TrimSpace(request.FormValue("WebhookURL")) conf.WebhookRequestBody = strings.TrimSpace(request.FormValue("WebhookRequestBody")) // 如启用公网访问,帐号密码不能为空 diff --git a/web/webhookTest.go b/web/webhookTest.go index 16357b80e..45987d940 100755 --- a/web/webhookTest.go +++ b/web/webhookTest.go @@ -28,6 +28,7 @@ func WebhookTest(writer http.ResponseWriter, request *http.Request) { fakeConfig := &config.Config{ Webhook: config.Webhook{ + WebhookDisable: false, WebhookURL: url, WebhookRequestBody: requestBody, }, diff --git a/web/writing.go b/web/writing.go index 3fcf292aa..3f289511f 100755 --- a/web/writing.go +++ b/web/writing.go @@ -21,6 +21,7 @@ type writtingData struct { DnsConf template.JS NotAllowWanAccess string config.User + WebhookDisable string config.Webhook Version string } @@ -66,6 +67,7 @@ func Writing(writer http.ResponseWriter, request *http.Request) { DnsConf: template.JS(getDnsConfStr(conf.DnsConf)), NotAllowWanAccess: BooltoOn(conf.NotAllowWanAccess), User: conf.User, + WebhookDisable: BooltoOn(conf.WebhookDisable), Webhook: conf.Webhook, Version: os.Getenv(VersionEnv), }) diff --git a/web/writing.html b/web/writing.html index 9dbba728a..d6a98f6fb 100755 --- a/web/writing.html +++ b/web/writing.html @@ -326,6 +326,14 @@
其它配置
Webhook
+ +
+ +
+ +
+
@@ -445,6 +453,7 @@
Webhook
document.getElementById('NotAllowWanAccess').checked = "{{.NotAllowWanAccess}}"=='on'; document.getElementById('Username').value = "{{.Username}}"; document.getElementById('Password').value = "{{.Password}}"; + document.getElementById('WebhookDisable').checked = "{{.WebhookDisable}}"=='on'; document.getElementById('WebhookURL').value = "{{.WebhookURL}}"; document.getElementById('WebhookRequestBody').value = "{{.WebhookRequestBody}}"; });