v2ray-core icon indicating copy to clipboard operation
v2ray-core copied to clipboard

[app/router] [features/routing] Refine resolution strategy and SkipDNSResolve handling

Open Vigilans opened this issue 3 years ago • 1 comments

This PR is a continuation of https://github.com/v2fly/v2ray-core/pull/1973. Unlike the base PR it contains changes to existing features API, so created as a separated PR.

This PR removes GetSkipDNSResolve() method from routing.Context interface, and adds a new Unwrap() method to interface for intelligent controlling of routing behavior.

SkipDNSResolve is moved out of routing.Context because compared with other data fields, it works more like a control flag. For separation of control and data channel, it is moved out of routing.Context and specially treated during the creation of ContextWithDNSClient.

ContextWithDNSClient and ContextWithOriginalDestination now returns a second boolean flag, indicating whether the returned context is different from the received context. If:

  • For ResolvableContext, the SkipDNSResolve is set in the context to wrap.
  • For OriginDestContext, the session.Content does not contain original destination IP.

Then the received original context is directly returned, with the second updated flag set to false. So:

  • By returning the original context, no IP resolving capability is added to context.
  • By knowing the context didn't get updated, the second round of routing rules traversal (from IPIfNonMatch) could just be skipped.

Vigilans avatar Sep 12 '22 10:09 Vigilans

Codecov Report

Base: 38.88% // Head: 38.79% // Decreases project coverage by -0.08% :warning:

Coverage data is based on head (82f0059) compared to base (2e0ea88). Patch coverage: 33.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1975      +/-   ##
==========================================
- Coverage   38.88%   38.79%   -0.09%     
==========================================
  Files         616      617       +1     
  Lines       36336    36386      +50     
==========================================
- Hits        14128    14117      -11     
- Misses      20630    20684      +54     
- Partials     1578     1585       +7     
Impacted Files Coverage Δ
app/router/command/config.go 96.07% <0.00%> (-3.93%) :arrow_down:
common/session/session.go 70.58% <ø> (ø)
features/routing/session/context_origindest.go 0.00% <0.00%> (ø)
app/router/config.pb.go 12.86% <5.26%> (-0.44%) :arrow_down:
infra/conf/synthetic/router/router.go 64.64% <37.50%> (-5.24%) :arrow_down:
app/dispatcher/default.go 29.71% <39.13%> (+0.30%) :arrow_up:
features/routing/dns/context.go 38.46% <42.85%> (-2.72%) :arrow_down:
app/router/router.go 28.93% <56.52%> (+1.34%) :arrow_up:
features/routing/session/context.go 67.27% <100.00%> (+0.60%) :arrow_up:
app/router/command/errors.generated.go 0.00% <0.00%> (-100.00%) :arrow_down:
... and 7 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov-commenter avatar Sep 12 '22 11:09 codecov-commenter

It has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Mar 30 '23 01:03 github-actions[bot]