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

NS1: Support NS1_URLFWD (#1046)

This commit is contained in:
Tom Limoncelli
2021-02-10 16:57:15 +00:00
committed by GitHub
parent a83d2c89a8
commit a2042c2eda
8 changed files with 146 additions and 138 deletions

View File

@@ -8,6 +8,7 @@ import (
"gopkg.in/ns1/ns1-go.v2/rest"
"gopkg.in/ns1/ns1-go.v2/rest/model/dns"
"gopkg.in/ns1/ns1-go.v2/rest/model/filter"
"github.com/StackExchange/dnscontrol/v3/models"
"github.com/StackExchange/dnscontrol/v3/pkg/diff"
@@ -25,6 +26,7 @@ var docNotes = providers.DocumentationNotes{
func init() {
providers.RegisterDomainServiceProviderType("NS1", newProvider, providers.CanUseSRV, docNotes)
providers.RegisterCustomRecordType("NS1_URLFWD", "NS1", "URLFWD")
}
type nsone struct {
@@ -129,11 +131,12 @@ func (n *nsone) modify(recs models.Records, domain string) error {
func buildRecord(recs models.Records, domain string, id string) *dns.Record {
r := recs[0]
rec := &dns.Record{
Domain: r.GetLabelFQDN(),
Type: r.Type,
ID: id,
TTL: int(r.TTL),
Zone: domain,
Domain: r.GetLabelFQDN(),
Type: r.Type,
ID: id,
TTL: int(r.TTL),
Zone: domain,
Filters: []*filter.Filter{}, // Work through a bug in the NS1 API library that causes 400 Input validation failed (Value None for field '<obj>.filters' is not of type array)
}
for _, r := range recs {
if r.Type == "MX" {
@@ -159,9 +162,10 @@ func convert(zr *dns.ZoneRecord, domain string) ([]*models.RecordConfig, error)
rec.SetLabelFromFQDN(zr.Domain, domain)
switch rtype := zr.Type; rtype {
case "ALIAS":
case "URLFWD":
rec.Type = rtype
if err := rec.SetTarget(ans); err != nil {
panic(fmt.Errorf("unparsable ALIAS record received from ns1: %w", err))
panic(fmt.Errorf("unparsable %s record received from ns1: %w", rtype, err))
}
default:
if err := rec.PopulateFromString(rtype, ans, domain); err != nil {