mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-12-09 05:36:27 +08:00
cleanups
This commit is contained in:
parent
c2971663ab
commit
60f2595a60
4 changed files with 6 additions and 28 deletions
|
|
@ -233,6 +233,8 @@ func (dc *DomainConfig) GetPopulateCorrections(providerName string) []*Correctio
|
||||||
return dc.pendingPopulateCorrections[providerName]
|
return dc.pendingPopulateCorrections[providerName]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MakeFakeDomainConfig makes a DomainConfig with the given domain name. This is a workaround so we don't have to change sygnatures of every function that needs a DomainConfig.
|
||||||
|
// In the future we'll eliminate this by passing a DomainFixedForms instead (and possibly renaming DomainFixedForms).
|
||||||
func MakeFakeDomainConfig(domain string) *DomainConfig {
|
func MakeFakeDomainConfig(domain string) *DomainConfig {
|
||||||
v := domaintags.MakeDomainNameVarieties(domain)
|
v := domaintags.MakeDomainNameVarieties(domain)
|
||||||
return &DomainConfig{
|
return &DomainConfig{
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// DomainFixedForms stores the various fixed forms of a domain name and tag.
|
// DomainFixedForms stores the various fixed forms of a domain name and tag.
|
||||||
|
// TODO(tlim): Rename this to DomainNameVarieties or something similar.
|
||||||
type DomainFixedForms struct {
|
type DomainFixedForms struct {
|
||||||
NameRaw string // "originalinput.com" (name as input by the user, lowercased (no tag))
|
NameRaw string // "originalinput.com" (name as input by the user, lowercased (no tag))
|
||||||
NameASCII string // "punycode.com"
|
NameASCII string // "punycode.com"
|
||||||
|
|
|
||||||
|
|
@ -1353,8 +1353,6 @@ function recordBuilder(type, opts) {
|
||||||
if (
|
if (
|
||||||
d.subdomain &&
|
d.subdomain &&
|
||||||
record.type != 'CF_SINGLE_REDIRECT' &&
|
record.type != 'CF_SINGLE_REDIRECT' &&
|
||||||
record.type != 'CF_REDIRECT' &&
|
|
||||||
record.type != 'CF_TEMP_REDIRECT' &&
|
|
||||||
record.type != 'CF_WORKER_ROUTE' &&
|
record.type != 'CF_WORKER_ROUTE' &&
|
||||||
record.type != 'ADGUARDHOME_A_PASSTHROUGH' &&
|
record.type != 'ADGUARDHOME_A_PASSTHROUGH' &&
|
||||||
record.type != 'ADGUARDHOME_AAAA_PASSTHROUGH'
|
record.type != 'ADGUARDHOME_AAAA_PASSTHROUGH'
|
||||||
|
|
@ -1492,28 +1490,6 @@ function _validateCloudflareRedirect(value) {
|
||||||
return value.indexOf(',') === -1;
|
return value.indexOf(',') === -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//var CF_REDIRECT = recordBuilder('CF_REDIRECT', {
|
|
||||||
// args: [
|
|
||||||
// ['source', _validateCloudflareRedirect],
|
|
||||||
// ['destination', _validateCloudflareRedirect],
|
|
||||||
// ],
|
|
||||||
// transform: function (record, args, modifiers) {
|
|
||||||
// record.name = '@';
|
|
||||||
// record.target = args.source + ',' + args.destination;
|
|
||||||
// },
|
|
||||||
//});
|
|
||||||
|
|
||||||
//var CF_TEMP_REDIRECT = recordBuilder('CF_TEMP_REDIRECT', {
|
|
||||||
// args: [
|
|
||||||
// ['source', _validateCloudflareRedirect],
|
|
||||||
// ['destination', _validateCloudflareRedirect],
|
|
||||||
// ],
|
|
||||||
// transform: function (record, args, modifiers) {
|
|
||||||
// record.name = '@';
|
|
||||||
// record.target = args.source + ',' + args.destination;
|
|
||||||
// },
|
|
||||||
//});
|
|
||||||
|
|
||||||
var CF_WORKER_ROUTE = recordBuilder('CF_WORKER_ROUTE', {
|
var CF_WORKER_ROUTE = recordBuilder('CF_WORKER_ROUTE', {
|
||||||
args: [
|
args: [
|
||||||
['pattern', _validateCloudflareRedirect],
|
['pattern', _validateCloudflareRedirect],
|
||||||
|
|
@ -2516,8 +2492,7 @@ function rawrecordBuilder(type) {
|
||||||
|
|
||||||
// PLEASE KEEP THIS LIST ALPHABETICAL!
|
// PLEASE KEEP THIS LIST ALPHABETICAL!
|
||||||
|
|
||||||
// CLOUDFLAREAPI:
|
var CF_REDIRECT = rawrecordBuilder('CF_REDIRECT');
|
||||||
var CF_SINGLE_REDIRECT = rawrecordBuilder('CLOUDFLAREAPI_SINGLE_REDIRECT');
|
var CF_SINGLE_REDIRECT = rawrecordBuilder('CLOUDFLAREAPI_SINGLE_REDIRECT');
|
||||||
var CF_TEMP_REDIRECT = rawrecordBuilder('CF_TEMP_REDIRECT');
|
var CF_TEMP_REDIRECT = rawrecordBuilder('CF_TEMP_REDIRECT');
|
||||||
var CF_REDIRECT = rawrecordBuilder('CF_REDIRECT');
|
|
||||||
var RP = rawrecordBuilder('RP');
|
var RP = rawrecordBuilder('RP');
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import (
|
||||||
|
|
||||||
// ImportRawRecords imports the RawRecordConfigs into RecordConfigs.
|
// ImportRawRecords imports the RawRecordConfigs into RecordConfigs.
|
||||||
func ImportRawRecords(domains []*models.DomainConfig) error {
|
func ImportRawRecords(domains []*models.DomainConfig) error {
|
||||||
|
|
||||||
for _, dc := range domains {
|
for _, dc := range domains {
|
||||||
for _, rawRec := range dc.RawRecords {
|
for _, rawRec := range dc.RawRecords {
|
||||||
|
|
||||||
|
|
@ -98,8 +97,9 @@ func NewRecordConfigFromStruct(name string, ttl uint32, t string, fields any, dc
|
||||||
return rec, nil
|
return rec, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setRecordNames updates the .Name* fields.
|
||||||
func setRecordNames(rec *models.RecordConfig, dc *models.DomainConfig, n string) {
|
func setRecordNames(rec *models.RecordConfig, dc *models.DomainConfig, n string) {
|
||||||
|
// FYI(tlim): This code could be collapse
|
||||||
if rec.SubDomain == "" {
|
if rec.SubDomain == "" {
|
||||||
// Not _EXTEND() mode:
|
// Not _EXTEND() mode:
|
||||||
if n == "@" {
|
if n == "@" {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue