Improve udp timeout

This commit is contained in:
世界 2022-07-25 22:02:39 +08:00
parent 5491895a60
commit 816d7b734c
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
13 changed files with 157 additions and 41 deletions

View file

@ -576,16 +576,22 @@ func (r *Router) RoutePacketConnection(ctx context.Context, conn N.PacketConn, m
func (r *Router) Exchange(ctx context.Context, message *dnsmessage.Message) (*dnsmessage.Message, error) {
ctx, transport := r.matchDNS(ctx)
ctx, cancel := context.WithTimeout(ctx, C.DNSTimeout)
defer cancel()
return r.dnsClient.Exchange(ctx, transport, message)
}
func (r *Router) Lookup(ctx context.Context, domain string, strategy dns.DomainStrategy) ([]netip.Addr, error) {
ctx, transport := r.matchDNS(ctx)
ctx, cancel := context.WithTimeout(ctx, C.DNSTimeout)
defer cancel()
return r.dnsClient.Lookup(ctx, transport, domain, strategy)
}
func (r *Router) LookupDefault(ctx context.Context, domain string) ([]netip.Addr, error) {
ctx, transport := r.matchDNS(ctx)
ctx, cancel := context.WithTimeout(ctx, C.DNSTimeout)
defer cancel()
return r.dnsClient.Lookup(ctx, transport, domain, r.defaultDomainStrategy)
}