fix: exclude wintun/tunnel virtual adapters from default interface detection on Windows - #15
Open
bohid02 wants to merge 1 commit into
Open
fix: exclude wintun/tunnel virtual adapters from default interface detection on Windows#15bohid02 wants to merge 1 commit into
bohid02 wants to merge 1 commit into
Conversation
…tection on Windows Third-party applications (e.g., OPPO Connect) create wintun adapters that register as IfType=6 (EthernetCSMACD). These are not excluded by the current type-based filter, causing them to be selected as the default outbound interface when their metric is lower than the physical NIC. This leads to DIRECT traffic being routed through the third-party wintun adapter, looping back into the TUN, and triggering "reject loopback connection" errors. Fix by checking the interface Description for "Wintun" or "Tunnel" keywords and excluding matching adapters from default interface selection. Related: clash-verge-rev/clash-verge-rev#6712 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On Windows, third-party applications (e.g., OPPO Connect, ZeroTier) can create wintun virtual adapters that register as
IfType=6(EthernetCSMACD) rather thanIfType=53(PropVirtual). The currentcheckUpdate()filter inmonitor_windows.goonly excludesIfTypePropVirtualandIfTypeSoftwareLoopback, so these third-party wintun adapters can be selected as the default outbound interface.When this happens, mihomo's DIRECT outbound traffic is routed through the third-party wintun adapter instead of the physical NIC, causing traffic to loop back into the TUN and triggering
reject loopback connectionerrors — resulting in complete network failure.Root Cause
The wintun kernel driver (
wintun.sys) registers all adapters as NDIS miniport withIfType=6(Ethernet). The existing type-based filter cannot distinguish them from real physical adapters:Fix
Add a Description-based filter to exclude adapters whose
InterfaceDescriptioncontains "Wintun" or "Tunnel". These are virtual tunnel adapters and should never be selected as the default outbound interface.Reproduction
ROOT\WINTUN\0000)auto-route: truereject loopback connectionerrorspnputil /remove-deviceimmediately resolves the issueVerification
ROOT\WINTUN\0000, Description = "Wintun Userspace Tunnel", IfType=6, InterfaceMetric=5Related