From 3ed24a9af6b042114eff0a87bd352912ad753e92 Mon Sep 17 00:00:00 2001 From: Jeffrey Cafferata Date: Tue, 5 Dec 2023 14:46:51 +0100 Subject: [PATCH 01/67] DOCS: Rename build filenames (#2681) --- README.md | 2 +- documentation/byo-secrets.md | 10 +++++----- documentation/release-engineering.md | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bacfcf734a..15a0b989c3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DNSControl -[![StackExchange/dnscontrol/build](https://github.com/StackExchange/dnscontrol/actions/workflows/build.yml/badge.svg)](https://github.com/StackExchange/dnscontrol/actions/workflows/build.yml) +[![StackExchange/dnscontrol/build](https://github.com/StackExchange/dnscontrol/actions/workflows/pr_test.yml/badge.svg)](https://github.com/StackExchange/dnscontrol/actions/workflows/pr_test.yml) [![Gitter chat](https://badges.gitter.im/dnscontrol/Lobby.png)](https://gitter.im/dnscontrol/Lobby) [![Google Group](https://img.shields.io/badge/google%20group-chat-green.svg)](https://groups.google.com/forum/#!forum/dnscontrol-discuss) [![PkgGoDev](https://pkg.go.dev/badge/github.com/StackExchange/dnscontrol)](https://pkg.go.dev/github.com/StackExchange/dnscontrol/v4) diff --git a/documentation/byo-secrets.md b/documentation/byo-secrets.md index 7b2e41ed57..20450d561e 100644 --- a/documentation/byo-secrets.md +++ b/documentation/byo-secrets.md @@ -62,16 +62,16 @@ Step 1: Create a branch Create a branch as you normally would to submit a PR to the project. -Step 2: Update `build.yml` +Step 2: Update `pr_test.yml` -In this branch, edit `.github/workflows/build.yml`: +In this branch, edit `.github/workflows/pr_test.yml`: 1. In the `integration-test-providers` section, the name of the provider. Add your provider's name (alphabetically). The line looks something like: -{% code title=".github/workflows/build.yml" %} +{% code title=".github/workflows/pr_test.yml" %} ``` PROVIDERS: "['BIND','HEXONET','AZURE_DNS','CLOUDFLAREAPI','GCLOUD','NAMEDOTCOM','ROUTE53','CLOUDNS','DIGITALOCEAN','GANDI_V5','HEDNS','INWX','NS1','POWERDNS','TRANSIP']" ``` @@ -83,7 +83,7 @@ Add it to the `env` section of `integrtests-diff2`. For example, the entry for BIND looks like: -{% code title=".github/workflows/build.yml" %} +{% code title=".github/workflows/pr_test.yml" %} ``` BIND_DOMAIN: ${{ vars.BIND_DOMAIN }} ``` @@ -95,7 +95,7 @@ If there are other env variables (for example, for an API key), add that as a "s For example, the entry for CLOUDFLAREAPI looks like this: -{% code title=".github/workflows/build.yml" %} +{% code title=".github/workflows/pr_test.yml" %} ``` CLOUDFLAREAPI_ACCOUNTID: ${{ secrets.CLOUDFLAREAPI_ACCOUNTID }} CLOUDFLAREAPI_TOKEN: ${{ secrets.CLOUDFLAREAPI_TOKEN }} diff --git a/documentation/release-engineering.md b/documentation/release-engineering.md index 17e21f07d6..1c66739ab4 100644 --- a/documentation/release-engineering.md +++ b/documentation/release-engineering.md @@ -130,7 +130,7 @@ find * -name \*.bak -delete GHA is configured to run an integration test for any provider listed in the "provider" list. However the test is skipped if the `*_DOMAIN` variable is not set. For example, the Google Cloud provider integration test is only run if `GCLOUD_DOMAIN` is set. * Q: Where is the list of providers to run integration tests on? -* A: In `.github/workflows/build.yml`: (1) the "PROVIDERS" list, (2) the `integrtests-diff2` section. +* A: In `.github/workflows/pr_test.yml`: (1) the "PROVIDERS" list, (2) the `integrtests-diff2` section. * Q: Where are non-secret environment variables stored? * A: GHA calls them "Variables". Update them here: https://github.com/StackExchange/dnscontrol/settings/variables/actions @@ -140,7 +140,7 @@ GHA is configured to run an integration test for any provider listed in the "pro ### How do I add a single new integration test? -1. Edit `.github/workflows/build.yml` +1. Edit `.github/workflows/pr_test.yml` 2. Add the `FOO_DOMAIN` variable name of the provider to the "PROVIDERS" list. 3. Set the `FOO_DOMAIN` variables in GHA via https://github.com/StackExchange/dnscontrol/settings/variables/actions 4. All other variables should be stored as secrets (for consistency). Add them to the `integrtests-diff2` section. From 76d93acaf5ea098eb68b0ad103a43288c8d169b5 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Tue, 5 Dec 2023 09:47:52 -0500 Subject: [PATCH 02/67] CHORE: Remove dead code: txtutil.SplitSingleLongTxt() and txtutil.Segment() (#2685) --- pkg/txtutil/txtutil.go | 10 ---------- providers/akamaiedgedns/akamaiEdgeDnsProvider.go | 3 --- providers/autodns/autoDnsProvider.go | 2 -- providers/axfrddns/axfrddnsProvider.go | 3 --- providers/azure_private_dns/azurePrivateDnsProvider.go | 3 --- providers/azuredns/azureDnsProvider.go | 3 --- providers/bind/bindProvider.go | 2 -- providers/cscglobal/convert.go | 2 -- providers/desec/desecProvider.go | 3 --- providers/digitalocean/digitaloceanProvider.go | 3 --- providers/dnsmadeeasy/dnsMadeEasyProvider.go | 3 --- providers/gandiv5/gandi_v5Provider.go | 2 -- providers/gcloud/gcloudProvider.go | 2 -- providers/hedns/hednsProvider.go | 3 --- providers/hetzner/hetznerProvider.go | 3 --- providers/hexonet/records.go | 2 -- providers/inwx/inwxProvider.go | 4 ---- providers/loopia/loopiaProvider.go | 3 --- providers/msdns/corrections.go | 3 --- providers/netcup/netcupProvider.go | 3 --- providers/oracle/oracleProvider.go | 2 -- providers/route53/route53Provider.go | 2 -- providers/rwth/dns.go | 2 -- 23 files changed, 68 deletions(-) diff --git a/pkg/txtutil/txtutil.go b/pkg/txtutil/txtutil.go index 55045b8c29..a6caf5e05e 100644 --- a/pkg/txtutil/txtutil.go +++ b/pkg/txtutil/txtutil.go @@ -1,20 +1,10 @@ package txtutil -// SplitSingleLongTxt does nothing. -// Deprecated: This is a no-op for backwards compatibility. -func SplitSingleLongTxt(records any) { -} - // ToChunks returns the string as chunks of 255-octet strings (the last string being the remainder). func ToChunks(s string) []string { return splitChunks(s, 255) } -// Segment returns the string as 255-octet segments, the last being the remainder. -func Segment(s string) []string { - return splitChunks(s, 255) -} - func splitChunks(buf string, lim int) []string { var chunk string chunks := make([]string, 0, len(buf)/lim+1) diff --git a/providers/akamaiedgedns/akamaiEdgeDnsProvider.go b/providers/akamaiedgedns/akamaiEdgeDnsProvider.go index a42fe4b523..7d1fabda16 100644 --- a/providers/akamaiedgedns/akamaiEdgeDnsProvider.go +++ b/providers/akamaiedgedns/akamaiEdgeDnsProvider.go @@ -17,7 +17,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff" "github.com/StackExchange/dnscontrol/v4/pkg/printer" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" ) @@ -106,8 +105,6 @@ func (a *edgeDNSProvider) EnsureZoneExists(domain string) error { // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (a *edgeDNSProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(existingRecords) - keysToUpdate, toReport, err := diff.NewCompat(dc).ChangedGroups(existingRecords) if err != nil { return nil, err diff --git a/providers/autodns/autoDnsProvider.go b/providers/autodns/autoDnsProvider.go index 6da132afe9..91d6f65f86 100644 --- a/providers/autodns/autoDnsProvider.go +++ b/providers/autodns/autoDnsProvider.go @@ -11,7 +11,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff2" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" ) @@ -68,7 +67,6 @@ func New(settings map[string]string, _ json.RawMessage) (providers.DNSServicePro // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (api *autoDNSProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { domain := dc.Name - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records var corrections []*models.Correction diff --git a/providers/axfrddns/axfrddnsProvider.go b/providers/axfrddns/axfrddnsProvider.go index f283ee9418..3fba136889 100644 --- a/providers/axfrddns/axfrddnsProvider.go +++ b/providers/axfrddns/axfrddnsProvider.go @@ -25,7 +25,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff2" "github.com/StackExchange/dnscontrol/v4/pkg/printer" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" "github.com/fatih/color" "github.com/miekg/dns" @@ -410,8 +409,6 @@ func hasNSDeletion(changes diff2.ChangeList) bool { // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (c *axfrddnsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(foundRecords) // Autosplit long TXT records - // Ignoring the SOA, others providers don't manage it either. if len(foundRecords) >= 1 && foundRecords[0].Type == "SOA" { foundRecords = foundRecords[1:] diff --git a/providers/azure_private_dns/azurePrivateDnsProvider.go b/providers/azure_private_dns/azurePrivateDnsProvider.go index 7ba34adc03..c798532dae 100644 --- a/providers/azure_private_dns/azurePrivateDnsProvider.go +++ b/providers/azure_private_dns/azurePrivateDnsProvider.go @@ -14,7 +14,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff2" "github.com/StackExchange/dnscontrol/v4/pkg/printer" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" ) @@ -183,8 +182,6 @@ func (a *azurednsProvider) getExistingRecords(domain string) (models.Records, [] // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (a *azurednsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(existingRecords) // Autosplit long TXT records - var corrections []*models.Correction changes, err := diff2.ByRecordSet(existingRecords, dc, nil) diff --git a/providers/azuredns/azureDnsProvider.go b/providers/azuredns/azureDnsProvider.go index 105e46e6e5..abe8c46dda 100644 --- a/providers/azuredns/azureDnsProvider.go +++ b/providers/azuredns/azureDnsProvider.go @@ -14,7 +14,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff2" "github.com/StackExchange/dnscontrol/v4/pkg/printer" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" ) @@ -193,8 +192,6 @@ func (a *azurednsProvider) getExistingRecords(domain string) (models.Records, [] // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (a *azurednsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(existingRecords) // Autosplit long TXT records - var corrections []*models.Correction // Azure is a "ByRecordSet" API. diff --git a/providers/bind/bindProvider.go b/providers/bind/bindProvider.go index 16a502553a..46f22f2091 100644 --- a/providers/bind/bindProvider.go +++ b/providers/bind/bindProvider.go @@ -25,7 +25,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/pkg/diff2" "github.com/StackExchange/dnscontrol/v4/pkg/prettyzone" "github.com/StackExchange/dnscontrol/v4/pkg/printer" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" "github.com/miekg/dns" ) @@ -210,7 +209,6 @@ func ParseZoneContents(content string, zoneName string, zonefileName string) (mo // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (c *bindProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(dc.Records) var corrections []*models.Correction changes := false diff --git a/providers/cscglobal/convert.go b/providers/cscglobal/convert.go index 6050cd8ec2..4ffab7c17e 100644 --- a/providers/cscglobal/convert.go +++ b/providers/cscglobal/convert.go @@ -6,7 +6,6 @@ import ( "net" "github.com/StackExchange/dnscontrol/v4/models" - "github.com/StackExchange/dnscontrol/v4/pkg/printer" ) // nativeToRecordA takes an A record from DNS and returns a native RecordConfig struct. @@ -65,7 +64,6 @@ func nativeToRecordTXT(nr nativeRecordTXT, origin string, defaultTTL uint32) *mo TTL: ttl, } rc.SetLabel(nr.Key, origin) - printer.Printf("DEBUG: inbound raw s=%s\n", nr.Value) rc.SetTargetTXT(nr.Value) return rc } diff --git a/providers/desec/desecProvider.go b/providers/desec/desecProvider.go index 34201f0130..4142e463fd 100644 --- a/providers/desec/desecProvider.go +++ b/providers/desec/desecProvider.go @@ -8,7 +8,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff" "github.com/StackExchange/dnscontrol/v4/pkg/printer" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" "github.com/miekg/dns/dnsutil" ) @@ -150,8 +149,6 @@ func PrepDesiredRecords(dc *models.DomainConfig, minTTL uint32) { // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (c *desecProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existing models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(dc.Records) - var minTTL uint32 c.mutex.Lock() if ttl, ok := c.domainIndex[dc.Name]; !ok { diff --git a/providers/digitalocean/digitaloceanProvider.go b/providers/digitalocean/digitaloceanProvider.go index 62ec0d7dd9..7ae78e34a9 100644 --- a/providers/digitalocean/digitaloceanProvider.go +++ b/providers/digitalocean/digitaloceanProvider.go @@ -10,7 +10,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" "github.com/digitalocean/godo" "github.com/miekg/dns/dnsutil" @@ -168,8 +167,6 @@ func (api *digitaloceanProvider) GetZoneRecords(domain string, meta map[string]s // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (api *digitaloceanProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records - ctx := context.Background() toReport, toCreate, toDelete, toModify, err := diff.NewCompat(dc).IncrementalDiff(existingRecords) diff --git a/providers/dnsmadeeasy/dnsMadeEasyProvider.go b/providers/dnsmadeeasy/dnsMadeEasyProvider.go index 3e6f1eb31e..2917ad82e1 100644 --- a/providers/dnsmadeeasy/dnsMadeEasyProvider.go +++ b/providers/dnsmadeeasy/dnsMadeEasyProvider.go @@ -8,7 +8,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" ) @@ -99,8 +98,6 @@ func New(settings map[string]string, _ json.RawMessage) (providers.DNSServicePro // } func (api *dnsMadeEasyProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records - domainName := dc.Name domain, err := api.findDomain(domainName) if err != nil { diff --git a/providers/gandiv5/gandi_v5Provider.go b/providers/gandiv5/gandi_v5Provider.go index 0aedb7aed3..5d661763ac 100644 --- a/providers/gandiv5/gandi_v5Provider.go +++ b/providers/gandiv5/gandi_v5Provider.go @@ -24,7 +24,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff2" "github.com/StackExchange/dnscontrol/v4/pkg/printer" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" "github.com/go-gandi/go-gandi" "github.com/go-gandi/go-gandi/config" @@ -195,7 +194,6 @@ func (client *gandiv5Provider) GetZoneRecordsCorrections(dc *models.DomainConfig } PrepDesiredRecords(dc) - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records g := gandi.NewLiveDNSClient(config.Config{ APIKey: client.apikey, diff --git a/providers/gcloud/gcloudProvider.go b/providers/gcloud/gcloudProvider.go index 6652c2691c..31f6e7f4d2 100644 --- a/providers/gcloud/gcloudProvider.go +++ b/providers/gcloud/gcloudProvider.go @@ -259,8 +259,6 @@ type correctionValues struct { // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (g *gcloudProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records - oldRRs, ok := g.oldRRsMap[dc.Name] if !ok { return nil, fmt.Errorf("oldRRsMap: no zone named %q", dc.Name) diff --git a/providers/hedns/hednsProvider.go b/providers/hedns/hednsProvider.go index d7d70fd97c..da506439b4 100644 --- a/providers/hedns/hednsProvider.go +++ b/providers/hedns/hednsProvider.go @@ -191,9 +191,6 @@ func (c *hednsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, recor } } - // Normalize - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records - return c.getDiff2DomainCorrections(dc, zoneID, prunedRecords) } diff --git a/providers/hetzner/hetznerProvider.go b/providers/hetzner/hetznerProvider.go index 0c373c94cb..fb638f39e4 100644 --- a/providers/hetzner/hetznerProvider.go +++ b/providers/hetzner/hetznerProvider.go @@ -7,7 +7,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" ) @@ -72,8 +71,6 @@ func (api *hetznerProvider) EnsureZoneExists(domain string) error { func (api *hetznerProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { domain := dc.Name - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records - toReport, create, del, modify, err := diff.NewCompat(dc).IncrementalDiff(existingRecords) if err != nil { return nil, err diff --git a/providers/hexonet/records.go b/providers/hexonet/records.go index 2ef35aaf70..2408b2456b 100644 --- a/providers/hexonet/records.go +++ b/providers/hexonet/records.go @@ -57,8 +57,6 @@ func (n *HXClient) GetZoneRecords(domain string, meta map[string]string) (models // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (n *HXClient) GetZoneRecordsCorrections(dc *models.DomainConfig, actual models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(dc.Records) - toReport, create, del, mod, err := diff.NewCompat(dc).IncrementalDiff(actual) if err != nil { return nil, err diff --git a/providers/inwx/inwxProvider.go b/providers/inwx/inwxProvider.go index 3ac148aedb..c511d85b6a 100644 --- a/providers/inwx/inwxProvider.go +++ b/providers/inwx/inwxProvider.go @@ -10,7 +10,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff" "github.com/StackExchange/dnscontrol/v4/pkg/printer" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" "github.com/nrdcg/goinwx" "github.com/pquerna/otp/totp" @@ -226,9 +225,6 @@ func checkRecords(records models.Records) error { // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (api *inwxAPI) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) { - - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records - err := checkRecords(dc.Records) if err != nil { return nil, err diff --git a/providers/loopia/loopiaProvider.go b/providers/loopia/loopiaProvider.go index 96815a9b52..896d123078 100644 --- a/providers/loopia/loopiaProvider.go +++ b/providers/loopia/loopiaProvider.go @@ -25,7 +25,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff" "github.com/StackExchange/dnscontrol/v4/pkg/printer" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" "github.com/miekg/dns/dnsutil" ) @@ -271,8 +270,6 @@ func (c *APIClient) GetZoneRecordsCorrections(dc *models.DomainConfig, existingR debugRecords("GenerateZoneRecordsCorrections input:\n", existingRecords) } - // Normalize - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records PrepDesiredRecords(dc) var keysToUpdate map[models.RecordKey][]string diff --git a/providers/msdns/corrections.go b/providers/msdns/corrections.go index f58e2ba20c..32cd6197aa 100644 --- a/providers/msdns/corrections.go +++ b/providers/msdns/corrections.go @@ -5,16 +5,13 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff2" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" ) // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (client *msdnsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) { var corrections []*models.Correction - // Normalize models.PostProcessRecords(foundRecords) - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records changes, err := diff2.ByRecord(foundRecords, dc, nil) if err != nil { diff --git a/providers/netcup/netcupProvider.go b/providers/netcup/netcupProvider.go index e55901772d..2fa866b319 100644 --- a/providers/netcup/netcupProvider.go +++ b/providers/netcup/netcupProvider.go @@ -71,9 +71,6 @@ func (api *netcupProvider) GetNameservers(domain string) ([]*models.Nameserver, func (api *netcupProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { domain := dc.Name - // no need for txtutil.SplitSingleLongTxt in function GetDomainCorrections - // txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records - // Setting the TTL is not supported for netcup for _, r := range dc.Records { r.TTL = 0 diff --git a/providers/oracle/oracleProvider.go b/providers/oracle/oracleProvider.go index 892e6cee8a..aac6204fc5 100644 --- a/providers/oracle/oracleProvider.go +++ b/providers/oracle/oracleProvider.go @@ -9,7 +9,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff" "github.com/StackExchange/dnscontrol/v4/pkg/printer" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" "github.com/StackExchange/dnscontrol/v4/providers" "github.com/oracle/oci-go-sdk/v32/common" "github.com/oracle/oci-go-sdk/v32/dns" @@ -204,7 +203,6 @@ func (o *oracleProvider) GetZoneRecords(zone string, meta map[string]string) (mo // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (o *oracleProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { var err error - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records // Ensure we don't emit changes for attempted modification of built-in apex NSs for _, rec := range dc.Records { diff --git a/providers/route53/route53Provider.go b/providers/route53/route53Provider.go index b9af6c1289..fb0568e87a 100644 --- a/providers/route53/route53Provider.go +++ b/providers/route53/route53Provider.go @@ -279,8 +279,6 @@ func (r *route53Provider) getZoneRecords(zone r53Types.HostedZone) (models.Recor // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (r *route53Provider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records - zone, err := r.getZone(dc) if err != nil { return nil, err diff --git a/providers/rwth/dns.go b/providers/rwth/dns.go index 88b31e6e7e..5ab10d9fc7 100644 --- a/providers/rwth/dns.go +++ b/providers/rwth/dns.go @@ -5,7 +5,6 @@ import ( "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/diff" - "github.com/StackExchange/dnscontrol/v4/pkg/txtutil" ) // RWTHDefaultNs is the default DNS NS for this provider. @@ -31,7 +30,6 @@ func (api *rwthProvider) GetNameservers(domain string) ([]*models.Nameserver, er // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (api *rwthProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) { - txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records domain := dc.Name toReport, create, del, modify, err := diff.NewCompat(dc).IncrementalDiff(existingRecords) From 57216f07f1d59d1453752344f1f88084b7853b21 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Tue, 5 Dec 2023 10:01:55 -0500 Subject: [PATCH 03/67] DOCS: Update docs related to diff2 and clean up useless mentions of diff2 (#2683) Co-authored-by: Costas Drogos Co-authored-by: imlonghao Co-authored-by: Jeffrey Cafferata Co-authored-by: Vincent Hagen --- .github/workflows/pr_test.yml | 2 +- documentation/byo-secrets.md | 2 +- documentation/release-engineering.md | 2 +- documentation/writing-providers.md | 67 ++++++++++------------------ 4 files changed, 27 insertions(+), 46 deletions(-) diff --git a/.github/workflows/pr_test.yml b/.github/workflows/pr_test.yml index 8727f721c1..7520eb7d0d 100644 --- a/.github/workflows/pr_test.yml +++ b/.github/workflows/pr_test.yml @@ -91,7 +91,7 @@ jobs: ENV_CONTEXT: ${{ toJson(env) }} VARS_CONTEXT: ${{ toJson(vars) }} SECRETS_CONTEXT: ${{ toJson(secrets) }} - integrtests-diff2: + integration-tests: if: github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' runs-on: ubuntu-latest container: diff --git a/documentation/byo-secrets.md b/documentation/byo-secrets.md index 20450d561e..d4d650bd18 100644 --- a/documentation/byo-secrets.md +++ b/documentation/byo-secrets.md @@ -79,7 +79,7 @@ The line looks something like: 2. Add your providers `_DOMAIN` env variable: -Add it to the `env` section of `integrtests-diff2`. +Add it to the `env` section of `integration-tests`. For example, the entry for BIND looks like: diff --git a/documentation/release-engineering.md b/documentation/release-engineering.md index 1c66739ab4..8f1302fc68 100644 --- a/documentation/release-engineering.md +++ b/documentation/release-engineering.md @@ -143,7 +143,7 @@ GHA is configured to run an integration test for any provider listed in the "pro 1. Edit `.github/workflows/pr_test.yml` 2. Add the `FOO_DOMAIN` variable name of the provider to the "PROVIDERS" list. 3. Set the `FOO_DOMAIN` variables in GHA via https://github.com/StackExchange/dnscontrol/settings/variables/actions -4. All other variables should be stored as secrets (for consistency). Add them to the `integrtests-diff2` section. +4. All other variables should be stored as secrets (for consistency). Add them to the `integration-tests` section. Set them in GHA via https://github.com/StackExchange/dnscontrol/settings/secrets/actions ### How do I add a "bring your own keys" integration test? diff --git a/documentation/writing-providers.md b/documentation/writing-providers.md index 791a2bc6dd..1e44de3630 100644 --- a/documentation/writing-providers.md +++ b/documentation/writing-providers.md @@ -67,62 +67,42 @@ was confusing so we can update this document with advice for future authors (or even better, update [this document](https://github.com/StackExchange/dnscontrol/blob/master/documentation/writing-providers.md) yourself.) -## NOTE: diff2 - -We are in the process of changing how providers work. Sadly this document -hasn't been fully updated yet. - -We are in the process of changing all providers from using `pkg/diff` to -`pkg/diff2`. diff2 is much easier to use as it does all the hard work for you. -Providers are easier to write, there's less code for you to write, and fewer -chances to make mistakes. +## Step 2: Pick a base provider -New providers only need to implement diff2. Older providers are implemented -both ways, with a flag (`--diff2`) enabling the newer code. Soon the new code -will become the default, then the old code will be removed. +It's a good idea to start by copying a similar provider. -The file `pkg/diff2/diff2.go` has instructions about how to use the new diff2 system. -You can also do `grep diff2.By providers/*/*.go` to find providers that use -the new system. +How can you tell a provider is similar? -Each DNS provider's API is different. Some update one DNS record at a time. +Each DNS provider's API falls into one of 4 category. Some update one DNS record at a time. Others, the only change they permit is to upload the entire zone even if only one record changed! Others are somewhere in between: all records at a label must be updated at once, or all records -in a RecordSet (the label + rType). diff2 provides functions for all of these situations: +in a RecordSet (the label + rType). -diff2.ByRecord() -- Updates are done one DNS record at a time. New records are added. Changes and deletes refer to an ID assigned to the record by the provider. -diff2.ByLabel() -- Updates are done for an entire label. Adds and changes are done by sending one or more records that will appear at that label (i.e. www.example.com). Deletes delete all records at that label. -diff2.ByRecordSet() -- Similar to ByLabel() but updates are done on the label+type level. If www.example.com has 2 A records and 2 MX records, +In summary, provider APIs basically fall into four general categories: +* Updates are done one record at a time (Record) +* Updates are done one label at a time (Label) +* Updates are done one label+type at a time (RecordSet) +* Updates require the entire zone to be uploaded (Zone). +To determine your provider's category, review your API documentation. +To determine an existing provider's category, see which `diff2.By*()` function is used. -## Step 2: Pick a base provider - -Pick a similar provider as your base. Providers basically fall -into three general categories: - -NOTE: diff2 changes this. For now, you can simply run `grep diff2.By providers/*/*.go` to see which -providers use ByZone, ByLabel, ByRecord, ByRecordSet and pick a similar provider to copy from. +DNSControl provides 4 helper functions that do all the hard work for +you. As input, they take the existing zone (what was downloaded via +the API) and the desired zone (what is in `dnsconfig.js`). They +return a list of instructions. Implement handlers for the instructions +and DNSControl is able to perform `dnscontrol push`. -* **zone:** The API requires you to upload the entire zone every time. (BIND, NAMECHEAP). -* **incremental-record:** The API lets you add/change/delete individual DNS records. (CLOUDFLARE, DNSIMPLE, NAMEDOTCOM, GCLOUD, HEXONET) -* **incremental-label:** Like incremental-record, but if there are - multiple records on a label (for example, example www.example.com -has A and MX records), you have to replace all the records at that -label. (GANDI_V5) -* **incremental-label-type:** Like incremental-record, but updates to any records at a label have to be done by type. For example, if a label (www.example.com) has many A and MX records, even the smallest change to one of the A records requires replacing all the A records. Any changes to the MX records requires replacing all the MX records. If an A record is converted to a CNAME, one must remove all the A records in one call, and add the CNAME record with another call. This is deceptively difficult to get right; if you have the choice between incremental-label-type and incremental-label, pick incremental-label. (DESEC, ROUTE53) -* **registrar only:** These providers are registrars but do not provide DNS service. (EASYNAME, INTERNETBS, OPENSRS) +The functions are: -All DNS providers use the "diff" module to detect differences. It takes -two zones and returns records that are unchanged, created, deleted, -and modified. -The zone providers use the -information to print a human-readable list of what is being changed, -but upload the entire new zone. -The incremental providers use the differences to -update individual records or recordsets. +* diff2.ByRecord() -- Updates are done one DNS record at a time. New records are added. Changes and deletes refer to an ID assigned to the record by the provider. +* diff2.ByLabel() -- Updates are done for an entire label. Adds and changes are done by sending one or more records that will appear at that label (i.e. www.example.com). Deletes delete all records at that label. +* diff2.ByRecordSet() -- Similar to ByLabel() but updates are done on the label+type level. If www.example.com has 2 A records and 2 MX records, updates must replace all the A records, or all the MX records, or add records of a different type. +* diff2.ByZone() -- Updates are done by uploading the entire zone every time. +The file `pkg/diff2/diff2.go` has instructions about how to use the diff2 system. ## Step 3: Create the driver skeleton @@ -134,6 +114,7 @@ The main driver should be called `providers/name/nameProvider.go`. The API abstraction is usually in a separate file (often called `api.go`). +Directory names should be consitent. It should be all lowercase and match the ALLCAPS provider name. ## Step 4: Activate the driver From 4e8fb894ef66528b4a9d53a877d25ed341ac55ba Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Tue, 5 Dec 2023 10:02:55 -0500 Subject: [PATCH 04/67] CSCGLOBAL: Be less noisy about rate limit delays (#2686) --- providers/cscglobal/api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/providers/cscglobal/api.go b/providers/cscglobal/api.go index 6ae57f5c61..161acccc46 100644 --- a/providers/cscglobal/api.go +++ b/providers/cscglobal/api.go @@ -647,7 +647,7 @@ func (client *providerClient) geturl(url string) ([]byte, error) { // Default CSCGlobal rate limit is twenty requests per second var backoff = time.Second - const maxBackoff = time.Second * 15 + const maxBackoff = time.Second * 25 retry: resp, err := hclient.Do(req) @@ -666,9 +666,9 @@ retry: if string(bodyString) == "Requests exceeded API Rate limit." { // a simple exponential back-off with a 3-minute max. - if backoff > 10 { + if backoff > (time.Second * 10) { // With this provider backups seem to be pretty common. Only - // announce it when the problem gets really bad. + // announce it for long delays. printer.Printf("Delaying %v due to ratelimit (CSCGLOBAL)\n", backoff) } time.Sleep(backoff) From dbb724b911477a0a696d5a4aa18fe31d1c0c4ecf Mon Sep 17 00:00:00 2001 From: Jan-Philipp Benecke Date: Tue, 5 Dec 2023 22:50:25 +0100 Subject: [PATCH 05/67] CLOUDFLARE: Fixed bug: Zone not populated with records if domain was created in the same run (#2690) Signed-off-by: Jan-Philipp Benecke --- providers/cloudflare/cloudflareProvider.go | 1 + 1 file changed, 1 insertion(+) diff --git a/providers/cloudflare/cloudflareProvider.go b/providers/cloudflare/cloudflareProvider.go index 432de0cf97..8a502810b2 100644 --- a/providers/cloudflare/cloudflareProvider.go +++ b/providers/cloudflare/cloudflareProvider.go @@ -823,6 +823,7 @@ func (c *cloudflareProvider) EnsureZoneExists(domain string) error { var id string id, err := c.createZone(domain) printer.Printf("Added zone for %s to Cloudflare account: %s\n", domain, id) + c.domainIndex = nil // clear the index to let the following functions get a fresh list with nameservers etc.. return err } From 8541fb8510543ad77b780012123107561439126f Mon Sep 17 00:00:00 2001 From: Matthew Gamble Date: Tue, 5 Dec 2023 16:59:32 -0500 Subject: [PATCH 06/67] AZURE_PRIVATE_DNS: Enable building this provider by default (#2688) --- providers/_all/all.go | 1 + 1 file changed, 1 insertion(+) diff --git a/providers/_all/all.go b/providers/_all/all.go index 9f6ab843b6..e1b450afa9 100644 --- a/providers/_all/all.go +++ b/providers/_all/all.go @@ -6,6 +6,7 @@ import ( _ "github.com/StackExchange/dnscontrol/v4/providers/akamaiedgedns" _ "github.com/StackExchange/dnscontrol/v4/providers/autodns" _ "github.com/StackExchange/dnscontrol/v4/providers/axfrddns" + _ "github.com/StackExchange/dnscontrol/v4/providers/azure_private_dns" _ "github.com/StackExchange/dnscontrol/v4/providers/azuredns" _ "github.com/StackExchange/dnscontrol/v4/providers/bind" _ "github.com/StackExchange/dnscontrol/v4/providers/cloudflare" From 742eaaf75fa0ad196aa1171de4e583122fa3467c Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 6 Dec 2023 14:45:51 -0500 Subject: [PATCH 07/67] MSDNS: Remove pssession from docs (it doesn't work) (#2689) --- documentation/providers/msdns.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/documentation/providers/msdns.md b/documentation/providers/msdns.md index 31eb419dd2..d3991d3457 100644 --- a/documentation/providers/msdns.md +++ b/documentation/providers/msdns.md @@ -13,8 +13,6 @@ DNSControl will use `New-PSSession` to execute the commands remotely if DNS and DNSControl are both updating a zone, there will be unhappiness. DNSControl will blindly remove the dynamic records unless precautions such as `IGNORE*` and `NO_PURGE` are in use. -* This is a new provider and has not been tested extensively, - especially the `pssession` feature. # Running on Non-Windows systems @@ -30,7 +28,6 @@ To use this provider, add an entry to `creds.json` with `TYPE` set to `MSDNS` along with other settings: * `dnsserver`: (optional) the name of the Microsoft DNS Server to communicate with. -* `pssession`: (optional) the name of the PowerShell PSSession host to run commands on. * `psusername`: (optional) the username to connect to the PowerShell PSSession host. * `pspassword`: (optional) the password to connect to the PowerShell PSSession host. @@ -42,7 +39,6 @@ Example: "msdns": { "TYPE": "MSDNS", "dnsserver": "ny-dc01", - "pssession": "mywindowshost", "psusername": "mywindowsusername", "pspassword": "mysupersecurepassword" } From 7e5d0881b19629025ff2ab6e8f36300cd72fcf05 Mon Sep 17 00:00:00 2001 From: Jeffrey Cafferata Date: Wed, 6 Dec 2023 22:19:51 +0100 Subject: [PATCH 08/67] DOCS: Providers: Fixed the broken absolute link (#2696) --- documentation/providers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/providers.md b/documentation/providers.md index 1ab8aac789..e65109c0c8 100644 --- a/documentation/providers.md +++ b/documentation/providers.md @@ -168,7 +168,7 @@ code to support this provider, we'd be glad to help in any way. #### Q: Why are the above GitHub issues marked "closed"? -A: Following [the bug triage process](/developer-info/bug-triage), the request +A: Following [the bug triage process](bug-triage.md), the request is closed once it is added to this list. If someone chooses to implement the provider, they re-open the issue. From 9fd65daf5cbab4d5223862ccf195dfda3003724d Mon Sep 17 00:00:00 2001 From: Jeffrey Cafferata Date: Wed, 6 Dec 2023 22:20:59 +0100 Subject: [PATCH 09/67] DOCS: Removed the (by GitBook) broken GitHub links (#2694) --- documentation/writing-providers.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/documentation/writing-providers.md b/documentation/writing-providers.md index 1e44de3630..a9f422ab7b 100644 --- a/documentation/writing-providers.md +++ b/documentation/writing-providers.md @@ -203,11 +203,11 @@ an automated way to test for this bug. The manual steps are here in ## Step 9: Update docs -* Edit [README.md](https://github.com/StackExchange/dnscontrol): Add the provider to the bullet list. -* Edit [documentation/providers.md](https://github.com/StackExchange/dnscontrol/blob/master/documentation/providers.md): Add the provider to the provider list. -* Edit [documentation/SUMMARY.md](https://github.com/StackExchange/dnscontrol/blob/master/documentation/SUMMARY.md): Add the provider to the provider list. +* Edit `README.md`: Add the provider to the bullet list. +* Edit `documentation/providers.md`: Add the provider to the provider list. +* Edit `documentation/SUMMARY.md`: Add the provider to the provider list. * Create `documentation/providers/PROVIDERNAME.md`: Use one of the other files in that directory as a base. -* Edit [OWNERS](https://github.com/StackExchange/dnscontrol/blob/master/OWNERS): Add the directory name and your GitHub username. +* Edit `OWNERS`: Add the directory name and your GitHub username. ## Step 10: Submit a PR From 0c7004825329e47221d5ec9e3020c06e1bacc46a Mon Sep 17 00:00:00 2001 From: Jeffrey Cafferata Date: Wed, 6 Dec 2023 22:22:02 +0100 Subject: [PATCH 10/67] DOCS: Removed the Zoo cross-platform environment variables package (#2693) --- documentation/integration-tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/integration-tests.md b/documentation/integration-tests.md index af81388071..a0c7baee98 100644 --- a/documentation/integration-tests.md +++ b/documentation/integration-tests.md @@ -13,7 +13,7 @@ For each step, it will run the config once and expect changes. It will run it ag ## Running a test 1. The integration tests need a test domain to run on. All the records of this domain will be deleted! -2. Define all environment variables expected for the provider you wish to run. I setup a local `.env` file with the appropriate values and use [zoo](https://github.com/jsonmaur/zoo) to run my commands. +2. Define all environment variables expected for the provider you wish to run. 3. run `cd integrationTest && go test -v -provider $NAME` where $NAME is the name of the provider you wish to run. Example: From 377193926c293fa7b95dfd56dc83aebf641b1a1e Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 6 Dec 2023 16:23:18 -0500 Subject: [PATCH 11/67] CHORE: Clarify TXT string limits (#2691) --- pkg/rejectif/txt.go | 12 ++++++++++++ providers/cscglobal/auditrecords.go | 2 -- providers/digitalocean/auditrecords.go | 4 ---- providers/loopia/auditrecords.go | 16 ++-------------- providers/msdns/auditrecords.go | 2 +- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/pkg/rejectif/txt.go b/pkg/rejectif/txt.go index f9b8427e94..2503f158fc 100644 --- a/pkg/rejectif/txt.go +++ b/pkg/rejectif/txt.go @@ -73,3 +73,15 @@ func TxtLongerThan255(rc *models.RecordConfig) error { } return nil } + +// TxtLongerThan returns a function that audits TXT records for length +// greater than maxLength. +func TxtLongerThan(maxLength int) func(rc *models.RecordConfig) error { + return func(rc *models.RecordConfig) error { + m := maxLength + if len(rc.GetTargetTXTJoined()) > m { + return fmt.Errorf("TXT records longer than %d octets (chars)", m) + } + return nil + } +} diff --git a/providers/cscglobal/auditrecords.go b/providers/cscglobal/auditrecords.go index 87ad6f3380..5cfee5a280 100644 --- a/providers/cscglobal/auditrecords.go +++ b/providers/cscglobal/auditrecords.go @@ -21,8 +21,6 @@ func AuditRecords(records []*models.RecordConfig) []error { a.Add("TXT", rejectif.TxtIsEmpty) // Last verified 2023-12-03 - //a.Add("TXT", rejectif.TxtLongerThan255) // Last verified 2022-06-10 - return a.Audit(records) } diff --git a/providers/digitalocean/auditrecords.go b/providers/digitalocean/auditrecords.go index a6e9eff829..01e7f50013 100644 --- a/providers/digitalocean/auditrecords.go +++ b/providers/digitalocean/auditrecords.go @@ -21,10 +21,6 @@ func AuditRecords(records []*models.RecordConfig) []error { a.Add("TXT", rejectif.TxtHasBackslash) // Last verified 2023-11-11 - a.Add("TXT", rejectif.TxtHasDoubleQuotes) // Last verified 2021-03-01 - // Double-quotes not permitted in TXT strings. I have a hunch that - // this is due to a broken parser on the DO side. - a.Add("TXT", rejectif.TxtIsEmpty) // Last verified 2023-11-11 return a.Audit(records) diff --git a/providers/loopia/auditrecords.go b/providers/loopia/auditrecords.go index d9d8cb2d5f..e8137f0637 100644 --- a/providers/loopia/auditrecords.go +++ b/providers/loopia/auditrecords.go @@ -1,8 +1,6 @@ package loopia import ( - "fmt" - "github.com/StackExchange/dnscontrol/v4/models" "github.com/StackExchange/dnscontrol/v4/pkg/rejectif" ) @@ -15,20 +13,10 @@ func AuditRecords(records []*models.RecordConfig) []error { a.Add("TXT", rejectif.TxtIsEmpty) // Last verified 2023-03-10: Loopia returns 404 - //Loopias TXT length limit appears to be 450 octets - a.Add("TXT", TxtHasSegmentLen450orLonger) + // Loopias TXT length limit appears to be 450 octets + a.Add("TXT", rejectif.TxtLongerThan(450)) // Last verified 2023-03-10 a.Add("MX", rejectif.MxNull) // Last verified 2023-03-23 return a.Audit(records) } - -// TxtHasSegmentLen450orLonger audits TXT records for strings that are >450 octets. -func TxtHasSegmentLen450orLonger(rc *models.RecordConfig) error { - for _, txt := range rc.GetTargetTXTSegmented() { - if len(txt) > 450 { - return fmt.Errorf("%q txtstring length > 450", rc.GetLabel()) - } - } - return nil -} diff --git a/providers/msdns/auditrecords.go b/providers/msdns/auditrecords.go index 8694ffcae9..f3fe4fa3dd 100644 --- a/providers/msdns/auditrecords.go +++ b/providers/msdns/auditrecords.go @@ -19,7 +19,7 @@ func AuditRecords(records []*models.RecordConfig) []error { a.Add("TXT", rejectif.TxtHasDoubleQuotes) // Last verified 2023-02-02 - a.Add("TXT", rejectif.TxtLongerThan255) // Last verified 2023-02-02 + a.Add("TXT", rejectif.TxtLongerThan(255)) // Last verified 2023-02-02 a.Add("TXT", rejectif.TxtHasSingleQuotes) // Last verified 2023-02-02 From 3b6643b12d0172d959a2cb4899778c02494044e5 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Wed, 6 Dec 2023 17:29:55 -0500 Subject: [PATCH 12/67] AZURE_PRIVATE_DNS: Rename module to conform to Go styleguide (#2697) --- OWNERS | 2 +- documentation/providers.md | 1 + providers/_all/all.go | 2 +- .../{azure_private_dns => azureprivatedns}/auditrecords.go | 2 +- .../azurePrivateDnsProvider.go | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) rename providers/{azure_private_dns => azureprivatedns}/auditrecords.go (94%) rename providers/{azure_private_dns => azureprivatedns}/azurePrivateDnsProvider.go (99%) diff --git a/OWNERS b/OWNERS index 7c34732a41..a436984258 100644 --- a/OWNERS +++ b/OWNERS @@ -2,7 +2,7 @@ providers/akamaiedgedns @svernick providers/autodns @arnoschoon providers/axfrddns @hnrgrgr providers/azuredns @vatsalyagoel -providers/azure_private_dns @matthewmgamble +providers/azureprivatedns @matthewmgamble providers/bind @tlimoncelli providers/cloudflare @tresni providers/cloudns @pragmaton diff --git a/documentation/providers.md b/documentation/providers.md index e65109c0c8..917baab155 100644 --- a/documentation/providers.md +++ b/documentation/providers.md @@ -18,6 +18,7 @@ If a feature is definitively not supported for whatever reason, we would also li | [`AUTODNS`](providers/autodns.md) | ❌ | ✅ | ❌ | ✅ | ✅ | ❔ | ❔ | ❔ | ❌ | ❔ | ✅ | ❌ | ❌ | ❌ | ❔ | ❌ | ❌ | ✅ | ✅ | | [`AXFRDDNS`](providers/axfrddns.md) | ❌ | ✅ | ❌ | ❔ | ✅ | ✅ | ❔ | ✅ | ✅ | ❔ | ✅ | ✅ | ✅ | ❔ | ✅ | ❌ | ❌ | ❌ | ❌ | | [`AZURE_DNS`](providers/azure_dns.md) | ✅ | ✅ | ❌ | ❌ | ✅ | ❔ | ❌ | ❌ | ✅ | ❔ | ✅ | ❌ | ❌ | ❔ | ❔ | ✅ | ✅ | ✅ | ✅ | +| [`AZURE_PRIVATE_DNS`](providers/azure_private_dns.md) | ✅ | ✅ | ❌ | ❌ | ❌ | ❔ | ❌ | ❌ | ✅ | ❔ | ✅ | ❌ | ❌ | ❔ | ❔ | ✅ | ✅ | ✅ | ✅ | | [`BIND`](providers/bind.md) | ✅ | ✅ | ❌ | ❔ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | | [`CLOUDFLAREAPI`](providers/cloudflareapi.md) | ✅ | ✅ | ❌ | ✅ | ✅ | ❔ | ❌ | ✅ | ✅ | ❔ | ✅ | ✅ | ✅ | ❔ | ❔ | ❌ | ✅ | ✅ | ✅ | | [`CLOUDNS`](providers/cloudns.md) | ❌ | ✅ | ❌ | ✅ | ✅ | ❔ | ❌ | ❔ | ✅ | ❔ | ✅ | ✅ | ✅ | ❔ | ❔ | ❔ | ✅ | ✅ | ✅ | diff --git a/providers/_all/all.go b/providers/_all/all.go index e1b450afa9..48be689e94 100644 --- a/providers/_all/all.go +++ b/providers/_all/all.go @@ -6,8 +6,8 @@ import ( _ "github.com/StackExchange/dnscontrol/v4/providers/akamaiedgedns" _ "github.com/StackExchange/dnscontrol/v4/providers/autodns" _ "github.com/StackExchange/dnscontrol/v4/providers/axfrddns" - _ "github.com/StackExchange/dnscontrol/v4/providers/azure_private_dns" _ "github.com/StackExchange/dnscontrol/v4/providers/azuredns" + _ "github.com/StackExchange/dnscontrol/v4/providers/azureprivatedns" _ "github.com/StackExchange/dnscontrol/v4/providers/bind" _ "github.com/StackExchange/dnscontrol/v4/providers/cloudflare" _ "github.com/StackExchange/dnscontrol/v4/providers/cloudns" diff --git a/providers/azure_private_dns/auditrecords.go b/providers/azureprivatedns/auditrecords.go similarity index 94% rename from providers/azure_private_dns/auditrecords.go rename to providers/azureprivatedns/auditrecords.go index 6c478a955d..cea8335b2a 100644 --- a/providers/azure_private_dns/auditrecords.go +++ b/providers/azureprivatedns/auditrecords.go @@ -1,4 +1,4 @@ -package azure_private_dns +package azureprivatedns import ( "github.com/StackExchange/dnscontrol/v4/models" diff --git a/providers/azure_private_dns/azurePrivateDnsProvider.go b/providers/azureprivatedns/azurePrivateDnsProvider.go similarity index 99% rename from providers/azure_private_dns/azurePrivateDnsProvider.go rename to providers/azureprivatedns/azurePrivateDnsProvider.go index c798532dae..a6484a4405 100644 --- a/providers/azure_private_dns/azurePrivateDnsProvider.go +++ b/providers/azureprivatedns/azurePrivateDnsProvider.go @@ -1,4 +1,4 @@ -package azure_private_dns +package azureprivatedns import ( "context" From cd371c114924377e13a7a0d809ce7459eafca4f7 Mon Sep 17 00:00:00 2001 From: Gert Van Gool Date: Fri, 8 Dec 2023 08:58:24 -0800 Subject: [PATCH 13/67] INWX: support MxNull records (#2700) Co-authored-by: Tom Limoncelli --- providers/inwx/auditrecords.go | 2 -- providers/inwx/inwxProvider.go | 12 ++++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/providers/inwx/auditrecords.go b/providers/inwx/auditrecords.go index fb15d2e71b..64dff42e24 100644 --- a/providers/inwx/auditrecords.go +++ b/providers/inwx/auditrecords.go @@ -11,8 +11,6 @@ import ( func AuditRecords(records []*models.RecordConfig) []error { a := rejectif.Auditor{} - a.Add("MX", rejectif.MxNull) // Last verified 2020-12-28 - a.Add("SRV", rejectif.SrvHasNullTarget) // Last verified 2020-12-28 a.Add("TXT", rejectif.TxtHasBackticks) // Last verified 2021-03-01 diff --git a/providers/inwx/inwxProvider.go b/providers/inwx/inwxProvider.go index c511d85b6a..f615d80829 100644 --- a/providers/inwx/inwxProvider.go +++ b/providers/inwx/inwxProvider.go @@ -180,7 +180,11 @@ func makeNameserverRecordRequest(domain string, rec *models.RecordConfig) *goinw req.Content = content[:len(content)-1] case "MX": req.Priority = int(rec.MxPreference) - req.Content = content[:len(content)-1] + if content == "." { + req.Content = content + } else { + req.Content = content[:len(content)-1] + } case "SRV": req.Priority = int(rec.SrvPriority) req.Content = fmt.Sprintf("%d %d %v", rec.SrvWeight, rec.SrvPort, content[:len(content)-1]) @@ -305,7 +309,11 @@ func (api *inwxAPI) GetZoneRecords(domain string, meta map[string]string) (model "PTR": true, } if rtypeAddDot[record.Type] { - record.Content = record.Content + "." + if record.Type == "MX" && record.Content == "." { + // null records don't need to be modified + } else { + record.Content = record.Content + "." + } } rc := &models.RecordConfig{ From e917568addf8ca64b55e439f90717d9bf8a56a3d Mon Sep 17 00:00:00 2001 From: Jeffrey Cafferata Date: Sun, 10 Dec 2023 16:26:41 +0100 Subject: [PATCH 14/67] CICD: Removed the old Travis configurations (#2707) --- .travis.yml | 21 ------ build/validate/validate.go | 130 ------------------------------------- 2 files changed, 151 deletions(-) delete mode 100644 .travis.yml delete mode 100644 build/validate/validate.go diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ec3b1fec7c..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: go - -go: - - 1.14.x - -install: pwd - -script: - - go run -mod=readonly build/validate/validate.go - - go test -mod=readonly ./... - -notifications: - email: - on_success: never # default: change - on_failure: always # default: always - webhooks: - urls: - - https://webhooks.gitter.im/e/4f27a4a85d6f4475be19 - on_success: always - on_failure: always - on_start: always diff --git a/build/validate/validate.go b/build/validate/validate.go deleted file mode 100644 index de90ef68ac..0000000000 --- a/build/validate/validate.go +++ /dev/null @@ -1,130 +0,0 @@ -package main - -import ( - "context" - "crypto/aes" - "crypto/cipher" - "encoding/base64" - "fmt" - "os" - "os/exec" - "strings" - - "github.com/google/go-github/v35/github" - "golang.org/x/oauth2" -) - -func main() { - failed := false - - run := func(ctx string, preStatus string, goodStatus string, f func() error) { - setStatus(stPending, preStatus, ctx) - if err := f(); err != nil { - fmt.Println(err) - setStatus(stError, err.Error(), ctx) - failed = true - } else { - setStatus(stSuccess, goodStatus, ctx) - } - } - - run("gofmt", "Checking gofmt", "gofmt ok", checkGoFmt) - run("gogen", "Checking go generate", "go generate ok", checkGoGenerate) - if failed { - os.Exit(1) - } -} - -func checkGoFmt() error { - cmd := exec.Command("gofmt", "-s", "-l", ".") - out, err := cmd.CombinedOutput() - if err != nil { - return err - } - if len(out) == 0 { - return nil - } - files := strings.Split(string(out), "\n") - fList := "" - for _, f := range files { - if strings.HasPrefix(f, "vendor") { - continue - } - if fList != "" { - fList += "\n" - } - fList += f - } - if fList == "" { - return nil - } - return fmt.Errorf("the following files need to have gofmt run on them:\n%s", fList) -} - -func checkGoGenerate() error { - cmd := exec.Command("go", "generate") - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err := cmd.Run() - if err != nil { - return err - } - modified, err := getModifiedFiles() - if err != nil { - return err - } - if len(modified) != 0 { - return fmt.Errorf("ERROR: The following files are modified after go generate:\n%s", strings.Join(modified, "\n")) - } - return nil -} - -func getModifiedFiles() ([]string, error) { - cmd := exec.Command("git", strings.Split("diff --name-only", " ")...) - out, err := cmd.CombinedOutput() - if err != nil { - return nil, err - } - if len(out) == 0 { - return nil, nil - } - return strings.Split(string(out), "\n"), nil -} - -const ( - stPending = "pending" - stSuccess = "success" - stError = "error" -) - -func setStatus(status string, desc string, ctx string) { - if commitish == "" || ctx == "" { - return - } - client.Repositories.CreateStatus(context.Background(), "StackExchange", "dnscontrol", commitish, &github.RepoStatus{ - Context: &ctx, - Description: &desc, - State: &status, - }) -} - -var client *github.Client -var commitish string - -func init() { - // not intended for security, just minimal obfuscation. - key, _ := base64.StdEncoding.DecodeString("qIOy76aRcXcxm3vb82tvZqW6JoYnpncgVKx7qej1y+4=") - iv, _ := base64.StdEncoding.DecodeString("okRtW8z6Mx04Y9yMk1cb5w==") - garb, _ := base64.StdEncoding.DecodeString("ut8AtS6re1g7m/onk0ciIq7OxNOdZ/tsQ5ay6OfxKcARnBGY0bQ+pA==") - c, _ := aes.NewCipher(key) - d := cipher.NewCFBDecrypter(c, iv) - t := make([]byte, len(garb)) - d.XORKeyStream(t, garb) - hc := oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(&oauth2.Token{AccessToken: string(t)})) - client = github.NewClient(hc) - - // get current version if in travis build - if tc := os.Getenv("TRAVIS_COMMIT"); tc != "" { - commitish = tc - } -} From 11f072b887ba67a73fcd33e360422e3d6fbc3bad Mon Sep 17 00:00:00 2001 From: Jeffrey Cafferata Date: Sun, 10 Dec 2023 16:27:24 +0100 Subject: [PATCH 15/67] CICD: Removed the old Chocolatey configuration (#2706) --- dnscontrol.nuspec | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 dnscontrol.nuspec diff --git a/dnscontrol.nuspec b/dnscontrol.nuspec deleted file mode 100644 index 015533866c..0000000000 --- a/dnscontrol.nuspec +++ /dev/null @@ -1,23 +0,0 @@ - - - - - dnscontrol - 0.0.0 - DnsControl - Stack Overflow - https://github.com/stackexchange/dnscontrol - 2020 - https://github.com/StackExchange/dnscontrol/blob/master/LICENSE - true - https://github.com/stackexchange/dnscontrol - https://docs.dnscontrol.org/ - dns - Synchronize your DNS to multiple providers from a simple DSL - This package simply installs the dnscontrol tool on your system - - - - - - From 99e3f9f0468cd81280f22f42adc4a7816b5e48d9 Mon Sep 17 00:00:00 2001 From: Jeffrey Cafferata Date: Sun, 10 Dec 2023 16:27:57 +0100 Subject: [PATCH 16/67] CICD: Removed the old Azure Pipelines configurations (#2705) --- azure-pipelines.yml | 70 --------------- build/azure-pipelines/choco.yaml | 19 ---- build/azure-pipelines/go-env.yaml | 6 -- build/azure-pipelines/integration.yml | 121 -------------------------- 4 files changed, 216 deletions(-) delete mode 100644 azure-pipelines.yml delete mode 100644 build/azure-pipelines/choco.yaml delete mode 100644 build/azure-pipelines/go-env.yaml delete mode 100644 build/azure-pipelines/integration.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 9ca9132c8b..0000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,70 +0,0 @@ -trigger: - batch: "true" - branches: - include: - - master - -jobs: - -- job: Compile - strategy: - maxParallel: 3 - matrix: - Windows: - OS: windows - OSX: - OS: darwin - Linux: - OS: linux - steps: - - template: build/azure-pipelines/go-env.yaml - - script: "go run -mod=readonly build/build.go -os $(OS)" - -- job: "unittests" - displayName: "Run Unit Tests" - steps: - - template: build/azure-pipelines/go-env.yaml - - script: "go test -mod=readonly ./..." - -- job: "modtidy" - displayName: "Check Go Modules" - steps: - - template: build/azure-pipelines/go-env.yaml - - script: | - set -e - go mod tidy - git status --porcelain - git diff - [ ! -n "$(git status --porcelain go.mod go.sum)" ] || { echo "Error: go.mod/go.sum outdated, please run go mod tidy."; false; } - -- job: "modvendor" - displayName: "Check Go Vendor" - steps: - - template: build/azure-pipelines/go-env.yaml - - script: | - set -e - go mod vendor - git status --porcelain - [ ! -n "$(git status --porcelain vendor)" ] || { echo "Error: Vendor does not match go.mod/go.sum, please run go mod vendor."; false; } - -- job: "GoFmt" - displayName: "Check Go Formatting" - steps: - - template: build/azure-pipelines/go-env.yaml - - script: | - set -e - go fmt ./... - git status --porcelain - git diff - [ ! -n "$(git status --porcelain)" ] || { echo "Error: Go files not formatted, please run go fmt ./... ."; false; } - -- job: "GoGen" - displayName: "Check Go Generate" - steps: - - template: build/azure-pipelines/go-env.yaml - - script: | - set -e - go generate . - git status --porcelain - git diff - [ ! -n "$(git status --porcelain)" ] || { echo "Error: Generated files not up to date, please run go generate . ."; false; } diff --git a/build/azure-pipelines/choco.yaml b/build/azure-pipelines/choco.yaml deleted file mode 100644 index aa912913de..0000000000 --- a/build/azure-pipelines/choco.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: -# https://aka.ms/yaml - -trigger: -- master - -pool: - vmImage: 'ubuntu-latest' - -steps: -- script: echo Hello, world! - displayName: 'Run a one-line script' - -- script: | - echo Add other tasks to build, test, and deploy your project. - echo See https://aka.ms/yaml - displayName: 'Run a multi-line script' diff --git a/build/azure-pipelines/go-env.yaml b/build/azure-pipelines/go-env.yaml deleted file mode 100644 index 9d2f56c441..0000000000 --- a/build/azure-pipelines/go-env.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# shared step for setting up go env -# see https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/go?view=azure-devops#build-a-container-image -steps: -- task: GoTool@0 - inputs: - version: '1.16' diff --git a/build/azure-pipelines/integration.yml b/build/azure-pipelines/integration.yml deleted file mode 100644 index c75efe39c9..0000000000 --- a/build/azure-pipelines/integration.yml +++ /dev/null @@ -1,121 +0,0 @@ -variables: - wd: '$(System.DefaultWorkingDirectory)/integrationTest' - -trigger: - batch: "true" - branches: - include: - - pipeline - -# Each provider gets its' own job. These will run in parallel. -# each job gets setup with only the env vars it needs for that run. -# these are defined in azure pipelines web ui as secret variables. - -jobs: - -- job: Route53 - steps: - - template: go-env.yaml - - script: go test -v -verbose -provider ROUTE53 - workingDirectory: $(wd) - env: - R53_DOMAIN: $(R53_DOMAIN) - R53_KEY_ID: $(R53_KEY_ID) - R53_KEY: $(R53_KEY) - -- job: GCloud - steps: - - template: go-env.yaml - - script: go test -v -verbose -provider GCLOUD - workingDirectory: $(wd) - env: - GCLOUD_DOMAIN: $(GCLOUD_DOMAIN) - GCLOUD_TYPE: $(GCLOUD_TYPE) - GCLOUD_EMAIL: $(GCLOUD_EMAIL) - GCLOUD_PROJECT: $(GCLOUD_PROJECT) - GCLOUD_PRIVATEKEY: $(GCLOUD_PRIVATEKEY) - -- job: NameDotCom - steps: - - template: go-env.yaml - - script: go test -v -verbose -provider NAMEDOTCOM - workingDirectory: $(wd) - env: - NAMEDOTCOM_DOMAIN: $(NAMEDOTCOM_DOMAIN) - NAMEDOTCOM_KEY: $(NAMEDOTCOM_KEY) - NAMEDOTCOM_USER: $(NAMEDOTCOM_USER) - -- job: Cloudflare - steps: - - template: go-env.yaml - - script: go test -v -timeout 30m -verbose -provider CLOUDFLAREAPI - workingDirectory: $(wd) - env: - CF_TOKEN: $(CF_TOKEN) - -- job: DigitalOcean - steps: - - template: go-env.yaml - - script: go test -v -verbose -provider DIGITALOCEAN - workingDirectory: $(wd) - env: - DO_DOMAIN: $(DO_DOMAIN) - DO_TOKEN: $(DO_TOKEN) - -- job: GandiV5 - steps: - - template: go-env.yaml - - script: go test -v -verbose -provider GANDI_V5 - workingDirectory: $(wd) - env: - GANDI_KEY: $(GANDI_V5_APIKEY) - GANDI_DOMAIN: $(GANDI_V5_DOMAIN) - -# - job: GandiLive -# steps: -# - template: go-env.yaml -# - script: go test -v -verbose -provider GANDI-LIVEDNS -# workingDirectory: $(wd) -# env: -# GANDILIVE_KEY: $(GANDILIVE_KEY) -# GANDILIVE_DOMAIN: $(GANDILIVE_DOMAIN) - -# - job: NS1 -# steps: -# - template: go-env.yaml -# - script: go test -v -verbose -provider NS1 -# workingDirectory: $(wd) -# env: -# NS1_TOKEN: $(NS1_TOKEN) -# NS1_DOMAIN: $(NS1_DOMAIN) - -- job: DNSIMPLE - steps: - - template: go-env.yaml - - script: go test -v -verbose -provider DNSIMPLE - workingDirectory: $(wd) - env: - DNSIMPLE_TOKEN: $(DNSIMPLE_TOKEN) - DNSIMPLE_DOMAIN: $(DNSIMPLE_DOMAIN) - -- job: Vultr - steps: - - template: go-env.yaml - - script: go test -v -verbose -provider VULTR - workingDirectory: $(wd) - env: - VULTR_DOMAIN: $(VULTR_DOMAIN) - VULTR_TOKEN: $(VULTR_TOKEN) - -- job: Azure - steps: - - template: go-env.yaml - - script: go test -v -verbose -provider AZURE_DNS - workingDirectory: $(wd) - env: - AZURE_CLIENT_ID: $(AZ_CLIENTID) - AZURE_CLIENT_SECRET: $(AZ_CLIENTSECRET) - AZURE_DOMAIN: $(AZ_DOMAIN) - AZURE_RESOURCE_GROUP: $(AZ_RSGNAME) - AZURE_SUBSCRIPTION_ID: $(AZ_SUBSCRIPTIONID) - AZURE_TENANT_ID: $(AZ_TENANTID) From a6091f2ed4aa73bec6608dbb0174d06ff70083a4 Mon Sep 17 00:00:00 2001 From: Costas Drogos Date: Sun, 10 Dec 2023 16:29:09 +0100 Subject: [PATCH 17/67] BUG: Register an error if EnzureZoneExists fails (#2703) --- commands/previewPush.go | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/previewPush.go b/commands/previewPush.go index 7ac4cce809..ebeff28cdc 100644 --- a/commands/previewPush.go +++ b/commands/previewPush.go @@ -211,6 +211,7 @@ func run(args PreviewArgs, push bool, interactive bool, out printer.CLI, report // this is the actual push, ensure domain exists at DSP if err := creator.EnsureZoneExists(domain.Name); err != nil { out.Warnf("Error creating domain: %s\n", err) + anyErrors = true continue // continue with next provider, as we couldn't create this one } } From 8f1b33ae17a6f1f776a1e3213f4f691445345fcf Mon Sep 17 00:00:00 2001 From: Jeffrey Cafferata Date: Sun, 10 Dec 2023 16:34:24 +0100 Subject: [PATCH 18/67] CICD: GoReleaser generates TypeScript file (#2704) Co-authored-by: Tom Limoncelli --- .gitignore | 1 + .goreleaser.yml | 4 +- commands/types/dnscontrol.d.ts | 2991 -------------------------------- 3 files changed, 4 insertions(+), 2992 deletions(-) delete mode 100644 commands/types/dnscontrol.d.ts diff --git a/.gitignore b/.gitignore index 84b1e05b47..70089b4c2e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /tmp +/commands/types/dnscontrol.d.ts dnscontrol-Darwin dnscontrol-Linux dnscontrol.exe diff --git a/.goreleaser.yml b/.goreleaser.yml index dc77e4f7da..ca667aa4ba 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -21,7 +21,9 @@ builds: - -linkmode=internal -s -w -X main.Version="{{ .Version }}" -X main.SHA="{{ .FullCommit }}" -X main.BuildTime={{ .Timestamp }} before: hooks: - - go mod tidy + - go fmt ./... + - go mod tidy + - go generate ./... changelog: sort: asc use: github diff --git a/commands/types/dnscontrol.d.ts b/commands/types/dnscontrol.d.ts deleted file mode 100644 index a850f30275..0000000000 --- a/commands/types/dnscontrol.d.ts +++ /dev/null @@ -1,2991 +0,0 @@ -// WARNING: These type definitions are experimental and subject to change in future releases. - -interface Domain { - name: string; - subdomain: string; - registrar: unknown; - meta: Record; - records: DNSRecord[]; - dnsProviders: Record; - defaultTTL: number; - nameservers: unknown[]; - ignored_names: unknown[]; - ignored_targets: unknown[]; - [key: string]: unknown; -} - -interface DNSRecord { - type: string; - meta: Record; - ttl: number; -} - -type DomainModifier = - | ((domain: Domain) => void) - | Partial - | DomainModifier[]; - -type RecordModifier = - | ((record: DNSRecord) => void) - | Partial; - -type Duration = - | `${number}${'s' | 'm' | 'h' | 'd' | 'w' | 'n' | 'y' | ''}` - | number /* seconds */; - - -/** - * `FETCH` is a wrapper for the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This allows dynamically setting DNS records based on an external data source, e.g. the API of your cloud provider. - * - * Compared to `fetch` from Fetch API, `FETCH` will call [PANIC](PANIC.md) to terminate the execution of the script, and therefore DNSControl, if a network error occurs. - * - * Otherwise the syntax of `FETCH` is the same as `fetch`. - * - * `FETCH` is not enabled by default. Please read the warnings below. - * - * > WARNING: - * > - * > 1. Relying on external sources adds a point of failure. If the external source doesn't work, your script won't either. Please make sure you are aware of the consequences. - * > 2. Make sure DNSControl only uses verified configuration if you want to use `FETCH`. For example, an attacker can send Pull Requests to your config repo, and have your CI test malicious configurations and make arbitrary HTTP requests. Therefore, `FETCH` must be explicitly enabled with flag `--allow-fetch` on DNSControl invocation. - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), [ - * A("@", "1.2.3.4"), - * ]); - * - * FETCH("https://example.com", { - * // All three options below are optional - * headers: {"X-Authentication": "barfoo"}, - * method: "POST", - * body: "Hello World", - * }).then(function(r) { - * return r.text(); - * }).then(function(t) { - * // Example of generating record based on response - * D_EXTEND("example.com", [ - * TXT("@", t.slice(0, 100)), - * ]); - * }); - * ``` - */ -declare function FETCH( - url: string, - init?: { - method?: - | 'GET' - | 'POST' - | 'PUT' - | 'PATCH' - | 'DELETE' - | 'HEAD' - | 'OPTIONS'; - headers?: { [key: string]: string | string[] }; - // Ignored by the underlying code - // redirect: 'follow' | 'error' | 'manual'; - body?: string; - } -): Promise; - -interface FetchResponse { - readonly bodyUsed: boolean; - readonly headers: ResponseHeaders; - readonly ok: boolean; - readonly status: number; - readonly statusText: string; - readonly type: string; - - text(): Promise; - json(): Promise; -} - -interface ResponseHeaders { - get(name: string): string | undefined; - getAll(name: string): string[]; - has(name: string): boolean; - - append(name: string, value: string): void; - delete(name: string): void; - set(name: string, value: string): void; -} - - -declare function require(name: `${string}.json`): any; -declare function require(name: string): true; - -/** - * Issuer critical flag. CA that does not understand this tag will refuse to issue certificate for this domain. - * - * CAA record is supported only by BIND, Google Cloud DNS, Amazon Route 53 and OVH. Some certificate authorities may not support this record until the mandatory date of September 2017. - */ -declare const CAA_CRITICAL: RecordModifier; - -/** - * @deprecated - * This disables a safety check intended to prevent: - * 1. Two owners toggling a record between two settings. - * 2. The other owner wiping all records at this label, which won't - * be noticed until the next time dnscontrol is run. - * See https://github.com/StackExchange/dnscontrol/issues/1106 - */ -declare const IGNORE_NAME_DISABLE_SAFETY_CHECK: RecordModifier; - -// Cloudflare aliases: - -/** Proxy disabled. */ -declare const CF_PROXY_OFF: RecordModifier; -/** Proxy enabled. */ -declare const CF_PROXY_ON: RecordModifier; -/** Proxy+Railgun enabled. */ -declare const CF_PROXY_FULL: RecordModifier; - -/** Proxy default off for entire domain (the default) */ -declare const CF_PROXY_DEFAULT_OFF: DomainModifier; -/** Proxy default on for entire domain */ -declare const CF_PROXY_DEFAULT_ON: DomainModifier; -/** UniversalSSL off for entire domain */ -declare const CF_UNIVERSALSSL_OFF: DomainModifier; -/** UniversalSSL on for entire domain */ -declare const CF_UNIVERSALSSL_ON: DomainModifier; - -/** - * Set default values for CLI variables. See: https://dnscontrol.org/cli-variables - */ -declare function CLI_DEFAULTS(vars: Record): void; - -/** - * `END` permits the last item to include a comma. - * - * ```js - * D("foo.com", ... - * A(...), - * A(...), - * A(...), - * END) - * ``` - */ -declare const END: DomainModifier & RecordModifier; - -/** - * Permit labels like `"foo.bar.com.bar.com"` (normally an error) - * - * ```js - * D("bar.com", ... - * A("foo.bar.com", "10.1.1.1", DISABLE_REPEATED_DOMAIN_CHECK), - * ) - * ``` - */ -declare const DISABLE_REPEATED_DOMAIN_CHECK: RecordModifier; - - -/** - * A adds an A record To a domain. The name should be the relative label for the record. Use `@` for the domain apex. - * - * The address should be an ip address, either a string, or a numeric value obtained via [IP](../global/IP.md). - * - * Modifiers can be any number of [record modifiers](https://docs.dnscontrol.org/language-reference/record-modifiers) or JSON objects, which will be merged into the record's metadata. - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * A("@", "1.2.3.4"), - * A("foo", "2.3.4.5"), - * A("test.foo", IP("1.2.3.4"), TTL(5000)), - * A("*", "1.2.3.4", {foo: 42}) - * ); - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/a - */ -declare function A(name: string, address: string | number, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * AAAA adds an AAAA record To a domain. The name should be the relative label for the record. Use `@` for the domain apex. - * - * The address should be an IPv6 address as a string. - * - * Modifiers can be any number of [record modifiers](https://docs.dnscontrol.org/language-reference/record-modifiers) or JSON objects, which will be merged into the record's metadata. - * - * ```javascript - * var addrV6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334" - * - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * AAAA("@", addrV6), - * AAAA("foo", addrV6), - * AAAA("test.foo", addrV6, TTL(5000)), - * AAAA("*", addrV6, {foo: 42}) - * ); - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/aaaa - */ -declare function AAAA(name: string, address: string, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * AKAMAICDN is a proprietary record type that is used to configure [Zone Apex Mapping](https://blogs.akamai.com/2019/08/fast-dns-zone-apex-mapping-dnssec.html). - * The AKAMAICDN target must be preconfigured in the Akamai network. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/service-provider-specific/akamai-edge-dns/akamaicdn - */ -declare function AKAMAICDN(name: string, target: string, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * ALIAS is a virtual record type that points a record at another record. It is analogous to a CNAME, but is usually resolved at request-time and served as an A record. Unlike CNAMEs, ALIAS records can be used at the zone apex (`@`) - * - * Different providers handle ALIAS records differently, and many do not support it at all. Attempting to use ALIAS records with a DNS provider type that does not support them will result in an error. - * - * The name should be the relative label for the domain. - * - * Target should be a string representing the target. If it is a single label we will assume it is a relative name on the current domain. If it contains *any* dots, it should be a fully qualified domain name, ending with a `.`. - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * ALIAS("@", "google.com."), // example.com -> google.com - * ); - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/alias - */ -declare function ALIAS(name: string, target: string, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * AUTODNSSEC_OFF tells the provider to disable AutoDNSSEC. It takes no - * parameters. - * - * See `AUTODNSSEC_ON` for further details. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/autodnssec_off - */ -declare const AUTODNSSEC_OFF: DomainModifier; - -/** - * AUTODNSSEC_ON tells the provider to enable AutoDNSSEC. - * - * AUTODNSSEC_OFF tells the provider to disable AutoDNSSEC. - * - * AutoDNSSEC is a feature where a DNS provider can automatically manage - * DNSSEC for a domain. Not all providers support this. - * - * At this time, AUTODNSSEC_ON takes no parameters. There is no ability - * to tune what the DNS provider sets, no algorithm choice. We simply - * ask that they follow their defaults when enabling a no-fuss DNSSEC - * data model. - * - * NOTE: No parenthesis should follow these keywords. That is, the - * correct syntax is `AUTODNSSEC_ON` not `AUTODNSSEC_ON()` - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * AUTODNSSEC_ON, // Enable AutoDNSSEC. - * A("@", "10.1.1.1") - * ); - * - * D("insecure.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * AUTODNSSEC_OFF, // Disable AutoDNSSEC. - * A("@", "10.2.2.2") - * ); - * ``` - * - * If neither `AUTODNSSEC_ON` or `AUTODNSSEC_OFF` is specified for a - * domain no changes will be requested. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/autodnssec_on - */ -declare const AUTODNSSEC_ON: DomainModifier; - -/** - * AZURE_ALIAS is a Azure specific virtual record type that points a record at either another record or an Azure entity. - * It is analogous to a CNAME, but is usually resolved at request-time and served as an A record. - * Unlike CNAMEs, ALIAS records can be used at the zone apex (`@`) - * - * Unlike the regular ALIAS directive, AZURE_ALIAS is only supported on AZURE. - * Attempting to use AZURE_ALIAS on another provider than Azure will result in an error. - * - * The name should be the relative label for the domain. - * - * The type can be any of the following: - * * A - * * AAAA - * * CNAME - * - * Target should be the Azure Id representing the target. It starts `/subscription/`. The resource id can be found in https://resources.azure.com/. - * - * The Target can : - * - * * Point to a public IP resource from a DNS `A/AAAA` record set. - * You can create an A/AAAA record set and make it an alias record set to point to a public IP resource (standard or basic). - * The DNS record set changes automatically if the public IP address changes or is deleted. - * Dangling DNS records that point to incorrect IP addresses are avoided. - * There is a current limit of 20 alias records sets per resource. - * * Point to a Traffic Manager profile from a DNS `A/AAAA/CNAME` record set. - * You can create an A/AAAA or CNAME record set and use alias records to point it to a Traffic Manager profile. - * It's especially useful when you need to route traffic at a zone apex, as traditional CNAME records aren't supported for a zone apex. - * For example, say your Traffic Manager profile is myprofile.trafficmanager.net and your business DNS zone is contoso.com. - * You can create an alias record set of type A/AAAA for contoso.com (the zone apex) and point to myprofile.trafficmanager.net. - * * Point to an Azure Content Delivery Network (CDN) endpoint. - * This is useful when you create static websites using Azure storage and Azure CDN. - * * Point to another DNS record set within the same zone. - * Alias records can reference other record sets of the same type. - * For example, a DNS CNAME record set can be an alias to another CNAME record set. - * This arrangement is useful if you want some record sets to be aliases and some non-aliases. - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider("AZURE_DNS"), - * AZURE_ALIAS("foo", "A", "/subscriptions/726f8cd6-6459-4db4-8e6d-2cd2716904e2/resourceGroups/test/providers/Microsoft.Network/trafficManagerProfiles/testpp2"), // record for traffic manager - * AZURE_ALIAS("foo", "CNAME", "/subscriptions/726f8cd6-6459-4db4-8e6d-2cd2716904e2/resourceGroups/test/providers/Microsoft.Network/dnszones/example.com/A/quux."), // record in the same zone - * ); - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/service-provider-specific/azure-dns/azure_alias - */ -declare function AZURE_ALIAS(name: string, type: "A" | "AAAA" | "CNAME", target: string, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * `CAA()` adds a CAA record to a domain. The name should be the relative label for the record. Use `@` for the domain apex. - * - * Tag can be one of - * 1. `"issue"` - * 2. `"issuewild"` - * 3. `"iodef"` - * - * Value is a string. The format of the contents is different depending on the tag. DNSControl will handle any escaping or quoting required, similar to TXT records. For example use `CAA("@", "issue", "letsencrypt.org")` rather than `CAA("@", "issue", "\"letsencrypt.org\"")`. - * - * Flags are controlled by modifier: - * - `CAA_CRITICAL`: Issuer critical flag. CA that does not understand this tag will refuse to issue certificate for this domain. - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * // Allow letsencrypt to issue certificate for this domain - * CAA("@", "issue", "letsencrypt.org"), - * // Allow no CA to issue wildcard certificate for this domain - * CAA("@", "issuewild", ";"), - * // Report all violation to test@example.com. If CA does not support - * // this record then refuse to issue any certificate - * CAA("@", "iodef", "mailto:test@example.com", CAA_CRITICAL) - * ); - * ``` - * - * DNSControl contains a [`CAA_BUILDER`](../record/CAA_BUILDER.md) which can be used to simply create `CAA()` records for your domains. Instead of creating each CAA record individually, you can simply configure your report mail address, the authorized certificate authorities and the builder cares about the rest. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/caa - */ -declare function CAA(name: string, tag: "issue" | "issuewild" | "iodef", value: string, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * DNSControl contains a `CAA_BUILDER` which can be used to simply create - * [`CAA()`](../domain/CAA.md) records for your domains. Instead of creating each [`CAA()`](../domain/CAA.md) record - * individually, you can simply configure your report mail address, the - * authorized certificate authorities and the builder cares about the rest. - * - * ## Example - * - * For example you can use: - * - * ```javascript - * CAA_BUILDER({ - * label: "@", - * iodef: "mailto:test@example.com", - * iodef_critical: true, - * issue: [ - * "letsencrypt.org", - * "comodoca.com", - * ], - * issuewild: "none", - * }) - * ``` - * - * The parameters are: - * - * * `label:` The label of the CAA record. (Optional. Default: `"@"`) - * * `iodef:` Report all violation to configured mail address. - * * `iodef_critical:` This can be `true` or `false`. If enabled and CA does not support this record, then certificate issue will be refused. (Optional. Default: `false`) - * * `issue:` An array of CAs which are allowed to issue certificates. (Use `"none"` to refuse all CAs) - * * `issuewild:` An array of CAs which are allowed to issue wildcard certificates. (Can be simply `"none"` to refuse issuing wildcard certificates for all CAs) - * - * `CAA_BUILDER()` returns multiple records (when configured as example above): - * - * ```javascript - * CAA("@", "iodef", "mailto:test@example.com", CAA_CRITICAL) - * CAA("@", "issue", "letsencrypt.org") - * CAA("@", "issue", "comodoca.com") - * CAA("@", "issuewild", ";") - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/caa_builder - */ -declare function CAA_BUILDER(opts: { label?: string; iodef: string; iodef_critical?: boolean; issue: string[]; issuewild: string }): DomainModifier; - -/** - * `CF_REDIRECT` uses Cloudflare-specific features ("Forwarding URL" Page Rules) to - * generate a HTTP 301 permanent redirect. - * - * If _any_ `CF_REDIRECT` or [`CF_TEMP_REDIRECT`](CF_TEMP_REDIRECT.md) functions are used then - * `dnscontrol` will manage _all_ "Forwarding URL" type Page Rules for the domain. - * Page Rule types other than "Forwarding URL” will be left alone. - * - * WARNING: Cloudflare does not currently fully document the Page Rules API and - * this interface is not extensively tested. Take precautions such as making - * backups and manually verifying `dnscontrol preview` output before running - * `dnscontrol push`. This is especially true when mixing Page Rules that are - * managed by DNSControl and those that aren't. - * - * HTTP 301 redirects are cached by browsers forever, usually ignoring any TTLs or - * other cache invalidation techniques. It should be used with great care. We - * suggest using a `CF_TEMP_REDIRECT` initially, then changing to a `CF_REDIRECT` - * only after sufficient time has elapsed to prove this is what you really want. - * - * This example redirects the bare (aka apex, or naked) domain to www: - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * CF_REDIRECT("example.com/*", "https://www.example.com/$1"), - * ); - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/service-provider-specific/cloudflare-dns/cf_redirect - */ -declare function CF_REDIRECT(source: string, destination: string, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * `CF_TEMP_REDIRECT` uses Cloudflare-specific features ("Forwarding URL" Page - * Rules) to generate a HTTP 302 temporary redirect. - * - * If _any_ [`CF_REDIRECT`](CF_REDIRECT.md) or `CF_TEMP_REDIRECT` functions are used then - * `dnscontrol` will manage _all_ "Forwarding URL" type Page Rules for the domain. - * Page Rule types other than "Forwarding URL” will be left alone. - * - * WARNING: Cloudflare does not currently fully document the Page Rules API and - * this interface is not extensively tested. Take precautions such as making - * backups and manually verifying `dnscontrol preview` output before running - * `dnscontrol push`. This is especially true when mixing Page Rules that are - * managed by DNSControl and those that aren't. - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * CF_TEMP_REDIRECT("example.example.com/*", "https://otherplace.yourdomain.com/$1"), - * ); - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/service-provider-specific/cloudflare-dns/cf_temp_redirect - */ -declare function CF_TEMP_REDIRECT(source: string, destination: string, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * `CF_WORKER_ROUTE` uses the [Cloudflare Workers](https://developers.cloudflare.com/workers/) - * API to manage [worker routes](https://developers.cloudflare.com/workers/platform/routes) - * for a given domain. - * - * If _any_ `CF_WORKER_ROUTE` function is used then `dnscontrol` will manage _all_ - * Worker Routes for the domain. To be clear: this means it will delete existing routes that - * were created outside of DNSControl. - * - * WARNING: This interface is not extensively tested. Take precautions such as making - * backups and manually verifying `dnscontrol preview` output before running - * `dnscontrol push`. - * - * This example assigns the patterns `api.example.com/*` and `example.com/api/*` to a `my-worker` script: - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * CF_WORKER_ROUTE("api.example.com/*", "my-worker"), - * CF_WORKER_ROUTE("example.com/api/*", "my-worker"), - * ); - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/service-provider-specific/cloudflare-dns/cf_worker_route - */ -declare function CF_WORKER_ROUTE(pattern: string, script: string): DomainModifier; - -/** - * Documentation needed. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/service-provider-specific/cloudns/cloudns_wr - */ -declare function CLOUDNS_WR(name: string, target: string, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * CNAME adds a CNAME record to the domain. The name should be the relative label for the domain. - * Using `@` or `*` for CNAME records is not recommended, as different providers support them differently. - * - * Target should be a string representing the CNAME target. If it is a single label we will assume it is a relative name on the current domain. If it contains *any* dots, it should be a fully qualified domain name, ending with a `.`. - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * CNAME("foo", "google.com."), // foo.example.com -> google.com - * CNAME("abc", "@"), // abc.example.com -> example.com - * CNAME("def", "test"), // def.example.com -> test.example.com - * ); - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/cname - */ -declare function CNAME(name: string, target: string, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * `D` adds a new Domain for DNSControl to manage. The first two arguments are required: the domain name (fully qualified `example.com` without a trailing dot), and the - * name of the registrar (as previously declared with [NewRegistrar](NewRegistrar.md)). Any number of additional arguments may be included to add DNS Providers with [DNSProvider](NewDnsProvider.md), - * add records with [A](../domain/A.md), [CNAME](../domain/CNAME.md), and so forth, or add metadata. - * - * Modifier arguments are processed according to type as follows: - * - * - A function argument will be called with the domain object as it's only argument. Most of the [built-in modifier functions](https://docs.dnscontrol.org/language-reference/domain-modifiers) return such functions. - * - An object argument will be merged into the domain's metadata collection. - * - An array argument will have all of it's members evaluated recursively. This allows you to combine multiple common records or modifiers into a variable that can - * be used like a macro in multiple domains. - * - * ```javascript - * // simple domain - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * A("@","1.2.3.4"), - * CNAME("test", "foo.example2.com.") - * ); - * - * // "macro" for records that can be mixed into any zone - * var GOOGLE_APPS_DOMAIN_MX = [ - * MX("@", 1, "aspmx.l.google.com."), - * MX("@", 5, "alt1.aspmx.l.google.com."), - * MX("@", 5, "alt2.aspmx.l.google.com."), - * MX("@", 10, "alt3.aspmx.l.google.com."), - * MX("@", 10, "alt4.aspmx.l.google.com."), - * ] - * - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * A("@","1.2.3.4"), - * CNAME("test", "foo.example2.com."), - * GOOGLE_APPS_DOMAIN_MX - * ); - * ``` - * - * # Split Horizon DNS - * - * DNSControl supports Split Horizon DNS. Simply - * define the domain two or more times, each with - * their own unique parameters. - * - * To differentiate the different domains, specify the domains as - * `domain.tld!tag`, such as `example.com!inside` and - * `example.com!outside`. - * - * ```javascript - * var REG_THIRDPARTY = NewRegistrar("ThirdParty"); - * var DNS_INSIDE = NewDnsProvider("Cloudflare"); - * var DNS_OUTSIDE = NewDnsProvider("bind"); - * - * D("example.com!inside", REG_THIRDPARTY, DnsProvider(DNS_INSIDE), - * A("www", "10.10.10.10") - * ); - * - * D("example.com!outside", REG_THIRDPARTY, DnsProvider(DNS_OUTSIDE), - * A("www", "20.20.20.20") - * ); - * - * D_EXTEND("example.com!inside", - * A("internal", "10.99.99.99") - * ); - * ``` - * - * A domain name without a `!` is assigned a tag that is the empty - * string. For example, `example.com` and `example.com!` are equivalent. - * However, we strongly recommend against using the empty tag, as it - * risks creating confusion. In other words, if you have `domain.tld` - * and `domain.tld!external` you now require humans to remember that - * `domain.tld` is the external one. I mean... the internal one. You - * may have noticed this mistake, but will your coworkers? Will you in - * six months? You get the idea. - * - * DNSControl command line flag `--domains` matches the full name (with the "!"). If you - * define domains `example.com!george` and `example.com!john` then: - * - * * `--domains=example.com` will not match either domain. - * * `--domains='example.com!george'` will match only match the first. - * * `--domains='example.com!george",example.com!john` will match both. - * - * NOTE: The quotes are required if your shell treats `!` as a special - * character, which is probably does. If you see an error that mentions - * `event not found` you probably forgot the quotes. - * - * @see https://docs.dnscontrol.org/language-reference/top-level-functions/d - */ -declare function D(name: string, registrar: string, ...modifiers: DomainModifier[]): void; - -/** - * `DEFAULTS` allows you to declare a set of default arguments to apply to all subsequent domains. Subsequent calls to [`D`](D.md) will have these - * arguments passed as if they were the first modifiers in the argument list. - * - * ## Example - * - * We want to create backup zone files for all domains, but not actually register them. Also create a [`DefaultTTL`](../domain/DefaultTTL.md). - * The domain `example.com` will have the defaults set. - * - * ```javascript - * var COMMON = NewDnsProvider("foo"); - * DEFAULTS( - * DnsProvider(COMMON, 0), - * DefaultTTL("1d") - * ); - * - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * A("@","1.2.3.4") - * ); - * ``` - * - * If you want to clear the defaults, you can do the following. - * The domain `example2.com` will **not** have the defaults set. - * - * ```javascript - * DEFAULTS(); - * - * D("example2.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * A("@","1.2.3.4") - * ); - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/top-level-functions/defaults - */ -declare function DEFAULTS(...modifiers: DomainModifier[]): void; - -/** - * `DISABLE_IGNORE_SAFETY_CHECK()` disables the safety check. Normally it is an - * error to insert records that match an `IGNORE()` pattern. This disables that - * safety check for the entire domain. - * - * It replaces the per-record `IGNORE_NAME_DISABLE_SAFETY_CHECK()` which is - * deprecated as of DNSControl v4.0.0.0. - * - * See [`IGNORE()`](../domain/IGNORE.md) for more information. - * - * ## Syntax - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * DISABLE_IGNORE_SAFETY_CHECK, - * ... - * TXT("myhost", "mytext"), - * IGNORE("myhost", "*", "*"), - * ... - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/disable_ignore_safety_check - */ -declare const DISABLE_IGNORE_SAFETY_CHECK: DomainModifier; - -/** - * DNSControl contains a `DMARC_BUILDER` which can be used to simply create - * DMARC policies for your domains. - * - * ## Example - * - * ### Simple example - * - * ```javascript - * DMARC_BUILDER({ - * policy: "reject", - * ruf: [ - * "mailto:mailauth-reports@example.com", - * ], - * }) - * ``` - * - * This yield the following record: - * - * ```text - * @ IN TXT "v=DMARC1; p=reject; ruf=mailto:mailauth-reports@example.com" - * ``` - * - * ### Advanced example - * - * ```javascript - * DMARC_BUILDER({ - * policy: "reject", - * subdomainPolicy: "quarantine", - * percent: 50, - * alignmentSPF: "r", - * alignmentDKIM: "strict", - * rua: [ - * "mailto:mailauth-reports@example.com", - * "https://dmarc.example.com/submit", - * ], - * ruf: [ - * "mailto:mailauth-reports@example.com", - * ], - * failureOptions: "1", - * reportInterval: "1h", - * }); - * ``` - * - * ```javascript - * DMARC_BUILDER({ - * label: "insecure", - * policy: "none", - * ruf: [ - * "mailto:mailauth-reports@example.com", - * ], - * failureOptions: { - * SPF: false, - * DKIM: true, - * }, - * }); - * ``` - * - * This yields the following records: - * - * ```text - * @ IN TXT "v=DMARC1; p=reject; sp=quarantine; adkim=s; aspf=r; pct=50; rua=mailto:mailauth-reports@example.com,https://dmarc.example.com/submit; ruf=mailto:mailauth-reports@example.com; fo=1; ri=3600" - * insecure IN TXT "v=DMARC1; p=none; ruf=mailto:mailauth-reports@example.com; fo=d" - * ``` - * - * ### Parameters - * - * * `label:` The DNS label for the DMARC record (`_dmarc` prefix is added, default: `"@"`) - * * `version:` The DMARC version to be used (default: `DMARC1`) - * * `policy:` The DMARC policy (`p=`), must be one of `"none"`, `"quarantine"`, `"reject"` - * * `subdomainPolicy:` The DMARC policy for subdomains (`sp=`), must be one of `"none"`, `"quarantine"`, `"reject"` (optional) - * * `alignmentSPF:` `"strict"`/`"s"` or `"relaxed"`/`"r"` alignment for SPF (`aspf=`, default: `"r"`) - * * `alignmentDKIM:` `"strict"`/`"s"` or `"relaxed"`/`"r"` alignment for DKIM (`adkim=`, default: `"r"`) - * * `percent:` Number between `0` and `100`, percentage for which policies are applied (`pct=`, default: `100`) - * * `rua:` Array of aggregate report targets (optional) - * * `ruf:` Array of failure report targets (optional) - * * `failureOptions:` Object or string; Object containing booleans `SPF` and `DKIM`, string is passed raw (`fo=`, default: `"0"`) - * * `failureFormat:` Format in which failure reports are requested (`rf=`, default: `"afrf"`) - * * `reportInterval:` Interval in which reports are requested (`ri=`) - * * `ttl:` Input for `TTL` method (optional) - * - * ### Caveats - * - * * TXT records are automatically split using `AUTOSPLIT`. - * * URIs in the `rua` and `ruf` arrays are passed raw. You must percent-encode all commas and exclamation points in the URI itself. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/dmarc_builder - */ -declare function DMARC_BUILDER(opts: { label?: string; version?: string; policy: 'none' | 'quarantine' | 'reject'; subdomainPolicy?: 'none' | 'quarantine' | 'reject'; alignmentSPF?: 'strict' | 's' | 'relaxed' | 'r'; alignmentDKIM?: 'strict' | 's' | 'relaxed' | 'r'; percent?: number; rua?: string[]; ruf?: string[]; failureOptions?: { SPF: boolean, DKIM: boolean } | string; failureFormat?: string; reportInterval?: Duration; ttl?: Duration }): DomainModifier; - -/** - * `DOMAIN_ELSEWHERE()` is a helper macro that lets you easily indicate that - * a domain's zones are managed elsewhere. That is, it permits you easily delegate - * a domain to a hard-coded list of DNS servers. - * - * `DOMAIN_ELSEWHERE` is useful when you control a domain's registrar but not the - * DNS servers. For example, suppose you own a domain but the DNS servers are run - * by someone else, perhaps a SaaS product you've subscribed to or a DNS server - * that is run by your brother-in-law who doesn't trust you with the API keys that - * would let you maintain the domain using DNSControl. You need an easy way to - * point (delegate) the domain at a specific list of DNS servers. - * - * For example these two statements are equivalent: - * - * ```javascript - * DOMAIN_ELSEWHERE("example.com", REG_MY_PROVIDER, ["ns1.foo.com", "ns2.foo.com"]); - * ``` - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * NO_PURGE, - * NAMESERVER("ns1.foo.com"), - * NAMESERVER("ns2.foo.com") - * ); - * ``` - * - * NOTE: The [`NO_PURGE`](../domain/NO_PURGE.md) is used out of abundance of caution but since no - * `DnsProvider()` statements exist, no updates would be performed. - * - * @see https://docs.dnscontrol.org/language-reference/top-level-functions/domain_elsewhere - */ -declare function DOMAIN_ELSEWHERE(name: string, registrar: string, nameserver_names: string[]): void; - -/** - * `DOMAIN_ELSEWHERE_AUTO()` is similar to `DOMAIN_ELSEWHERE()` but instead of - * a hardcoded list of nameservers, a DnsProvider() is queried. - * - * `DOMAIN_ELSEWHERE_AUTO` is useful when you control a domain's registrar but the - * DNS zones are managed by another system. Luckily you have enough access to that - * other system that you can query it to determine the zone's nameservers. - * - * For example, suppose you own a domain but the DNS servers for it are in Azure. - * Further suppose that something in Azure maintains the zones (automatic or - * human). Azure picks the nameservers for the domains automatically, and that - * list may change occasionally. `DOMAIN_ELSEWHERE_AUTO` allows you to easily - * query Azure to determine the domain's delegations so that you do not need to - * hard-code them in your dnsconfig.js file. - * - * For example these two statements are equivalent: - * - * ```javascript - * DOMAIN_ELSEWHERE_AUTO("example.com", REG_NAMEDOTCOM, DSP_AZURE); - * ``` - * - * ```javascript - * D("example.com", REG_NAMEDOTCOM, - * NO_PURGE, - * DnsProvider(DSP_AZURE) - * ); - * ``` - * - * NOTE: The [`NO_PURGE`](../domain/NO_PURGE.md) is used to prevent DNSControl from changing the records. - * - * @see https://docs.dnscontrol.org/language-reference/top-level-functions/domain_elsewhere_auto - */ -declare function DOMAIN_ELSEWHERE_AUTO(name: string, domain: string, registrar: string, dnsProvider: string): void; - -/** - * DS adds a DS record to the domain. - * - * Key Tag should be a number. - * - * Algorithm should be a number. - * - * Digest Type must be a number. - * - * Digest must be a string. - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * DS("example.com", 2371, 13, 2, "ABCDEF") - * ); - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/ds - */ -declare function DS(name: string, keytag: number, algorithm: number, digesttype: number, digest: string, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * `D_EXTEND` adds records (and metadata) to a domain previously defined - * by [`D()`](D.md). It can also be used to add subdomain records (and metadata) - * to a previously defined domain. - * - * The first argument is a domain name. If it exactly matches a - * previously defined domain, `D_EXTEND()` behaves the same as [`D()`](D.md), - * simply adding records as if they had been specified in the original - * [`D()`](D.md). - * - * If the domain name does not match an existing domain, but could be a - * (non-delegated) subdomain of an existing domain, the new records (and - * metadata) are added with the subdomain part appended to all record - * names (labels), and targets (as appropriate). See the examples below. - * - * Matching the domain name to previously-defined domains is done using a - * `longest match` algorithm. If `domain.tld` and `sub.domain.tld` are - * defined as separate domains via separate [`D()`](D.md) statements, then - * `D_EXTEND("sub.sub.domain.tld", ...)` would match `sub.domain.tld`, - * not `domain.tld`. - * - * Some operators only act on an apex domain (e.g. - * [`CF_REDIRECT`](../domain/CF_REDIRECT.md) and [`CF_TEMP_REDIRECT`](../domain/CF_TEMP_REDIRECT.md)). Using them - * in a `D_EXTEND` subdomain may not be what you expect. - * - * ```javascript - * D("domain.tld", REG_MY_PROVIDER, DnsProvider(DNS), - * A("@", "127.0.0.1"), // domain.tld - * A("www", "127.0.0.2"), // www.domain.tld - * CNAME("a", "b") // a.domain.tld -> b.domain.tld - * ); - * D_EXTEND("domain.tld", - * A("aaa", "127.0.0.3"), // aaa.domain.tld - * CNAME("c", "d") // c.domain.tld -> d.domain.tld - * ); - * D_EXTEND("sub.domain.tld", - * A("bbb", "127.0.0.4"), // bbb.sub.domain.tld - * A("ccc", "127.0.0.5"), // ccc.sub.domain.tld - * CNAME("e", "f") // e.sub.domain.tld -> f.sub.domain.tld - * ); - * D_EXTEND("sub.sub.domain.tld", - * A("ddd", "127.0.0.6"), // ddd.sub.sub.domain.tld - * CNAME("g", "h") // g.sub.sub.domain.tld -> h.sub.sub.domain.tld - * ); - * D_EXTEND("sub.domain.tld", - * A("@", "127.0.0.7"), // sub.domain.tld - * CNAME("i", "j") // i.sub.domain.tld -> j.sub.domain.tld - * ); - * ``` - * - * This will end up in the following modifications: (This output assumes the `--full` flag) - * - * ```text - * ******************** Domain: domain.tld - * ----- Getting nameservers from: cloudflare - * ----- DNS Provider: cloudflare...7 corrections - * #1: CREATE A aaa.domain.tld 127.0.0.3 - * #2: CREATE A bbb.sub.domain.tld 127.0.0.4 - * #3: CREATE A ccc.sub.domain.tld 127.0.0.5 - * #4: CREATE A ddd.sub.sub.domain.tld 127.0.0.6 - * #5: CREATE A sub.domain.tld 127.0.0.7 - * #6: CREATE A www.domain.tld 127.0.0.2 - * #7: CREATE A domain.tld 127.0.0.1 - * #8: CREATE CNAME a.domain.tld b.domain.tld. - * #9: CREATE CNAME c.domain.tld d.domain.tld. - * #10: CREATE CNAME e.sub.domain.tld f.sub.domain.tld. - * #11: CREATE CNAME g.sub.sub.domain.tld h.sub.sub.domain.tld. - * #12: CREATE CNAME i.sub.domain.tld j.sub.domain.tld. - * ``` - * - * ProTips: `D_EXTEND()` permits you to create very complex and - * sophisticated configurations, but you shouldn't. Be nice to the next - * person that edits the file, who may not be as expert as yourself. - * Enhance readability by putting any `D_EXTEND()` statements immediately - * after the original [`D()`](D.md), like in above example. Avoid the temptation - * to obscure the addition of records to existing domains with randomly - * placed `D_EXTEND()` statements. Don't build up a domain using loops of - * `D_EXTEND()` statements. You'll be glad you didn't. - * - * @see https://docs.dnscontrol.org/language-reference/top-level-functions/d_extend - */ -declare function D_EXTEND(name: string, ...modifiers: DomainModifier[]): void; - -/** - * DefaultTTL sets the TTL for all subsequent records following it in a domain that do not explicitly set one with [`TTL`](../record/TTL.md). If neither `DefaultTTL` or `TTL` exist for a record, - * the record will inherit the DNSControl global internal default of 300 seconds. See also [`DEFAULTS`](../global/DEFAULTS.md) to override the internal defaults. - * - * NS records are currently a special case, and do not inherit from `DefaultTTL`. See [`NAMESERVER_TTL`](../domain/NAMESERVER_TTL.md) to set a default TTL for all NS records. - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * DefaultTTL("4h"), - * A("@","1.2.3.4"), // uses default - * A("foo", "2.3.4.5", TTL(600)) // overrides default - * ); - * ``` - * - * The DefaultTTL duration is the same format as [`TTL`](../record/TTL.md), an integer number of seconds - * or a string with a unit such as `"4d"`. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/defaultttl - */ -declare function DefaultTTL(ttl: Duration): DomainModifier; - -/** - * DnsProvider indicates that the specified provider should be used to manage - * records for this domain. The name must match the name used with [NewDnsProvider](../global/NewDnsProvider.md). - * - * The nsCount parameter determines how the nameservers will be managed from this provider. - * - * Leaving the parameter out means "fetch and use all nameservers from this provider as authoritative". ie: `DnsProvider("name")` - * - * Using `0` for nsCount means "do not fetch nameservers from this domain, or give them to the registrar". - * - * Using a different number, ie: `DnsProvider("name",2)`, means "fetch all nameservers from this provider, - * but limit it to this many. - * - * See [this page](../../nameservers.md) for a detailed explanation of how DNSControl handles nameservers and NS records. - * - * If a domain (`D()`) does not include any `DnsProvider()` functions, - * the DNS records will not be modified. In fact, if you want to control - * the Registrar for a domain but not the DNS records themselves, simply - * do not include a `DnsProvider()` function for that `D()`. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/dnsprovider - */ -declare function DnsProvider(name: string, nsCount?: number): DomainModifier; - -/** - * Documentation needed. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/frame - */ -declare function FRAME(name: string, target: string, ...modifiers: RecordModifier[]): DomainModifier; - -/** - * `IGNORE()` makes it possible for DNSControl to share management of a domain - * with an external system. The parameters of `IGNORE()` indicate which records - * are managed elsewhere and should not be modified or deleted. - * - * Use case: Suppose a domain is managed by both DNSControl and a third-party - * system. This creates a problem because DNSControl will try to delete records - * inserted by the other system. The other system may get confused and re-insert - * those records. The two systems will get into an endless update cycle where - * each will revert changes made by the other in an endless loop. - * - * To solve this problem simply include `IGNORE()` statements that identify which - * records are managed elsewhere. DNSControl will not modify or delete those - * records. - * - * Technically `IGNORE_NAME` is a promise that DNSControl will not modify or - * delete existing records that match particular patterns. It is like - * [`NO_PURGE`](../domain/NO_PURGE.md) that matches only specific records. - * - * Including a record that is ignored is considered an error and may have - * undefined behavior. This safety check can be disabled using the - * [`DISABLE_IGNORE_SAFETY_CHECK`](../domain/DISABLE_IGNORE_SAFETY_CHECK.md) feature. - * - * ## Syntax - * - * The `IGNORE()` function can be used with up to 3 parameters: - * - * ```javascript - * IGNORE(labelSpec, typeSpec, targetSpec): - * IGNORE(labelSpec, typeSpec): - * IGNORE(labelSpec): - * ``` - * - * * `labelSpec` is a glob that matches the DNS label. For example `"foo"` or `"foo*"`. `"*"` matches all labels, as does the empty string (`""`). - * * `typeSpec` is a comma-separated list of DNS types. For example `"A"` matches DNS A records, `"A,CNAME"` matches both A and CNAME records. `"*"` matches any DNS type, as does the empty string (`""`). - * * `targetSpec` is a glob that matches the DNS target. For example `"foo"` or `"foo*"`. `"*"` matches all targets, as does the empty string (`""`). - * - * `typeSpec` and `targetSpec` default to `"*"` if they are omitted. - * - * ## Globs - * - * The `labelSpec` and `targetSpec` parameters supports glob patterns in the style - * of the [gobwas/glob](https://github.com/gobwas/glob) library. All of the - * following patterns will work: - * - * * `IGNORE("*.foo")` will ignore all records in the style of `bar.foo`, but will not ignore records using a double subdomain, such as `foo.bar.foo`. - * * `IGNORE("**.foo")` will ignore all subdomains of `foo`, including double subdomains. - * * `IGNORE("?oo")` will ignore all records of three symbols ending in `oo`, for example `foo` and `zoo`. It will not match `.` - * * `IGNORE("[abc]oo")` will ignore records `aoo`, `boo` and `coo`. `IGNORE("[a-c]oo")` is equivalent. - * * `IGNORE("[!abc]oo")` will ignore all three symbol records ending in `oo`, except for `aoo`, `boo`, `coo`. `IGNORE("[!a-c]oo")` is equivalent. - * * `IGNORE("{bar,[fz]oo}")` will ignore `bar`, `foo` and `zoo`. - * * `IGNORE("\\*.foo")` will ignore the literal record `*.foo`. - * - * ## Typical Usage - * - * General examples: - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * IGNORE("foo"), // matches any records on foo.example.com - * IGNORE("baz", "A"), // matches any A records on label baz.example.com - * IGNORE("*", "MX", "*"), // matches all MX records - * IGNORE("*", "CNAME", "dev-*"), // matches CNAMEs with targets prefixed `dev-*` - * IGNORE("bar", "A,MX"), // ignore only A and MX records for name bar - * IGNORE("*", "*", "dev-*"), // Ignore targets with a `dev-` prefix - * IGNORE("*", "A", "1\.2\.3\."), // Ignore targets in the 1.2.3.0/24 CIDR block - * END); - * ``` - * - * Ignore Let's Encrypt (ACME) validation records: - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * IGNORE("_acme-challenge", "TXT"), - * IGNORE("_acme-challenge.**", "TXT"), - * END); - * ``` - * - * Ignore DNS records typically inserted by Microsoft ActiveDirectory: - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * IGNORE("_gc", "SRV"), // General Catalog - * IGNORE("_gc.**", "SRV"), // General Catalog - * IGNORE("_kerberos", "SRV"), // Kerb5 server - * IGNORE("_kerberos.**", "SRV"), // Kerb5 server - * IGNORE("_kpasswd", "SRV"), // Kpassword - * IGNORE("_kpasswd.**", "SRV"), // Kpassword - * IGNORE("_ldap", "SRV"), // LDAP - * IGNORE("_ldap.**", "SRV"), // LDAP - * IGNORE("_msdcs", "NS"), // Microsoft Domain Controller Service - * IGNORE("_msdcs.**", "NS"), // Microsoft Domain Controller Service - * IGNORE("_vlmcs", "SRV"), // FQDN of the KMS host - * IGNORE("_vlmcs.**", "SRV"), // FQDN of the KMS host - * IGNORE("domaindnszones", "A"), - * IGNORE("domaindnszones.**", "A"), - * IGNORE("forestdnszones", "A"), - * IGNORE("forestdnszones.**", "A"), - * END); - * ``` - * - * ## Detailed examples - * - * Here are some examples that illustrate how matching works. - * - * All the examples assume the following DNS records are the "existing" records - * that a third-party is maintaining. (Don't be confused by the fact that we're - * using DNSControl notation for the records. Pretend some other system inserted them.) - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * A("@", "151.101.1.69"), - * A("www", "151.101.1.69"), - * A("foo", "1.1.1.1"), - * A("bar", "2.2.2.2"), - * CNAME("cshort", "www"), - * CNAME("cfull", "www.plts.org."), - * CNAME("cfull2", "www.bar.plts.org."), - * CNAME("cfull3", "bar.www.plts.org."), - * END); - * - * D_EXTEND("more.example.com", - * A("foo", "1.1.1.1"), - * A("bar", "2.2.2.2"), - * CNAME("mshort", "www"), - * CNAME("mfull", "www.plts.org."), - * CNAME("mfull2", "www.bar.plts.org."), - * CNAME("mfull3", "bar.www.plts.org."), - * END); - * ``` - * - * ```javascript - * IGNORE("@", "", ""), - * // Would match: - * // foo.example.com. A 1.1.1.1 - * // foo.more.example.com. A 1.1.1.1 - * ``` - * - * ```javascript - * IGNORE("example.com.", "", ""), - * // Would match: - * // nothing - * ``` - * - * ```javascript - * IGNORE("foo", "", ""), - * // Would match: - * // foo.example.com. A 1.1.1.1 - * ``` - * - * ```javascript - * IGNORE("foo.**", "", ""), - * // Would match: - * // foo.more.example.com. A 1.1.1.1 - * ``` - * - * ```javascript - * IGNORE("www", "", ""), - * // Would match: - * // www.example.com. A 174.136.107.196 - * ``` - * - * ```javascript - * IGNORE("www.*", "", ""), - * // Would match: - * // nothing - * ``` - * - * ```javascript - * IGNORE("www.example.com", "", ""), - * // Would match: - * // nothing - * ``` - * - * ```javascript - * IGNORE("www.example.com.", "", ""), - * // Would match: - * // none - * ``` - * - * ```javascript - * //IGNORE("", "", "1.1.1.*"), - * // Would match: - * // foo.example.com. A 1.1.1.1 - * // foo.more.example.com. A 1.1.1.1 - * ``` - * - * ```javascript - * //IGNORE("", "", "www"), - * // Would match: - * // none - * ``` - * - * ```javascript - * IGNORE("", "", "*bar*"), - * // Would match: - * // cfull2.example.com. CNAME www.bar.plts.org. - * // cfull3.example.com. CNAME bar.www.plts.org. - * // mfull2.more.example.com. CNAME www.bar.plts.org. - * // mfull3.more.example.com. CNAME bar.www.plts.org. - * ``` - * - * ```javascript - * IGNORE("", "", "bar.**"), - * // Would match: - * // cfull3.example.com. CNAME bar.www.plts.org. - * // mfull3.more.example.com. CNAME bar.www.plts.org. - * ``` - * - * ## Conflict handling - * - * It is considered as an error for a `dnsconfig.js` to both ignore and insert the - * same record in a domain. This is done as a safety mechanism. - * - * This will generate an error: - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * ... - * TXT("myhost", "mytext"), - * IGNORE("myhost", "*", "*"), // Error! Ignoring an item we inserted - * ... - * ``` - * - * To disable this safety check, add the `DISABLE_IGNORE_SAFETY_CHECK` statement - * to the `D()`. - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * DISABLE_IGNORE_SAFETY_CHECK, - * ... - * TXT("myhost", "mytext"), - * IGNORE("myhost", "*", "*"), - * ... - * ``` - * - * FYI: Previously DNSControl permitted disabling this check on - * a per-record basis using `IGNORE_NAME_DISABLE_SAFETY_CHECK`: - * - * The `IGNORE_NAME_DISABLE_SAFETY_CHECK` feature does not exist in the diff2 - * world and its use will result in a validation error. Use the above example - * instead. - * - * ```javascript - * // THIS NO LONGER WORKS! Use DISABLE_IGNORE_SAFETY_CHECK instead. See above. - * TXT("myhost", "mytext", IGNORE_NAME_DISABLE_SAFETY_CHECK), - * ``` - * - * ## Caveats - * - * WARNING: Two systems updating the same domain is complex. Complex things are risky. Use `IGNORE()` - * as a last resort. Even then, test extensively. - * - * * There is no locking. If the external system and DNSControl make updates at the exact same time, the results are undefined. - * * IGNORE` works fine with records inserted into a `D()` via `D_EXTEND()`. The matching is done on the resulting FQDN of the label or target. - * * `targetSpec` does not match fields other than the primary target. For example, `MX` records have a target hostname plus a priority. There is no way to match the priority. - * * The BIND provider can not ignore records it doesn't know about. If it does not have access to an existing zonefile, it will create a zonefile from scratch. That new zonefile will not have any external records. It will seem like they were not ignored, but in reality BIND didn't have visibility to them so that they could be ignored. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/ignore - */ -declare function IGNORE(labelSpec: string, typeSpec?: string, targetSpec?: string): DomainModifier; - -/** - * `IGNORE_NAME(a)` is the same as `IGNORE(a, "*", "*")`. - * - * `IGNORE_NAME(a, b)` is the same as `IGNORE(a, b, "*")`. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/ignore_name - */ -declare function IGNORE_NAME(pattern: string, rTypes?: string): DomainModifier; - -/** - * `IGNORE_TARGET_NAME(target)` is the same as `IGNORE("*", "*", target)`. - * - * `IGNORE_TARGET_NAME(target, rtype)` is the same as `IGNORE("*", rtype, target)`. - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/ignore_target - */ -declare function IGNORE_TARGET(pattern: string, rType: string): DomainModifier; - -/** - * Includes all records from a given domain - * - * ```javascript - * D("example.com!external", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * A("test", "8.8.8.8") - * ); - * - * D("example.com!internal", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * INCLUDE("example.com!external"), - * A("home", "127.0.0.1") - * ); - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/include - */ -declare function INCLUDE(domain: string): DomainModifier; - -/** - * Converts an IPv4 address from string to an integer. This allows performing mathematical operations with the IP address. - * - * ```javascript - * var addrA = IP("1.2.3.4") - * var addrB = addrA + 1 - * // addrB = 1.2.3.5 - * ``` - * - * NOTE: `IP()` does not accept IPv6 addresses (PRs gladly accepted!). IPv6 addresses are simply strings: - * - * ```javascript - * // IPv4 Var - * var addrA1 = IP("1.2.3.4"); - * var addrA2 = "1.2.3.4"; - * - * // IPv6 Var - * var addrAAAA = "0:0:0:0:0:0:0:0"; - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/top-level-functions/ip - */ -declare function IP(ip: string): number; - -/** - * The parameter number types are as follows: - * - * ``` - * name: string - * target: string - * deg1: uint32 - * min1: uint32 - * sec1: float32 - * deg2: uint32 - * min2: uint32 - * sec2: float32 - * altitude: uint32 - * size: float32 - * horizontal_precision: float32 - * vertical_precision: float32 - * ``` - * - * ## Description ## - * - * Strictly follows [RFC 1876](https://datatracker.ietf.org/doc/html/rfc1876). - * - * A LOC record holds a geographical position. In the zone file, it may look like: - * - * ```text - * ; - * pipex.net. LOC 52 14 05 N 00 08 50 E 10m - * ``` - * - * On the wire, it is in a binary format. - * - * A use case for LOC is suggested in the RFC: - * - * > Some uses for the LOC RR have already been suggested, including the - * USENET backbone flow maps, a "visual traceroute" application showing - * the geographical path of an IP packet, and network management - * applications that could use LOC RRs to generate a map of hosts and - * routers being managed. - * - * There is the UK based [https://find.me.uk](https://find.me.uk/) whereby you can do: - * - * ```sh - * dig loc .find.me.uk - * ``` - * - * There are some behaviours that you should be aware of, however: - * - * > If omitted, minutes and seconds default to zero, size defaults to 1m, - * horizontal precision defaults to 10000m, and vertical precision - * defaults to 10m. These defaults are chosen to represent typical - * ZIP/postal code area sizes, since it is often easy to find - * approximate geographical location by ZIP/postal code. - * - * Alas, the world does not revolve around US ZIP codes, but here we are. Internally, - * the LOC record type will supply defaults where values were absent on DNS import. - * One must supply the `LOC()` js helper all parameters. If that seems like too - * much work, see also helper functions: - * - * * [`LOC_BUILDER_DD({})`](../record/LOC_BUILDER_DD.md) - build a `LOC` by supplying only **d**ecimal **d**egrees. - * * [`LOC_BUILDER_DMS_STR({})`](../record/LOC_BUILDER_DMS_STR.md) - accepts DMS 33°51′31″S 151°12′51″E - * * [`LOC_BUILDER_DMM_STR({})`](../record/LOC_BUILDER_DMM_STR.md) - accepts DMM 25.24°S 153.15°E - * * [`LOC_BUILDER_STR({})`](../record/LOC_BUILDER_STR.md) - tries the cooordinate string in all `LOC_BUILDER_DM*_STR()` functions until one works - * - * ## Format ## - * - * The coordinate format for `LOC()` is: - * - * `degrees,minutes,seconds,[NnSs],deg,min,sec,[EeWw],altitude,size,horizontal_precision,vertical_precision` - * - * ## Examples ## - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * // LOC "subdomain", d1, m1, s1, "[NnSs]", d2, m2, s2, "[EeWw]", alt, siz, hp, vp) - * //42 21 54 N 71 06 18 W -24m 30m - * , LOC("@", 42, 21, 54, "N", 71, 6, 18, "W", -24, 30, 0, 0) - * //42 21 43.952 N 71 5 6.344 W -24m 1m 200m 10m - * , LOC("a", 42, 21, 43.952, "N", 71, 5, 6.344, "W", -24, 1, 200, 10) - * //52 14 05 N 00 08 50 E 10m - * , LOC("b", 52, 14, 5, "N", 0, 8, 50, "E", 10, 0, 0, 0) - * //32 7 19 S 116 2 25 E 10m - * , LOC("c", 32, 7, 19, "S",116, 2, 25, "E", 10, 0, 0, 0) - * //42 21 28.764 N 71 00 51.617 W -44m 2000m - * , LOC("d", 42, 21, 28.764, "N", 71, 0, 51.617, "W", -44, 2000, 0, 0) - * ); - * - * ``` - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/loc - */ -declare function LOC(deg1: number, min1: number, sec1: number, deg2: number, min2: number, sec2: number, altitude: number, size: number, horizontal_precision: number, vertical_precision: number): DomainModifier; - -/** - * `LOC_BUILDER_DD({})` actually takes an object with the following properties: - * - * - label (optional, defaults to `@`) - * - x (float32) - * - y (float32) - * - alt (float32, optional) - * - ttl (optional) - * - * A helper to build [`LOC`](../domain/LOC.md) records. Supply four parameters instead of 12. - * - * Internally assumes some defaults for [`LOC`](../domain/LOC.md) records. - * - * The cartesian coordinates are decimal degrees, like you typically find in e.g. Google Maps. - * - * Examples. - * - * Big Ben: - * `51.50084265331501, -0.12462541415599787` - * - * The White House: - * `38.89775977858357, -77.03655125982903` - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * LOC_BUILDER_DD({ - * label: "big-ben", - * x: 51.50084265331501, - * y: -0.12462541415599787, - * alt: 6, - * }) - * , LOC_BUILDER_DD({ - * label: "white-house", - * x: 38.89775977858357, - * y: -77.03655125982903, - * alt: 19, - * }) - * , LOC_BUILDER_DD({ - * label: "white-house-ttl", - * x: 38.89775977858357, - * y: -77.03655125982903, - * alt: 19, - * ttl: "5m", - * }) - * ); - * - * ``` - * - * Part of the series: - * * [`LOC()`](../domain/LOC.md) - build a `LOC` by supplying all 12 parameters - * * [`LOC_BUILDER_DD({})`](../record/LOC_BUILDER_DD.md) - accepts cartesian x, y - * * [`LOC_BUILDER_DMS_STR({})`](../record/LOC_BUILDER_DMS_STR.md) - accepts DMS 33°51′31″S 151°12′51″E - * * [`LOC_BUILDER_DMM_STR({})`](../record/LOC_BUILDER_DMM_STR.md) - accepts DMM 25.24°S 153.15°E - * * [`LOC_BUILDER_STR({})`](../record/LOC_BUILDER_STR.md) - tries the cooordinate string in all `LOC_BUILDER_DM*_STR()` functions until one works - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/loc_builder_dd - */ -declare function LOC_BUILDER_DD(opts: { label?: string; x: number; y: number; alt?: number; ttl?: Duration }): DomainModifier; - -/** - * `LOC_BUILDER_DMM({})` actually takes an object with the following properties: - * - * - label (string, optional, defaults to `@`) - * - str (string) - * - alt (float32, optional) - * - ttl (optional) - * - * A helper to build [`LOC`](../domain/LOC.md) records. Supply three parameters instead of 12. - * - * Internally assumes some defaults for [`LOC`](../domain/LOC.md) records. - * - * Accepts a string with decimal minutes (DMM) coordinates in the form: 25.24°S 153.15°E - * - * Note that the following are acceptable forms (symbols differ): - * * `25.24°S 153.15°E` - * * `25.24 S 153.15 E` - * * `25.24° S 153.15° E` - * * `25.24S 153.15E` - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * LOC_BUILDER_STR({ - * label: "tasmania", - * str: "42°S 147°E", - * alt: 3, - * }) - * ); - * - * ``` - * - * Part of the series: - * * [`LOC()`](../domain/LOC.md) - build a `LOC` by supplying all 12 parameters - * * [`LOC_BUILDER_DD({})`](../record/LOC_BUILDER_DD.md) - accepts cartesian x, y - * * [`LOC_BUILDER_DMS_STR({})`](../record/LOC_BUILDER_DMS_STR.md) - accepts DMS 33°51′31″S 151°12′51″E - * * [`LOC_BUILDER_DMM_STR({})`](../record/LOC_BUILDER_DMM_STR.md) - accepts DMM 25.24°S 153.15°E - * * [`LOC_BUILDER_STR({})`](../record/LOC_BUILDER_STR.md) - tries the cooordinate string in all `LOC_BUILDER_DM*_STR()` functions until one works - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/loc_builder_dmm_str - */ -declare function LOC_BUILDER_DMM_STR(opts: { label?: string; str: string; alt?: number; ttl?: Duration }): DomainModifier; - -/** - * `LOC_BUILDER_DMS_STR({})` actually takes an object with the following properties: - * - * - label (string, optional, defaults to `@`) - * - str (string) - * - alt (float32, optional) - * - ttl (optional) - * - * A helper to build [`LOC`](../domain/LOC.md) records. Supply three parameters instead of 12. - * - * Internally assumes some defaults for [`LOC`](../domain/LOC.md) records. - * - * Accepts a string with degrees, minutes, and seconds (DMS) coordinates in the form: 41°24'12.2"N 2°10'26.5"E - * - * Note that the following are acceptable forms (symbols differ): - * * `33°51′31″S 151°12′51″E` - * * `33°51'31"S 151°12'51"E` - * * `33d51m31sS 151d12m51sE` - * * `33d51m31s S 151d12m51s E` - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * LOC_BUILDER_DMS_STR({ - * label: "sydney-opera-house", - * str: "33°51′31″S 151°12′51″E", - * alt: 4, - * ttl: "5m", - * }) - * ); - * - * ``` - * - * Part of the series: - * * [`LOC()`](../domain/LOC.md) - build a `LOC` by supplying all 12 parameters - * * [`LOC_BUILDER_DD({})`](../record/LOC_BUILDER_DD.md) - accepts cartesian x, y - * * [`LOC_BUILDER_DMS_STR({})`](../record/LOC_BUILDER_DMS_STR.md) - accepts DMS 33°51′31″S 151°12′51″E - * * [`LOC_BUILDER_DMM_STR({})`](../record/LOC_BUILDER_DMM_STR.md) - accepts DMM 25.24°S 153.15°E - * * [`LOC_BUILDER_STR({})`](../record/LOC_BUILDER_STR.md) - tries the cooordinate string in all `LOC_BUILDER_DM*_STR()` functions until one works - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/loc_builder_dms_str - */ -declare function LOC_BUILDER_DMS_STR(opts: { label?: string; str: string; alt?: number; ttl?: Duration }): DomainModifier; - -/** - * `LOC_BUILDER_STR({})` actually takes an object with the following: properties. - * - * - label (optional, defaults to `@`) - * - str (string) - * - alt (float32, optional) - * - ttl (optional) - * - * A helper to build [`LOC`](../domain/LOC.md) records. Supply three parameters instead of 12. - * - * Internally assumes some defaults for [`LOC`](../domain/LOC.md) records. - * - * Accepts a string and tries all `LOC_BUILDER_DM*_STR({})` methods: - * * [`LOC_BUILDER_DMS_STR({})`](../record/LOC_BUILDER_DMS_STR.md) - accepts DMS 33°51′31″S 151°12′51″E - * * [`LOC_BUILDER_DMM_STR({})`](../record/LOC_BUILDER_DMM_STR.md) - accepts DMM 25.24°S 153.15°E - * - * ```javascript - * D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), - * , LOC_BUILDER_STR({ - * label: "old-faithful", - * str: "44.46046°N 110.82815°W", - * alt: 2240, - * }) - * , LOC_BUILDER_STR({ - * label: "ribblehead-viaduct", - * str: "54.210436°N 2.370231°W", - * alt: 300, - * }) - * , LOC_BUILDER_STR({ - * label: "guinness-brewery", - * str: "53°20′40″N 6°17′20″W", - * alt: 300, - * }) - * ); - * - * ``` - * - * Part of the series: - * * [`LOC()`](../domain/LOC.md) - build a `LOC` by supplying all 12 parameters - * * [`LOC_BUILDER_DD({})`](../record/LOC_BUILDER_DD.md) - accepts cartesian x, y - * * [`LOC_BUILDER_DMS_STR({})`](../record/LOC_BUILDER_DMS_STR.md) - accepts DMS 33°51′31″S 151°12′51″E - * * [`LOC_BUILDER_DMM_STR({})`](../record/LOC_BUILDER_DMM_STR.md) - accepts DMM 25.24°S 153.15°E - * * [`LOC_BUILDER_STR({})`](../record/LOC_BUILDER_STR.md) - tries the cooordinate string in all `LOC_BUILDER_DM*_STR()` functions until one works - * - * @see https://docs.dnscontrol.org/language-reference/domain-modifiers/loc_builder_str - */ -declare function LOC_BUILDER_STR(opts: { label?: string; str: string; alt?: number; ttl?: Duration }): DomainModifier; - -/** - * DNSControl offers a `M365_BUILDER` which can be used to simply set up Microsoft 365 for a domain in an opinionated way. - * - * It defaults to a setup without support for legacy Skype for Business applications. - * It doesn't set up SPF or DMARC. See [`SPF_BUILDER`](/language-reference/record-modifiers/dmarc_builder) and [`DMARC_BUILDER`](/language-reference/record-modifiers/spf_builder). - * - * ## Example - * - * ### Simple example - * - * ```javascript - * M365_BUILDER({ - * initialDomain: "example.onmicrosoft.com", - * }); - * ``` - * - * This sets up `MX` records, Autodiscover, and DKIM. - * - * ### Advanced example - * - * ```javascript - * M365_BUILDER({ - * label: "test", - * mx: false, - * autodiscover: false, - * dkim: false, - * mdm: true, - * domainGUID: "test-example-com", // Can be automatically derived in this case, if example.com is the context. - * initialDomain: "example.onmicrosoft.com", - * }); - * ``` - * - * This sets up Mobile Device Management only. - * - * ### Parameters - * - * * `label` The label of the Microsoft 365 domain, useful if it is a subdomain (default: `"@"`) - * * `mx` Set an `MX` record? (default: `true`) - * * `autodiscover` Set Autodiscover `CNAME` record? (default: `true`) - * * `dkim` Set DKIM `CNAME` records? (default: `true`) - * * `skypeForBusiness` Set Skype for Business/Microsoft Teams records? (default: `false`) - * * `mdm` Set Mobile Device Management records? (default: `false`) - * * `domainGUID` The GUID of _this_ Microsoft 365 domain (default: `