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

Change the default behavior of IPOnDemand domain strategy #329

Merged
merged 5 commits into from May 20, 2021
Merged

Change the default behavior of IPOnDemand domain strategy #329

merged 5 commits into from May 20, 2021

Conversation

ghost
Copy link

@ghost ghost commented May 20, 2021

Hi everyone,

I noticed that the previous domain strategy will nullify domain rules when ip_on_demand is used.

Therefore here is my proposal on this section that:

  1. For IP, nothing is changed;
  2. For domains, "as_is" checks only domain list, "ip_on_demand" checks ip list before domain list, and "ip_if_non_match" checks domain list before ip list.

I am looking forward to your ideas and feedback.

Regards,
Chinese White Dolphin

tunnel/router/client.go
tunnel/router/client.go Outdated Show resolved Hide resolved
tunnel/router/client.go Outdated Show resolved Hide resolved
tunnel/router/client.go Outdated Show resolved Hide resolved
tunnel/router/client.go Outdated Show resolved Hide resolved
@Loyalsoldier Loyalsoldier changed the title A proposal on domain strategy Change the default behavior of IPOnDemand domain strategy May 20, 2021
Copy link
Collaborator

@Loyalsoldier Loyalsoldier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the default behavior of IPOnDemand, but I think it's more appropriate than it used to be.

@Loyalsoldier Loyalsoldier merged commit 63d0f73 into p4gefau1t:master May 20, 2021
@Loyalsoldier
Copy link
Collaborator

Loyalsoldier commented May 20, 2021

For users don't know what's going on:

The concept of domain strategy(AsIs, IPOnDemand and IPIfNonMatch) is originated from V2Ray. The routing system of V2Ray supports priority(from top to bottom) when setting geoip and geosite rules, which makes IPOnDemand and IPIfNonMatch diverse and easy to understand. (Docs)

In Trojan-Go(<= v0.10.0) instead, no priority between geoip rules and geosite rules. In other words, all geoip rules or all geosite rules are treated as a whole, therefore the major difference between IPOnDemand and IPIfNonMatch then will be whether to resolve the destination address(domain) to IP immediately.

After this PR, the new default behavior will be:

  • When the destination address is an IP: just match geoip rules.
  • When the destination address is a domain:
    • AsIs: just match geosite rules; do NOT resolve domain to IP;
    • IPOnDemand: resolve domain to IP, match geoip rules first; if no match, then match geosite rules;
    • IPIfNonMatch: match geosite rules first; if no match, resolve domain to IP, then match geoip rules.

The resolved IP will just be used to pick a route policy(block, bypass or proxy), the destination address(domain) will not be changed.

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.

1 participant