mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-10-06 20:05:50 +08:00
almost ready
This commit is contained in:
parent
e14c804882
commit
fda523e949
5 changed files with 199 additions and 261 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
go.mod
2
go.mod
|
@ -158,5 +158,3 @@ require (
|
||||||
gopkg.in/sourcemap.v1 v1.0.5 // indirect
|
gopkg.in/sourcemap.v1 v1.0.5 // indirect
|
||||||
moul.io/http2curl v1.0.0 // indirect
|
moul.io/http2curl v1.0.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
tool golang.org/x/tools/cmd/stringer
|
|
||||||
|
|
|
@ -11,6 +11,21 @@ type SPFRecord struct {
|
||||||
Parts []*SPFPart
|
Parts []*SPFPart
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lookups returns the number of DNS lookups required by s.
|
||||||
|
// NB(tlim): This needs to be in this file or "gopherjs build" fails.
|
||||||
|
func (s *SPFRecord) Lookups() int {
|
||||||
|
count := 0
|
||||||
|
for _, p := range s.Parts {
|
||||||
|
if p.IsLookup {
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
if p.IncludeRecord != nil {
|
||||||
|
count += p.IncludeRecord.Lookups()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
// SPFPart stores a part of an SPF record, with attributes.
|
// SPFPart stores a part of an SPF record, with attributes.
|
||||||
type SPFPart struct {
|
type SPFPart struct {
|
||||||
Text string
|
Text string
|
||||||
|
|
|
@ -26,20 +26,6 @@ func dump(rec *SPFRecord, indent string, w io.Writer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookups returns the number of DNS lookups required by s.
|
|
||||||
func (s *SPFRecord) Lookups() int {
|
|
||||||
count := 0
|
|
||||||
for _, p := range s.Parts {
|
|
||||||
if p.IsLookup {
|
|
||||||
count++
|
|
||||||
}
|
|
||||||
if p.IncludeRecord != nil {
|
|
||||||
count += p.IncludeRecord.Lookups()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print prints an SPFRecord.
|
// Print prints an SPFRecord.
|
||||||
func (s *SPFRecord) Print() string {
|
func (s *SPFRecord) Print() string {
|
||||||
w := &bytes.Buffer{}
|
w := &bytes.Buffer{}
|
||||||
|
|
Loading…
Add table
Reference in a new issue