Skip to content

Commit

Permalink
fix: defaultNS not working in system dns
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Oct 5, 2024
1 parent 8f5a864 commit 9937ae1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions dns/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ type systemClient struct {

func (c *systemClient) ExchangeContext(ctx context.Context, m *D.Msg) (msg *D.Msg, err error) {
dnsClients, err := c.getDnsClients()
if len(dnsClients) == 0 && len(c.defaultNS) > 0 {
dnsClients = c.defaultNS
err = nil
}
if err != nil {
if len(c.defaultNS) > 0 {
dnsClients = c.defaultNS
} else {
return
}
return
}
msg, _, err = batchExchange(ctx, dnsClients, m)
return
Expand All @@ -45,11 +45,16 @@ func (c *systemClient) ExchangeContext(ctx context.Context, m *D.Msg) (msg *D.Ms
// Address implements dnsClient
func (c *systemClient) Address() string {
dnsClients, _ := c.getDnsClients()
isDefault := ""
if len(dnsClients) == 0 && len(c.defaultNS) > 0 {
dnsClients = c.defaultNS
isDefault = "[defaultNS]"
}
addrs := make([]string, 0, len(dnsClients))
for _, c := range dnsClients {
addrs = append(addrs, c.Address())
}
return fmt.Sprintf("system(%s)", strings.Join(addrs, ","))
return fmt.Sprintf("system%s(%s)", isDefault, strings.Join(addrs, ","))
}

var _ dnsClient = (*systemClient)(nil)
Expand Down

0 comments on commit 9937ae1

Please sign in to comment.