mirror of
https://github.com/2dust/v2rayN.git
synced 2025-11-29 11:12:54 +00:00
Parse eh
This commit is contained in:
parent
4b79799175
commit
2fd8fe02d5
1 changed files with 15 additions and 10 deletions
|
|
@ -366,25 +366,30 @@ public partial class CoreConfigSingboxService
|
|||
transport.type = nameof(ETransport.ws);
|
||||
var wsPath = node.Path;
|
||||
|
||||
// Parse ed parameter from path using regex
|
||||
// Parse eh and ed parameters from path using regex
|
||||
if (!wsPath.IsNullOrEmpty())
|
||||
{
|
||||
var regex = new Regex(@"[?&]ed=(\d+)");
|
||||
var match = regex.Match(wsPath);
|
||||
if (match.Success && int.TryParse(match.Groups[1].Value, out var edValue))
|
||||
var edRegex = new Regex(@"[?&]ed=(\d+)");
|
||||
var edMatch = edRegex.Match(wsPath);
|
||||
if (edMatch.Success && int.TryParse(edMatch.Groups[1].Value, out var edValue))
|
||||
{
|
||||
transport.max_early_data = edValue;
|
||||
transport.early_data_header_name = "Sec-WebSocket-Protocol";
|
||||
// Remove ed parameter from path
|
||||
wsPath = regex.Replace(wsPath, "");
|
||||
// Clean up any leftover & at the beginning of query string
|
||||
|
||||
wsPath = edRegex.Replace(wsPath, "");
|
||||
wsPath = wsPath.Replace("?&", "?");
|
||||
// Remove trailing ? if no parameters left
|
||||
if (wsPath.EndsWith("?"))
|
||||
if (wsPath.EndsWith('?'))
|
||||
{
|
||||
wsPath = wsPath.TrimEnd('?');
|
||||
}
|
||||
}
|
||||
|
||||
var ehRegex = new Regex(@"[?&]eh=([^&]+)");
|
||||
var ehMatch = ehRegex.Match(wsPath);
|
||||
if (ehMatch.Success)
|
||||
{
|
||||
transport.early_data_header_name = Uri.UnescapeDataString(ehMatch.Groups[1].Value);
|
||||
}
|
||||
}
|
||||
|
||||
transport.path = wsPath.IsNullOrEmpty() ? null : wsPath;
|
||||
|
|
|
|||
Loading…
Reference in a new issue