Skip to content

Wake-on-LAN: send through the TV's network so a VPN can't swallow it - #18

Merged
Xarishark merged 6 commits into
mainfrom
feat/prefered-network-device-for-wol
Dec 2, 2026
Merged

Xarishark merged 6 commits into
mainfrom
feat/prefered-network-device-for-wol

Conversation

@Xarishark

Copy link
Copy Markdown
Owner

What and why

Wake-on-LAN sent magic packets to 255.255.255.255 from an unbound socket, which lets Windows pick the adapter. With a full-tunnel VPN that uses a TAP-style adapter (OpenVPN TAP, Hamachi, Radmin VPN, ZeroTier), Windows sends the broadcast into the VPN and the TV never wakes.

  • Choose the adapter by subnet. Director lists the up IPv4 adapters (GetAdaptersAddresses) and sends from each one whose subnet holds the TV's IP address. Each one sends to 255.255.255.255, to that subnet's broadcast address and straight to the TV. Picking by subnet, not by route, also covers VPNs that claim the TV's subnet; a tunnel is used only when no real adapter is on that subnet.
  • Fallbacks.
    • If adapters can't be listed, Director sends from the local address Windows uses to reach the TV (a UDP connect, which sends nothing).
    • If no subnet holds the TV's IP (the PC or network changed), it broadcasts on every adapter with a gateway. VPN, link-local and host-only virtual adapters are skipped.
    • The old unbound broadcast is still sent last, so a wake never does less than before.
  • Failures. Each path gets its own socket, and one failing path no longer cancels the wake. If Windows refuses paths (access denied, unreachable), the message names a VPN that blocks local traffic as the likely cause.
  • Logs record which adapters and destinations a wake used and any errors per path, by adapter name only, never addresses.
  • Docs: TVs, Troubleshooting, Architecture and Development pages, plus an Unreleased CHANGELOG entry.

For reviewers:

  • New windows features: Win32_NetworkManagement_IpHelper, Win32_NetworkManagement_Ndis and Win32_Networking_WinSock. There's no new crate and Cargo.lock is unchanged.
  • New file: src/tv/windows_adapters.rs.
  • Signature change: tv_network::wake now takes the TV's address.
  • Settings: no settings fields were added, so tvs.json is unchanged and a downgrade stays safe. A per-TV adapter choice was left out for that reason.
  • Packet count: a wake now sends about 15 packets instead of 3 (one saved MAC). The two 100 ms pauses between rounds are unchanged, and every caller already runs off the UI thread.

Checks

  • cargo fmt --all -- --check
  • cargo clippy --locked --all-targets -- -D warnings
  • cargo test --locked -- --test-threads=1 (170 lib + 22 app passed, on a Windows 11 VM)
  • Docs and README updated where behaviour changed
  • THIRD_PARTY_LICENSES.md regenerated if dependencies changed (no dependency changes)

Tested by hand

On a Windows 11 VM, using pktmon to see which adapter each packet leaves from, with a second VM on the same subnet as the "TV":

  • Before: with an OpenVPN TAP adapter (low metric, full-tunnel 0/1 + 128/1 routes), the unbound broadcast left through the TAP adapter.
  • After, same setup: director tv wake sent the broadcast, the subnet broadcast and unicast to the TV from Ethernet. The unbound extra still went to the TAP adapter.
  • No VPN: every packet left through Ethernet.
  • WireGuard (wintun) doesn't cause the original problem: Windows never broadcasts through point-to-point adapters.
  • Firewall block: a Windows Firewall rule blocking the app on Ethernet drops the packets silently, so the send still reports success. The VPN message only appears when Windows actually returns an error, and the Troubleshooting page says so.

Not yet tested against a real TV.

@Xarishark
Xarishark enabled auto-merge December 2, 2026 18:36
@Xarishark
Xarishark merged commit 84e60cf into main Dec 2, 2026
2 checks passed
@Xarishark
Xarishark deleted the feat/prefered-network-device-for-wol branch December 2, 2026 18:37
@Xarishark Xarishark mentioned this pull request Dec 2, 2026
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