mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-09 22:15:00 +03:00
fix(singbox): keep the ws path query when removing ed (#10548)
Removing "?ed=2048" from a WebSocket path also removed the '?', so "/ws?ed=2048&key=value" was sent to sing-box as "/ws&key=value". Match "ed" without the separator in front of it and trim the leftover '&' or '?' instead.
This commit is contained in:
@@ -542,7 +542,9 @@ public partial class CoreConfigSingboxService
|
||||
// Parse eh and ed parameters from path using regex
|
||||
if (!wsPath.IsNullOrEmpty())
|
||||
{
|
||||
var edRegex = new Regex(@"[?&]ed=(\d+)");
|
||||
// Keep the '?' or '&' in front of "ed" out of the match, so removing it
|
||||
// leaves "/ws?ed=2048&key=value" as "/ws?key=value", not "/ws&key=value".
|
||||
var edRegex = new Regex(@"(?<=[?&])ed=(\d+)&?");
|
||||
var edMatch = edRegex.Match(wsPath);
|
||||
if (edMatch.Success && int.TryParse(edMatch.Groups[1].Value, out var edValue))
|
||||
{
|
||||
@@ -550,11 +552,7 @@ public partial class CoreConfigSingboxService
|
||||
transport.early_data_header_name = "Sec-WebSocket-Protocol";
|
||||
|
||||
wsPath = edRegex.Replace(wsPath, "");
|
||||
wsPath = wsPath.Replace("?&", "?");
|
||||
if (wsPath.EndsWith('?'))
|
||||
{
|
||||
wsPath = wsPath.TrimEnd('?');
|
||||
}
|
||||
wsPath = wsPath.TrimEnd('&').TrimEnd('?');
|
||||
}
|
||||
|
||||
var ehRegex = new Regex(@"[?&]eh=([^&]+)");
|
||||
|
||||
Reference in New Issue
Block a user