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,27 +366,32 @@ public partial class CoreConfigSingboxService
|
||||||
transport.type = nameof(ETransport.ws);
|
transport.type = nameof(ETransport.ws);
|
||||||
var wsPath = node.Path;
|
var wsPath = node.Path;
|
||||||
|
|
||||||
// Parse ed parameter from path using regex
|
// Parse eh and ed parameters from path using regex
|
||||||
if (!wsPath.IsNullOrEmpty())
|
if (!wsPath.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
var regex = new Regex(@"[?&]ed=(\d+)");
|
var edRegex = new Regex(@"[?&]ed=(\d+)");
|
||||||
var match = regex.Match(wsPath);
|
var edMatch = edRegex.Match(wsPath);
|
||||||
if (match.Success && int.TryParse(match.Groups[1].Value, out var edValue))
|
if (edMatch.Success && int.TryParse(edMatch.Groups[1].Value, out var edValue))
|
||||||
{
|
{
|
||||||
transport.max_early_data = edValue;
|
transport.max_early_data = edValue;
|
||||||
transport.early_data_header_name = "Sec-WebSocket-Protocol";
|
transport.early_data_header_name = "Sec-WebSocket-Protocol";
|
||||||
// Remove ed parameter from path
|
|
||||||
wsPath = regex.Replace(wsPath, "");
|
wsPath = edRegex.Replace(wsPath, "");
|
||||||
// Clean up any leftover & at the beginning of query string
|
|
||||||
wsPath = wsPath.Replace("?&", "?");
|
wsPath = wsPath.Replace("?&", "?");
|
||||||
// Remove trailing ? if no parameters left
|
if (wsPath.EndsWith('?'))
|
||||||
if (wsPath.EndsWith("?"))
|
|
||||||
{
|
{
|
||||||
wsPath = wsPath.TrimEnd('?');
|
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;
|
transport.path = wsPath.IsNullOrEmpty() ? null : wsPath;
|
||||||
if (node.RequestHost.IsNotEmpty())
|
if (node.RequestHost.IsNotEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue