fix: remove wrong check of OverrideAndroidVPN when creating android routing rules #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug description:
The iproute2 rule being created here is:
9000: from all fwmark 0xY/0x20000 goto 9010
.Its purpose is to control whether traffic that has been marked by
VPNService.protect
will bypass Mihomo.According to the current code,
OverrideAndroidVPN == true
, this rule is created as9000: from all fwmark 0x20000/0x20000 goto 9010
, soVpnProtect
bit is 1VpnProtect
bit is 0OverrideAndroidVPN == false
, this rule is created as9000: from all fwmark 0x0/0x20000 goto 9010
, meaning thatVpnProtect
bit is 0VpnProtect
bit is 1In fact, this rule should always be created as
9000: from all fwmark 0x20000/0x20000 goto 9010
, regardless of whetherOverrideAndroidVPN
istrue
or notThe reason is: the design goal of
OverrideAndroidVPN
is to guide Mihomo whether or not to use Android VPN as an upstream NIC.OverrideAndroidVPN == true
, withauto-detect-interface
, Mihomo automatically recognizes the Android VPN (tun0) as the upstream NIC, and all requests outbound from Mihomo are sent to tun0.OverrideAndroidVPN == false
, all requests outbound from Mihomo should bypass the Android VPN, and go directly to the primary NIC (e.g. wlan0).So, anyway, by the design of this feature, there should not be a situation where traffic sent outbound by Android VPN is still received by Mihomo. In other words, any traffic marked with Android
VpnProtect
mark must bypass Mihomo, and other normal traffic must goes into Mihomo, no matter what the parameters are set to. This ensures that Mihomo can always receives and processes traffic properly.Current logic leads to the bug that, when
OverrideAndroidVPN
is set tofalse
, all network traffic will first bypasses Mihomo and goes to the Android VPN for processing, then directly goes into the primary NIC (e.g., wlan0). Mihomo is unable to receive any of the traffic. This is obviously problematic, I think.