forked from TrueCloudLab/lego
arvandcloud: fix record name. (#1202)
This commit is contained in:
parent
6ada79b536
commit
8630274c31
9 changed files with 36 additions and 36 deletions
|
@ -201,7 +201,7 @@ func (d *DNSProvider) newTxtRecord(zone, fqdn, value string) (*alidns.AddDomainR
|
||||||
request.DomainName = zone
|
request.DomainName = zone
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
request.RR, err = d.extractRecordName(fqdn, zone)
|
request.RR, err = extractRecordName(fqdn, zone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ func (d *DNSProvider) findTxtRecords(domain, fqdn string) ([]alidns.Record, erro
|
||||||
return records, fmt.Errorf("API call has failed: %w", err)
|
return records, fmt.Errorf("API call has failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
recordName, err := d.extractRecordName(fqdn, zoneName)
|
recordName, err := extractRecordName(fqdn, zoneName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -242,8 +242,8 @@ func (d *DNSProvider) findTxtRecords(domain, fqdn string) ([]alidns.Record, erro
|
||||||
return records, nil
|
return records, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) extractRecordName(fqdn, domain string) (string, error) {
|
func extractRecordName(fqdn, zone string) (string, error) {
|
||||||
asciiDomain, err := idna.ToASCII(domain)
|
asciiDomain, err := idna.ToASCII(zone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("fail to convert punycode: %w", err)
|
return "", fmt.Errorf("fail to convert punycode: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
|
|
||||||
record := internal.DNSRecord{
|
record := internal.DNSRecord{
|
||||||
Type: "txt",
|
Type: "txt",
|
||||||
Name: d.extractRecordName(fqdn, domain),
|
Name: extractRecordName(fqdn, authZone),
|
||||||
Value: internal.TXTRecordValue{Text: value},
|
Value: internal.TXTRecordValue{Text: value},
|
||||||
TTL: d.config.TTL,
|
TTL: d.config.TTL,
|
||||||
UpstreamHTTPS: "default",
|
UpstreamHTTPS: "default",
|
||||||
|
@ -177,9 +177,9 @@ func getZone(fqdn string) (string, error) {
|
||||||
return dns01.UnFqdn(authZone), nil
|
return dns01.UnFqdn(authZone), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) extractRecordName(fqdn, domain string) string {
|
func extractRecordName(fqdn, zone string) string {
|
||||||
name := dns01.UnFqdn(fqdn)
|
name := dns01.UnFqdn(fqdn)
|
||||||
if idx := strings.Index(name, "."+domain); idx != -1 {
|
if idx := strings.Index(name, "."+zone); idx != -1 {
|
||||||
return name[:idx]
|
return name[:idx]
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
|
|
|
@ -202,9 +202,9 @@ func newTxtRecord(zoneName, fqdn, value string, ttl int) dnsimple.ZoneRecordAttr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractRecordName(fqdn, domain string) string {
|
func extractRecordName(fqdn, zone string) string {
|
||||||
name := dns01.UnFqdn(fqdn)
|
name := dns01.UnFqdn(fqdn)
|
||||||
if idx := strings.Index(name, "."+domain); idx != -1 {
|
if idx := strings.Index(name, "."+zone); idx != -1 {
|
||||||
return name[:idx]
|
return name[:idx]
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
|
|
|
@ -157,7 +157,7 @@ func (d *DNSProvider) getHostedZone(domain string) (string, string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) newTxtRecord(zone, fqdn, value string, ttl int) *dnspod.Record {
|
func (d *DNSProvider) newTxtRecord(zone, fqdn, value string, ttl int) *dnspod.Record {
|
||||||
name := d.extractRecordName(fqdn, zone)
|
name := extractRecordName(fqdn, zone)
|
||||||
|
|
||||||
return &dnspod.Record{
|
return &dnspod.Record{
|
||||||
Type: "TXT",
|
Type: "TXT",
|
||||||
|
@ -180,7 +180,7 @@ func (d *DNSProvider) findTxtRecords(domain, fqdn string) ([]dnspod.Record, erro
|
||||||
return records, fmt.Errorf("API call has failed: %w", err)
|
return records, fmt.Errorf("API call has failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
recordName := d.extractRecordName(fqdn, zoneName)
|
recordName := extractRecordName(fqdn, zoneName)
|
||||||
|
|
||||||
for _, record := range result {
|
for _, record := range result {
|
||||||
if record.Name == recordName {
|
if record.Name == recordName {
|
||||||
|
@ -191,9 +191,9 @@ func (d *DNSProvider) findTxtRecords(domain, fqdn string) ([]dnspod.Record, erro
|
||||||
return records, nil
|
return records, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) extractRecordName(fqdn, domain string) string {
|
func extractRecordName(fqdn, zone string) string {
|
||||||
name := dns01.UnFqdn(fqdn)
|
name := dns01.UnFqdn(fqdn)
|
||||||
if idx := strings.Index(name, "."+domain); idx != -1 {
|
if idx := strings.Index(name, "."+zone); idx != -1 {
|
||||||
return name[:idx]
|
return name[:idx]
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
|
|
|
@ -101,12 +101,12 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
domainZone, err := d.getZone(fqdn)
|
domainZone, err := getZone(fqdn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("godaddy: failed to get zone: %w", err)
|
return fmt.Errorf("godaddy: failed to get zone: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
recordName := d.extractRecordName(fqdn, domainZone)
|
recordName := extractRecordName(fqdn, domainZone)
|
||||||
|
|
||||||
records, err := d.getRecords(domainZone, "TXT", recordName)
|
records, err := d.getRecords(domainZone, "TXT", recordName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -140,12 +140,12 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||||
|
|
||||||
domainZone, err := d.getZone(fqdn)
|
domainZone, err := getZone(fqdn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("godaddy: failed to get zone: %w", err)
|
return fmt.Errorf("godaddy: failed to get zone: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
recordName := d.extractRecordName(fqdn, domainZone)
|
recordName := extractRecordName(fqdn, domainZone)
|
||||||
|
|
||||||
records, err := d.getRecords(domainZone, "TXT", recordName)
|
records, err := d.getRecords(domainZone, "TXT", recordName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -182,15 +182,15 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) extractRecordName(fqdn, domain string) string {
|
func extractRecordName(fqdn, zone string) string {
|
||||||
name := dns01.UnFqdn(fqdn)
|
name := dns01.UnFqdn(fqdn)
|
||||||
if idx := strings.Index(name, "."+domain); idx != -1 {
|
if idx := strings.Index(name, "."+zone); idx != -1 {
|
||||||
return name[:idx]
|
return name[:idx]
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) getZone(fqdn string) (string, error) {
|
func getZone(fqdn string) (string, error) {
|
||||||
authZone, err := dns01.FindZoneByFqdn(fqdn)
|
authZone, err := dns01.FindZoneByFqdn(fqdn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
|
@ -115,7 +115,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
|
|
||||||
request := &namecom.Record{
|
request := &namecom.Record{
|
||||||
DomainName: domain,
|
DomainName: domain,
|
||||||
Host: d.extractRecordName(fqdn, domainDetails.DomainName),
|
Host: extractRecordName(fqdn, domainDetails.DomainName),
|
||||||
Type: "TXT",
|
Type: "TXT",
|
||||||
TTL: uint32(d.config.TTL),
|
TTL: uint32(d.config.TTL),
|
||||||
Answer: value,
|
Answer: value,
|
||||||
|
@ -180,9 +180,9 @@ func (d *DNSProvider) getRecords(domain string) ([]*namecom.Record, error) {
|
||||||
return records, nil
|
return records, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) extractRecordName(fqdn, domain string) string {
|
func extractRecordName(fqdn, zone string) string {
|
||||||
name := dns01.UnFqdn(fqdn)
|
name := dns01.UnFqdn(fqdn)
|
||||||
if idx := strings.Index(name, "."+domain); idx != -1 {
|
if idx := strings.Index(name, "."+zone); idx != -1 {
|
||||||
return name[:idx]
|
return name[:idx]
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
|
|
|
@ -132,7 +132,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
authZone = dns01.UnFqdn(authZone)
|
authZone = dns01.UnFqdn(authZone)
|
||||||
subDomain := d.extractRecordName(fqdn, authZone)
|
subDomain := extractRecordName(fqdn, authZone)
|
||||||
|
|
||||||
reqURL := fmt.Sprintf("/domain/zone/%s/record", authZone)
|
reqURL := fmt.Sprintf("/domain/zone/%s/record", authZone)
|
||||||
reqData := Record{FieldType: "TXT", SubDomain: subDomain, Target: value, TTL: d.config.TTL}
|
reqData := Record{FieldType: "TXT", SubDomain: subDomain, Target: value, TTL: d.config.TTL}
|
||||||
|
@ -205,9 +205,9 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
return d.config.PropagationTimeout, d.config.PollingInterval
|
return d.config.PropagationTimeout, d.config.PollingInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) extractRecordName(fqdn, domain string) string {
|
func extractRecordName(fqdn, zone string) string {
|
||||||
name := dns01.UnFqdn(fqdn)
|
name := dns01.UnFqdn(fqdn)
|
||||||
if idx := strings.Index(name, "."+domain); idx != -1 {
|
if idx := strings.Index(name, "."+zone); idx != -1 {
|
||||||
return name[:idx]
|
return name[:idx]
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
|
|
|
@ -21,7 +21,7 @@ func (d *DNSProvider) addTXTRecord(fqdn, domain, value string, ttl int) error {
|
||||||
return fmt.Errorf("sakuracloud: %w", err)
|
return fmt.Errorf("sakuracloud: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
name := d.extractRecordName(fqdn, zone.Name)
|
name := extractRecordName(fqdn, zone.Name)
|
||||||
|
|
||||||
zone.AddRecord(zone.CreateNewRecord(name, "TXT", value, ttl))
|
zone.AddRecord(zone.CreateNewRecord(name, "TXT", value, ttl))
|
||||||
_, err = d.client.Update(zone.ID, zone)
|
_, err = d.client.Update(zone.ID, zone)
|
||||||
|
@ -41,7 +41,7 @@ func (d *DNSProvider) cleanupTXTRecord(fqdn, domain string) error {
|
||||||
return fmt.Errorf("sakuracloud: %w", err)
|
return fmt.Errorf("sakuracloud: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
records := d.findTxtRecords(fqdn, zone)
|
records := findTxtRecords(fqdn, zone)
|
||||||
|
|
||||||
for _, record := range records {
|
for _, record := range records {
|
||||||
var updRecords []sacloud.DNSRecordSet
|
var updRecords []sacloud.DNSRecordSet
|
||||||
|
@ -85,8 +85,8 @@ func (d *DNSProvider) getHostedZone(domain string) (*sacloud.DNS, error) {
|
||||||
return nil, fmt.Errorf("zone %s not found", zoneName)
|
return nil, fmt.Errorf("zone %s not found", zoneName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) findTxtRecords(fqdn string, zone *sacloud.DNS) []sacloud.DNSRecordSet {
|
func findTxtRecords(fqdn string, zone *sacloud.DNS) []sacloud.DNSRecordSet {
|
||||||
recordName := d.extractRecordName(fqdn, zone.Name)
|
recordName := extractRecordName(fqdn, zone.Name)
|
||||||
|
|
||||||
var res []sacloud.DNSRecordSet
|
var res []sacloud.DNSRecordSet
|
||||||
for _, record := range zone.Settings.DNS.ResourceRecordSets {
|
for _, record := range zone.Settings.DNS.ResourceRecordSets {
|
||||||
|
@ -97,9 +97,9 @@ func (d *DNSProvider) findTxtRecords(fqdn string, zone *sacloud.DNS) []sacloud.D
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) extractRecordName(fqdn, domain string) string {
|
func extractRecordName(fqdn, zone string) string {
|
||||||
name := dns01.UnFqdn(fqdn)
|
name := dns01.UnFqdn(fqdn)
|
||||||
if idx := strings.Index(name, "."+domain); idx != -1 {
|
if idx := strings.Index(name, "."+zone); idx != -1 {
|
||||||
return name[:idx]
|
return name[:idx]
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
|
|
|
@ -100,7 +100,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return fmt.Errorf("vultr: %w", err)
|
return fmt.Errorf("vultr: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
name := d.extractRecordName(fqdn, zoneDomain)
|
name := extractRecordName(fqdn, zoneDomain)
|
||||||
|
|
||||||
err = d.client.DNSRecord.Create(ctx, zoneDomain, "TXT", name, `"`+value+`"`, d.config.TTL, 0)
|
err = d.client.DNSRecord.Create(ctx, zoneDomain, "TXT", name, `"`+value+`"`, d.config.TTL, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -175,7 +175,7 @@ func (d *DNSProvider) findTxtRecords(ctx context.Context, domain, fqdn string) (
|
||||||
return "", records, fmt.Errorf("API call has failed: %w", err)
|
return "", records, fmt.Errorf("API call has failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
recordName := d.extractRecordName(fqdn, zoneDomain)
|
recordName := extractRecordName(fqdn, zoneDomain)
|
||||||
for _, record := range result {
|
for _, record := range result {
|
||||||
if record.Type == "TXT" && record.Name == recordName {
|
if record.Type == "TXT" && record.Name == recordName {
|
||||||
records = append(records, record)
|
records = append(records, record)
|
||||||
|
@ -185,9 +185,9 @@ func (d *DNSProvider) findTxtRecords(ctx context.Context, domain, fqdn string) (
|
||||||
return zoneDomain, records, nil
|
return zoneDomain, records, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) extractRecordName(fqdn, domain string) string {
|
func extractRecordName(fqdn, zone string) string {
|
||||||
name := dns01.UnFqdn(fqdn)
|
name := dns01.UnFqdn(fqdn)
|
||||||
if idx := strings.Index(name, "."+domain); idx != -1 {
|
if idx := strings.Index(name, "."+zone); idx != -1 {
|
||||||
return name[:idx]
|
return name[:idx]
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
|
|
Loading…
Reference in a new issue