chore: wireguard dns can work with domain-based server

This commit is contained in:
wwqgtxx
2023-04-11 14:10:57 +08:00
parent 92cc268209
commit 90f95d7c78
11 changed files with 51 additions and 6 deletions

View File

@ -412,8 +412,11 @@ func (r *Resolver) asyncExchange(ctx context.Context, client []dnsClient, msg *D
return ch
}
// HasProxyServer has proxy server dns client
func (r *Resolver) HasProxyServer() bool {
// Invalid return this resolver can or can't be used
func (r *Resolver) Invalid() bool {
if r == nil {
return false
}
return len(r.main) > 0
}

View File

@ -170,6 +170,14 @@ func getDialHandler(r *Resolver, proxyAdapter C.ProxyAdapter, proxyName string,
Host: host,
DstPort: port,
}
if proxyAdapter.IsL3Protocol(metadata) {
dstIP, err := resolver.ResolveIPWithResolver(ctx, host, r)
if err != nil {
return nil, err
}
metadata.Host = ""
metadata.DstIP = dstIP
}
if proxyAdapter != nil {
return proxyAdapter.DialContext(ctx, metadata, opts...)
}