mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 09:18:34 +00:00
Co-authored-by: yuhan6665 <1588741+yuhan6665@users.noreply.github.com>
This commit is contained in:
parent
f50eff5ebb
commit
d7cd71b741
3 changed files with 27 additions and 19 deletions
|
@ -55,19 +55,13 @@ func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, clientIP net.
|
|||
ForceAttemptHTTP2: true,
|
||||
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
dispatcherCtx := context.Background()
|
||||
if inbound := session.InboundFromContext(ctx); inbound != nil {
|
||||
dispatcherCtx = session.ContextWithInbound(dispatcherCtx, inbound)
|
||||
}
|
||||
if content := session.ContentFromContext(ctx); content != nil {
|
||||
dispatcherCtx = session.ContextWithContent(dispatcherCtx, content)
|
||||
}
|
||||
dispatcherCtx = internet.ContextWithLookupDomain(dispatcherCtx, internet.LookupDomainFromContext(ctx))
|
||||
|
||||
dest, err := net.ParseDestination(network + ":" + addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dispatcherCtx = session.ContextWithContent(dispatcherCtx, &session.Content{Protocol: "tls"})
|
||||
dispatcherCtx = log.ContextWithAccessMessage(dispatcherCtx, &log.AccessMessage{
|
||||
From: "DoH",
|
||||
To: s.dohURL,
|
||||
|
@ -76,6 +70,12 @@ func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, clientIP net.
|
|||
})
|
||||
|
||||
link, err := s.dispatcher.Dispatch(dispatcherCtx, dest)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
default:
|
||||
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ type Server struct {
|
|||
sync.Mutex
|
||||
hosts *StaticHosts
|
||||
clientIP net.IP
|
||||
clients []Client // clientIdx -> Client
|
||||
clients []Client // clientIdx -> Client
|
||||
ctx context.Context
|
||||
ipIndexMap []*MultiGeoIPMatcher // clientIdx -> *MultiGeoIPMatcher
|
||||
domainRules [][]string // clientIdx -> domainRuleIdx -> DomainRule
|
||||
|
@ -307,7 +307,7 @@ func (s *Server) queryIPTimeout(idx int, client Client, domain string, option dn
|
|||
Tag: s.tag,
|
||||
})
|
||||
}
|
||||
ctx = internet.ContextWithLookupDomain(ctx, Fqdn(domain))
|
||||
ctx = internet.ContextWithLookupDomain(ctx, domain)
|
||||
ips, err := client.QueryIP(ctx, domain, option)
|
||||
cancel()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue