2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 07:57:21 +08:00

fix: 更新阿里云dns

This commit is contained in:
2026-01-30 18:16:08 +08:00
parent ce83fdd4db
commit 7de7eabca3
3 changed files with 3 additions and 62 deletions

View File

@@ -21,8 +21,6 @@ type Certificate struct {
type Client struct {
Account acme.Account
zClient acmez.Client
// 手动 DNS 所需的信号通道
manualDNSSolver
}
// UseDns 使用 DNS 接口验证
@@ -36,22 +34,6 @@ func (c *Client) UseDns(dnsType DnsType, param DNSParam) {
}
}
// UseManualDns 使用手动 DNS 验证
func (c *Client) UseManualDns(check ...bool) {
c.controlChan = make(chan struct{})
c.dnsChan = make(chan any)
c.certChan = make(chan any)
c.zClient.ChallengeSolvers = map[string]acmez.Solver{
acme.ChallengeTypeDNS01: &manualDNSSolver{
check: len(check) > 0 && check[0],
controlChan: c.controlChan,
dnsChan: c.dnsChan,
certChan: c.certChan,
records: []DNSRecord{},
},
}
}
// UseHTTP 使用 HTTP 验证
// conf 配置文件路径
// webServer web 服务器类型 ("nginx" 或 "apache")
@@ -136,20 +118,6 @@ func (c *Client) ObtainIPCertificate(ctx context.Context, sans []string, keyType
return Certificate{PrivateKey: pemPrivateKey, Certificate: crt}, nil
}
// ObtainCertificateManual 手动验证 SSL 证书
func (c *Client) ObtainCertificateManual() (Certificate, error) {
// 发送信号,开始验证
c.controlChan <- struct{}{}
// 等待验证完成
certs := <-c.certChan
if err, ok := certs.(error); ok {
return Certificate{}, err
}
return certs.(Certificate), nil
}
// RenewCertificate 续签 SSL 证书
func (c *Client) RenewCertificate(ctx context.Context, certUrl string, domains []string, keyType KeyType) (Certificate, error) {
_, err := c.zClient.GetCertificateChain(ctx, c.Account, certUrl)
@@ -160,33 +128,6 @@ func (c *Client) RenewCertificate(ctx context.Context, certUrl string, domains [
return c.ObtainCertificate(ctx, domains, keyType)
}
// GetDNSRecords 获取 DNS 解析(手动设置)
func (c *Client) GetDNSRecords(ctx context.Context, domains []string, keyType KeyType) ([]DNSRecord, error) {
go func(ctx context.Context, domains []string, keyType KeyType) {
certs, err := c.ObtainCertificate(ctx, domains, keyType)
// 将证书和错误信息发送到 certChan
if err != nil {
c.certChan <- err
return
}
c.certChan <- certs
}(ctx, domains, keyType)
// 这里要少一次循环,因为需要卡住最后一次的 dnsChan等待手动 DNS 验证完成
for i := 1; i < len(domains); i++ {
<-c.dnsChan
c.controlChan <- struct{}{}
}
// 因为上面少了一次循环,所以这里接收到的即为完整的 DNS 记录切片
data := <-c.dnsChan
if err, ok := data.(error); ok {
return nil, err
}
return data.([]DNSRecord), nil
}
// GetRenewalInfo 获取续签建议
func (c *Client) GetRenewalInfo(ctx context.Context, cert x509.Certificate) (acme.RenewalInfo, error) {
return c.zClient.GetRenewalInfo(ctx, &cert)