feat(provider): new acme dns-01 provider: conohavps

This commit is contained in:
Fu Diwei
2026-05-29 23:47:06 +08:00
committed by RHQYZ
parent c89da616c6
commit 795e8df4ad
24 changed files with 1113 additions and 14 deletions
@@ -28,6 +28,7 @@ import AccessConfigFieldsProviderCdnfly from "./AccessConfigFieldsProviderCdnfly
import AccessConfigFieldsProviderCloudflare from "./AccessConfigFieldsProviderCloudflare";
import AccessConfigFieldsProviderClouDNS from "./AccessConfigFieldsProviderClouDNS";
import AccessConfigFieldsProviderCMCCCloud from "./AccessConfigFieldsProviderCMCCCloud";
import AccessConfigFieldsProviderConoHaVPS from "./AccessConfigFieldsProviderConoHaVPS";
import AccessConfigFieldsProviderConstellix from "./AccessConfigFieldsProviderConstellix";
import AccessConfigFieldsProviderCPanel from "./AccessConfigFieldsProviderCPanel";
import AccessConfigFieldsProviderCTCCCloud from "./AccessConfigFieldsProviderCTCCCloud";
@@ -146,6 +147,7 @@ const providerComponentMap: Partial<Record<AccessProviderType, React.ComponentTy
[ACCESS_PROVIDERS.CLOUDFLARE]: AccessConfigFieldsProviderCloudflare,
[ACCESS_PROVIDERS.CLOUDNS]: AccessConfigFieldsProviderClouDNS,
[ACCESS_PROVIDERS.CMCCCLOUD]: AccessConfigFieldsProviderCMCCCloud,
[ACCESS_PROVIDERS.CONOHAVPS]: AccessConfigFieldsProviderConoHaVPS,
[ACCESS_PROVIDERS.CONSTELLIX]: AccessConfigFieldsProviderConstellix,
[ACCESS_PROVIDERS.CPANEL]: AccessConfigFieldsProviderCPanel,
[ACCESS_PROVIDERS.CTCCCLOUD]: AccessConfigFieldsProviderCTCCCloud,
@@ -0,0 +1,236 @@
import { getI18n, useTranslation } from "react-i18next";
import { Form, Input, Select } from "antd";
import { createSchemaFieldRule } from "antd-zod";
import { z } from "zod";
import Show from "@/components/Show";
import { useFormNestedFieldsContext } from "./_context";
const API_VERSION_V2 = "v2" as const;
const API_VERSION_V3 = "v3" as const;
const AccessConfigFormFieldsProviderConoHaVPS = () => {
const { i18n, t } = useTranslation();
const { parentNamePath } = useFormNestedFieldsContext();
const formSchema = z.object({
[parentNamePath]: getSchema({ i18n }),
});
const formRule = createSchemaFieldRule(formSchema);
const formInst = Form.useFormInstance<z.infer<typeof formSchema>>();
const initialValues = getInitialValues();
const fieldApiVersion = Form.useWatch([parentNamePath, "apiVersion"], formInst);
return (
<>
<Form.Item
name={[parentNamePath, "apiVersion"]}
initialValue={initialValues.apiVersion}
label={t("access.form.conohavps_api_version.label")}
rules={[formRule]}
>
<Select
options={[API_VERSION_V2, API_VERSION_V3].map((s) => ({ label: s, value: s }))}
placeholder={t("access.form.conohavps_api_version.placeholder")}
/>
</Form.Item>
<Show>
<Show.Case when={fieldApiVersion === API_VERSION_V2}>
<Form.Item
name={[parentNamePath, "apiUserName"]}
initialValue={initialValues.apiUserName}
label={t("access.form.conohavps_api_v2_username.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.conohavps_api_v2_username.tooltip") }}></span>}
>
<Input autoComplete="new-password" placeholder={t("access.form.conohavps_api_v2_username.placeholder")} />
</Form.Item>
<Form.Item
name={[parentNamePath, "apiPassword"]}
initialValue={initialValues.apiPassword}
label={t("access.form.conohavps_api_v2_password.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.conohavps_api_v2_password.tooltip") }}></span>}
>
<Input.Password autoComplete="new-password" placeholder={t("access.form.conohavps_api_v2_password.placeholder")} />
</Form.Item>
<Form.Item
name={[parentNamePath, "tenantId"]}
initialValue={initialValues.tenantId}
label={t("access.form.conohavps_api_v2_tenant_id.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.conohavps_api_v2_tenant_id.tooltip") }}></span>}
>
<Input placeholder={t("access.form.conohavps_api_v2_tenant_id.placeholder")} />
</Form.Item>
</Show.Case>
<Show.Case when={fieldApiVersion === API_VERSION_V3}>
<Form.Item
name={[parentNamePath, "apiUserId"]}
initialValue={initialValues.apiUserId}
label={t("access.form.conohavps_api_v3_user_id.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.conohavps_api_v3_user_id.tooltip") }}></span>}
>
<Input autoComplete="new-password" placeholder={t("access.form.conohavps_api_v3_user_id.placeholder")} />
</Form.Item>
<Form.Item
name={[parentNamePath, "apiUserName"]}
initialValue={initialValues.apiUserName}
label={t("access.form.conohavps_api_v3_user_name.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.conohavps_api_v3_user_name.tooltip") }}></span>}
>
<Input autoComplete="new-password" placeholder={t("access.form.conohavps_api_v3_user_name.placeholder")} />
</Form.Item>
<Form.Item
name={[parentNamePath, "apiPassword"]}
initialValue={initialValues.apiPassword}
label={t("access.form.conohavps_api_v3_password.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.conohavps_api_v3_password.tooltip") }}></span>}
>
<Input.Password autoComplete="new-password" placeholder={t("access.form.conohavps_api_v3_password.placeholder")} />
</Form.Item>
<Form.Item
name={[parentNamePath, "tenantId"]}
initialValue={initialValues.tenantId}
label={t("access.form.conohavps_api_v3_project_id.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.conohavps_api_v3_project_id.tooltip") }}></span>}
>
<Input placeholder={t("access.form.conohavps_api_v3_project_id.placeholder")} />
</Form.Item>
<Form.Item
name={[parentNamePath, "tenantName"]}
initialValue={initialValues.tenantName}
label={t("access.form.conohavps_api_v3_project_name.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.conohavps_api_v3_project_name.tooltip") }}></span>}
>
<Input placeholder={t("access.form.conohavps_api_v3_project_name.placeholder")} />
</Form.Item>
</Show.Case>
</Show>
</>
);
};
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
return {
apiVersion: API_VERSION_V3,
apiUserId: "",
apiUserName: "",
apiPassword: "",
tenantId: "",
tenantName: "",
};
};
const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) => {
const { t } = i18n;
return z
.object({
apiVersion: z.enum([API_VERSION_V2, API_VERSION_V3]),
apiUserId: z.string().nullish(),
apiUserName: z.string().nullish(),
apiPassword: z.string().nonempty(),
tenantId: z.string().nullish(),
tenantName: z.string().nullish(),
})
.superRefine((values, ctx) => {
switch (values.apiVersion) {
case API_VERSION_V2:
{
const scUserName = z.string().nonempty();
const spUserName = scUserName.safeParse(values.apiUserName);
if (!spUserName.success) {
ctx.addIssue({
code: "custom",
message: z.treeifyError(spUserName.error).errors.join(),
path: ["apiUserName"],
});
}
const scTenantId = z.string().nonempty();
const spTenantId = scTenantId.safeParse(values.tenantId);
if (!spTenantId.success) {
ctx.addIssue({
code: "custom",
message: z.treeifyError(spTenantId.error).errors.join(),
path: ["tenantId"],
});
}
}
break;
case API_VERSION_V3:
{
const scUserId = z.string().nonempty();
const spUserId = scUserId.safeParse(values.apiUserId);
const scUserName = z.string().nonempty();
const spUserName = scUserName.safeParse(values.apiUserName);
if (!spUserId.success && !spUserName.success) {
ctx.addIssue({
code: "custom",
message: z.treeifyError(spUserName.error).errors.join(),
path: ["apiUserName"],
});
} else if (spUserId.success && spUserName.success) {
ctx.addIssue({
code: "custom",
message: t("access.form.conohavps_api_v3_user_id.errmsg.conflict"),
path: ["apiUserId"],
});
ctx.addIssue({
code: "custom",
message: t("access.form.conohavps_api_v3_user_name.errmsg.conflict"),
path: ["apiUserName"],
});
}
const scTenantId = z.string().nonempty();
const spTenantId = scTenantId.safeParse(values.tenantId);
const scTenantName = z.string().nonempty();
const spTenantName = scTenantName.safeParse(values.tenantName);
if (!spTenantId.success && !spTenantName.success) {
ctx.addIssue({
code: "custom",
message: z.treeifyError(spTenantId.error).errors.join(),
path: ["tenantId"],
});
} else if (spTenantId.success && spTenantName.success) {
ctx.addIssue({
code: "custom",
message: t("access.form.conohavps_api_v3_project_id.errmsg.conflict"),
path: ["tenantId"],
});
ctx.addIssue({
code: "custom",
message: t("access.form.conohavps_api_v3_project_name.errmsg.conflict"),
path: ["tenantName"],
});
}
}
break;
}
});
};
const _default = Object.assign(AccessConfigFormFieldsProviderConoHaVPS, {
getInitialValues,
getSchema,
});
export default _default;
+4
View File
@@ -41,6 +41,7 @@ export const ACCESS_PROVIDERS = Object.freeze({
CLOUDFLARE: "cloudflare",
CLOUDNS: "cloudns",
CMCCCLOUD: "cmcccloud",
CONOHAVPS: "conohavps",
CONSTELLIX: "constellix",
CPANEL: "cpanel",
CTCCCLOUD: "ctcccloud",
@@ -213,6 +214,7 @@ export const accessProvidersMap: Map<AccessProvider["type"] | string, AccessProv
[ACCESS_PROVIDERS.BOOKMYNAME, "provider.bookmyname", "/imgs/providers/bookmyname.png", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.CLOUDFLARE, "provider.cloudflare", "/imgs/providers/cloudflare.svg", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.CLOUDNS, "provider.cloudns", "/imgs/providers/cloudns.png", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.CONOHAVPS, "provider.conohavps", "/imgs/providers/conohavps.svg", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.CONSTELLIX, "provider.constellix", "/imgs/providers/constellix.png", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.DESEC, "provider.desec", "/imgs/providers/desec.svg", [ACCESS_USAGES.DNS]],
[ACCESS_PROVIDERS.DIGITALOCEAN, "provider.digitalocean", "/imgs/providers/digitalocean.svg", [ACCESS_USAGES.DNS]],
@@ -375,6 +377,7 @@ export const ACME_DNS01_PROVIDERS = Object.freeze({
CLOUDNS: `${ACCESS_PROVIDERS.CLOUDNS}`,
CMCCCLOUD: `${ACCESS_PROVIDERS.CMCCCLOUD}`, // 兼容旧值,等同于 `CMCCCLOUD_DNS`
CMCCCLOUD_DNS: `${ACCESS_PROVIDERS.CMCCCLOUD}-dns`,
CONOHAVPS: `${ACCESS_PROVIDERS.CONOHAVPS}`,
CONSTELLIX: `${ACCESS_PROVIDERS.CONSTELLIX}`,
CPANEL: `${ACCESS_PROVIDERS.CPANEL}`,
CTCCCLOUD: `${ACCESS_PROVIDERS.CTCCCLOUD}`, // 兼容旧值,等同于 `CTCCCLOUD_SMARTDNS`
@@ -459,6 +462,7 @@ export const acmeDns01ProvidersMap: Map<ACMEDns01Provider["type"] | string, ACME
[ACME_DNS01_PROVIDERS.BUNNY, "provider.bunny"],
[ACME_DNS01_PROVIDERS.CLOUDFLARE, "provider.cloudflare"],
[ACME_DNS01_PROVIDERS.CLOUDNS, "provider.cloudns"],
[ACME_DNS01_PROVIDERS.CONOHAVPS, "provider.conohavps"],
[ACME_DNS01_PROVIDERS.CONSTELLIX, "provider.constellix"],
[ACME_DNS01_PROVIDERS.DESEC, "provider.desec"],
[ACME_DNS01_PROVIDERS.DIGITALOCEAN, "provider.digitalocean"],
+56
View File
@@ -377,6 +377,62 @@
"placeholder": "Please enter CMCC ECloud AccessKeySecret",
"tooltip": "For more information, see <a href=\"https://ecloud.10086.cn/op-help-center/doc/article/49739\" target=\"_blank\">https://ecloud.10086.cn/op-help-center/doc/article/49739</a>"
},
"conohavps_api_version": {
"label": "ConoHa VPS version",
"placeholder": "Please select ConoHa VPS version"
},
"conohavps_api_v2_username": {
"label": "ConoHa VPS API username",
"placeholder": "Please enter ConoHa VPS 2.0 API username",
"tooltip": "For more information, see <a href=\"https://doc.conoha.jp/reference/api-vps2/api-guideline-vps2/api-guideline-v2/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps2/api-guideline-vps2/api-guideline-v2/</a>"
},
"conohavps_api_v2_password": {
"label": "ConoHa VPS API password",
"placeholder": "Please enter ConoHa VPS 2.0 API password",
"tooltip": "For more information, see <a href=\"https://doc.conoha.jp/reference/api-vps2/api-guideline-vps2/api-guideline-v2/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps2/api-guideline-vps2/api-guideline-v2/</a>"
},
"conohavps_api_v2_tenant_id": {
"label": "ConoHa VPS tenant ID",
"placeholder": "Please enter ConoHa VPS 2.0 tenant ID",
"tooltip": "For more information, see <a href=\"https://doc.conoha.jp/reference/api-vps2/api-identity-vps2/identity-post_tokens-v2/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps2/api-identity-vps2/identity-post_tokens-v2/</a>"
},
"conohavps_api_v3_user_id": {
"label": "ConoHa VPS API user ID",
"placeholder": "Please enter ConoHa VPS 3.0 API user ID",
"errmsg": {
"conflict": "Conflict with the \"API user name\", please retain only one field"
},
"tooltip": "For more information, see <a href=\"https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/</a>"
},
"conohavps_api_v3_user_name": {
"label": "ConoHa VPS API user name",
"placeholder": "Please enter ConoHa VPS 3.0 API user name",
"errmsg": {
"conflict": "Conflict with the \"API user ID\", please retain only one field"
},
"tooltip": "For more information, see <a href=\"https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/</a>"
},
"conohavps_api_v3_password": {
"label": "ConoHa VPS API password",
"placeholder": "Please enter ConoHa VPS 3.0 API password",
"tooltip": "For more information, see <a href=\"https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/</a>"
},
"conohavps_api_v3_project_id": {
"label": "ConoHa VPS project ID",
"placeholder": "Please enter ConoHa VPS 3.0 tenant project ID",
"errmsg": {
"conflict": "Conflict with the \"project name\", please retain only one field"
},
"tooltip": "For more information, see <a href=\"https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-get_api_info-v3/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-get_api_info-v3/</a>"
},
"conohavps_api_v3_project_name": {
"label": "ConoHa VPS project name",
"placeholder": "Please enter ConoHa VPS 3.0 tenant project name",
"errmsg": {
"conflict": "Conflict with the \"project ID\", please retain only one field"
},
"tooltip": "For more information, see <a href=\"https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-get_api_info-v3/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-get_api_info-v3/</a>"
},
"constellix_api_key": {
"label": "Constellix API key",
"placeholder": "Please enter Constellix API key",
@@ -95,6 +95,7 @@
"cloudns": "ClouDNS",
"cmcccloud": "China Mobile ECloud",
"cmcccloud_dns": "China Mobile ECloud - DNS",
"conohavps": "ConoHa VPS",
"constellix": "Constellix",
"cpanel": "cPanel",
"ctcccloud": "China Telecom StateCloud",
+56
View File
@@ -375,6 +375,62 @@
"placeholder": "请输入移动云 AccessKeySecret",
"tooltip": "这是什么?请参阅 <a href=\"https://ecloud.10086.cn/op-help-center/doc/article/49739\" target=\"_blank\">https://ecloud.10086.cn/op-help-center/doc/article/49739</a>"
},
"conohavps_api_version": {
"label": "ConoHa VPS 版本",
"placeholder": "请选择 ConoHa VPS 版本"
},
"conohavps_api_v2_username": {
"label": "ConoHa VPS API 用户名",
"placeholder": "请输入 ConoHa VPS 2.0 API 用户名",
"tooltip": "这是什么?请参阅 <a href=\"https://doc.conoha.jp/reference/api-vps2/api-guideline-vps2/api-guideline-v2/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps2/api-guideline-vps2/api-guideline-v2/</a>"
},
"conohavps_api_v2_password": {
"label": "ConoHa VPS API 密码",
"placeholder": "请输入 ConoHa VPS 2.0 API 密码",
"tooltip": "这是什么?请参阅 <a href=\"https://doc.conoha.jp/reference/api-vps2/api-guideline-vps2/api-guideline-v2/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps2/api-guideline-vps2/api-guideline-v2/</a>"
},
"conohavps_api_v2_tenant_id": {
"label": "ConoHa VPS 租户 ID",
"placeholder": "请输入 ConoHa VPS 2.0 租户 ID",
"tooltip": "这是什么?请参阅 <a href=\"https://doc.conoha.jp/reference/api-vps2/api-identity-vps2/identity-post_tokens-v2/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps2/api-identity-vps2/identity-post_tokens-v2/</a>"
},
"conohavps_api_v3_user_id": {
"label": "ConoHa VPS API 用户 ID",
"placeholder": "请输入 ConoHa VPS 3.0 API 用户 ID",
"errmsg": {
"conflict": "与字段「API 用户名」冲突,请二选一"
},
"tooltip": "这是什么?请参阅 <a href=\"https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/</a>"
},
"conohavps_api_v3_user_name": {
"label": "ConoHa VPS API 用户名",
"placeholder": "请输入 ConoHa VPS 3.0 API 用户名",
"errmsg": {
"conflict": "与字段「API 用户 ID」冲突,请二选一"
},
"tooltip": "这是什么?请参阅 <a href=\"https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/</a>"
},
"conohavps_api_v3_password": {
"label": "ConoHa VPS API 密码",
"placeholder": "请输入 ConoHa VPS 3.0 API 密码",
"tooltip": "这是什么?请参阅 <a href=\"https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-create_api_user-v3/</a>"
},
"conohavps_api_v3_project_id": {
"label": "ConoHa VPS 项目 ID",
"placeholder": "请输入 ConoHa VPS 3.0 租户项目 ID",
"errmsg": {
"conflict": "与字段「项目名称」冲突,请二选一"
},
"tooltip": "这是什么?请参阅 <a href=\"https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-get_api_info-v3/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-get_api_info-v3/</a>"
},
"conohavps_api_v3_project_name": {
"label": "ConoHa VPS 项目名称",
"placeholder": "请输入 ConoHa VPS 3.0 租户项目名称",
"errmsg": {
"conflict": "与字段「项目 ID」冲突,请二选一"
},
"tooltip": "这是什么?请参阅 <a href=\"https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-get_api_info-v3/\" target=\"_blank\">https://doc.conoha.jp/reference/api-vps3/api-cp-vps3/cp-get_api_info-v3/</a>"
},
"constellix_api_key": {
"label": "Constellix API Key",
"placeholder": "请输入 Constellix API Key",
@@ -95,6 +95,7 @@
"cloudns": "ClouDNS",
"cmcccloud": "移动云",
"cmcccloud_dns": "移动云 - 云解析 DNS",
"conohavps": "ConoHa VPS",
"constellix": "Constellix",
"cpanel": "cPanel",
"ctcccloud": "天翼云",