Repository navigation
fix: a DNS preset goes to the adapter Windows sends its traffic through, and the confirmation names it - #2937
Merged
Conversation
…gh, and the confirmation names it - DnsService's adapter selector takes the interface of the route Find-NetRoute finds to a public IPv4 address, then a public IPv6 one, among the adapters that are up, and falls back to the old order, the first non-virtual adapter up by ifIndex, only without such a route. The lowest ifIndex is only the order adapters were created in, so on a laptop on a dock a family preset went to the Wi-Fi while names resolved through the Ethernet's servers. - The capture prints the adapter's name, DnsSnapshot.AdapterName carries it, and the Change and Reset confirmations say "the network adapter "Ethernet 3"" instead of an interface number.
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.
Closes #2879.
Confirmed in the selector: every DNS path on the tab, the Current DNS readout, the capture before a change, Set, Reset to DHCP and the fallback of Undo, picked the first adapter that is up and not virtual, ordered by
ifIndex, which is the order adapters were created in. Nothing asked which adapter carries the traffic. I could not reproduce the dock case here, with one physical adapter up; the integration tests give the selector a Wi-Fi at interface 5 and a dock's Ethernet at 17 carrying the route.The changes:
ActiveAdapterSelector, the one rule all of them share, reads the adapters that are up once, asksFind-NetRoutefor the route to a public IPv4 address and, without one, a public IPv6 address, and takes the adapter of that route's interface.Find-NetRouteworks the route out from the table and sends nothing. Only when there is no route to an adapter that is up does it fall back to the old order, first non-virtual adapter byifIndex, then any. On this PC, through the real cmdlets, it picks the same adapter as before, the only physical one up.IFNAME=with the adapter's name,DnsSnapshot.AdapterNamecarries it, and the confirmations read "Change DNS on the network adapter "Ethernet 3" to …" and "Reset DNS on the network adapter "Ethernet 3" to automatic (DHCP)?". The name only labels: identity stays the GUID and index, and it is never put into a script. Without a name the text falls back to "network interface 12".Docs
README, DNS & Hosts: the change goes to the adapter Windows sends its traffic through, the confirmation names it, and Current DNS reads that same adapter.
Tests
DnsScriptTests(integration), now withFind-NetRouteshadowed in every test so the machine's own routes never answer: the index is the best route's adapter, 17, not the lowest number, 5; an IPv6-only route is followed too; with no route, or a route to an interface that is not an adapter that is up, it is the first adapter up; and Current DNS lists the servers of the route's adapter, not the Wi-Fi's.DnsServiceTests: the capture prints the name and keeps it whole, an=in it included; a capture without a name gives an empty one.DnsHostsViewModelTests: Change and Reset name the adapter as Windows does.DnsServiceTests,DnsHostsViewModelTests,DnsHostsViewModelGateTests,ArchitectureTestsandInclusiveTermsTests(400), andDnsScriptTests(12). All four projects build with 0 warnings, anddotnet format --verify-no-changesis clean.