feat(xray): update xray-core to v26.9.8 and adapt panel
Bump xtls/xray-core to 37ceb8b4b6 (v26.9.8) and the three binary pins (DockerInit.sh, release.yml Linux + Windows) in lockstep. No deleted symbols; the impact is entirely on the JSON config surface. Outbound "proxySettings" is now refused by the config loader (moved to streamSettings.sockopt.dialerProxy) and a freedom outbound rejects sockopt.addressPortStrategy. Either key in a stored template would keep the core from starting after the upgrade, so a new OutboundRemovedKeysFix seeder rewrites xrayTemplateConfig once: proxySettings.tag becomes sockopt.dialerProxy (an existing dialerProxy wins) and addressPortStrategy is dropped from freedom outbounds. Template saves and outbound subscriptions already run through the vendored loader, so the new refusals surface there with the core's own message. REALITY no longer applies a built-in minClientVer (26.3.27) when the field is empty. The form placeholder and the min/max hints in all 13 locales now say that empty means no minimum. New upstream keys the Zod schemas would otherwise strip, with form support where a sibling field already had it: - blackhole response type "custom" with base64 customResponseData - realm finalmask ipMode (dual/v4/v6) and portMapping (UPnP / NAT-PMP) - quicParams brutalDisableLossCompensation, disableChromeParrot, disableGSO, disableStatelessReset - hysteria masquerade proxy xForwarded - wireguard outbound remoteDNS - routing rule localOS freedom.domainStrategy is only deprecated upstream (auto-migrated to sockopt.domainStrategy with a warning) and is left untouched.
This commit is contained in:
36 files changed
+554
-61
No files matched your search
+104
-1
@@ -1193,7 +1193,7 @@ func runSeeders(isUsersEmpty bool) error {
|
||||
}
|
||||
|
||||
if empty && isUsersEmpty {
|
||||
seeders := []string{"UserPasswordHash", "ClientsTable", "InboundClientsArrayFix", "InboundClientTgIdFix2", "InboundClientSubIdFix", "FreedomFinalRulesReverseFix", "FreedomFinalRulesPrivateEgressBlock", "InboundRealityFinalmaskTcpStrip", "ApiTokensHash", "LegacyProxySettingsCleanup", "WireguardPeersToClients", "MtprotoSecretsToClients", "NodeInboundsAdopted", "ResetIpLimitNoFail2ban"}
|
||||
seeders := []string{"UserPasswordHash", "ClientsTable", "InboundClientsArrayFix", "InboundClientTgIdFix2", "InboundClientSubIdFix", "FreedomFinalRulesReverseFix", "FreedomFinalRulesPrivateEgressBlock", "InboundRealityFinalmaskTcpStrip", "ApiTokensHash", "LegacyProxySettingsCleanup", "OutboundRemovedKeysFix", "WireguardPeersToClients", "MtprotoSecretsToClients", "NodeInboundsAdopted", "ResetIpLimitNoFail2ban"}
|
||||
for _, name := range seeders {
|
||||
if err := db.Create(&model.HistoryOfSeeders{SeederName: name}).Error; err != nil {
|
||||
return err
|
||||
@@ -1298,6 +1298,12 @@ func runSeeders(isUsersEmpty bool) error {
|
||||
}
|
||||
}
|
||||
|
||||
if !slices.Contains(seedersHistory, "OutboundRemovedKeysFix") {
|
||||
if err := migrateOutboundRemovedKeys(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if !slices.Contains(seedersHistory, "NodeInboundsAdopted") {
|
||||
if err := seedNodeInboundsAdopted(); err != nil {
|
||||
return err
|
||||
@@ -1484,6 +1490,103 @@ func clearLegacyProxySettings() error {
|
||||
})
|
||||
}
|
||||
|
||||
func migrateOutboundRemovedKeys() error {
|
||||
var setting model.Setting
|
||||
err := db.Model(model.Setting{}).Where("key = ?", "xrayTemplateConfig").First(&setting).Error
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return db.Create(&model.HistoryOfSeeders{SeederName: "OutboundRemovedKeysFix"}).Error
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
updated, changed, rErr := rewriteRemovedOutboundKeys(setting.Value)
|
||||
if rErr != nil {
|
||||
log.Printf("OutboundRemovedKeysFix: skip (invalid xrayTemplateConfig json): %v", rErr)
|
||||
return db.Create(&model.HistoryOfSeeders{SeederName: "OutboundRemovedKeysFix"}).Error
|
||||
}
|
||||
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
if changed {
|
||||
if err := tx.Model(&model.Setting{}).Where("key = ?", "xrayTemplateConfig").
|
||||
Update("value", updated).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return tx.Create(&model.HistoryOfSeeders{SeederName: "OutboundRemovedKeysFix"}).Error
|
||||
})
|
||||
}
|
||||
|
||||
// rewriteRemovedOutboundKeys moves outbound proxySettings.tag to sockopt.dialerProxy
|
||||
// and drops freedom sockopt.addressPortStrategy: xray-core v26.9.8 refuses both.
|
||||
func rewriteRemovedOutboundKeys(raw string) (string, bool, error) {
|
||||
if strings.TrimSpace(raw) == "" {
|
||||
return raw, false, nil
|
||||
}
|
||||
var cfg map[string]any
|
||||
if err := json.Unmarshal([]byte(raw), &cfg); err != nil {
|
||||
return raw, false, err
|
||||
}
|
||||
outbounds, ok := cfg["outbounds"].([]any)
|
||||
if !ok {
|
||||
return raw, false, nil
|
||||
}
|
||||
changed := false
|
||||
for _, ob := range outbounds {
|
||||
obj, ok := ob.(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if proxySettings, present := obj["proxySettings"]; present {
|
||||
ps, _ := proxySettings.(map[string]any)
|
||||
if tag, _ := ps["tag"].(string); tag != "" {
|
||||
sockopt := outboundSockopt(obj, true)
|
||||
if current, _ := sockopt["dialerProxy"].(string); current == "" {
|
||||
sockopt["dialerProxy"] = tag
|
||||
}
|
||||
}
|
||||
delete(obj, "proxySettings")
|
||||
changed = true
|
||||
}
|
||||
if proto, _ := obj["protocol"].(string); proto == "freedom" {
|
||||
if sockopt := outboundSockopt(obj, false); sockopt != nil {
|
||||
if _, present := sockopt["addressPortStrategy"]; present {
|
||||
delete(sockopt, "addressPortStrategy")
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !changed {
|
||||
return raw, false, nil
|
||||
}
|
||||
out, err := json.MarshalIndent(cfg, "", " ")
|
||||
if err != nil {
|
||||
return raw, false, err
|
||||
}
|
||||
return string(out), true, nil
|
||||
}
|
||||
|
||||
func outboundSockopt(obj map[string]any, create bool) map[string]any {
|
||||
stream, _ := obj["streamSettings"].(map[string]any)
|
||||
if stream == nil {
|
||||
if !create {
|
||||
return nil
|
||||
}
|
||||
stream = map[string]any{}
|
||||
obj["streamSettings"] = stream
|
||||
}
|
||||
sockopt, _ := stream["sockopt"].(map[string]any)
|
||||
if sockopt == nil {
|
||||
if !create {
|
||||
return nil
|
||||
}
|
||||
sockopt = map[string]any{}
|
||||
stream["sockopt"] = sockopt
|
||||
}
|
||||
return sockopt
|
||||
}
|
||||
|
||||
func normalizeSettingPaths() error {
|
||||
pathKeys := []string{"webBasePath", "subPath", "subJsonPath", "subClashPath"}
|
||||
var rows []model.Setting
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/xray"
|
||||
)
|
||||
|
||||
func TestRewriteRemovedOutboundKeys(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
raw string
|
||||
wantChanged bool
|
||||
wantOutbound map[string]any
|
||||
}{
|
||||
{
|
||||
name: "proxySettings.tag becomes sockopt.dialerProxy",
|
||||
raw: `{"outbounds":[{"protocol":"vless","tag":"chain","settings":{},"proxySettings":{"tag":"hop","transportLayer":true}}]}`,
|
||||
wantChanged: true,
|
||||
wantOutbound: map[string]any{
|
||||
"protocol": "vless", "tag": "chain", "settings": map[string]any{},
|
||||
"streamSettings": map[string]any{"sockopt": map[string]any{"dialerProxy": "hop"}},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "an existing dialerProxy wins over proxySettings",
|
||||
raw: `{"outbounds":[{"protocol":"vless","tag":"chain","proxySettings":{"tag":"hop"},"streamSettings":{"network":"tcp","sockopt":{"dialerProxy":"keep"}}}]}`,
|
||||
wantChanged: true,
|
||||
wantOutbound: map[string]any{
|
||||
"protocol": "vless", "tag": "chain",
|
||||
"streamSettings": map[string]any{"network": "tcp", "sockopt": map[string]any{"dialerProxy": "keep"}},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "freedom drops sockopt.addressPortStrategy",
|
||||
raw: `{"outbounds":[{"protocol":"freedom","tag":"direct","streamSettings":{"sockopt":{"addressPortStrategy":"SrvPortOnly","tcpFastOpen":true}}}]}`,
|
||||
wantChanged: true,
|
||||
wantOutbound: map[string]any{
|
||||
"protocol": "freedom", "tag": "direct",
|
||||
"streamSettings": map[string]any{"sockopt": map[string]any{"tcpFastOpen": true}},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "addressPortStrategy stays on other protocols",
|
||||
raw: `{"outbounds":[{"protocol":"vless","tag":"proxy","streamSettings":{"sockopt":{"addressPortStrategy":"SrvPortOnly"}}}]}`,
|
||||
wantChanged: false,
|
||||
wantOutbound: map[string]any{
|
||||
"protocol": "vless", "tag": "proxy",
|
||||
"streamSettings": map[string]any{"sockopt": map[string]any{"addressPortStrategy": "SrvPortOnly"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
updated, changed, err := rewriteRemovedOutboundKeys(tc.raw)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if changed != tc.wantChanged {
|
||||
t.Fatalf("changed = %v, want %v", changed, tc.wantChanged)
|
||||
}
|
||||
var cfg struct {
|
||||
Outbounds []map[string]any `json:"outbounds"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(updated), &cfg); err != nil {
|
||||
t.Fatalf("rewritten template is not JSON: %v", err)
|
||||
}
|
||||
if len(cfg.Outbounds) != 1 {
|
||||
t.Fatalf("got %d outbounds, want 1", len(cfg.Outbounds))
|
||||
}
|
||||
got, _ := json.Marshal(cfg.Outbounds[0])
|
||||
want, _ := json.Marshal(tc.wantOutbound)
|
||||
if string(got) != string(want) {
|
||||
t.Fatalf("outbound = %s, want %s", got, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRewriteRemovedOutboundKeysSatisfiesCore(t *testing.T) {
|
||||
raw := `{"outbounds":[{"protocol":"freedom","tag":"direct","settings":{},"proxySettings":{"tag":"hop"},"streamSettings":{"sockopt":{"addressPortStrategy":"SrvPortOnly"}}}]}`
|
||||
var before struct {
|
||||
Outbounds []json.RawMessage `json:"outbounds"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(raw), &before); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := xray.ValidateOutboundConfig(before.Outbounds[0]); err == nil {
|
||||
t.Fatal("expected the vendored core to refuse the legacy outbound")
|
||||
}
|
||||
|
||||
updated, changed, err := rewriteRemovedOutboundKeys(raw)
|
||||
if err != nil || !changed {
|
||||
t.Fatalf("rewrite: changed=%v err=%v", changed, err)
|
||||
}
|
||||
var after struct {
|
||||
Outbounds []json.RawMessage `json:"outbounds"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(updated), &after); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := xray.ValidateOutboundConfig(after.Outbounds[0]); err != nil {
|
||||
t.Fatalf("rewritten outbound still refused by xray-core: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRewriteRemovedOutboundKeysInvalidJSON(t *testing.T) {
|
||||
_, changed, err := rewriteRemovedOutboundKeys("{not json")
|
||||
if err == nil {
|
||||
t.Fatal("expected an error for invalid JSON")
|
||||
}
|
||||
if changed {
|
||||
t.Fatal("invalid JSON must not report a change")
|
||||
}
|
||||
}
|
||||
@@ -501,6 +501,7 @@
|
||||
"type": "النوع",
|
||||
"upstreamUrl": "Upstream URL",
|
||||
"rewriteHost": "إعادة كتابة Host",
|
||||
"xForwarded": "ترويسات X-Forwarded",
|
||||
"skipTlsVerify": "تخطي التحقق من TLS",
|
||||
"directory": "الدليل",
|
||||
"statusCode": "رمز الحالة",
|
||||
@@ -602,8 +603,8 @@
|
||||
"maxTimeDiff": "أقصى فرق زمن (ms)",
|
||||
"minClientVer": "أدنى إصدار للعميل",
|
||||
"maxClientVer": "أقصى إصدار للعميل",
|
||||
"minClientVerHint": "تركه فارغًا لا يعني بلا قيود: سيفرض Xray-core الحد الأدنى المدمج في إصدار النواة الذي تشغّله (26.3.27 في الإصدارات الحالية) ويرفض العملاء الذين يبلغون عن إصدار أقدم — بما في ذلك النوى الخارجية مثل Mihomo و sing-box. القيمة 1.0.0 تقبلها، مقابل السماح ببصمات TLS قديمة.",
|
||||
"maxClientVerHint": "تركه فارغًا يعني بلا حد أقصى. إذا عُيّن، يجب ألا يقل عن الحد الأدنى الفعلي — أدنى إصدار للعميل، أو الحد الأدنى المدمج في Xray-core عندما يكون ذلك الحقل فارغًا — وإلا سيُرفض جميع العملاء.",
|
||||
"minClientVerHint": "تركه فارغًا يعني بلا حد أدنى: يقبل Xray-core أي إصدار عميل، بما في ذلك النوى الخارجية مثل Mihomo وsing-box. عيّن إصدارًا لرفض العملاء الذين يبلغون عن إصدار أقدم.",
|
||||
"maxClientVerHint": "تركه فارغًا يعني بلا حد أقصى. إذا عُيّن، يجب ألا يقل عن أدنى إصدار للعميل — وإلا سيُرفض جميع العملاء.",
|
||||
"clientVerInvalid": "يجب أن يتكون إصدار العميل من ثلاثة أرقام كحد أقصى مفصولة بنقاط، كل منها 0-255 (مثل 26.3.27)",
|
||||
"maxClientVerBelowMin": "أقصى إصدار للعميل يجب ألا يقل عن أدنى إصدار للعميل",
|
||||
"shortIds": "Short IDs",
|
||||
@@ -1613,6 +1614,7 @@
|
||||
"inboundTag": "وسم الوارد",
|
||||
"inboundTagPlaceholder": "وسم الوارد المستخدم في قواعد التوجيه",
|
||||
"responseType": "نوع الاستجابة",
|
||||
"customResponseData": "استجابة مخصصة (base64)",
|
||||
"rewriteNetwork": "إعادة كتابة الشبكة",
|
||||
"unchanged": "(دون تغيير)",
|
||||
"unchangedAddress": "(دون تغيير) مثل 1.1.1.1",
|
||||
@@ -1625,6 +1627,7 @@
|
||||
"blockDelay": "تأخير الحظر (ms)",
|
||||
"reverseSniffing": "Sniffing عكسي",
|
||||
"reserved": "محجوز",
|
||||
"remoteDNS": "DNS بعيد",
|
||||
"minUploadInterval": "أدنى فاصل رفع (ms)",
|
||||
"maxUploadSizeBytes": "حجم الرفع الأقصى (بايت)",
|
||||
"uplinkChunkSize": "حجم chunk الرفع",
|
||||
|
||||
Loaded 3 of 36 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user