chore: better dns log

This commit is contained in:
Skyxim
2023-01-28 22:33:03 +08:00
parent 2cf66f41cb
commit e52d599326
6 changed files with 43 additions and 4 deletions

View File

@ -2,12 +2,14 @@ package dns
import (
"context"
"go.uber.org/atomic"
"net"
"net/netip"
"strings"
"sync"
"time"
"go.uber.org/atomic"
"github.com/Dreamacro/clash/component/dhcp"
"github.com/Dreamacro/clash/component/iface"
"github.com/Dreamacro/clash/component/resolver"
@ -34,6 +36,17 @@ type dhcpClient struct {
err error
}
var _ dnsClient = (*dhcpClient)(nil)
// Address implements dnsClient
func (d *dhcpClient) Address() string {
addrs := make([]string, 0)
for _, c := range d.clients {
addrs = append(addrs, c.Address())
}
return strings.Join(addrs, ",")
}
func (d *dhcpClient) Exchange(m *D.Msg) (msg *D.Msg, err error) {
ctx, cancel := context.WithTimeout(context.Background(), resolver.DefaultDNSTimeout)
defer cancel()