diff --git a/v2rayN/ServiceLib/Models/V2rayConfig.cs b/v2rayN/ServiceLib/Models/V2rayConfig.cs index 9a47c583..23dfb3f9 100644 --- a/v2rayN/ServiceLib/Models/V2rayConfig.cs +++ b/v2rayN/ServiceLib/Models/V2rayConfig.cs @@ -324,7 +324,8 @@ namespace ServiceLib.Models public class WsSettings4Ray { - public string path { get; set; } + public string? path { get; set; } + public string? host { get; set; } public Headers4Ray headers { get; set; } } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index e1f26b1b..f878e4b2 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -442,7 +442,7 @@ namespace ServiceLib.Services.CoreConfig #region private gen function - public async Task GenLog(SingboxConfig singboxConfig) + private async Task GenLog(SingboxConfig singboxConfig) { try { @@ -570,7 +570,7 @@ namespace ServiceLib.Services.CoreConfig return inbound; } - public async Task GenOutbound(ProfileItem node, Outbound4Sbox outbound) + private async Task GenOutbound(ProfileItem node, Outbound4Sbox outbound) { try { @@ -694,7 +694,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenOutboundMux(ProfileItem node, Outbound4Sbox outbound) + private async Task GenOutboundMux(ProfileItem node, Outbound4Sbox outbound) { try { @@ -717,7 +717,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenOutboundTls(ProfileItem node, Outbound4Sbox outbound) + private async Task GenOutboundTls(ProfileItem node, Outbound4Sbox outbound) { try { @@ -767,7 +767,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenOutboundTransport(ProfileItem node, Outbound4Sbox outbound) + private async Task GenOutboundTransport(ProfileItem node, Outbound4Sbox outbound) { try { @@ -994,7 +994,7 @@ namespace ServiceLib.Services.CoreConfig } } - public async Task GenRoutingUserRule(RulesItem item, List rules) + private async Task GenRoutingUserRule(RulesItem item, List rules) { try { @@ -1152,7 +1152,7 @@ namespace ServiceLib.Services.CoreConfig return true; } - public async Task GenDns(ProfileItem? node, SingboxConfig singboxConfig) + private async Task GenDns(ProfileItem? node, SingboxConfig singboxConfig) { try { @@ -1183,7 +1183,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenDnsDomains(ProfileItem? node, SingboxConfig singboxConfig, DNSItem? dNSItem) + private async Task GenDnsDomains(ProfileItem? node, SingboxConfig singboxConfig, DNSItem? dNSItem) { var dns4Sbox = singboxConfig.dns ?? new(); dns4Sbox.servers ??= []; @@ -1236,7 +1236,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenExperimental(SingboxConfig singboxConfig) + private async Task GenExperimental(SingboxConfig singboxConfig) { //if (_config.guiItem.enableStatistics) { diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 6dedb1f0..fffab122 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -359,7 +359,7 @@ namespace ServiceLib.Services.CoreConfig #region private gen function - public async Task GenLog(V2rayConfig v2rayConfig) + private async Task GenLog(V2rayConfig v2rayConfig) { try { @@ -384,7 +384,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenInbounds(V2rayConfig v2rayConfig) + private async Task GenInbounds(V2rayConfig v2rayConfig) { try { @@ -481,7 +481,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenRoutingUserRule(RulesItem4Ray? rule, V2rayConfig v2rayConfig) + private async Task GenRoutingUserRule(RulesItem4Ray? rule, V2rayConfig v2rayConfig) { try { @@ -559,7 +559,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenOutbound(ProfileItem node, Outbounds4Ray outbound) + private async Task GenOutbound(ProfileItem node, Outbounds4Ray outbound) { try { @@ -754,7 +754,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenOutboundMux(ProfileItem node, Outbounds4Ray outbound, bool enabled) + private async Task GenOutboundMux(ProfileItem node, Outbounds4Ray outbound, bool enabled) { try { @@ -778,14 +778,15 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenBoundStreamSettings(ProfileItem node, StreamSettings4Ray streamSettings) + private async Task GenBoundStreamSettings(ProfileItem node, StreamSettings4Ray streamSettings) { try { streamSettings.network = node.GetNetwork(); - string host = node.RequestHost.TrimEx(); - string sni = node.Sni; - string useragent = ""; + var host = node.RequestHost.TrimEx(); + var path = node.Path.TrimEx(); + var sni = node.Sni.TrimEx(); + var useragent = ""; if (!_config.CoreBasicItem.DefUserAgent.IsNullOrEmpty()) { try @@ -858,9 +859,9 @@ namespace ServiceLib.Services.CoreConfig { type = node.HeaderType }; - if (Utils.IsNotEmpty(node.Path)) + if (Utils.IsNotEmpty(path)) { - kcpSettings.seed = node.Path; + kcpSettings.seed = path; } streamSettings.kcpSettings = kcpSettings; break; @@ -868,9 +869,10 @@ namespace ServiceLib.Services.CoreConfig case nameof(ETransport.ws): WsSettings4Ray wsSettings = new(); wsSettings.headers = new Headers4Ray(); - string path = node.Path; + if (Utils.IsNotEmpty(host)) { + wsSettings.host = host; wsSettings.headers.Host = host; } if (Utils.IsNotEmpty(path)) @@ -888,9 +890,9 @@ namespace ServiceLib.Services.CoreConfig case nameof(ETransport.httpupgrade): HttpupgradeSettings4Ray httpupgradeSettings = new(); - if (Utils.IsNotEmpty(node.Path)) + if (Utils.IsNotEmpty(path)) { - httpupgradeSettings.path = node.Path; + httpupgradeSettings.path = path; } if (Utils.IsNotEmpty(host)) { @@ -909,9 +911,9 @@ namespace ServiceLib.Services.CoreConfig scMinPostsIntervalMs = "30-50" }; - if (Utils.IsNotEmpty(node.Path)) + if (Utils.IsNotEmpty(path)) { - xhttpSettings.path = node.Path; + xhttpSettings.path = path; } if (Utils.IsNotEmpty(host)) { @@ -937,7 +939,7 @@ namespace ServiceLib.Services.CoreConfig { httpSettings.host = Utils.String2List(host); } - httpSettings.path = node.Path; + httpSettings.path = path; streamSettings.httpSettings = httpSettings; @@ -947,7 +949,7 @@ namespace ServiceLib.Services.CoreConfig QuicSettings4Ray quicsettings = new() { security = host, - key = node.Path, + key = path, header = new Header4Ray { type = node.HeaderType @@ -971,7 +973,7 @@ namespace ServiceLib.Services.CoreConfig GrpcSettings4Ray grpcSettings = new() { authority = Utils.IsNullOrEmpty(host) ? null : host, - serviceName = node.Path, + serviceName = path, multiMode = node.HeaderType == Global.GrpcMultiMode, idle_timeout = _config.GrpcItem.IdleTimeout, health_check_timeout = _config.GrpcItem.HealthCheckTimeout, @@ -1001,9 +1003,9 @@ namespace ServiceLib.Services.CoreConfig request = request.Replace("$requestUserAgent$", $"{useragent.AppendQuotes()}"); //Path string pathHttp = @"/"; - if (Utils.IsNotEmpty(node.Path)) + if (Utils.IsNotEmpty(path)) { - string[] arrPath = node.Path.Split(','); + string[] arrPath = path.Split(','); pathHttp = string.Join(",".AppendQuotes(), arrPath); } request = request.Replace("$requestPath$", $"{pathHttp.AppendQuotes()}"); @@ -1021,7 +1023,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenDns(ProfileItem? node, V2rayConfig v2rayConfig) + private async Task GenDns(ProfileItem? node, V2rayConfig v2rayConfig) { try { @@ -1084,7 +1086,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenDnsDomains(ProfileItem? node, JsonNode dns, DNSItem? dNSItem) + private async Task GenDnsDomains(ProfileItem? node, JsonNode dns, DNSItem? dNSItem) { if (node == null) { return 0; } @@ -1104,7 +1106,7 @@ namespace ServiceLib.Services.CoreConfig return 0; } - public async Task GenStatistic(V2rayConfig v2rayConfig) + private async Task GenStatistic(V2rayConfig v2rayConfig) { if (_config.GuiItem.EnableStatistics) {