2015-12-03 20:01:46 +00:00
|
|
|
package acme
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2018-05-30 17:53:04 +00:00
|
|
|
|
|
|
|
"github.com/xenolf/lego/log"
|
2015-12-03 20:01:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
dnsTemplate = "%s %d IN TXT \"%s\""
|
|
|
|
)
|
|
|
|
|
2016-01-15 04:06:25 +00:00
|
|
|
// DNSProviderManual is an implementation of the ChallengeProvider interface
|
2015-12-03 20:01:46 +00:00
|
|
|
type DNSProviderManual struct{}
|
|
|
|
|
|
|
|
// NewDNSProviderManual returns a DNSProviderManual instance.
|
|
|
|
func NewDNSProviderManual() (*DNSProviderManual, error) {
|
|
|
|
return &DNSProviderManual{}, nil
|
|
|
|
}
|
|
|
|
|
2016-01-15 04:06:25 +00:00
|
|
|
// Present prints instructions for manually creating the TXT record
|
|
|
|
func (*DNSProviderManual) Present(domain, token, keyAuth string) error {
|
|
|
|
fqdn, value, ttl := DNS01Record(domain, keyAuth)
|
2015-12-03 20:01:46 +00:00
|
|
|
dnsRecord := fmt.Sprintf(dnsTemplate, fqdn, ttl, value)
|
2016-03-20 22:00:00 +00:00
|
|
|
|
2016-04-11 22:59:59 +00:00
|
|
|
authZone, err := FindZoneByFqdn(fqdn, RecursiveNameservers)
|
2016-03-20 22:00:00 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-05-30 17:53:04 +00:00
|
|
|
log.Printf("[INFO] acme: Please create the following TXT record in your %s zone:", authZone)
|
|
|
|
log.Printf("[INFO] acme: %s", dnsRecord)
|
|
|
|
log.Printf("[INFO] acme: Press 'Enter' when you are done")
|
2016-03-20 22:00:00 +00:00
|
|
|
|
2015-12-03 20:01:46 +00:00
|
|
|
reader := bufio.NewReader(os.Stdin)
|
|
|
|
_, _ = reader.ReadString('\n')
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-01-15 04:06:25 +00:00
|
|
|
// CleanUp prints instructions for manually removing the TXT record
|
|
|
|
func (*DNSProviderManual) CleanUp(domain, token, keyAuth string) error {
|
|
|
|
fqdn, _, ttl := DNS01Record(domain, keyAuth)
|
|
|
|
dnsRecord := fmt.Sprintf(dnsTemplate, fqdn, ttl, "...")
|
2016-03-20 22:00:00 +00:00
|
|
|
|
2016-04-11 22:59:59 +00:00
|
|
|
authZone, err := FindZoneByFqdn(fqdn, RecursiveNameservers)
|
2016-03-20 22:00:00 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-05-30 17:53:04 +00:00
|
|
|
log.Printf("[INFO] acme: You can now remove this TXT record from your %s zone:", authZone)
|
|
|
|
log.Printf("[INFO] acme: %s", dnsRecord)
|
2015-12-03 20:01:46 +00:00
|
|
|
return nil
|
|
|
|
}
|