Skip to content

Commit

Permalink
NS1: remove deprecated NS1_URLFWD (#3400)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Limoncelli <[email protected]>
  • Loading branch information
costasd and tlimoncelli authored Jan 27, 2025
1 parent f264047 commit 4f5655e
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 113 deletions.
26 changes: 0 additions & 26 deletions commands/types/dnscontrol.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2294,32 +2294,6 @@ declare const NO_PURGE: DomainModifier;
*/
declare function NS(name: string, target: string, ...modifiers: RecordModifier[]): DomainModifier;

/**
* `NS1_URLFWD` is an NS1-specific feature that maps to NS1's URLFWD record, which creates HTTP 301 (permanent) or 302 (temporary) redirects.
*
* ```javascript
* D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
* NS1_URLFWD("urlfwd", "/ http://example.com 302 2 0")
* );
* ```
*
* The fields are:
* * name: the record name
* * target: a complex field containing the following, space separated:
* * from - the path to match
* * to - the url to redirect to
* * redirectType - (0 - masking, 301, 302)
* * pathForwardingMode - (0 - All, 1 - Capture, 2 - None)
* * queryForwardingMode - (0 - disabled, 1 - enabled)
*
* WARNING: According to NS1, this type of record is deprecated and in the process
* of being replaced by the premium-only `REDIRECT` record type. While still able to be
* configured through the API, as suggested by NS1, please try not to use it, going forward.
*
* @see https://docs.dnscontrol.org/language-reference/domain-modifiers/service-provider-specific/ns1/ns1_urlfwd
*/
declare function NS1_URLFWD(name: string, target: string, ...modifiers: RecordModifier[]): DomainModifier;

/**
* NewDnsProvider activates a DNS Service Provider (DSP) specified in `creds.json`.
* A DSP stores a DNS zone's records and provides DNS service for the zone (i.e.
Expand Down
2 changes: 0 additions & 2 deletions documentation/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@
* [CF_WORKER_ROUTE](language-reference/domain-modifiers/CF_WORKER_ROUTE.md)
* ClouDNS
* [CLOUDNS_WR](language-reference/domain-modifiers/CLOUDNS_WR.md)
* NS1
* [NS1_URLFWD](language-reference/domain-modifiers/NS1_URLFWD.md)
* Record Modifiers
* [TTL](language-reference/record-modifiers/TTL.md)
* Service Provider specific
Expand Down
2 changes: 0 additions & 2 deletions documentation/adding-new-rtypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@ Add the new file `FOO.md` to the documentation table of contents [`documentation
* [CLOUDNS_WR](language-reference/domain-modifiers/CLOUDNS_WR.md)
+ * ASDF
+ * [ASDF_NINJA](language-reference/domain-modifiers/ASDF_NINJA.md)
* NS1
* [NS1_URLFWD](language-reference/domain-modifiers/NS1_URLFWD.md)
...
* Record Modifiers
...
Expand Down
38 changes: 0 additions & 38 deletions documentation/language-reference/domain-modifiers/NS1_URLFWD.md

This file was deleted.

2 changes: 1 addition & 1 deletion models/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (dc *DomainConfig) Punycode() error {

// Set the target:
switch rec.Type { // #rtype_variations
case "ALIAS", "MX", "NS", "CNAME", "DNAME", "PTR", "SRV", "URL", "URL301", "FRAME", "R53_ALIAS", "NS1_URLFWD", "AKAMAICDN", "CLOUDNS_WR", "PORKBUN_URLFWD":
case "ALIAS", "MX", "NS", "CNAME", "DNAME", "PTR", "SRV", "URL", "URL301", "FRAME", "R53_ALIAS", "AKAMAICDN", "CLOUDNS_WR", "PORKBUN_URLFWD":
// These rtypes are hostnames, therefore need to be converted (unlike, for example, an AAAA record)
t, err := idna.ToASCII(rec.GetTargetField())
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion models/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
// IMPORT_TRANSFORM
// NAMESERVER
// NO_PURGE
// NS1_URLFWD
// PAGE_RULE
// PORKBUN_URLFWD
// PURGE
Expand Down
1 change: 0 additions & 1 deletion pkg/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,6 @@ var CF_WORKER_ROUTE = recordBuilder('CF_WORKER_ROUTE', {
var URL = recordBuilder('URL');
var URL301 = recordBuilder('URL301');
var FRAME = recordBuilder('FRAME');
var NS1_URLFWD = recordBuilder('NS1_URLFWD');
var CLOUDNS_WR = recordBuilder('CLOUDNS_WR');
var PORKBUN_URLFWD = recordBuilder('PORKBUN_URLFWD');

Expand Down
4 changes: 0 additions & 4 deletions pkg/normalize/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,6 @@ func checkTargets(rec *models.RecordConfig, domain string) (errs []error) {
if label == "@" {
check(errors.New("cannot create NS record for bare domain. Use NAMESERVER instead"))
}
case "NS1_URLFWD":
if len(strings.Fields(target)) != 5 {
check(errors.New("record should follow format: \"from to redirectType pathForwardingMode queryForwarding\""))
}
case "PTR":
check(checkTarget(target))
case "SOA":
Expand Down
22 changes: 0 additions & 22 deletions pkg/normalize/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,28 +274,6 @@ func TestNSAtRoot(t *testing.T) {
}
}

func TestNS1URLFWDValid(t *testing.T) {
rec := &models.RecordConfig{Type: "NS1_URLFWD"}
rec.SetLabel("test1", "foo.com")
rec.MustSetTarget("/ http://example.com 302 2 0")

errs := checkTargets(rec, "foo.com")
if len(errs) > 0 {
t.Error("Expect no error with valid NS1_URLFWD target")
}
}

func TestNS1URLFWDInvalid(t *testing.T) {
rec := &models.RecordConfig{Type: "NS1_URLFWD"}
rec.SetLabel("test2", "foo.com")
rec.MustSetTarget("/ http://example.com 302 2")

errs := checkTargets(rec, "foo.com")
if len(errs) == 0 {
t.Error("Expect error with invalid NS1_URLFWD target")
}
}

func TestTransforms(t *testing.T) {
tests := []struct {
givenIP string
Expand Down
14 changes: 0 additions & 14 deletions providers/ns1/ns1Provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func init() {
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType(providerName, fns, providers.CanUseSRV, docNotes)
providers.RegisterCustomRecordType("NS1_URLFWD", providerName, "")
providers.RegisterMaintainer(providerName, providerMaintainer)
}

Expand Down Expand Up @@ -253,10 +252,6 @@ func (n *nsone) add(recs models.Records, domain string) error {
}

func (n *nsone) remove(key models.RecordKey, domain string) error {
if key.Type == "NS1_URLFWD" {
key.Type = "URLFWD"
}

for rtr := 0; ; rtr++ {
httpResp, err := n.Records.Delete(domain, key.NameFQDN, key.Type)
if httpResp.StatusCode == http.StatusTooManyRequests && rtr < clientRetries {
Expand Down Expand Up @@ -340,10 +335,6 @@ func buildRecord(recs models.Records, domain string, id string) *dns.Record {
strconv.Itoa(int(r.DsDigestType)),
r.DsDigest,
}})
} else if r.Type == "NS1_URLFWD" {
printer.Warnf("NS1_URLFWD is deprecated and may stop working anytime now. Please avoid such records going forward.\n")
rec.Type = "URLFWD"
rec.AddAnswer(&dns.Answer{Rdata: strings.Fields(r.GetTargetField())})
} else if r.Type == "SVCB" || r.Type == "HTTPS" {
rec.AddAnswer(&dns.Answer{Rdata: []string{
strconv.Itoa(int(r.SvcPriority)),
Expand Down Expand Up @@ -383,11 +374,6 @@ func convert(zr *dns.ZoneRecord, domain string) ([]*models.RecordConfig, error)
if err := rec.SetTarget(ans); err != nil {
return nil, fmt.Errorf("unparsable %s record received from ns1: %w", rtype, err)
}
case "URLFWD":
rec.Type = "NS1_URLFWD"
if err := rec.SetTarget(ans); err != nil {
return nil, fmt.Errorf("unparsable %s record received from ns1: %w", rtype, err)
}
case "CAA":
// dnscontrol expects quotes around multivalue CAA entries, API doesn't add them
xAns := strings.SplitN(ans, " ", 3)
Expand Down
4 changes: 2 additions & 2 deletions providers/vultr/vultrProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (api *vultrProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, cur

for _, rec := range dc.Records {
switch rec.Type { // #rtype_variations
case "ALIAS", "MX", "NS", "CNAME", "PTR", "SRV", "URL", "URL301", "FRAME", "R53_ALIAS", "NS1_URLFWD", "AKAMAICDN", "CLOUDNS_WR":
case "ALIAS", "MX", "NS", "CNAME", "PTR", "SRV", "URL", "URL301", "FRAME", "R53_ALIAS", "AKAMAICDN", "CLOUDNS_WR":
// These rtypes are hostnames, therefore need to be converted (unlike, for example, an AAAA record)
t, err := idna.ToUnicode(rec.GetTargetField())
if err != nil {
Expand Down Expand Up @@ -230,7 +230,7 @@ func toRecordConfig(domain string, r govultr.DomainRecord) (*models.RecordConfig
rc.SetLabel(r.Name, domain)

switch rtype := r.Type; rtype {
case "ALIAS", "MX", "NS", "CNAME", "PTR", "SRV", "URL", "URL301", "FRAME", "R53_ALIAS", "NS1_URLFWD", "AKAMAICDN", "CLOUDNS_WR":
case "ALIAS", "MX", "NS", "CNAME", "PTR", "SRV", "URL", "URL301", "FRAME", "R53_ALIAS", "AKAMAICDN", "CLOUDNS_WR":
var err error
data, err = idna.ToUnicode(data)
if err != nil {
Expand Down

0 comments on commit 4f5655e

Please sign in to comment.