Skip to content

Commit

Permalink
Better function names
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonSludge committed Mar 2, 2021
1 parent 5c6c0bb commit 5b95206
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/dns-inventory/dns-inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func main() {

if len(*hostFlag) == 0 {
// Acquire TXT records.
records := dns.GetRecords(cfg)
records := dns.GetAllRecords(cfg)
if len(records) == 0 {
log.Fatal("empty TXT records list")
}
Expand Down
14 changes: 7 additions & 7 deletions internal/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ func init() {
}
}

// GetRecords acquires DNS records from a remote DNS server.
func GetRecords(cfg *config.Main) []dns.RR {
// GetAllRecords acquires DNS records from a remote DNS server.
func GetAllRecords(cfg *config.Main) []dns.RR {
records := make([]dns.RR, 0)

for _, zone := range cfg.Zones {
var rrs []dns.RR
var err error

if cfg.NoTx {
rrs, err = GetRecord(cfg.Address, zone, cfg.NoTxHost, cfg.Timeout)
rrs, err = GetRecords(cfg.Address, zone, cfg.NoTxHost, cfg.Timeout)
} else {
rrs, err = TransferZone(cfg.Address, zone, cfg.NoTxHost, cfg.Timeout)
}
Expand Down Expand Up @@ -92,8 +92,8 @@ func TransferZone(server string, domain string, notxName string, timeout string)
return records, nil
}

// GetRecord performs a DNS query for TXT records of a specific host.
func GetRecord(server string, domain string, host string, timeout string) ([]dns.RR, error) {
// GetRecords performs a DNS query for TXT records of a specific host.
func GetRecords(server string, domain string, host string, timeout string) ([]dns.RR, error) {
records := make([]dns.RR, 0)
var name string

Expand Down Expand Up @@ -144,7 +144,7 @@ func GetHostRecords(cfg *config.Main, host string) ([]dns.RR, error) {
}

// Get no-transfer host records.
rrs, err = GetRecord(cfg.Address, zone, cfg.NoTxHost, cfg.Timeout)
rrs, err = GetRecords(cfg.Address, zone, cfg.NoTxHost, cfg.Timeout)
if err != nil {
return records, err
}
Expand All @@ -158,7 +158,7 @@ func GetHostRecords(cfg *config.Main, host string) ([]dns.RR, error) {
}
} else {
// No-transfer mode is disabled, no special logic is needed.
records, err = GetRecord(cfg.Address, "", host, cfg.Timeout)
records, err = GetRecords(cfg.Address, "", host, cfg.Timeout)
if err != nil {
return records, err
}
Expand Down

0 comments on commit 5b95206

Please sign in to comment.