feat: optimize acmedns provider

This commit is contained in:
Fu Diwei 2025-09-03 21:39:07 +08:00
parent d7e20a0b83
commit 5cc2567ba2
12 changed files with 65 additions and 71 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -1,2 +0,0 @@
<svg viewBox="0 0 512 512" version="1.1" xmlns="http://www.w3.org/2000/svg" height="200" width="200">
<circle style="fill:#32BEA6;" cx="256" cy="256" r="256"/><g><path style="fill:#FFFFFF;" d="M58.016,202.296h18.168v42.48h0.296c2.192-3.368,5.128-6.152,8.936-8.2 c3.512-2.056,7.76-3.224,12.304-3.224c12.16,0,24.896,8.064,24.896,30.912v42.04H104.6v-39.992c0-10.4-3.808-18.168-13.776-18.168 c-7.032,0-12.008,4.688-13.912,10.112c-0.584,1.472-0.728,3.368-0.728,5.424v42.624H58.016V202.296z"/><path style="fill:#FFFFFF;" d="M161.76,214.6v20.368h17.144v13.48H161.76v31.496c0,8.64,2.344,13.176,9.224,13.176 c3.08,0,5.424-0.44,7.032-0.872l0.296,13.768c-2.64,1.032-7.328,1.768-13.04,1.768c-6.584,0-12.16-2.2-15.52-5.856 c-3.816-4.112-5.568-10.544-5.568-19.92v-33.544h-10.248V234.96h10.248v-16.12L161.76,214.6z"/><path style="fill:#FFFFFF;" d="M213.192,214.6v20.368h17.144v13.48h-17.144v31.496c0,8.64,2.344,13.176,9.224,13.176 c3.08,0,5.424-0.44,7.032-0.872l0.296,13.768c-2.64,1.032-7.328,1.768-13.04,1.768c-6.584,0-12.16-2.2-15.52-5.856 c-3.816-4.112-5.568-10.544-5.568-19.92v-33.544h-10.248V234.96h10.248v-16.12L213.192,214.6z"/><path style="fill:#FFFFFF;" d="M243.984,258.688c0-9.376-0.296-16.992-0.592-23.728h15.832l0.872,10.984h0.296 c5.264-8.056,13.616-12.6,24.464-12.6c16.408,0,30.024,14.064,30.024,36.328c0,25.784-16.256,38.232-32.512,38.232 c-8.936,0-16.408-3.808-20.072-9.512H262v36.904h-18.016V258.688z M262,276.416c0,1.76,0.144,3.368,0.584,4.976 c1.76,7.328,8.2,12.6,15.824,12.6c11.424,0,18.168-9.52,18.168-23.584c0-12.592-6.16-22.848-17.728-22.848 c-7.472,0-14.36,5.424-16.112,13.336c-0.448,1.464-0.736,3.072-0.736,4.536L262,276.416L262,276.416z"/><path style="fill:#FFFFFF;" d="M327.504,247.12c0-6.744,4.688-11.568,11.136-11.568c6.592,0,10.984,4.832,11.136,11.568 c0,6.592-4.392,11.432-11.136,11.432C332.048,258.552,327.504,253.712,327.504,247.12z M327.504,296.488 c0-6.744,4.688-11.576,11.136-11.576c6.592,0,10.984,4.688,11.136,11.576c0,6.448-4.392,11.424-11.136,11.424 C332.048,307.912,327.504,302.936,327.504,296.488z"/><path style="fill:#FFFFFF;" d="M355.8,312.16l35.744-106.2h12.6l-35.752,106.2H355.8z"/><path style="fill:#FFFFFF;" d="M405.176,312.16l35.744-106.2h12.592l-35.728,106.2H405.176z"/></g></svg>

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -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 (
<>
<Form.Item
name="apiBase"
initialValue={initialValues.apiBase}
label={t("access.form.acmedns_api_base.label")}
name={[parentNamePath, "serverUrl"]}
initialValue={initialValues.serverUrl}
label={t("access.form.acmedns_server_url.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.acmedns_api_base.tooltip") }}></span>}
>
<Input placeholder={t("access.form.acmedns_api_base.placeholder")} />
<Input placeholder={t("access.form.acmedns_server_url.placeholder")} />
</Form.Item>
<Form.Item
name="storageBaseUrl"
initialValue={initialValues.storageBaseUrl}
label={t("access.form.acmedns_storage_base_url.label")}
name={[parentNamePath, "credentials"]}
initialValue={initialValues.credentials}
label={t("access.form.acmedns_credentials.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.acmedns_storage_base_url.tooltip") }}></span>}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.acmedns_credentials.tooltip") }}></span>}
>
<Input allowClear placeholder={t("access.form.acmedns_storage_base_url.placeholder")} />
</Form.Item>
<Form.Item
name="storagePath"
initialValue={initialValues.storagePath}
label={t("access.form.acmedns_storage_path.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.acmedns_storage_path.tooltip") }}></span>}
>
<Input allowClear placeholder={t("access.form.acmedns_storage_path.placeholder")} />
<TextFileInput autoSize={{ minRows: 3, maxRows: 10 }} placeholder={t("access.form.acmedns_credentials.placeholder")} />
</Form.Item>
</>
);
@ -52,9 +43,8 @@ const AccessConfigFieldsProviderACMEDNS = () => {
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
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<typeof getI18n> }) =
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")),
});
};

