mirror of
https://github.com/safing/portmaster
synced 2025-09-02 02:29:12 +00:00
DoH Delete old code
This commit is contained in:
parent
4a7ab13bf5
commit
0d21ee7d0d
1 changed files with 23 additions and 47 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue