Documentation
¶
Overview ¶
Package protocol 定义 LACTSSL 插件协议 v1 的线格式。
该包不依赖任何第三方库,主程序与插件仓库都直接引用它, 避免协议结构出现两份定义。
Index ¶
- Constants
- type Certificate
- type DNSCondition
- type DNSField
- type DNSManifest
- type DNSOption
- type DNSProvider
- type DNSRequest
- type DeployCondition
- type DeployField
- type DeployManifest
- type DeployOption
- type DeployOptionsRequest
- type DeployOptionsResponse
- type DeployRequest
- type Deployer
- type NotifyChannel
- type NotifyField
- type NotifyManifest
- type NotifyOption
- type NotifyRequest
- type VerifyCheck
- type VerifyResponse
Constants ¶
const ( // MemoryLimitEnv 是主程序传入的常驻内存预算(字节)。 MemoryLimitEnv = "LACTSSL_PLUGIN_MEMORY_LIMIT" // ProtocolEnv 是主程序传入的协议版本。 ProtocolEnv = "LACTSSL_PLUGIN_PROTOCOL" // DeployFeaturesEnv 是主程序声明的部署插件特性列表(逗号分隔)。 DeployFeaturesEnv = "LACTSSL_DEPLOY_PLUGIN_FEATURES" // DNSFeaturesEnv 是主程序声明的 DNS 插件特性列表(逗号分隔)。 DNSFeaturesEnv = "LACTSSL_DNS_PLUGIN_FEATURES" )
helper 进程的环境变量约定。
const ( VerifyStatusOK = "ok" VerifyStatusFailed = "failed" VerifyStatusSkipped = "skipped" VerifyStatusUnsupported = "unsupported" VerifyStatusError = "error" )
验证检查项状态。
const FeatureDynamicOptions = "dynamic-options-v1"
FeatureDynamicOptions 告知部署 helper 宿主支持 options 子命令和 fields[].options_source / multiple 元数据。旧版宿主不会声明该特性, helper 因此继续输出与旧版完全一致的 manifest。
const FeatureMergedDeployers = "merged-deployers-v1"
FeatureMergedDeployers 告知部署 helper 只输出合并后的规范目标。
const FeatureVerify = "verify-v1"
FeatureVerify 表示服务商/部署目标支持 verify 子命令的只读探测。
const ProtocolVersion = "v1"
ProtocolVersion 是当前 helper 协议版本。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Certificate ¶
type Certificate struct {
Domain string `json:"domain"`
Domains []string `json:"domains,omitempty"`
Issuer string `json:"issuer,omitempty"`
Serial string `json:"serial,omitempty"`
NotBefore string `json:"not_before,omitempty"`
NotAfter string `json:"not_after,omitempty"`
CertPEM string `json:"cert_pem"`
FullchainPEM string `json:"fullchain_pem"`
KeyPEM string `json:"key_pem"`
}
Certificate 是交给插件的最小证书材料。 私钥只通过 stdin 传递,不写入 argv 或环境变量。
type DNSCondition ¶
DNSCondition 描述字段显示条件。
type DNSField ¶
type DNSField struct {
Key string `json:"key"`
Label string `json:"label"`
LabelI18n map[string]string `json:"label_i18n,omitempty"`
Type string `json:"type"`
Required bool `json:"required,omitempty"`
Secret bool `json:"secret,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
PlaceholderI18n map[string]string `json:"placeholder_i18n,omitempty"`
Help string `json:"help,omitempty"`
HelpI18n map[string]string `json:"help_i18n,omitempty"`
Default string `json:"default,omitempty"`
Options []DNSOption `json:"options,omitempty"`
ShowIf *DNSCondition `json:"show_if,omitempty"`
}
DNSField 描述外部服务商的配置字段,与内置 FieldDef 的 JSON 结构保持兼容。
type DNSManifest ¶
type DNSManifest struct {
// Protocol 目前固定为 v1。
Protocol string `json:"protocol"`
// Capabilities 是 helper 级能力位,例如 verify-v1。
Capabilities []string `json:"capabilities,omitempty"`
// Name 是 helper 的可读名称,仅用于日志与展示。
Name string `json:"name,omitempty"`
// Version 是 helper 版本号,仅用于展示。
Version string `json:"version,omitempty"`
// SHA256 是 helper 可执行文件的 sha256;非空时主程序会校验。
SHA256 string `json:"sha256,omitempty"`
// Providers 是该 helper 支持的服务商列表。
Providers []DNSProvider `json:"providers"`
}
DNSManifest 是 DNS helper 通过 `manifest` 子命令输出的协议描述。
type DNSOption ¶
type DNSOption struct {
Label string `json:"label"`
LabelI18n map[string]string `json:"label_i18n,omitempty"`
Value string `json:"value"`
}
DNSOption 是下拉选项。
type DNSProvider ¶
type DNSProvider struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
NameI18n map[string]string `json:"name_i18n,omitempty"`
Description string `json:"description,omitempty"`
DescriptionI18n map[string]string `json:"description_i18n,omitempty"`
Aliases []string `json:"aliases,omitempty"`
Fields []DNSField `json:"fields,omitempty"`
// Capabilities 非空表示该服务商支持 verify 子命令中的只读探测。
Capabilities []string `json:"capabilities,omitempty"`
}
DNSProvider 描述一个由 helper 提供的 DNS 服务商。 Name/Description 是默认语言,*I18n 是可选的多语言覆盖表;旧版宿主忽略。
type DNSRequest ¶
type DNSRequest struct {
Action string `json:"action"`
Provider string `json:"provider"`
Config map[string]string `json:"config,omitempty"`
Domain string `json:"domain,omitempty"`
Token string `json:"token,omitempty"`
KeyAuth string `json:"key_auth,omitempty"`
// Mode 仅用于 verify:read 表示只读探测。
Mode string `json:"mode,omitempty"`
// Locale 让 helper 返回对应语言的检查消息。
Locale string `json:"locale,omitempty"`
}
DNSRequest 是 present / cleanup / verify 的 stdin 请求。
type DeployCondition ¶
type DeployCondition struct {
Key string `json:"key"`
Value string `json:"value,omitempty"`
Values []string `json:"values,omitempty"`
}
DeployCondition 描述字段显示条件。 Value 兼容单值条件;Values 非空时表示满足任一值即可显示。
type DeployField ¶
type DeployField struct {
Key string `json:"key"`
Label string `json:"label"`
LabelI18n map[string]string `json:"label_i18n,omitempty"`
Type string `json:"type"`
Required bool `json:"required,omitempty"`
Secret bool `json:"secret,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
PlaceholderI18n map[string]string `json:"placeholder_i18n,omitempty"`
Help string `json:"help,omitempty"`
HelpI18n map[string]string `json:"help_i18n,omitempty"`
Default string `json:"default,omitempty"`
Options []DeployOption `json:"options,omitempty"`
ShowIf *DeployCondition `json:"show_if,omitempty"`
// OptionsSource 非空表示选项由插件动态提供。新版宿主会调用
// helper 的 options 子命令读取当前可选项;旧版宿主忽略该字段并按普通
// text/select 字段渲染。
OptionsSource string `json:"options_source,omitempty"`
// Multiple 表示宿主应允许选择多个值;字段值仍以逗号分隔的字符串保存。
Multiple bool `json:"multiple,omitempty"`
}
DeployField 描述外部部署目标的配置字段。
type DeployManifest ¶
type DeployManifest struct {
Protocol string `json:"protocol"`
// Capabilities 是 helper 级能力位,例如 verify-v1。
Capabilities []string `json:"capabilities,omitempty"`
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
SHA256 string `json:"sha256,omitempty"`
// Deployers 是该 helper 支持的部署目标列表。
Deployers []Deployer `json:"deployers"`
}
DeployManifest 是部署 helper 通过 `manifest` 子命令输出的协议描述。
type DeployOption ¶
type DeployOption struct {
Label string `json:"label"`
LabelI18n map[string]string `json:"label_i18n,omitempty"`
Value string `json:"value"`
}
DeployOption 是下拉选项。
type DeployOptionsRequest ¶ added in v1.3.8
type DeployOptionsRequest struct {
Action string `json:"action"`
Protocol string `json:"protocol,omitempty"`
Provider string `json:"provider"`
Field string `json:"field"`
Source string `json:"source,omitempty"`
Query string `json:"query,omitempty"`
Auth map[string]string `json:"auth,omitempty"`
Config map[string]string `json:"config,omitempty"`
}
DeployOptionsRequest 是 options 的 stdin 请求。 宿主只传入当前字段与已保存的凭据/部署参数,插件负责调用远端 API。
type DeployOptionsResponse ¶ added in v1.3.8
type DeployOptionsResponse struct {
Options []DeployOption `json:"options"`
}
DeployOptionsResponse 是 options 的 stdout 响应。
type DeployRequest ¶
type DeployRequest struct {
Action string `json:"action"`
Protocol string `json:"protocol,omitempty"`
Provider string `json:"provider"`
Auth map[string]string `json:"auth,omitempty"`
Config map[string]string `json:"config,omitempty"`
Certificate Certificate `json:"certificate"`
// Mode 仅用于 verify:read 表示只读探测。
Mode string `json:"mode,omitempty"`
// Locale 让 helper 返回对应语言的检查消息。
Locale string `json:"locale,omitempty"`
}
DeployRequest 是 deploy / verify 的 stdin 请求。
type Deployer ¶
type Deployer struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
NameI18n map[string]string `json:"name_i18n,omitempty"`
Description string `json:"description,omitempty"`
DescriptionI18n map[string]string `json:"description_i18n,omitempty"`
Aliases []string `json:"aliases,omitempty"`
Fields []DeployField `json:"fields,omitempty"`
// DeployFields 是任务流程部署节点中的参数。
DeployFields []DeployField `json:"deploy_fields,omitempty"`
// Capabilities 非空表示该部署目标支持 verify 子命令中的只读探测。
Capabilities []string `json:"capabilities,omitempty"`
}
Deployer 描述一个由 helper 提供的部署目标。 Name 与 Description 是默认语言,*I18n 是可选的多语言覆盖表; 旧版宿主忽略这些字段,新版宿主按当前语言优先取覆盖值。
type NotifyChannel ¶
type NotifyChannel struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Aliases []string `json:"aliases,omitempty"`
// Fields 是渠道配置字段;secret 或 password 字段会被脱敏并加密保存。
Fields []NotifyField `json:"fields,omitempty"`
}
NotifyChannel 描述一个由 helper 提供的通知渠道。
type NotifyField ¶
type NotifyField struct {
Key string `json:"key"`
Label string `json:"label,omitempty"`
LabelKey string `json:"label_key,omitempty"`
Type string `json:"type,omitempty"`
Required bool `json:"required,omitempty"`
Secret bool `json:"secret,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Help string `json:"help,omitempty"`
Default string `json:"default,omitempty"`
Options []NotifyOption `json:"options,omitempty"`
}
NotifyField 描述通知渠道的配置字段。 LabelKey 供官方前端做本地化;第三方插件可以直接使用 Label。
type NotifyManifest ¶
type NotifyManifest struct {
Protocol string `json:"protocol"`
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
SHA256 string `json:"sha256,omitempty"`
// Channels 是该 helper 支持的通知渠道列表。
Channels []NotifyChannel `json:"channels"`
}
NotifyManifest 是通知 helper 通过 `manifest` 子命令输出的协议描述。
type NotifyOption ¶
type NotifyOption struct {
Label string `json:"label,omitempty"`
LabelKey string `json:"label_key,omitempty"`
Value string `json:"value"`
}
NotifyOption 是下拉选项。
type NotifyRequest ¶
type NotifyRequest struct {
Action string `json:"action"`
Protocol string `json:"protocol,omitempty"`
Channel string `json:"channel"`
Config map[string]any `json:"config,omitempty"`
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
}
NotifyRequest 是 send 的 stdin 请求。
type VerifyCheck ¶ added in v1.3.8
type VerifyCheck struct {
Key string `json:"key"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
}
VerifyCheck 是一项只读探测结果。
type VerifyResponse ¶ added in v1.3.8
type VerifyResponse struct {
OK bool `json:"ok"`
Checks []VerifyCheck `json:"checks"`
}
VerifyResponse 是 verify 子命令的 stdout 响应。