Skip to content

Commit

Permalink
fix stats on inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHlt committed Oct 3, 2023
1 parent 83403d6 commit 318d11a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions resolvers/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (h *GSLBHandler) isAllowedInspect(ctx context.Context) bool {
return false
}

func (h *GSLBHandler) answerAllEntries() []dns.RR {
func (h *GSLBHandler) answerAllEntries(ctx context.Context) []dns.RR {
rrs := make([]dns.RR, 0)
h.entries.Range(func(key, value interface{}) bool {
entryRef := value.(entryRef)
Expand All @@ -188,6 +188,7 @@ func (h *GSLBHandler) answerAllEntries() []dns.RR {
rrs = append(rrs, rr)
return true
})
stats.AddQuerySuccess(ctx, getAllEntriesFqdn, "TXT")
return rrs
}

Expand Down Expand Up @@ -221,17 +222,18 @@ func (h *GSLBHandler) seeAll(ctx context.Context, entry *entries.Entry, queryTyp
return []dns.RR{}
}
rrs := make([]dns.RR, 0)
fqdn := fmt.Sprintf("%s%s", allMemberHost, entry.GetFqdn())
for _, member := range members {
rr, err := dns.NewRR(
fmt.Sprintf("%s%s %d IN %s %s", allMemberHost, entry.GetFqdn(), entry.GetTtl(), dns.TypeToString[queryType], member.GetIp()),
fmt.Sprintf("%s %d IN %s %s", fqdn, entry.GetTtl(), dns.TypeToString[queryType], member.GetIp()),
)
if err != nil {
log.Errorf("error creating dns RR: %s", err.Error())
continue
}
rrs = append(rrs, rr)
}
stats.AddQuerySuccess(ctx, entry.GetFqdn(), dns.TypeToString[queryType])
stats.AddQuerySuccess(ctx, fqdn, dns.TypeToString[queryType])
return rrs
}

Expand Down

0 comments on commit 318d11a

Please sign in to comment.