|
@@ -14,8 +14,6 @@ import (
|
|
|
"sync/atomic"
|
|
"sync/atomic"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
- dns_feature "v2ray.com/core/features/dns"
|
|
|
|
|
-
|
|
|
|
|
"golang.org/x/net/dns/dnsmessage"
|
|
"golang.org/x/net/dns/dnsmessage"
|
|
|
"v2ray.com/core/common"
|
|
"v2ray.com/core/common"
|
|
|
"v2ray.com/core/common/net"
|
|
"v2ray.com/core/common/net"
|
|
@@ -23,6 +21,7 @@ import (
|
|
|
"v2ray.com/core/common/session"
|
|
"v2ray.com/core/common/session"
|
|
|
"v2ray.com/core/common/signal/pubsub"
|
|
"v2ray.com/core/common/signal/pubsub"
|
|
|
"v2ray.com/core/common/task"
|
|
"v2ray.com/core/common/task"
|
|
|
|
|
+ dns_feature "v2ray.com/core/features/dns"
|
|
|
"v2ray.com/core/features/routing"
|
|
"v2ray.com/core/features/routing"
|
|
|
"v2ray.com/core/transport/internet"
|
|
"v2ray.com/core/transport/internet"
|
|
|
)
|
|
)
|
|
@@ -221,13 +220,11 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
|
|
|
if d, ok := ctx.Deadline(); ok {
|
|
if d, ok := ctx.Deadline(); ok {
|
|
|
deadline = d
|
|
deadline = d
|
|
|
} else {
|
|
} else {
|
|
|
- deadline = time.Now().Add(time.Second * 8)
|
|
|
|
|
|
|
+ deadline = time.Now().Add(time.Second * 5)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for _, req := range reqs {
|
|
for _, req := range reqs {
|
|
|
-
|
|
|
|
|
go func(r *dnsRequest) {
|
|
go func(r *dnsRequest) {
|
|
|
-
|
|
|
|
|
// generate new context for each req, using same context
|
|
// generate new context for each req, using same context
|
|
|
// may cause reqs all aborted if any one encounter an error
|
|
// may cause reqs all aborted if any one encounter an error
|
|
|
dnsCtx := context.Background()
|
|
dnsCtx := context.Background()
|
|
@@ -245,7 +242,8 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
|
|
|
// forced to use mux for DOH
|
|
// forced to use mux for DOH
|
|
|
dnsCtx = session.ContextWithMuxPrefered(dnsCtx, true)
|
|
dnsCtx = session.ContextWithMuxPrefered(dnsCtx, true)
|
|
|
|
|
|
|
|
- dnsCtx, cancel := context.WithDeadline(dnsCtx, deadline)
|
|
|
|
|
|
|
+ var cancel context.CancelFunc
|
|
|
|
|
+ dnsCtx, cancel = context.WithDeadline(dnsCtx, deadline)
|
|
|
defer cancel()
|
|
defer cancel()
|
|
|
|
|
|
|
|
b, err := dns.PackMessage(r.msg)
|
|
b, err := dns.PackMessage(r.msg)
|
|
@@ -269,7 +267,6 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte, error) {
|
|
func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte, error) {
|
|
|
-
|
|
|
|
|
body := bytes.NewBuffer(b)
|
|
body := bytes.NewBuffer(b)
|
|
|
req, err := http.NewRequest("POST", s.dohURL, body)
|
|
req, err := http.NewRequest("POST", s.dohURL, body)
|
|
|
if err != nil {
|
|
if err != nil {
|