mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-13 17:35:02 +03:00
fix(finalmask): hop client UDP through the udphop mask
xray-core 26.9.9 dropped finalmask.quicParams.udpHop for the client-only
"udphop" UDP mask {mode, interval, remoteIPs, remotePorts}. The panel kept
writing the old key, so hysteria/xhttp outbounds and JSON-subscription
clients silently stopped hopping ports.
An inbound keeps quicParams.udpHop: it is panel metadata advertised as the
link's mport, and a udphop mask on a listener fails with "udphop: client
only". The conversion (maskcompat.UpgradeLegacyUDPHop, intervalRemote mode)
runs only where a client config is produced:
- UDPHopClientMaskFix seeder over hosts, sub-JSON finalmask, cached
outbound-subscription outbounds and template outbounds (never inbounds);
- GetXrayConfig heals template outbounds at build time;
- the JSON subscription upgrades each generated client stream;
- the Go and frontend link importers upgrade a legacy fm= param.
The finalmask editor gains a side prop: the client side lifts the dead key
on mount and offers a udphop mask editor (also for xhttp's HTTP/3 dial);
the inbound side keeps the UDP Hop switch, labelled as advertised.
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/logger"
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/util/json_util"
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/util/maskcompat"
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/util/random"
|
||||
wgutil "github.com/mhsanaei/3x-ui/v3/internal/util/wireguard"
|
||||
)
|
||||
@@ -640,6 +641,8 @@ func (s *SubJsonService) getConfig(subReq *SubService, inbound *model.Inbound, c
|
||||
if finalmask, ok := newStream["finalmask"].(map[string]any); ok {
|
||||
newStream["finalmask"] = withLegacyFragmentRanges(finalmask)
|
||||
}
|
||||
// An inbound keeps its hop range as quicParams.udpHop; clients hop only with the mask.
|
||||
maskcompat.UpgradeLegacyUDPHop(newStream["finalmask"])
|
||||
streamSettings, _ := json.MarshalIndent(newStream, "", " ")
|
||||
hostMux := hostMuxOverride(extPrxy)
|
||||
|
||||
@@ -1001,6 +1004,7 @@ func (s *SubJsonService) genHy(inbound *model.Inbound, newStream map[string]any,
|
||||
if finalmask, ok := hyStream["finalmask"].(map[string]any); ok {
|
||||
newStream["finalmask"] = mergeFinalMask(newStream["finalmask"], finalmask)
|
||||
}
|
||||
maskcompat.UpgradeLegacyUDPHop(newStream["finalmask"])
|
||||
|
||||
newStream["network"] = "hysteria"
|
||||
newStream["security"] = "tls"
|
||||
|
||||
@@ -81,3 +81,36 @@ func TestGetInboundsBySubIdIncludesMasque(t *testing.T) {
|
||||
t.Fatalf("masque inbound not returned for subId: %+v", inbounds)
|
||||
}
|
||||
}
|
||||
|
||||
// An inbound keeps its hop range in quicParams.udpHop (udphop refuses to run on a server),
|
||||
// but the client config must carry the udphop mask: the core ignores the old key since 26.9.9.
|
||||
func TestSubJsonServiceTurnsInboundHopIntoClientUDPHopMask(t *testing.T) {
|
||||
inbound := &model.Inbound{
|
||||
Listen: "203.0.113.10", Port: 443, Protocol: model.Hysteria, Remark: "hy",
|
||||
Settings: `{"version":2,"clients":[{"email":"ivy@example.test","auth":"a"}]}`,
|
||||
StreamSettings: `{"network":"hysteria","security":"tls",
|
||||
"hysteriaSettings":{"version":2},
|
||||
"tlsSettings":{"serverName":"hy.example.test","alpn":["h3"]},
|
||||
"finalmask":{"quicParams":{"udpHop":{"ports":"20000-30000","interval":"5-10"}}}}`,
|
||||
}
|
||||
client := model.Client{Email: "ivy@example.test", Auth: "a"}
|
||||
|
||||
configs := NewSubJsonService("", "", "", "", nil).getConfig(&SubService{address: "sub.example.com"}, inbound, client, "sub.example.com")
|
||||
if len(configs) != 1 {
|
||||
t.Fatalf("got %d configs, want one", len(configs))
|
||||
}
|
||||
var config struct {
|
||||
Outbounds []struct {
|
||||
Protocol string `json:"protocol"`
|
||||
StreamSettings map[string]any `json:"streamSettings"`
|
||||
} `json:"outbounds"`
|
||||
}
|
||||
if err := json.Unmarshal(configs[0], &config); err != nil {
|
||||
t.Fatalf("decode config: %v", err)
|
||||
}
|
||||
got, _ := json.Marshal(config.Outbounds[0].StreamSettings["finalmask"])
|
||||
const want = `{"udp":[{"settings":{"interval":"5-10","mode":"intervalRemote","remotePorts":"20000-30000"},"type":"udphop"}]}`
|
||||
if string(got) != want {
|
||||
t.Fatalf("client finalmask\n got: %s\nwant: %s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user