mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6277] [Feature]: HWID is not supported Clash/Mihomo clients #4260
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4260
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @LORD07Sson on GitHub (Aug 21, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6277
Describe the bug
When HWID is enabled for a VLESS inbound, connections through Clash/Mihomo clients do not work 404...
The same VLESS configuration works correctly when HWID is disabled. This appears to be a compatibility issue between the HWID authentication/identification mechanism and Clash/Mihomo clients.
Clash and Mihomo do not appear to support the HWID parameter required by the inbound configuration, which makes the generated configuration unusable with these clients when HWID is enabled.
How to reproduce the problem
1.Create a VLESS inbound
2.Enable HWID for the inbound/client
3.Generate or import the configuration into a Clash/Mihomo-based client
4.Connect using the generated configuration
5.Observe that the connection does not work
6.Disable HWID for the same inbound/client
7.Try connecting again with Clash/Mihomo
8.The connection works normally
Expected behavior
When generating a subscription or configuration for Clash/Mihomo, x-ui should automatically handle the lack of HWID support. If the selected client does not support HWID, the subscription should be generated without the HWID parameter instead of producing an unusable configuration.
Ideally, there should also be an option to manually add or generate a subscription without HWID for clients that do not support it, while keeping HWID enabled for clients that support it
Actual behavior
When HWID is enabled, the generated configuration cannot be used successfully with Clash/Mihomo. Disabling HWID fixes the problem
Relevant logs
Screenshots
No response
3x-ui version
Dev
Xray-core version
26.7.28
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24
Which parts of the panel are affected?
Subscription (share links / Clash / JSON)
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
No — direct access
Before submitting
@github-actions[bot] commented on GitHub (Aug 21, 2026):
The 404 is the HWID gate working as written, not a broken subscription: as soon as a client's HWID Limit is greater than 0, the panel refuses every machine-readable subscription body for a request that does not carry an
X-HWIDheader, and Clash/Mihomo never send that header. So your observation is right, and your conclusion ("Clash/Mihomo do not support the HWID parameter") is right too — it just isn't a defect in the panel, it is the gate's designed behaviour.What the code does
internal/sub/controller.go:615-633— the gate reads the device id straight off the request headers:internal/web/service/client_hwid.go:100-103— a missing or too-shortX-HWIDis denied (Allowedstaysfalse), withminHwidLength = 6atclient_hwid.go:34:The gate runs on all three body routes — raw
/sub/(controller.go:390),/json/(controller.go:714) and/clash/(controller.go:765) — and that is pinned by a test, which is why this reads as intended rather than accidental:TestSubscriptionHwidGateAcrossBodyRoutes(internal/sub/hwid_controller_test.go:87-98) asserts404plusX-Hwid-Not-Supported: truefor/sub/,/json/and/clash/when noX-HWIDheader is sent.TestSubscriptionHwidGateSkipsHtmlInfoPage(hwid_controller_test.go:124-134) pins the opposite for the browser page — which explains why the same link still opens fine in a browser while the client gets a 404.You can confirm it on your own server in two commands (the second one registers a device, see the cleanup note below):
The first returns
404withX-Hwid-Active: trueandX-Hwid-Not-Supported: true; the second returns200. Anything registered that way can be removed with the HWID Devices button next to the HWID Limit field in the client edit dialog.What you can do today
0for clients that use Clash/Mihomo —0short-circuits the gate before any header is looked at (client_hwid.go:92-95:if limit <= 0 { res.Allowed = true; return res, nil }), and the limit is stored per client (LimitHwid,internal/database/model/model.go:924), so a mixed fleet is already possible.MAX(limit_hwid)over all enabled clients sharing the samesub_id(client_hwid.go:70-77). If your Clash user shares a subId with an HWID-limited client, the limit still applies to them. Give them their own subId.X-HWID(the feature's own tests useHapp/1.0andKaring/2.0user agents — an indication of the intended client set, not a compatibility list I can verify from this repository).The rest of your report — "generate the subscription without HWID for clients that don't support it" — is a feature request, not a bug, so I have relabelled the issue
enhancement(removingbug) and left it open for a maintainer to decide, rather than closing it. Two notes for whoever picks it up: auto-detecting "unsupported" clients would have to key off theUser-Agent, which any device can set, so it would weaken the gate it bypasses (my reading, not something the source states); and the HWID Limit tooltip currently says only "Maximum registered devices for subscription requests. 0 = unlimited." (internal/web/translation/en-US.json:743) — it never warns that a non-zero value makes the link unusable in clients that don't sendX-HWID, which is what made this look like a bug.Verdict: Not a bug (expected behaviour)
Severity: N/A
Confidence: High
Root cause: No defect.
SUBController.enforceHwid(internal/sub/controller.go:615-633) denies with 404 wheneverClientService.EnforceHwidForSubIDreturnsAllowed=false, andclient_hwid.go:100-103returns exactly that for a request whoseX-HWIDheader is shorter thanminHwidLength = 6(client_hwid.go:34) — i.e. any client that sends no such header, including Clash/Mihomo. Triggering condition: a client withlimitHwid > 0sharing the requestedsub_id.Already fixed: Not applicable — behaviour is current on the default branch (HEAD
5321665d);git log -S 'enforceHwid' -- internal/sub/controller.goreturns only694ad6de. The feature itself landed in694ad6de"feat(sub): add per-client subscription HWID limits (#5802)" (2026-08-15), after v3.6.0 (2026-07-30), so it exists only in Dev builds — consistent with the reported version.Duplicate of: None. Related: #6234 and #6245 (both HWID enhancement requests — bulk edit and single-device removal — different asks, no shared root cause)
Evidence:
internal/sub/controller.go:617Hwid: c.GetHeader("X-HWID"),;controller.go:628-631if !result.Allowed { c.Status(http.StatusNotFound); return false };internal/web/service/client_hwid.go:100-103if len(req.Hwid) < minHwidLength { res.NotSupported = true; return res, nil };client_hwid.go:34const minHwidLength = 6;client_hwid.go:92-95limit 0 allows;client_hwid.go:70-77Select("COALESCE(MAX(limit_hwid), 0)")oversub_id; gate call sitescontroller.go:390,:714,:765; testsTestSubscriptionHwidGateAcrossBodyRoutes(internal/sub/hwid_controller_test.go:87-98) andTestClientHwidGateRegistersAndBlocks(internal/web/service/client_hwid_test.go:55-61); tooltip textinternal/web/translation/en-US.json:743.Not determined: Whether Clash/Mihomo can be made to send a custom
X-HWIDheader at all — that is third-party client behaviour I cannot verify from this repository. The twocurlcommands above settle it for your setup: if the header-less request 404s and the one withX-HWIDreturns 200, the gate is the whole story.This reply was generated automatically; a maintainer may follow up.