DoH Delete old code
This commit is contained in:
@@ -2,13 +2,8 @@ package resolver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
@@ -45,7 +40,7 @@ func (pr *PlainResolver) Query(ctx context.Context, q *Query) (*RRCache, error)
|
||||
// create query
|
||||
dnsQuery := new(dns.Msg)
|
||||
dnsQuery.SetQuestion(q.FQDN, uint16(q.QType))
|
||||
var reply *dns.Msg
|
||||
|
||||
// get timeout from context and config
|
||||
var timeout time.Duration
|
||||
if deadline, ok := ctx.Deadline(); !ok {
|
||||
@@ -57,24 +52,6 @@ func (pr *PlainResolver) Query(ctx context.Context, q *Query) (*RRCache, error)
|
||||
timeout = defaultRequestTimeout
|
||||
}
|
||||
|
||||
if strings.HasPrefix(pr.resolver.ServerAddress, "https:") {
|
||||
buf, err := dnsQuery.Pack()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b64dns := base64.RawStdEncoding.EncodeToString(buf)
|
||||
url := fmt.Sprintf("%s/dns-query?dns=%s", pr.resolver.ServerAddress, b64dns)
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
reply := new(dns.Msg)
|
||||
reply.Unpack(body)
|
||||
} else {
|
||||
// create client
|
||||
dnsClient := &dns.Client{
|
||||
Timeout: timeout,
|
||||
@@ -102,7 +79,6 @@ func (pr *PlainResolver) Query(ctx context.Context, q *Query) (*RRCache, error)
|
||||
if pr.resolver.IsBlockedUpstream(reply) {
|
||||
return nil, &BlockedUpstreamError{pr.resolver.Info.DescriptiveName()}
|
||||
}
|
||||
}
|
||||
|
||||
// hint network environment at successful connection
|
||||
netenv.ReportSuccessfulConnection()
|
||||
|
||||
Reference in New Issue
Block a user