util

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package util 提供部署插件实现共用的配置与证书转换工具。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseURL added in v1.2.4

func BaseURL(value string) (string, error)

BaseURL 清理并校验用户填写的 HTTP(S) 地址。

func Bool added in v1.2.4

func Bool(value string) bool

Bool 解析常见布尔写法。

func CertName added in v1.2.4

func CertName(cert *deploy.Certificate, prefix string) string

CertName 生成默认证书名称:主域名 + 时间戳。

func Certificate

func Certificate(value protocol.Certificate) *deploy.Certificate

Certificate 把插件协议中的证书材料还原为部署实现使用的结构。

func ChainPEM added in v1.2.4

func ChainPEM(fullchain string) string

ChainPEM 去掉 fullchain 中的第一张叶子证书,返回中间证书链。

func CleanName added in v1.2.4

func CleanName(value string) string

CleanName 把域名转换为适合做资源名称的字符串。

func Client added in v1.2.4

func Client(cfg map[string]string) *http.Client

Client 返回部署插件共用的出站 HTTP 客户端。 skip_verify=true 仅用于用户明确允许的面板自签证书场景。

func ClientWithTimeout added in v1.2.4

func ClientWithTimeout(cfg map[string]string, timeout time.Duration) *http.Client

ClientWithTimeout 返回指定超时的出站客户端。

func DomainMatch added in v1.2.4

func DomainMatch(left, right string) bool

DomainMatch 判断证书域名与目标域名是否匹配,支持通配符。

func Domains added in v1.2.4

func Domains(cert *deploy.Certificate) []string

Domains 返回证书包含的全部域名(去重、去空)。

func DomainsMatch added in v1.2.4

func DomainsMatch(left, right []string) bool

DomainsMatch 判断两组域名是否存在交集。

func FirstDomain added in v1.2.4

func FirstDomain(cert *deploy.Certificate) string

FirstDomain 返回证书主域名,优先 domain,其次 domains 的第一个。

func Int added in v1.2.4

func Int(value string, fallback int) int

Int 解析整数,失败时返回默认值。

func JoinURL added in v1.2.4

func JoinURL(base, path string) string

JoinURL 拼接路径,避免出现重复或缺失的斜杠。

func MatchAny added in v1.2.4

func MatchAny(certDomains, targets []string) bool

MatchAny 判断目标是否与任一证书域名匹配。

func Merge

func Merge(auth, config map[string]string) map[string]string

Merge 合并凭据认证字段与部署节点参数,部署节点中的同名参数优先。

func RawQuery added in v1.2.4

func RawQuery(values map[string]string) string

RawQuery 构造查询字符串,空值会被忽略。

func SplitList

func SplitList(value string) []string

SplitList 按逗号、分号、空白或换行拆分多值配置。

func Truncate

func Truncate(s string, n int) string

Truncate 按字符数截断文本,用于限制错误信息中的响应体大小。

Types

type FlexInt64 added in v1.2.4

type FlexInt64 int64

FlexInt64 兼容 JSON 数字与字符串形式的整数。 部分云厂商在不同版本/地域会混用 "123" 与 123。

func (FlexInt64) Int64 added in v1.2.4

func (v FlexInt64) Int64() int64

Int64 返回底层整数。

func (*FlexInt64) UnmarshalJSON added in v1.2.4

func (v *FlexInt64) UnmarshalJSON(data []byte) error

UnmarshalJSON 实现 json.Unmarshaler。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL