mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-07 12:54:33 +00:00
refactor(backend): retire hysteria2 as a top-level protocol
Hysteria v2 is not a separate xray protocol — it is plain "hysteria" with streamSettings.version = 2. The frontend already dropped hysteria2 from the protocol enum in 5a90f7e3; the backend was still carrying the literal as a compat alias. Removed: - model.Hysteria2 constant - model.IsHysteria helper (only callers were buildProxy + genHysteriaLink) - TestIsHysteria - "hysteria2" from the Inbound.Protocol validate oneof enum - All `case model.Hysteria, model.Hysteria2:` and `case "hysteria", "hysteria2":` branches across client.go, inbound.go, outbound.go, xray.go, port_conflict.go, xray/api.go, subService.go, subJsonService.go, subClashService.go - Stale #4081 comments Kept (correctly — these are client-side URI/config schemes that are independent of the xray protocol type): - hysteria2:// share-link URI in subService.genHysteriaLink - "hysteria2" Clash proxy type in subClashService.buildHysteriaProxy - Comments referring to Hysteria v2 as a transport version Note: this change does not include a DB migration. Existing rows with protocol = 'hysteria2' will fall through to the default switch arms after upgrade. A separate `UPDATE inbounds SET protocol = 'hysteria' WHERE protocol = 'hysteria2'` is required for installs that still hold legacy data.
This commit is contained in:
@@ -103,15 +103,17 @@ func applyZodValidations(expr string, t TypeRef, rules []ValidateRule) string {
|
||||
expr += fmt.Sprintf(".lt(%s)", r.Param)
|
||||
}
|
||||
case "min":
|
||||
if t.Kind == KindString {
|
||||
switch t.Kind {
|
||||
case KindString:
|
||||
expr += fmt.Sprintf(".min(%s)", r.Param)
|
||||
} else if t.Kind == KindInt || t.Kind == KindNumber {
|
||||
case KindInt, KindNumber:
|
||||
expr += fmt.Sprintf(".min(%s)", r.Param)
|
||||
}
|
||||
case "max":
|
||||
if t.Kind == KindString {
|
||||
switch t.Kind {
|
||||
case KindString:
|
||||
expr += fmt.Sprintf(".max(%s)", r.Param)
|
||||
} else if t.Kind == KindInt || t.Kind == KindNumber {
|
||||
case KindInt, KindNumber:
|
||||
expr += fmt.Sprintf(".max(%s)", r.Param)
|
||||
}
|
||||
case "url":
|
||||
|
||||
@@ -64,7 +64,7 @@ func parseStructTag(raw string) (json string, validate string, gormHasDash bool)
|
||||
json = tag.Get("json")
|
||||
validate = tag.Get("validate")
|
||||
if g := tag.Get("gorm"); g != "" {
|
||||
for _, part := range strings.Split(g, ";") {
|
||||
for part := range strings.SplitSeq(g, ";") {
|
||||
if strings.TrimSpace(part) == "-" {
|
||||
gormHasDash = true
|
||||
}
|
||||
@@ -95,17 +95,17 @@ func parseValidateTag(tag string) []ValidateRule {
|
||||
return nil
|
||||
}
|
||||
var rules []ValidateRule
|
||||
for _, part := range strings.Split(tag, ",") {
|
||||
for part := range strings.SplitSeq(tag, ",") {
|
||||
part = strings.TrimSpace(part)
|
||||
if part == "" {
|
||||
continue
|
||||
}
|
||||
eq := strings.IndexByte(part, '=')
|
||||
if eq < 0 {
|
||||
before, after, ok := strings.Cut(part, "=")
|
||||
if !ok {
|
||||
rules = append(rules, ValidateRule{Name: part})
|
||||
continue
|
||||
}
|
||||
rules = append(rules, ValidateRule{Name: part[:eq], Param: part[eq+1:]})
|
||||
rules = append(rules, ValidateRule{Name: before, Param: after})
|
||||
}
|
||||
return rules
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user