1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

LINODE: Fix Linode provider (#333)

This commit is contained in:
Koen Vlaswinkel
2018-03-08 19:48:11 +01:00
committed by Tom Limoncelli
parent 8db97d1132
commit afa80c24bd
2 changed files with 20 additions and 17 deletions

View File

@ -46,7 +46,7 @@
"COMMENT": "25: Linode's hostname validation does not allow the target domain TLD", "COMMENT": "25: Linode's hostname validation does not allow the target domain TLD",
"token": "$LINODE_TOKEN", "token": "$LINODE_TOKEN",
"domain": "$LINODE_DOMAIN", "domain": "$LINODE_DOMAIN",
"knownFailures": "25" "knownFailures": "27"
}, },
"NS1": { "NS1": {
"domain": "$NS1_DOMAIN", "domain": "$NS1_DOMAIN",

View File

@ -135,12 +135,14 @@ func (api *LinodeApi) GetDomainCorrections(dc *models.DomainConfig) ([]*models.C
// Linode always has read-only NS servers, but these are not mentioned in the API response // Linode always has read-only NS servers, but these are not mentioned in the API response
// https://github.com/linode/manager/blob/edd99dc4e1be5ab8190f243c3dbf8b830716255e/src/constants.js#L184 // https://github.com/linode/manager/blob/edd99dc4e1be5ab8190f243c3dbf8b830716255e/src/constants.js#L184
for _, name := range defaultNameServerNames { for _, name := range defaultNameServerNames {
existingRecords = append(existingRecords, &models.RecordConfig{ rc := &models.RecordConfig{
NameFQDN: dc.Name, NameFQDN: dc.Name,
Type: "NS", Type: "NS",
Target: name,
Original: &domainRecord{}, Original: &domainRecord{},
}) }
rc.SetTarget(name)
existingRecords = append(existingRecords, rc)
} }
// Normalize // Normalize
@ -221,19 +223,8 @@ func (api *LinodeApi) GetDomainCorrections(dc *models.DomainConfig) ([]*models.C
} }
func toRc(dc *models.DomainConfig, r *domainRecord) *models.RecordConfig { func toRc(dc *models.DomainConfig, r *domainRecord) *models.RecordConfig {
// This handles "@" etc. rc := &models.RecordConfig{
name := dnsutil.AddOrigin(r.Name, dc.Name)
target := r.Target
// Make target FQDN (#rtype_variations)
if r.Type == "CNAME" || r.Type == "MX" || r.Type == "NS" || r.Type == "SRV" {
target = dnsutil.AddOrigin(target+".", dc.Name)
}
return &models.RecordConfig{
NameFQDN: name,
Type: r.Type, Type: r.Type,
Target: target,
TTL: r.TTLSec, TTL: r.TTLSec,
MxPreference: r.Priority, MxPreference: r.Priority,
SrvPriority: r.Priority, SrvPriority: r.Priority,
@ -241,13 +232,25 @@ func toRc(dc *models.DomainConfig, r *domainRecord) *models.RecordConfig {
SrvPort: uint16(r.Port), SrvPort: uint16(r.Port),
Original: r, Original: r,
} }
rc.SetLabel(r.Name, dc.Name)
switch rtype := r.Type; rtype { // #rtype_variations
case "TXT":
rc.SetTargetTXT(r.Target)
case "CNAME", "MX", "NS", "SRV":
rc.SetTarget(dnsutil.AddOrigin(r.Target+".", dc.Name))
default:
rc.SetTarget(r.Target)
}
return rc
} }
func toReq(dc *models.DomainConfig, rc *models.RecordConfig) (*recordEditRequest, error) { func toReq(dc *models.DomainConfig, rc *models.RecordConfig) (*recordEditRequest, error) {
req := &recordEditRequest{ req := &recordEditRequest{
Type: rc.Type, Type: rc.Type,
Name: dnsutil.TrimDomainName(rc.NameFQDN, dc.Name), Name: dnsutil.TrimDomainName(rc.NameFQDN, dc.Name),
Target: rc.Target, Target: rc.GetTargetField(),
TTL: int(rc.TTL), TTL: int(rc.TTL),
Priority: 0, Priority: 0,
Port: int(rc.SrvPort), Port: int(rc.SrvPort),