From 51548f67881ab7aeb292f266cb5cc1a3b72fa7ae Mon Sep 17 00:00:00 2001 From: v-me-50 Date: Thu, 4 Sep 2025 17:57:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwebhook=E5=89=8D=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E5=AF=BC=E8=87=B4=E5=B7=A5=E4=BD=9C=E6=B5=81=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/cert/apply/lego/webhook/lego.go | 4 +-- .../internal/cert/deploy/webhook/deploy.go | 27 +++++++++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/backend/internal/cert/apply/lego/webhook/lego.go b/backend/internal/cert/apply/lego/webhook/lego.go index 8f1bbf4..3487918 100644 --- a/backend/internal/cert/apply/lego/webhook/lego.go +++ b/backend/internal/cert/apply/lego/webhook/lego.go @@ -23,16 +23,14 @@ type DNSProvider struct { } func NewConfig(WebhookConfigStr map[string]string) *Config { - fmt.Println(WebhookConfigStr) WebhookConfig := &public.WebhookConfig{ Url: WebhookConfigStr["url"], Data: WebhookConfigStr["data"], Method: WebhookConfigStr["method"], Headers: WebhookConfigStr["headers"], - IgnoreSSL: WebhookConfigStr["ignore_ssl"] == "true", + IgnoreSSL: WebhookConfigStr["ignore_ssl"] == "1", } - fmt.Println(WebhookConfig.Url) return &Config{ WebhookConfig: WebhookConfig, diff --git a/backend/internal/cert/deploy/webhook/deploy.go b/backend/internal/cert/deploy/webhook/deploy.go index e824454..a071509 100644 --- a/backend/internal/cert/deploy/webhook/deploy.go +++ b/backend/internal/cert/deploy/webhook/deploy.go @@ -32,12 +32,35 @@ func Deploy(cfg map[string]any) error { return fmt.Errorf("api配置错误") } // 解析 JSON 配置 - var providerConfig public.WebhookConfig - err = json.Unmarshal([]byte(providerConfigStr), &providerConfig) + var providerConfigMap map[string]interface{} + + err = json.Unmarshal([]byte(providerConfigStr), &providerConfigMap) if err != nil { return err } + var ignoreSSL bool + switch v := providerConfigMap["ignore_ssl"].(type) { + case string: + if v == "1" { + ignoreSSL = true + } + case float64: + if v != 0 { + ignoreSSL = true + } + case bool: + ignoreSSL = v + } + + providerConfig := public.WebhookConfig{ + Url: providerConfigMap["url"].(string), + Data: providerConfigMap["data"].(string), + Method: providerConfigMap["method"].(string), + Headers: providerConfigMap["headers"].(string), + IgnoreSSL: ignoreSSL, + } + certStr, ok := cert["cert"].(string) if !ok || certStr == "" { return fmt.Errorf("cert is required and must be a string")