mirror of https://github.com/allinssl/allinssl
parent
f1544ecd8b
commit
51548f6788
|
@ -23,16 +23,14 @@ type DNSProvider struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig(WebhookConfigStr map[string]string) *Config {
|
func NewConfig(WebhookConfigStr map[string]string) *Config {
|
||||||
fmt.Println(WebhookConfigStr)
|
|
||||||
|
|
||||||
WebhookConfig := &public.WebhookConfig{
|
WebhookConfig := &public.WebhookConfig{
|
||||||
Url: WebhookConfigStr["url"],
|
Url: WebhookConfigStr["url"],
|
||||||
Data: WebhookConfigStr["data"],
|
Data: WebhookConfigStr["data"],
|
||||||
Method: WebhookConfigStr["method"],
|
Method: WebhookConfigStr["method"],
|
||||||
Headers: WebhookConfigStr["headers"],
|
Headers: WebhookConfigStr["headers"],
|
||||||
IgnoreSSL: WebhookConfigStr["ignore_ssl"] == "true",
|
IgnoreSSL: WebhookConfigStr["ignore_ssl"] == "1",
|
||||||
}
|
}
|
||||||
fmt.Println(WebhookConfig.Url)
|
|
||||||
|
|
||||||
return &Config{
|
return &Config{
|
||||||
WebhookConfig: WebhookConfig,
|
WebhookConfig: WebhookConfig,
|
||||||
|
|
|
@ -32,12 +32,35 @@ func Deploy(cfg map[string]any) error {
|
||||||
return fmt.Errorf("api配置错误")
|
return fmt.Errorf("api配置错误")
|
||||||
}
|
}
|
||||||
// 解析 JSON 配置
|
// 解析 JSON 配置
|
||||||
var providerConfig public.WebhookConfig
|
var providerConfigMap map[string]interface{}
|
||||||
err = json.Unmarshal([]byte(providerConfigStr), &providerConfig)
|
|
||||||
|
err = json.Unmarshal([]byte(providerConfigStr), &providerConfigMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
certStr, ok := cert["cert"].(string)
|
||||||
if !ok || certStr == "" {
|
if !ok || certStr == "" {
|
||||||
return fmt.Errorf("cert is required and must be a string")
|
return fmt.Errorf("cert is required and must be a string")
|
||||||
|
|
Loading…
Reference in New Issue