diff --git a/internal/certapply/applicators/sp_acmedns.go b/internal/certapply/applicators/sp_acmedns.go index e0814fc9..2a9ca423 100644 --- a/internal/certapply/applicators/sp_acmedns.go +++ b/internal/certapply/applicators/sp_acmedns.go @@ -18,9 +18,8 @@ func init() { } provider, err := acmedns.NewChallengeProvider(&acmedns.ChallengeProviderConfig{ - ApiBase: credentials.ApiBase, - StorageBaseUrl: credentials.StorageBaseUrl, - StoragePath: credentials.StoragePath, + ServerUrl: credentials.ServerUrl, + Credentials: credentials.Credentials, }) return provider, err }); err != nil { diff --git a/internal/domain/access.go b/internal/domain/access.go index 4debd7f8..d43462ed 100644 --- a/internal/domain/access.go +++ b/internal/domain/access.go @@ -33,9 +33,8 @@ type AccessConfigForACMECA struct { } type AccessConfigForACMEDNS struct { - ApiBase string `json:"apiBase"` - StorageBaseUrl string `json:"storageBaseUrl,omitempty"` - StoragePath string `json:"storagePath,omitempty"` + ServerUrl string `json:"serverUrl"` + Credentials string `json:"credentials"` } type AccessConfigForACMEHttpReq struct { diff --git a/internal/tools/mproc/sender.go b/internal/tools/mproc/sender.go index 822be69c..2a2f3add 100644 --- a/internal/tools/mproc/sender.go +++ b/internal/tools/mproc/sender.go @@ -41,7 +41,7 @@ func (s *sender[TIn, TOut]) SendWithContext(ctx context.Context, params *TIn) (* aesCryptor := xcrypto.NewAESCryptor(aesKey) // 准备临时输入文件 - tempIn, err := os.CreateTemp("", "certimate_mprocin_*.tmp") + tempIn, err := os.CreateTemp("", "certimate.mprocin_*.tmp") if err != nil { return nil, fmt.Errorf("failed to create temp input file: %w", err) } else { @@ -64,7 +64,7 @@ func (s *sender[TIn, TOut]) SendWithContext(ctx context.Context, params *TIn) (* defer os.Remove(tempIn.Name()) // 准备临时输出文件 - tempOut, err := os.CreateTemp("", "certimate_mprocout_*.tmp") + tempOut, err := os.CreateTemp("", "certimate.mprocout_*.tmp") if err != nil { return nil, fmt.Errorf("failed to create temp output file: %w", err) } else { @@ -73,7 +73,7 @@ func (s *sender[TIn, TOut]) SendWithContext(ctx context.Context, params *TIn) (* defer os.Remove(tempOut.Name()) // 准备临时错误文件 - tempErr, err := os.CreateTemp("", "certimate_mprocerr_*.tmp") + tempErr, err := os.CreateTemp("", "certimate.mprocerr_*.tmp") if err != nil { return nil, fmt.Errorf("failed to create temp error file: %w", err) } else { diff --git a/pkg/core/ssl-applicator/acme-dns01/providers/acmedns/acmedns.go b/pkg/core/ssl-applicator/acme-dns01/providers/acmedns/acmedns.go index 992766f8..33f95652 100644 --- a/pkg/core/ssl-applicator/acme-dns01/providers/acmedns/acmedns.go +++ b/pkg/core/ssl-applicator/acme-dns01/providers/acmedns/acmedns.go @@ -2,7 +2,8 @@ package acmedns import ( "errors" - "net/url" + "fmt" + "os" "github.com/go-acme/lego/v4/providers/dns/acmedns" @@ -10,9 +11,8 @@ import ( ) type ChallengeProviderConfig struct { - ApiBase string `json:"apiBase,omitempty"` - StorageBaseUrl string `json:"storageBaseUrl,omitempty"` - StoragePath string `json:"storagePath,omitempty"` + ServerUrl string `json:"serverUrl"` + Credentials string `json:"credentials"` } func NewChallengeProvider(config *ChallengeProviderConfig) (core.ACMEChallenger, error) { @@ -20,11 +20,20 @@ func NewChallengeProvider(config *ChallengeProviderConfig) (core.ACMEChallenger, return nil, errors.New("the configuration of the acme challenge provider is nil") } - ApiBase, _ := url.Parse(config.ApiBase) + tempfile, err := os.CreateTemp("", "certimate.acmedns_*.tmp") + if err != nil { + return nil, fmt.Errorf("failed to create temp credentials file: %w", err) + } else { + if _, err := tempfile.Write([]byte(config.Credentials)); err != nil { + return nil, fmt.Errorf("failed to write temp credentials file: %w", err) + } + + tempfile.Close() + } + providerConfig := acmedns.NewDefaultConfig() - providerConfig.APIBase = ApiBase.String() - providerConfig.StorageBaseURL = config.StorageBaseUrl - providerConfig.StoragePath = config.StoragePath + providerConfig.APIBase = config.ServerUrl + providerConfig.StoragePath = tempfile.Name() provider, err := acmedns.NewDNSProviderConfig(providerConfig) if err != nil { diff --git a/ui/public/imgs/providers/acmedns.png b/ui/public/imgs/providers/acmedns.png new file mode 100644 index 00000000..9d0f5a9f Binary files /dev/null and b/ui/public/imgs/providers/acmedns.png differ diff --git a/ui/public/imgs/providers/acmedns.svg b/ui/public/imgs/providers/acmedns.svg deleted file mode 100644 index 936ca077..00000000 --- a/ui/public/imgs/providers/acmedns.svg +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/ui/src/components/access/forms/AccessConfigFieldsProviderACMEDNS.tsx b/ui/src/components/access/forms/AccessConfigFieldsProviderACMEDNS.tsx index 3a0c21a1..c26cd012 100644 --- a/ui/src/components/access/forms/AccessConfigFieldsProviderACMEDNS.tsx +++ b/ui/src/components/access/forms/AccessConfigFieldsProviderACMEDNS.tsx @@ -3,6 +3,8 @@ import { Form, Input } from "antd"; import { createSchemaFieldRule } from "antd-zod"; import { z } from "zod/v4"; +import TextFileInput from "@/components/TextFileInput"; + import { useFormNestedFieldsContext } from "./_context"; const AccessConfigFieldsProviderACMEDNS = () => { @@ -18,33 +20,22 @@ const AccessConfigFieldsProviderACMEDNS = () => { return ( <> } > - + } + tooltip={} > - - - - } - > - + ); @@ -52,9 +43,8 @@ const AccessConfigFieldsProviderACMEDNS = () => { const getInitialValues = (): Nullish>> => { return { - apiBase: "https://auth.acme-dns.io/", - storageBaseUrl: "", - storagePath: "", + serverUrl: "https://auth.acme-dns.io/", + credentials: "", }; }; @@ -62,15 +52,20 @@ const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType }) = const { t } = i18n; return z.object({ - apiBase: z.url(t("common.errmsg.url_invalid")), - storageBaseUrl: z + serverUrl: z.url(t("common.errmsg.url_invalid")), + credentials: z .string() - .max(256, t("common.errmsg.string_max", { max: 256 })) - .nullish(), - storagePath: z - .string() - .max(256, t("common.errmsg.string_max", { max: 256 })) - .nullish(), + .max(20480, t("common.errmsg.string_max", { max: 20480 })) + .refine((v) => { + if (!v) return false; + + try { + const obj = JSON.parse(v); + return typeof obj === "object" && !Array.isArray(obj); + } catch { + return false; + } + }, t("access.form.acmedns_credentials.errmsg.json_invalid")), }); }; diff --git a/ui/src/domain/provider.ts b/ui/src/domain/provider.ts index 4e2102e3..13bd180d 100644 --- a/ui/src/domain/provider.ts +++ b/ui/src/domain/provider.ts @@ -174,7 +174,7 @@ export const accessProvidersMap: Maphttps://go-acme.github.io/lego/dns/acme-dns/", - "access.form.acmedns_storage_base_url.label": "ACME-DNS Credentials URL PATH", - "access.form.acmedns_storage_base_url.placeholder": "Enter the URL path to the ACME-DNS JSON credentials JSON file. Each credentials are stored in a separate JSON file. This file will be used for TXT record updates.", - "access.form.acmedns_storage_base_url.tooltip": "For more information, see https://go-acme.github.io/lego/dns/acme-dns/", - "access.form.acmedns_storage_path.label": "ACME-DNS Credentials Local Path", - "access.form.acmedns_storage_path.placeholder": "Please enter the ACME-DNS JSON Credentials JSON File Path. Each credentials are in a separate JSON file. It will be used for TXT record updates.", - "access.form.acmedns_storage_path.tooltip": "For more information, see https://go-acme.github.io/lego/dns/acme-dns/", + "access.form.acmedns_server_url.label": "ACME-DNS server URL", + "access.form.acmedns_server_url.placeholder": "Please enter ACME-DNS server URL", + "access.form.acmedns_credentials.label": "ACME-DNS credentials", + "access.form.acmedns_credentials.placeholder": "Please enter ACME-DNS credentials", + "access.form.acmedns_credentials.tooltip": "For more information, see https://github.com/joohoi/acme-dns", + "access.form.acmedns_credentials.errmsg.json_invalid": "Please enter a valiod JSON string", "access.form.acmehttpreq_endpoint.label": "Endpoint", "access.form.acmehttpreq_endpoint.placeholder": "Please enter endpoint", "access.form.acmehttpreq_endpoint.tooltip": "For more information, see https://go-acme.github.io/lego/dns/httpreq/", diff --git a/ui/src/i18n/locales/en/nls.provider.json b/ui/src/i18n/locales/en/nls.provider.json index eb0b16b6..0607dbbf 100644 --- a/ui/src/i18n/locales/en/nls.provider.json +++ b/ui/src/i18n/locales/en/nls.provider.json @@ -3,7 +3,7 @@ "provider.1panel.console": "1Panel - Console itself", "provider.1panel.site": "1Panel - Website", "provider.acmeca": "ACME Custom CA Endpoint", - "provider.acmedns": "ACME DNS", + "provider.acmedns": "ACME-DNS", "provider.acmehttpreq": "ACME Custom HTTP Endpoint", "provider.aliyun": "Alibaba Cloud", "provider.aliyun.alb": "Alibaba Cloud - ALB (Application Load Balancer)", diff --git a/ui/src/i18n/locales/zh/nls.access.json b/ui/src/i18n/locales/zh/nls.access.json index 4d232911..d97447a7 100644 --- a/ui/src/i18n/locales/zh/nls.access.json +++ b/ui/src/i18n/locales/zh/nls.access.json @@ -58,15 +58,12 @@ "access.form.acmeca_eab_kid.placeholder": "请输入 ACME EAB KID", "access.form.acmeca_eab_hmac_key.label": "ACME EAB HMAC Key(可选)", "access.form.acmeca_eab_hmac_key.placeholder": "请输入 ACME EAB HMAC Key", - "access.form.acmedns_api_base.label": "ACME-DNS API 地址", - "access.form.acmedns_api_base.placeholder": "请输入 ACME-DNS API 地址", - "access.form.acmedns_api_base.tooltip": "这是什么?请参阅 https://go-acme.github.io/lego/dns/acme-dns/", - "access.form.acmedns_storage_base_url.label": "ACME-DNS JSON 帐户数据服务器", - "access.form.acmedns_storage_base_url.placeholder": "请输入 ACME-DNS JSON 帐户数据服务器地址", - "access.form.acmedns_storage_base_url.tooltip": "这是什么?请参阅 https://go-acme.github.io/lego/dns/acme-dns/", - "access.form.acmedns_storage_path.label": "ACME-DNS JSON 帐户数据文件", - "access.form.acmedns_storage_path.placeholder": "ACME-DNS JSON 帐户数据文件。每个域的帐户都将注册/保存到此文件,并用于 TXT 更新。", - "access.form.acmedns_storage_path.tooltip": "这是什么?请参阅 https://go-acme.github.io/lego/dns/acme-dns/", + "access.form.acmedns_server_url.label": "ACME-DNS 服务地址", + "access.form.acmedns_server_url.placeholder": "请输入 ACME-DNS 服务地址", + "access.form.acmedns_credentials.label": "ACME-DNS 凭证文件", + "access.form.acmedns_credentials.placeholder": "请输入 ACME-DNS 凭证文件", + "access.form.acmedns_credentials.tooltip": "这是什么?请参阅 https://github.com/joohoi/acme-dns", + "access.form.acmedns_credentials.errmsg.json_invalid": "请输入有效的 JSON 格式字符串", "access.form.acmehttpreq_endpoint.label": "服务端点", "access.form.acmehttpreq_endpoint.placeholder": "请输入服务端点", "access.form.acmehttpreq_endpoint.tooltip": "这是什么?请参阅 https://go-acme.github.io/lego/dns/httpreq/", diff --git a/ui/src/i18n/locales/zh/nls.provider.json b/ui/src/i18n/locales/zh/nls.provider.json index c4592212..2f1b6429 100644 --- a/ui/src/i18n/locales/zh/nls.provider.json +++ b/ui/src/i18n/locales/zh/nls.provider.json @@ -3,7 +3,7 @@ "provider.1panel.console": "1Panel - 面板自身", "provider.1panel.site": "1Panel - 网站", "provider.acmeca": "ACME 自定义 CA 端点", - "provider.acmedns": "ACME DNS", + "provider.acmedns": "ACME-DNS", "provider.acmehttpreq": "ACME 自定义 HTTP 端点", "provider.aliyun": "阿里云", "provider.aliyun.alb": "阿里云 - 应用型负载均衡 ALB",