ipn/ipnlocal, net/dns/resolver: use exit node's DoH proxy when available

Updates #1713

Change-Id: I3695a40ec12d2b4e6dac41cf4559daca6dddd68e
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2021-11-30 15:19:18 -08:00
committed by Brad Fitzpatrick
parent 16abd7e07c
commit 3ae6f898cf
2 changed files with 45 additions and 14 deletions

View File

@@ -423,8 +423,10 @@ func (f *forwarder) sendDoH(ctx context.Context, urlBase string, c *http.Client,
// send expects the reply to have the same txid as txidOut.
func (f *forwarder) send(ctx context.Context, fq *forwardQuery, rr resolverAndDelay) ([]byte, error) {
if strings.HasPrefix(rr.name.Addr, "http://") {
metricDNSFwdErrorType.Add(1)
return nil, fmt.Errorf("http:// resolvers not supported yet")
// TODO(bradfitz): this only work for TUN mode right now; plumb a universal dialer
// that can handle the dozen special cases for modes/platforms/routes.
TODOHTTPClient := http.DefaultClient
return f.sendDoH(ctx, rr.name.Addr, TODOHTTPClient, fq.packet)
}
if strings.HasPrefix(rr.name.Addr, "https://") {
metricDNSFwdErrorType.Add(1)