2019-03-11 16:56:48 +00:00
|
|
|
package dns01
|
2018-12-06 21:50:17 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2019-05-06 18:11:06 +00:00
|
|
|
"time"
|
2018-12-06 21:50:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
dnsTemplate = `%s %d IN TXT "%s"`
|
|
|
|
)
|
|
|
|
|
2020-05-08 17:35:25 +00:00
|
|
|
// DNSProviderManual is an implementation of the ChallengeProvider interface.
|
2018-12-06 21:50:17 +00:00
|
|
|
type DNSProviderManual struct{}
|
|
|
|
|
|
|
|
// NewDNSProviderManual returns a DNSProviderManual instance.
|
|
|
|
func NewDNSProviderManual() (*DNSProviderManual, error) {
|
|
|
|
return &DNSProviderManual{}, nil
|
|
|
|
}
|
|
|
|
|
2020-05-08 17:35:25 +00:00
|
|
|
// Present prints instructions for manually creating the TXT record.
|
2018-12-06 21:50:17 +00:00
|
|
|
func (*DNSProviderManual) Present(domain, token, keyAuth string) error {
|
|
|
|
fqdn, value := GetRecord(domain, keyAuth)
|
|
|
|
|
|
|
|
authZone, err := FindZoneByFqdn(fqdn)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("lego: Please create the following TXT record in your %s zone:\n", authZone)
|
|
|
|
fmt.Printf(dnsTemplate+"\n", fqdn, DefaultTTL, value)
|
|
|
|
fmt.Printf("lego: Press 'Enter' when you are done\n")
|
|
|
|
|
|
|
|
_, err = bufio.NewReader(os.Stdin).ReadBytes('\n')
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-05-08 17:35:25 +00:00
|
|
|
// CleanUp prints instructions for manually removing the TXT record.
|
2018-12-06 21:50:17 +00:00
|
|
|
func (*DNSProviderManual) CleanUp(domain, token, keyAuth string) error {
|
|
|
|
fqdn, _ := GetRecord(domain, keyAuth)
|
|
|
|
|
|
|
|
authZone, err := FindZoneByFqdn(fqdn)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("lego: You can now remove this TXT record from your %s zone:\n", authZone)
|
|
|
|
fmt.Printf(dnsTemplate+"\n", fqdn, DefaultTTL, "...")
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2019-05-06 18:11:06 +00:00
|
|
|
|
|
|
|
// Sequential All DNS challenges for this provider will be resolved sequentially.
|
|
|
|
// Returns the interval between each iteration.
|
|
|
|
func (d *DNSProviderManual) Sequential() time.Duration {
|
|
|
|
return DefaultPropagationTimeout
|
|
|
|
}
|