mirror of
https://github.com/joohoi/acme-dns.git
synced 2024-12-22 21:33:51 +07:00
139a0dd03b
* Update deps to support go 1.23 * Test updated golangci config * Fix deprecated ioutil references
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/mholt/acmez/v2/acme"
|
|
)
|
|
|
|
// ChallengeProvider implements go-acme/lego Provider interface which is used for ACME DNS challenge handling
|
|
type ChallengeProvider struct {
|
|
servers []*DNSServer
|
|
}
|
|
|
|
// NewChallengeProvider creates a new instance of ChallengeProvider
|
|
func NewChallengeProvider(servers []*DNSServer) ChallengeProvider {
|
|
return ChallengeProvider{servers: servers}
|
|
}
|
|
|
|
// Present is used for making the ACME DNS challenge token available for DNS
|
|
func (c *ChallengeProvider) Present(ctx context.Context, challenge acme.Challenge) error {
|
|
for _, s := range c.servers {
|
|
s.PersonalKeyAuth = challenge.DNS01KeyAuthorization()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// CleanUp is called after the run to remove the ACME DNS challenge tokens from DNS records
|
|
func (c *ChallengeProvider) CleanUp(ctx context.Context, _ acme.Challenge) error {
|
|
for _, s := range c.servers {
|
|
s.PersonalKeyAuth = ""
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Wait is a dummy function as we are just going to be ready to answer the challenge from the get-go
|
|
func (c *ChallengeProvider) Wait(_ context.Context, _ acme.Challenge) error {
|
|
return nil
|
|
}
|