forked from TrueCloudLab/lego
namecheap: fix panic. (#764)
This commit is contained in:
parent
4f6d1077a2
commit
27f26ed3d1
2 changed files with 7 additions and 5 deletions
|
@ -180,10 +180,12 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
|
|
||||||
// Find the challenge TXT record and remove it if found.
|
// Find the challenge TXT record and remove it if found.
|
||||||
var found bool
|
var found bool
|
||||||
for i, h := range records {
|
var newRecords []Record
|
||||||
|
for _, h := range records {
|
||||||
if h.Name == ch.key && h.Type == "TXT" {
|
if h.Name == ch.key && h.Type == "TXT" {
|
||||||
records = append(records[:i], records[i+1:]...)
|
|
||||||
found = true
|
found = true
|
||||||
|
} else {
|
||||||
|
newRecords = append(newRecords, h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +193,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err = d.setHosts(ch.sld, ch.tld, records)
|
err = d.setHosts(ch.sld, ch.tld, newRecords)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("namecheap: %v", err)
|
return fmt.Errorf("namecheap: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,10 +208,10 @@ func mockServer(tc *testCase, t *testing.T) http.Handler {
|
||||||
case "namecheap.domains.dns.getHosts":
|
case "namecheap.domains.dns.getHosts":
|
||||||
assertHdr(tc, t, &values)
|
assertHdr(tc, t, &values)
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, tc.getHostsResponse)
|
fmt.Fprint(w, tc.getHostsResponse)
|
||||||
case "namecheap.domains.getTldList":
|
case "namecheap.domains.getTldList":
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, responseGetTlds)
|
fmt.Fprint(w, responseGetTlds)
|
||||||
default:
|
default:
|
||||||
t.Errorf("Unexpected GET command: %s", cmd)
|
t.Errorf("Unexpected GET command: %s", cmd)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue