Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[app/proxyman] DomainStrategy support for all outbounds #2334

Merged

Conversation

Vigilans
Copy link
Contributor

DomainStrategy is a setting in freedom outbound that may convert a domain address to ip address for dialing using v2ray's own DNS. This PR made this setting available to all outbounds, for following reasons:

  • For certain cases it would be very useful if an outbound could use v2ray's DNS to resolve its proxy address to use. E.g., to choose between ipv4 or ipv6 address of a domain, if either address has route of better quality.
  • Freedom outbound's DomainStrategy's implementation is problematic if underlying transport relies on the domain. E.g. HTTP/2 transport will use the domain in its SNI, but freedom outbound replaces it before calling Dial(), which is too early.

This PR adds a Resolver field to session.Outbound, when set it will resolve the domain right before calling the final system dialer (which will call system resolver for the domain), so we can control the ip to use for e.g. vmess proxy server's address, while preserving the domain semantic for transport layer.

Usage:

{
  "outbounds": [
    {
      "tag": "...",
      "protocol": "vmess",
      "settings": {
        "vnext": [{
          "address": "...", "port": 443,
          "users": [{ "id": "...", "security": "zero", "alterId": 0 }]
        }]
      },
      "domainStrategy": "UseIP", // DNS could use queryStrategy to control whether return IPv4 or IPv6
      "streamSettings": {
        "network": "h2",
        "security": "tls",
        "httpSettings": {
          "host": ["..."],
          "path": "..."
        }
      }
    }
  ]
}

@Vigilans Vigilans force-pushed the vigilans/domain-strategy-all-outbounds branch from f23999c to 236d903 Compare February 17, 2023 21:54
@codecov-commenter
Copy link

Codecov Report

Base: 39.21% // Head: 39.12% // Decreases project coverage by -0.10% ⚠️

Coverage data is based on head (236d903) compared to base (83ea1ba).
Patch coverage: 11.42% of modified lines in pull request are covered.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2334      +/-   ##
==========================================
- Coverage   39.21%   39.12%   -0.10%     
==========================================
  Files         617      617              
  Lines       36859    36917      +58     
==========================================
- Hits        14454    14443      -11     
- Misses      20816    20879      +63     
- Partials     1589     1595       +6     
Impacted Files Coverage Δ
app/proxyman/outbound/handler.go 30.23% <0.00%> (-9.50%) ⬇️
common/session/session.go 70.58% <ø> (ø)
app/proxyman/config.pb.go 17.78% <5.26%> (-0.73%) ⬇️
infra/conf/v4/v2ray.go 38.56% <25.00%> (-0.39%) ⬇️
proxy/freedom/freedom.go 47.31% <25.00%> (+1.85%) ⬆️
transport/internet/dialer.go 50.00% <30.76%> (-8.34%) ⬇️
app/router/command/errors.generated.go 0.00% <0.00%> (-100.00%) ⬇️
app/proxyman/outbound/errors.generated.go 0.00% <0.00%> (-100.00%) ⬇️
common/task/task.go 88.88% <0.00%> (-7.41%) ⬇️
... and 6 more

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants