Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip RRSIG records in response. #328

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/discovery/srv.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func srvFetch(cfg config.DiscoveryConfig) (*[]core.Backend, error) {
for _, ans := range r.Answer {
record, ok := ans.(*dns.SRV)
if !ok {
// RRSIG is allowed because DNSSEC could be enabled.
if _, ok := ans.(*dns.RRSIG); ok {
continue
}
return nil, errors.New("Non-SRV record in SRV answer")
}

Expand Down Expand Up @@ -149,12 +153,15 @@ func srvIPLookup(cfg config.DiscoveryConfig, pattern string, typ uint16) (string
return "", nil
}

switch ans := resp.Answer[0].(type) {
case *dns.A:
return ans.A.String(), nil
case *dns.AAAA:
return fmt.Sprintf("[%s]", ans.AAAA.String()), nil
default:
return "", nil
for _, answer := range resp.Answer {
switch ans := answer.(type) {
case *dns.A:
return ans.A.String(), nil
case *dns.AAAA:
return fmt.Sprintf("[%s]", ans.AAAA.String()), nil
default:
continue
}
}
return "", nil
}