mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-02-24 15:43:08 +08:00
NETCUP: Handle CNAMEs with a single @ as destination correctly (#1947)
This commit is contained in:
parent
b4cbd1299f
commit
261961c5b8
1 changed files with 12 additions and 2 deletions
|
@ -71,6 +71,17 @@ type responseLogin struct {
|
|||
SessionID string `json:"apisessionid"`
|
||||
}
|
||||
|
||||
// addTailingDot adds a dot if it's missing from what the netcup api has returned to us.
|
||||
func addTailingDot(destination string) string {
|
||||
if destination == "@" || len(destination) == 0 {
|
||||
return destination
|
||||
}
|
||||
if destination[len(destination)-1:] != "." {
|
||||
return destination + "."
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
func toRecordConfig(domain string, r *record) *models.RecordConfig {
|
||||
priority, _ := strconv.ParseUint(r.Priority, 10, 16)
|
||||
|
||||
|
@ -89,7 +100,7 @@ func toRecordConfig(domain string, r *record) *models.RecordConfig {
|
|||
case "TXT":
|
||||
_ = rc.SetTargetTXT(r.Destination)
|
||||
case "NS", "ALIAS", "CNAME", "MX":
|
||||
_ = rc.SetTarget(dnsutil.AddOrigin(r.Destination+".", domain))
|
||||
_ = rc.SetTarget(dnsutil.AddOrigin(addTailingDot(r.Destination), domain))
|
||||
case "SRV":
|
||||
parts := strings.Split(r.Destination, " ")
|
||||
priority, _ := strconv.ParseUint(parts[0], 10, 16)
|
||||
|
@ -108,7 +119,6 @@ func toRecordConfig(domain string, r *record) *models.RecordConfig {
|
|||
default:
|
||||
_ = rc.SetTarget(r.Destination)
|
||||
}
|
||||
|
||||
return rc
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue