mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: 支持一键安装脚本
This commit is contained in:
@@ -17,6 +17,18 @@ input:
|
||||
apiKey
|
||||
required: true
|
||||
encrypt: true
|
||||
version:
|
||||
title: 版本
|
||||
component:
|
||||
name: a-select
|
||||
options:
|
||||
- label: v3.x
|
||||
value: '3'
|
||||
- label: v2.x
|
||||
value: '2'
|
||||
helper: apisix系统的版本
|
||||
value: '3'
|
||||
required: true
|
||||
testRequest:
|
||||
title: 测试
|
||||
component:
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
name: hipmdnsmgr
|
||||
title: HiPM DNSMgr
|
||||
icon: svg:icon-dns
|
||||
desc: HiPM DNSMgr API Token 授权
|
||||
input:
|
||||
endpoint:
|
||||
title: 服务器地址
|
||||
component:
|
||||
name: a-input
|
||||
allowClear: true
|
||||
placeholder: http://localhost:3001
|
||||
required: true
|
||||
helper: 'HiPM DNSMgr 服务器地址,例如: http://localhost:3001'
|
||||
apiToken:
|
||||
title: API Token
|
||||
required: true
|
||||
encrypt: true
|
||||
helper: 在 DNSMgr 设置 > API Token 中创建的令牌
|
||||
testRequest:
|
||||
title: 测试连接
|
||||
component:
|
||||
name: api-test
|
||||
action: TestRequest
|
||||
helper: 点击测试接口是否正常
|
||||
pluginType: access
|
||||
type: builtIn
|
||||
scriptFilePath: /plugins/plugin-hipmdnsmgr/access/hipmdnsmgr-access.js
|
||||
@@ -0,0 +1,53 @@
|
||||
name: nginxProxyManager
|
||||
title: Nginx Proxy Manager 授权
|
||||
desc: 用于登录 Nginx Proxy Manager,并为代理主机证书部署提供授权。
|
||||
icon: logos:nginx
|
||||
input:
|
||||
endpoint:
|
||||
title: NPM 地址
|
||||
component:
|
||||
name: a-input
|
||||
allowClear: true
|
||||
placeholder: https://npm.example.com
|
||||
helper: 请输入 Nginx Proxy Manager 根地址,不要带 /api 后缀。
|
||||
required: true
|
||||
email:
|
||||
title: 邮箱
|
||||
component:
|
||||
name: a-input
|
||||
allowClear: true
|
||||
placeholder: admin@example.com
|
||||
required: true
|
||||
password:
|
||||
title: 密码
|
||||
component:
|
||||
name: a-input-password
|
||||
allowClear: true
|
||||
placeholder: 请输入密码
|
||||
required: true
|
||||
encrypt: true
|
||||
totpSecret:
|
||||
title: TOTP 密钥
|
||||
component:
|
||||
name: a-input-password
|
||||
allowClear: true
|
||||
placeholder: Optional base32 TOTP secret
|
||||
helper: 当 Nginx Proxy Manager 账号开启 2FA 时必填。
|
||||
required: false
|
||||
encrypt: true
|
||||
ignoreTls:
|
||||
title: 忽略无效 TLS
|
||||
component:
|
||||
name: a-switch
|
||||
vModel: checked
|
||||
helper: 仅在 Nginx Proxy Manager 使用自签 HTTPS 证书时开启。
|
||||
required: false
|
||||
testRequest:
|
||||
title: 测试
|
||||
component:
|
||||
name: api-test
|
||||
action: onTestRequest
|
||||
helper: 测试登录并拉取代理主机列表。
|
||||
pluginType: access
|
||||
type: builtIn
|
||||
scriptFilePath: /plugins/plugin-nginx-proxy-manager/access.js
|
||||
@@ -62,8 +62,8 @@ input:
|
||||
pty:
|
||||
title: 伪终端
|
||||
helper: >-
|
||||
如果登录报错:all authentication methods
|
||||
failed,可以尝试开启伪终端模式进行keyboard-interactive方式登录
|
||||
如果登录报错:all authentication methods failed / unable to
|
||||
exec,可以尝试开启伪终端模式进行keyboard-interactive方式登录
|
||||
|
||||
开启后对日志输出有一定的影响
|
||||
component:
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
name: technitium
|
||||
title: Technitium DNS Server
|
||||
icon: clarity:server-line
|
||||
desc: Technitium DNS Server 自建DNS服务器授权
|
||||
input:
|
||||
apiUrl:
|
||||
title: API地址
|
||||
value: http://localhost:5380
|
||||
component:
|
||||
name: a-input
|
||||
allowClear: true
|
||||
placeholder: http://localhost:5380
|
||||
required: true
|
||||
username:
|
||||
title: 用户名
|
||||
component:
|
||||
name: a-input
|
||||
allowClear: true
|
||||
placeholder: admin
|
||||
required: false
|
||||
password:
|
||||
title: 密码
|
||||
component:
|
||||
name: a-input
|
||||
type: password
|
||||
allowClear: true
|
||||
placeholder: 密码
|
||||
required: false
|
||||
encrypt: true
|
||||
testRequest:
|
||||
title: 测试
|
||||
component:
|
||||
name: api-test
|
||||
action: TestRequest
|
||||
helper: 点击测试接口是否正常
|
||||
pluginType: access
|
||||
type: builtIn
|
||||
scriptFilePath: /plugins/plugin-technitium/access.js
|
||||
@@ -0,0 +1,71 @@
|
||||
showRunStrategy: false
|
||||
default:
|
||||
strategy:
|
||||
runStrategy: 1
|
||||
name: NginxProxyManagerDeploy
|
||||
title: Nginx Proxy Manager-部署到主机
|
||||
desc: 上传自定义证书到 Nginx Proxy Manager,并绑定到所选主机。
|
||||
icon: logos:nginx
|
||||
group: panel
|
||||
input:
|
||||
cert:
|
||||
title: 域名证书
|
||||
helper: 请选择前置任务产出的证书。
|
||||
component:
|
||||
name: output-selector
|
||||
from:
|
||||
- ':cert:'
|
||||
required: true
|
||||
order: 0
|
||||
certDomains:
|
||||
title: 证书域名
|
||||
component:
|
||||
name: cert-domains-getter
|
||||
required: false
|
||||
order: 0
|
||||
accessId:
|
||||
title: NPM授权
|
||||
component:
|
||||
name: access-selector
|
||||
type: nginxProxyManager
|
||||
helper: 选择用于部署的 Nginx Proxy Manager 授权。
|
||||
required: true
|
||||
order: 0
|
||||
proxyHostIds:
|
||||
title: 代理主机
|
||||
component:
|
||||
name: remote-select
|
||||
vModel: value
|
||||
mode: tags
|
||||
type: plugin
|
||||
action: onGetProxyHostOptions
|
||||
search: true
|
||||
pager: false
|
||||
multi: true
|
||||
watches:
|
||||
- certDomains
|
||||
- accessId
|
||||
helper: 选择要绑定此证书的一个或多个代理主机。
|
||||
required: true
|
||||
order: 0
|
||||
certificateLabel:
|
||||
title: 证书标识
|
||||
component:
|
||||
name: a-input
|
||||
allowClear: true
|
||||
placeholder: certd_npm_example_com
|
||||
helper: 可选。留空时默认使用 certd_npm_<主域名规范化>。
|
||||
required: false
|
||||
order: 0
|
||||
cleanupMatchingCertificates:
|
||||
title: 自动清理未使用证书
|
||||
component:
|
||||
name: a-switch
|
||||
vModel: checked
|
||||
helper: 部署成功后,自动删除除当前证书外所有未被任何主机引用的证书。
|
||||
required: false
|
||||
order: 0
|
||||
output: {}
|
||||
pluginType: deploy
|
||||
type: builtIn
|
||||
scriptFilePath: /plugins/plugin-nginx-proxy-manager/plugins/plugin-deploy-to-proxy-hosts.js
|
||||
@@ -0,0 +1,8 @@
|
||||
name: hipmdnsmgr
|
||||
title: HiPM DNSMgr
|
||||
desc: HiPM DNSMgr DNS 解析提供商
|
||||
accessType: hipmdnsmgr
|
||||
icon: svg:icon-dns
|
||||
pluginType: dnsProvider
|
||||
type: builtIn
|
||||
scriptFilePath: /plugins/plugin-hipmdnsmgr/dns-provider/hipmdnsmgr-dns-provider.js
|
||||
@@ -0,0 +1,9 @@
|
||||
name: technitium
|
||||
title: Technitium DNS Server
|
||||
desc: Technitium DNS Server 自建DNS服务器
|
||||
icon: clarity:server-line
|
||||
accessType: technitium
|
||||
order: 10
|
||||
pluginType: dnsProvider
|
||||
type: builtIn
|
||||
scriptFilePath: /plugins/plugin-technitium/dns-provider.js
|
||||
@@ -126,12 +126,12 @@ export class NextTerminalAccess extends BaseAccess {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
|
||||
|
||||
this.ctx.logger.debug(`Next Terminal API 请求: ${req.method} ${this.baseUrl}${req.url}`);
|
||||
const baseUrl = this.normalizeEndpoint(this.baseUrl);
|
||||
this.ctx.logger.debug(`Next Terminal API 请求: ${req.method} ${baseUrl}${req.url}`);
|
||||
|
||||
const resp = await this.ctx.http.request({
|
||||
url: req.url,
|
||||
baseURL: this.baseUrl,
|
||||
baseURL: baseUrl,
|
||||
method: req.method,
|
||||
headers,
|
||||
params: req.params,
|
||||
|
||||
@@ -29,25 +29,6 @@ interface TokenResponse {
|
||||
challenge_token?: string;
|
||||
}
|
||||
|
||||
function normalizeEndpoint(endpoint: string): string {
|
||||
const trimmed = String(endpoint ?? "").trim();
|
||||
if (!trimmed) {
|
||||
throw new Error("Nginx Proxy Manager 地址不能为空");
|
||||
}
|
||||
|
||||
const withoutTrailingSlash = trimmed.replace(/\/+$/, "");
|
||||
return withoutTrailingSlash.endsWith("/api")
|
||||
? withoutTrailingSlash.slice(0, -4)
|
||||
: withoutTrailingSlash;
|
||||
}
|
||||
|
||||
function describeError(error: unknown, action: string): Error {
|
||||
if (error instanceof Error) {
|
||||
return new Error(`${action} failed: ${error.message}`);
|
||||
}
|
||||
return new Error(`${action} failed`);
|
||||
}
|
||||
|
||||
@IsAccess({
|
||||
name: "nginxProxyManager",
|
||||
title: "Nginx Proxy Manager 授权",
|
||||
@@ -127,8 +108,27 @@ export class NginxProxyManagerAccess extends BaseAccess {
|
||||
private token: string | undefined;
|
||||
private tokenPromise: Promise<string> | undefined;
|
||||
|
||||
normalizeEndpoint(endpoint: string): string {
|
||||
const trimmed = String(endpoint ?? "").trim();
|
||||
if (!trimmed) {
|
||||
throw new Error("Nginx Proxy Manager 地址不能为空");
|
||||
}
|
||||
|
||||
const withoutTrailingSlash = trimmed.replace(/\/+$/, "");
|
||||
return withoutTrailingSlash.endsWith("/api")
|
||||
? withoutTrailingSlash.slice(0, -4)
|
||||
: withoutTrailingSlash;
|
||||
}
|
||||
|
||||
private describeError(error: unknown, action: string): Error {
|
||||
if (error instanceof Error) {
|
||||
return new Error(`${action} failed: ${error.message}`);
|
||||
}
|
||||
return new Error(`${action} failed`);
|
||||
}
|
||||
|
||||
private get apiBaseUrl(): string {
|
||||
const endpoint = normalizeEndpoint(this.endpoint);
|
||||
const endpoint = this.normalizeEndpoint(this.endpoint);
|
||||
return `${endpoint}/api`;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ export class NginxProxyManagerAccess extends BaseAccess {
|
||||
url: "/nginx/certificates",
|
||||
params: {
|
||||
...(searchQuery ? { query: searchQuery } : {}),
|
||||
...(expand.length > 0 ? { expand: expand.join(",") } : {}),
|
||||
...(expand.length > 0 ? { expand: expand.join(", ") } : {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -286,7 +286,7 @@ export class NginxProxyManagerAccess extends BaseAccess {
|
||||
try {
|
||||
code = authenticator.generate(this.totpSecret);
|
||||
} catch (error) {
|
||||
throw describeError(error, "Generating TOTP code");
|
||||
throw this.describeError(error, "Generating TOTP code");
|
||||
}
|
||||
|
||||
const completedLogin = await this.request<TokenResponse>({
|
||||
@@ -344,9 +344,9 @@ export class NginxProxyManagerAccess extends BaseAccess {
|
||||
rejectUnauthorized: false
|
||||
} : undefined,
|
||||
});
|
||||
return response.data;
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw describeError(error, action);
|
||||
throw this.describeError(error, action);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-9
@@ -5,7 +5,7 @@ import {
|
||||
RunStrategy,
|
||||
TaskInput,
|
||||
} from "@certd/pipeline";
|
||||
import { CertInfo, CertReader } from "@certd/plugin-cert";
|
||||
import { CertInfo, CertReader, createCertDomainGetterInputDefine } from "@certd/plugin-cert";
|
||||
import { NginxProxyManagerAccess, ProxyHost } from "../access.js";
|
||||
|
||||
interface ProxyHostOption {
|
||||
@@ -38,13 +38,7 @@ export class NginxProxyManagerDeploy extends AbstractTaskPlugin {
|
||||
})
|
||||
cert!: CertInfo;
|
||||
|
||||
@TaskInput({
|
||||
title: "证书域名",
|
||||
component: {
|
||||
name: "cert-domains-getter",
|
||||
},
|
||||
required: false,
|
||||
})
|
||||
@TaskInput(createCertDomainGetterInputDefine())
|
||||
certDomains!: string[];
|
||||
|
||||
@TaskInput({
|
||||
@@ -297,7 +291,6 @@ export class NginxProxyManagerDeploy extends AbstractTaskPlugin {
|
||||
"dead_hosts",
|
||||
"streams",
|
||||
]);
|
||||
|
||||
const candidates = certificates.filter((certificate) => {
|
||||
return certificate.id !== currentCertificateId;
|
||||
});
|
||||
|
||||
@@ -124,6 +124,9 @@ export class TechnitiumAccess extends BaseAccess {
|
||||
this.ctx.logger.info(`获取域名列表,req:${JSON.stringify(req)}`);
|
||||
const pager = new Pager(req);
|
||||
|
||||
// 规范API地址
|
||||
this.apiUrl = this.normalizeEndpoint(this.apiUrl);
|
||||
|
||||
// 构建API URL
|
||||
const apiUrl = `${this.apiUrl}/api/zones/list`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user