mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-07 13:24:21 +00:00
d8221a8153
The Host VLESS Route field was stored and shown in the panel but never applied to any generated subscription (raw, JSON, Clash), so the UUID was emitted unmodified (#5655). Xray reads the route from the UUID's 3rd group (bytes 6-7, net.PortFromBytes) and masks those bytes to zero before authenticating, so a value can be baked into the share/JSON/Clash UUIDs without breaking the user match. A shared applyVlessRoute helper encodes a single 0-65535 value as the 3rd group; empty/invalid/non-UUID input is left unchanged, so legacy data never yields a broken link and no DB migration is needed. The field was wrongly validated as a multi-segment port spec (that form belongs to the separate server-side routing rule). It is now a single value 0-65535, with frontend validation, link-preview parity (genVlessLink/hostToExternalProxyEntry), hint + error translations across all 13 locales, and tests on every path. Closes #5655
35 lines
729 B
Go
35 lines
729 B
Go
package sub
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// xray reads the route from UUID bytes 6-7 (net.PortFromBytes) and masks them to
|
|
// zero before auth, so baking a 0-65535 value into the 3rd group routes without
|
|
// breaking the user match. Empty/invalid/non-UUID input is returned unchanged.
|
|
func applyVlessRoute(id, route string) string {
|
|
route = strings.TrimSpace(route)
|
|
if route == "" {
|
|
return id
|
|
}
|
|
n, err := strconv.Atoi(route)
|
|
if err != nil || n < 0 || n > 65535 {
|
|
return id
|
|
}
|
|
u, err := uuid.Parse(id)
|
|
if err != nil {
|
|
return id
|
|
}
|
|
u[6] = byte(n >> 8)
|
|
u[7] = byte(n)
|
|
return u.String()
|
|
}
|
|
|
|
func hostVlessRoute(ep map[string]any) string {
|
|
v, _ := ep["vlessRoute"].(string)
|
|
return v
|
|
}
|