diff --git a/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs b/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs index 957a61f6..c51f6185 100644 --- a/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs +++ b/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs @@ -319,6 +319,7 @@ public class StreamSettings4Ray public GrpcSettings4Ray? grpcSettings { get; set; } public HysteriaSettings4Ray? hysteriaSettings { get; set; } + public MasqueSettings4Ray? masqueSettings { get; set; } public JsonObject? finalmask { get; set; } @@ -461,12 +462,6 @@ public class MasqueWarpSettings4Ray public List? address { get; set; } } -public class UdpHop4Ray -{ - public string? ports { get; set; } - public string? interval { get; set; } -} - public class Finalmask4Ray { public List? tcp { get; set; } @@ -491,6 +486,12 @@ public class MaskSettings4Ray public List? stunServers { get; set; } public string? packetSize { get; set; } + // udphop + public string? mode { get; set; } + public string? interval { get; set; } + // public List? remoteIPs { get; set; } + public string? remotePorts { get; set; } + // fragment public string? packets { get; set; } @@ -517,7 +518,6 @@ public class QuicParams4Ray public string? congestion { get; set; } public string? brutalUp { get; set; } public string? brutalDown { get; set; } - public UdpHop4Ray? udpHop { get; set; } } public class AccountsItem4Ray diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs index 0803f9b3..8ca56dbe 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs @@ -394,17 +394,6 @@ public partial class CoreConfigV2rayService }; var kcpFinalmask = new Finalmask4Ray(); - if (Global.KcpHeaderMaskMap.TryGetValue(headerType, out var header)) - { - kcpFinalmask.udp = - [ - new Mask4Ray - { - type = "mkcp-legacy", - settings = new MaskSettings4Ray { header = header }, - } - ]; - } kcpFinalmask.udp ??= []; if (kcpSeed.IsNullOrEmpty()) { @@ -421,7 +410,17 @@ public partial class CoreConfigV2rayService settings = new MaskSettings4Ray { value = kcpSeed }, }); } - kcpFinalmask.udp?.Reverse(); + if (Global.KcpHeaderMaskMap.TryGetValue(headerType, out var header)) + { + kcpFinalmask.udp = + [ + new Mask4Ray + { + type = "mkcp-legacy", + settings = new MaskSettings4Ray { header = header }, + }, + ]; + } streamSettings.kcpSettings = kcpSettings; streamSettings.finalmask = (JsonObject)JsonUtils.SerializeToNode(kcpFinalmask); break; @@ -522,16 +521,6 @@ public partial class CoreConfigV2rayService : Global.Hysteria2DefaultHopInt).ToString(); var hy2Finalmask = new Finalmask4Ray(); var quicParams = new QuicParams4Ray(); - if (!ports.IsNullOrEmpty() && - (ports.Contains(':') || ports.Contains('-') || ports.Contains(','))) - { - var udpHop = new UdpHop4Ray - { - ports = ports.Replace(':', '-'), - interval = hopInterval, - }; - quicParams.udpHop = udpHop; - } if (upMbps > 0 || downMbps > 0) { quicParams.congestion = "brutal"; @@ -544,15 +533,6 @@ public partial class CoreConfigV2rayService } hy2Finalmask.quicParams = quicParams; hy2Finalmask.udp ??= []; - if (HyRealm.TryParse(protocolExtra.Hy2RealmUrl, out var realm) - && realm is not null) - { - hy2Finalmask.udp.Add(new Mask4Ray - { - type = "realm", - settings = new MaskSettings4Ray { url = realm.ToUriForFinalmask(), stunServers = realm.StunList }, - }); - } if (!protocolExtra.SalamanderPass.IsNullOrEmpty()) { var isGecko = !protocolExtra.GeckoMinPacketSize.IsNullOrEmpty() || !protocolExtra.GeckoMaxPacketSize.IsNullOrEmpty(); @@ -570,12 +550,35 @@ public partial class CoreConfigV2rayService settings = salamanderSettings, }); } + if (HyRealm.TryParse(protocolExtra.Hy2RealmUrl, out var realm) + && realm is not null) + { + hy2Finalmask.udp.Add(new Mask4Ray + { + type = "realm", + settings = new MaskSettings4Ray { url = realm.ToUriForFinalmask(), stunServers = realm.StunList }, + }); + } + else if (!ports.IsNullOrEmpty() + && (ports.Contains(':') || ports.Contains('-') || ports.Contains(','))) + { + var udpHopFinalmask = new Mask4Ray + { + type = "udphop", + settings = new MaskSettings4Ray + { + mode = "intervallocal,intervalremote", + interval = hopInterval, + remotePorts = ports.Replace(':', '-'), + }, + }; + hy2Finalmask.udp.Add(udpHopFinalmask); + } streamSettings.hysteriaSettings = new() { version = 2, auth = _node.Password, }; - hy2Finalmask.udp?.Reverse(); streamSettings.finalmask = (JsonObject)JsonUtils.SerializeToNode(hy2Finalmask); break;