View File

@ -174,7 +174,7 @@ export const accessProvidersMap: Map<AccessProvider["type"] | string, AccessProv
[ACCESS_PROVIDERS.CMCCCLOUD, "provider.cmcccloud", "/imgs/providers/cmcccloud.svg", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.WESTCN, "provider.westcn", "/imgs/providers/westcn.svg", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.POWERDNS, "provider.powerdns", "/imgs/providers/powerdns.svg", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.ACMEDNS, "provider.acmedns", "/imgs/providers/acmedns.svg", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.ACMEDNS, "provider.acmedns", "/imgs/providers/acmedns.png", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.ACMEHTTPREQ, "provider.acmehttpreq", "/imgs/providers/acmehttpreq.svg", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.LETSENCRYPT, "provider.letsencrypt", "/imgs/providers/letsencrypt.svg", [ACCESS_USAGES.CA], "builtin"],

View File

@ -59,15 +59,12 @@
"access.form.acmeca_eab_kid.placeholder": "Please enter ACME EAB KID",
"access.form.acmeca_eab_hmac_key.label": "ACME EAB HMAC key (Optional)",
"access.form.acmeca_eab_hmac_key.placeholder": "Please enter ACME EAB HMAC key",
"access.form.acmedns_api_base.label": "ACME-DNS API URL",
"access.form.acmedns_api_base.placeholder": "Please enter ACME-DNS API URL",
"access.form.acmedns_api_base.tooltip": "For more information, see <a href=\"https://go-acme.github.io/lego/dns/acme-dns/\" target=\"_blank\">https://go-acme.github.io/lego/dns/acme-dns/</a>",
"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 <a href=\"https://go-acme.github.io/lego/dns/acme-dns/\" target=\"_blank\">https://go-acme.github.io/lego/dns/acme-dns/</a>",
"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 <a href=\"https://go-acme.github.io/lego/dns/acme-dns/\" target=\"_blank\">https://go-acme.github.io/lego/dns/acme-dns/</a>",
"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 <a href=\"https://github.com/joohoi/acme-dns\" target=\"_blank\">https://github.com/joohoi/acme-dns</a>",
"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 <a href=\"https://go-acme.github.io/lego/dns/httpreq/\" target=\"_blank\">https://go-acme.github.io/lego/dns/httpreq/</a>",

View File

@ -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)",

View File

@ -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": "这是什么?请参阅 <a href=\"https://go-acme.github.io/lego/dns/acme-dns/\" target=\"_blank\">https://go-acme.github.io/lego/dns/acme-dns/</a>",
"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": "这是什么?请参阅 <a href=\"https://go-acme.github.io/lego/dns/acme-dns/\" target=\"_blank\">https://go-acme.github.io/lego/dns/acme-dns/</a>",
"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": "这是什么?请参阅 <a href=\"https://go-acme.github.io/lego/dns/acme-dns/\" target=\"_blank\">https://go-acme.github.io/lego/dns/acme-dns/</a>",
"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": "这是什么?请参阅 <a href=\"https://github.com/joohoi/acme-dns\" target=\"_blank\">https://github.com/joohoi/acme-dns</a>",
"access.form.acmedns_credentials.errmsg.json_invalid": "请输入有效的 JSON 格式字符串",
"access.form.acmehttpreq_endpoint.label": "服务端点",
"access.form.acmehttpreq_endpoint.placeholder": "请输入服务端点",
"access.form.acmehttpreq_endpoint.tooltip": "这是什么?请参阅 <a href=\"https://go-acme.github.io/lego/dns/httpreq/\" target=\"_blank\">https://go-acme.github.io/lego/dns/httpreq/</a>",

View File

@ -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",