Skip to content

fix(ui): offer only TUN stacks mihomo accepts - #2247

Merged
kunish merged 1 commit into
MetaCubeX:mainfrom
Dv2Corn:fix/tun-stack-options
Nov 7, 2026
Merged

kunish merged 1 commit into
MetaCubeX:mainfrom
Dv2Corn:fix/tun-stack-options

Conversation

@Dv2Corn

@Dv2Corn Dv2Corn commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Description

On the Config page the TUN stack select still offers LWIP (config.vue#L115). mihomo removed the lwIP stack in 9fc1fc4 (first released in 1.18). It now accepts gvisor, system, mixed and, since 1.19.31, mips (constant/tun.go).

Choosing LWIP therefore makes PATCH /configs fail with 400 invalid tun stack. On a remote backend that error is dropped: saveTun calls mutate with no error handler (config.vue#L92-L94), so nothing happens and the select keeps showing LWIP.

The value is also copied verbatim into the select (config.vue#L218, #L231). mihomo reports Mips, which is not in the list, and the agent and profiles use lowercase (gvisor). In both cases the select matches no option and shows something other than what the kernel runs.

Changes:

  • useTunConfig.ts exports the stack list, Mixed, gVisor, System and Mips, in the casing GET /configs reports.
    • normalizeTunStack() maps a reported stack onto its option regardless of case.
    • An unknown stack is kept and added as an extra option, so the select always shows the real value.
  • The remote save path now awaits the PATCH (mutateAsync). A refused change shows a tunSaveFailed toast with the error message, and config.vue puts the TUN form back to the backend config. Desktop mode is unchanged; useTun already reports its errors.
  • tunSaveFailed is added to all seven locales.
  • In packages/agent, the buildTunConfig comment and pass-through test now say mips instead of lwip.

Closes #2196

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or build changes

Screenshots / Recordings

Not included. The only visible change is the option list (LWIP replaced by Mips) and an error toast on a refused save.

Checklist

  • I have read the contributing guide
  • My code follows the project's code style (pnpm lint passes)
  • I have added/updated tests where applicable
  • pnpm typecheck passes
  • I have updated documentation if behavior changed
  • I have tested on the relevant platform(s): unit tests only, in a Linux container (see below)

Testing Performed

Environment: Node 24.22.2 and pnpm 10.34.1, in a Linux container.

  • composables/__tests__/useTunConfig.spec.ts:
    • New cases cover the stack list (no lwIP), case-insensitive matching, the Mixed fallback, unknown stacks staying visible, and refused or accepted remote saves for both the stack and the toggle.
    • The existing remote stack case now uses Mips instead of LWIP.
    • On unmodified main with the new tests: 7 of 30 fail. After the fix: 30 of 30 pass.
  • pnpm --filter @metacubexd/ui test:unit: 59 files, 687 tests pass. This includes the locale parity check.
  • pnpm --filter @metacubexd/agent test: 16 files, 261 tests pass.
  • pnpm --filter @metacubexd/ui typecheck and pnpm --filter @metacubexd/agent typecheck: no errors.
  • ESLint (no --fix) on the changed UI files: clean. prettier --check on all changed files: clean.
  • E2E tests and a manual check against a live mihomo were not run.

Additional Notes

  • mihomo older than 1.19.31 does not know mips, and sing-box does not either. Selecting it there is refused like LWIP is today, but the error is now shown and the select goes back to the running stack.
  • The default shown when no stack is reported stays Mixed, as before.

The TUN stack select still offered LWIP, which mihomo dropped in 1.18.
Picking it made PATCH /configs fail with "invalid tun stack", the error
was swallowed, and after a reload the select matched no option.

- Offer Mixed, gVisor, System and Mips, the values mihomo parses
  (constant/tun.go), and match the reported stack case-insensitively.
- Keep an unknown reported stack visible as an extra option.
- Surface a refused TUN save as a toast and put the form back to the
  backend value instead of leaving the unsaved choice selected.

Closes MetaCubeX#2196
@kunish
kunish merged commit ca41801 into MetaCubeX:main Nov 7, 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.

[Bug] 配置中将TUN 模式堆栈切换为LWIP,再次刷新,TUN 模式堆栈会变更为非LWIP

2 participants