Chore: mix the proxy adapter and interface to dns client

This commit is contained in:
yaling888
2022-06-03 11:27:41 +08:00
parent a4d135ed21
commit 3dbba5d8d2
4 changed files with 26 additions and 11 deletions

View File

@ -3,6 +3,7 @@ package dns
import (
"context"
"crypto/tls"
"errors"
"fmt"
"net"
"net/netip"
@ -19,6 +20,8 @@ import (
D "github.com/miekg/dns"
)
var errProxyNotFound = errors.New("proxy adapter not found")
func putMsgToCache(c *cache.LruCache[string, *D.Msg], key string, msg *D.Msg) {
var ttl uint32
switch {
@ -135,7 +138,7 @@ func (wpc *wrapPacketConn) RemoteAddr() net.Addr {
func dialContextWithProxyAdapter(ctx context.Context, adapterName string, network string, dstIP netip.Addr, port string, opts ...dialer.Option) (net.Conn, error) {
proxy, ok := tunnel.Proxies()[adapterName]
if !ok {
return nil, fmt.Errorf("proxy adapter [%s] not found", adapterName)
return nil, errProxyNotFound
}
networkType := C.TCP