mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
SPF Flatten for non apex domains (#1220)
This commit is contained in:
@ -452,6 +452,16 @@ func (recs Records) FQDNMap() (m map[string]bool) {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (recs Records) GetByType(typeName string) Records {
|
||||||
|
results := Records{}
|
||||||
|
for _, rec := range recs {
|
||||||
|
if rec.Type == typeName {
|
||||||
|
results = append(results, rec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
// GroupedByKey returns a map of keys to records.
|
// GroupedByKey returns a map of keys to records.
|
||||||
func (recs Records) GroupedByKey() map[RecordKey]Records {
|
func (recs Records) GroupedByKey() map[RecordKey]Records {
|
||||||
groups := map[RecordKey]Records{}
|
groups := map[RecordKey]Records{}
|
||||||
|
@ -15,9 +15,9 @@ func flattenSPFs(cfg *models.DNSConfig) []error {
|
|||||||
var errs []error
|
var errs []error
|
||||||
var err error
|
var err error
|
||||||
for _, domain := range cfg.Domains {
|
for _, domain := range cfg.Domains {
|
||||||
apexTXTs := domain.Records.GroupedByKey()[models.RecordKey{Type: "TXT", NameFQDN: domain.Name}]
|
txtRecords := domain.Records.GetByType("TXT")
|
||||||
// flatten all spf records that have the "flatten" metadata
|
// flatten all spf records that have the "flatten" metadata
|
||||||
for _, txt := range apexTXTs {
|
for _, txt := range txtRecords {
|
||||||
var rec *spflib.SPFRecord
|
var rec *spflib.SPFRecord
|
||||||
txtTarget := strings.Join(txt.TxtStrings, "")
|
txtTarget := strings.Join(txt.TxtStrings, "")
|
||||||
if txt.Metadata["flatten"] != "" || txt.Metadata["split"] != "" {
|
if txt.Metadata["flatten"] != "" || txt.Metadata["split"] != "" {
|
||||||
|
Reference in New Issue
Block a user