mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 05:31:44 +08:00
fix: 更新阿里云dns
This commit is contained in:
2
go.mod
2
go.mod
@@ -25,7 +25,7 @@ require (
|
||||
github.com/klauspost/compress v1.18.3
|
||||
github.com/leonelquinteros/gotext v1.7.2
|
||||
github.com/lib/pq v1.11.1
|
||||
github.com/libdns/alidns v1.0.6-beta.3
|
||||
github.com/libdns/alidns v1.0.6-beta.3.0.20260121104221-597b1e580e21
|
||||
github.com/libdns/cloudflare v0.2.2
|
||||
github.com/libdns/cloudns v1.1.0
|
||||
github.com/libdns/gcore v0.0.0-20250427050847-9964da923833
|
||||
|
||||
4
go.sum
4
go.sum
@@ -202,8 +202,8 @@ github.com/leonelquinteros/gotext v1.7.2 h1:bDPndU8nt+/kRo1m4l/1OXiiy2v7Z7dfPQ9+
|
||||
github.com/leonelquinteros/gotext v1.7.2/go.mod h1:9/haCkm5P7Jay1sxKDGJ5WIg4zkz8oZKw4ekNpALob8=
|
||||
github.com/lib/pq v1.11.1 h1:wuChtj2hfsGmmx3nf1m7xC2XpK6OtelS2shMY+bGMtI=
|
||||
github.com/lib/pq v1.11.1/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA=
|
||||
github.com/libdns/alidns v1.0.6-beta.3 h1:KAmb7FQ1tRzKsaAUGa7ZpGKAMRANwg7+1c7tUbSELq8=
|
||||
github.com/libdns/alidns v1.0.6-beta.3/go.mod h1:RECwyQ88e9VqQVtSrvX76o1ux3gQUKGzMgxICi+u7Ec=
|
||||
github.com/libdns/alidns v1.0.6-beta.3.0.20260121104221-597b1e580e21 h1:BGtptgrEJGjDQz63r4xkcQ/2ERXpna9WVUtrTtmW8d0=
|
||||
github.com/libdns/alidns v1.0.6-beta.3.0.20260121104221-597b1e580e21/go.mod h1:RECwyQ88e9VqQVtSrvX76o1ux3gQUKGzMgxICi+u7Ec=
|
||||
github.com/libdns/cloudflare v0.2.2 h1:XWHv+C1dDcApqazlh08Q6pjytYLgR2a+Y3xrXFu0vsI=
|
||||
github.com/libdns/cloudflare v0.2.2/go.mod h1:w9uTmRCDlAoafAsTPnn2nJ0XHK/eaUMh86DUk8BWi60=
|
||||
github.com/libdns/cloudns v1.1.0 h1:W+1MadtxKySn3b5RITFTsXgTIvr5VoO5x97cewjlDcs=
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user