Skip to content

fix(config): accept Windows interface names - #154

Merged
fylorn merged 2 commits into
mainfrom
fix/windows-nic-names
Sep 24, 2026
Merged

fylorn merged 2 commits into
mainfrom
fix/windows-nic-names

Conversation

@fylorn

@fylorn fylorn commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Found on a real Windows install of ThinkWatch Lite 2026.9.11: choosing "LAN" in the listen settings and saving fails with bind takes loopback, all, the name of an interface such as en0, …; it reads 以太网 (same for vEthernet (Default Switch)).

On Windows the interface list (nics.rs) deliberately uses the adapter's display name rather than its GUID. looks_like_nic still applied the Unix kernel-name rule (ASCII, .-_, under 16 bytes), so every Windows interface was rejected.

  • nic_shape(windows, s): on Windows a name only has to be non-empty, have no control characters or surrounding whitespace, and be at most 256 characters; the Unix rule is unchanged. It takes the platform as a parameter so both rules are tested on any host.
  • a_bind_typo_says_what_the_forms_are used 192.168.1.5@wifi, which is now a valid Windows name; it uses a value with a leading space, rejected on both.
  • New test: names with Chinese, spaces and parentheses survive edit::set (the path the UI's save uses) and read back unchanged; on Windows they parse as Bind::Nic.

cargo fmt --check, cargo clippy --all-targets -D warnings, cargo test --workspace pass on macOS; the Windows job runs the Windows side.

🤖 Generated with Claude Code

fylorn and others added 2 commits September 24, 2026 09:46
On Windows the interface list shows each adapter's display name
(`以太网`, `vEthernet (Default Switch)`, `WLAN 2`), chosen over the GUID
so people can tell them apart. The bind parser still judged names by the
Unix rule (short ASCII kernel names like en0), so on a real Windows
install every interface in the list was rejected on save.

The shape check is now per platform: on Windows, a name only has to be
non-empty, free of control characters and surrounding whitespace, and at
most 256 characters. The Unix rule is unchanged. Both rules are tested on
any host, and a name with spaces, parentheses or Chinese survives being
written into the configuration and read back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`192.168.1.5@wifi` is a valid Windows interface name now; a control
character is not a name on either platform (and survives the trim).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 3b567c5 into main Sep 24, 2026
2 checks passed
@fylorn
fylorn deleted the fix/windows-nic-names branch September 24, 2026 02:03
@fylorn fylorn mentioned this pull request Sep 24, 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