修复申请部署

pull/79/head^2
zhangchenhao 2025-05-12 19:49:59 +08:00
parent 7deeed1403
commit 79c04f7b00
2 changed files with 20 additions and 19 deletions

View File

@ -233,14 +233,15 @@ func Apply(cfg map[string]any, logger *public.Logger) (map[string]any, error) {
} }
err = client.Challenge.SetDNS01Provider(provider, err = client.Challenge.SetDNS01Provider(provider,
dns01.WrapPreCheck(func(domain, fqdn, value string, check dns01.PreCheckFunc) (bool, error) { // dns01.WrapPreCheck(func(domain, fqdn, value string, check dns01.PreCheckFunc) (bool, error) {
// 跳过预检查 // // 跳过预检查
return true, nil // return true, nil
}), // }),
dns01.AddRecursiveNameservers([]string{ dns01.AddRecursiveNameservers([]string{
"8.8.8.8:53", "8.8.8.8:53",
"1.1.1.1:53", "1.1.1.1:53",
})) }),
)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -40,12 +40,12 @@ func Request1panel(data *map[string]any, method, providerID, requestUrl string)
} }
timestamp := fmt.Sprintf("%d", time.Now().Unix()) timestamp := fmt.Sprintf("%d", time.Now().Unix())
token := generateToken(timestamp, providerConfig["api_key"]) token := generateToken(timestamp, providerConfig["api_key"])
// data, requestUrl, method := GetDeploy1PBody(cfg, Type) // data, requestUrl, method := GetDeploy1PBody(cfg, Type)
if requestUrl == "" || data == nil { if requestUrl == "" || data == nil {
return nil, fmt.Errorf("不支持的部署类型") return nil, fmt.Errorf("不支持的部署类型")
} }
// 编码为 JSON // 编码为 JSON
jsonData, err := json.Marshal(data) jsonData, err := json.Marshal(data)
if err != nil { if err != nil {
@ -61,12 +61,12 @@ func Request1panel(data *map[string]any, method, providerID, requestUrl string)
// fmt.Println(err) // fmt.Println(err)
return nil, err return nil, err
} }
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
req.Header.Set("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36") req.Header.Set("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36")
req.Header.Set("1Panel-Timestamp", timestamp) req.Header.Set("1Panel-Timestamp", timestamp)
req.Header.Set("1Panel-Token", token) req.Header.Set("1Panel-Token", token)
// 自定义 Transport跳过 SSL 证书验证 // 自定义 Transport跳过 SSL 证书验证
ignoreSsl := false ignoreSsl := false
if providerConfig["ignore_ssl"] == "1" { if providerConfig["ignore_ssl"] == "1" {
@ -75,7 +75,7 @@ func Request1panel(data *map[string]any, method, providerID, requestUrl string)
tr := &http.Transport{ tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl}, TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl},
} }
client := &http.Client{Transport: tr} client := &http.Client{Transport: tr}
resp, err := client.Do(req) resp, err := client.Do(req)
if err != nil { if err != nil {
@ -84,7 +84,7 @@ func Request1panel(data *map[string]any, method, providerID, requestUrl string)
} }
body, _ := io.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
defer resp.Body.Close() defer resp.Body.Close()
var res map[string]interface{} var res map[string]interface{}
err = json.Unmarshal(body, &res) err = json.Unmarshal(body, &res)
if err != nil { if err != nil {
@ -102,7 +102,7 @@ func Request1panel(data *map[string]any, method, providerID, requestUrl string)
return nil, fmt.Errorf("证书部署失败: %s", msg) return nil, fmt.Errorf("证书部署失败: %s", msg)
} }
return res, nil return res, nil
} }
func Deploy1panel(cfg map[string]any) error { func Deploy1panel(cfg map[string]any) error {
@ -128,7 +128,7 @@ func Deploy1panel(cfg map[string]any) error {
if !ok { if !ok {
return fmt.Errorf("证书错误cert") return fmt.Errorf("证书错误cert")
} }
data := map[string]interface{}{ data := map[string]interface{}{
"cert": certPem, "cert": certPem,
"key": keyPem, "key": keyPem,
@ -179,14 +179,14 @@ func Deploy1panelSite(cfg map[string]any) error {
if err != nil { if err != nil {
return fmt.Errorf("获取网站参数失败: %v", err) return fmt.Errorf("获取网站参数失败: %v", err)
} }
siteData, ok = siteData["data"].(map[string]any) siteData, ok = siteData["data"].(map[string]any)
if !ok { if !ok {
return fmt.Errorf("获取网站参数失败: data") return fmt.Errorf("获取网站参数失败: data")
} }
SSLProtocol, ok := siteData["ssl_protocol"].(string) SSLProtocol, ok := siteData["SSLProtocol"].(string)
if !ok { if !ok {
return fmt.Errorf("获取网站参数失败: data.ssl_protocol") return fmt.Errorf("获取网站参数失败: data.SSLProtocol")
} }
algorithm, ok := siteData["algorithm"].(string) algorithm, ok := siteData["algorithm"].(string)
if !ok { if !ok {
@ -200,11 +200,11 @@ func Deploy1panelSite(cfg map[string]any) error {
if !ok { if !ok {
return fmt.Errorf("获取网站参数失败: data.hsts") return fmt.Errorf("获取网站参数失败: data.hsts")
} }
httpConfig, ok := siteData["http_config"].(string) httpConfig, ok := siteData["httpConfig"].(string)
if !ok { if !ok {
return fmt.Errorf("获取网站参数失败: data.http_config") return fmt.Errorf("获取网站参数失败: data.httpConfig")
} }
data := map[string]any{ data := map[string]any{
"SSLProtocol": SSLProtocol, "SSLProtocol": SSLProtocol,
// "acmeAccountId": siteData["SSL"].(map[string]any)["acmeAccountId"].(float64), // "acmeAccountId": siteData["SSL"].(map[string]any)["acmeAccountId"].(float64),