mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-09 02:41:22 +08:00
fix: defaultNS not working in system dns
This commit is contained in:
parent
8f5a86410c
commit
9937ae1002
@ -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 err != nil {
|
||||
if len(c.defaultNS) > 0 {
|
||||
if len(dnsClients) == 0 && len(c.defaultNS) > 0 {
|
||||
dnsClients = c.defaultNS
|
||||
} else {
|
||||
return
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
msg, _, err = batchExchange(ctx, dnsClients, m)
|
||||
return
|
||||
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user