mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-07 04:38:40 +00:00
refactor: new dns app
This commit is contained in:
parent
4e63c22197
commit
8884e948fe
24 changed files with 1240 additions and 620 deletions
|
@ -28,6 +28,12 @@ func (c routingContext) GetTargetPort() net.Port {
|
|||
return net.Port(c.RoutingContext.GetTargetPort())
|
||||
}
|
||||
|
||||
// GetSkipDNSResolve is a mock implementation here to match the interface,
|
||||
// SkipDNSResolve is set from dns module, no use if coming from a protobuf object?
|
||||
func (c routingContext) GetSkipDNSResolve() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// AsRoutingContext converts a protobuf RoutingContext into an implementation of routing.Context.
|
||||
func AsRoutingContext(r *RoutingContext) routing.Context {
|
||||
return routingContext{r}
|
||||
|
|
|
@ -80,7 +80,13 @@ func (r *Router) PickRoute(ctx routing.Context) (routing.Route, error) {
|
|||
}
|
||||
|
||||
func (r *Router) pickRouteInternal(ctx routing.Context) (*Rule, routing.Context, error) {
|
||||
if r.domainStrategy == Config_IpOnDemand {
|
||||
|
||||
// SkipDNSResolve is set from DNS module.
|
||||
// the DOH remote server maybe a domain name,
|
||||
// this prevents cycle resolving dead loop
|
||||
skipDNSResolve := ctx.GetSkipDNSResolve()
|
||||
|
||||
if r.domainStrategy == Config_IpOnDemand && !skipDNSResolve {
|
||||
ctx = routing_dns.ContextWithDNSClient(ctx, r.dns)
|
||||
}
|
||||
|
||||
|
@ -90,7 +96,7 @@ func (r *Router) pickRouteInternal(ctx routing.Context) (*Rule, routing.Context,
|
|||
}
|
||||
}
|
||||
|
||||
if r.domainStrategy != Config_IpIfNonMatch || len(ctx.GetTargetDomain()) == 0 {
|
||||
if r.domainStrategy != Config_IpIfNonMatch || len(ctx.GetTargetDomain()) == 0 || skipDNSResolve {
|
||||
return nil, ctx, common.ErrNoClue
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue