PACKETFRAME: always include default nameservers (#1368)

This commit is contained in:
Hampton 2022-01-07 09:24:24 -05:00 committed by GitHub
parent ea20c13e67
commit 6e29b556a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 7 deletions

View file

@ -14,6 +14,11 @@ const (
defaultBaseURL = "https://packetframe.com/api/"
)
var defaultNameServerNames = []string{
"ns1.packetframe.com",
"ns2.packetframe.com",
}
type zone struct {
ID string `json:"id"`
Zone string `json:"zone"`
@ -75,6 +80,16 @@ func (c *packetframeProvider) getRecords(zoneID string) ([]domainRecord, error)
}
records = append(records, dr.Data.Records...)
for i := range defaultNameServerNames {
records = append(records, domainRecord{
Type: "NS",
TTL: 86400,
Value: defaultNameServerNames[i] + ".",
Zone: zoneID,
ID: "0",
})
}
return records, nil
}

View file

@ -21,11 +21,6 @@ type packetframeProvider struct {
domainIndex map[string]zone
}
var defaultNameServerNames = []string{
"ns1.packetframe.com",
"ns2.packetframe.com",
}
// newPacketframe creates the provider.
func newPacketframe(m map[string]string, metadata json.RawMessage) (providers.DNSServiceProvider, error) {
if m["token"] == "" {
@ -153,8 +148,12 @@ func (api *packetframeProvider) GetDomainCorrections(dc *models.DomainConfig) ([
for _, m := range delete {
original := m.Existing.Original.(*domainRecord)
if original.ID == "0" { // Skip the default nameservers
continue
}
corr := &models.Correction{
Msg: fmt.Sprintf("Deleting record %q from %q", original.ID, zone.Zone),
Msg: m.String(),
F: func() error {
err := api.deleteRecord(zone.ID, original.ID)
return err
@ -165,10 +164,14 @@ func (api *packetframeProvider) GetDomainCorrections(dc *models.DomainConfig) ([
for _, m := range modify {
original := m.Existing.Original.(*domainRecord)
if original.ID == "0" { // Skip the default nameservers
continue
}
req, _ := toReq(zone.ID, dc, m.Desired)
req.ID = original.ID
corr := &models.Correction{
Msg: fmt.Sprintf("Modifying record %q from %q", original.ID, zone.Zone),
Msg: m.String(),
F: func() error {
err := api.modifyRecord(req)
return err