Add kcp mtu (#9178)

* Add kcp mtu

* Typo
This commit is contained in:
DHR60
2026-04-25 02:39:39 +00:00
committed by GitHub
parent c4e071cac3
commit ee6ae3d91d
8 changed files with 76 additions and 26 deletions

View File

@@ -106,6 +106,9 @@ public class AddServerViewModel : MyReactiveObject
[Reactive]
public string KcpSeed { get; set; }
[Reactive]
public int? KcpMtu { get; set; }
public string TransportHeaderType
{
get => SelectedSource.GetNetwork() switch
@@ -287,26 +290,26 @@ public class AddServerViewModel : MyReactiveObject
Cert = SelectedSource?.Cert?.ToString() ?? string.Empty;
CertSha = SelectedSource?.CertSha?.ToString() ?? string.Empty;
var protocolExtra = SelectedSource?.GetProtocolExtra();
var transport = SelectedSource?.GetTransportExtra();
Ports = protocolExtra?.Ports ?? string.Empty;
AlterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
Flow = protocolExtra?.Flow ?? string.Empty;
SalamanderPass = protocolExtra?.SalamanderPass ?? string.Empty;
UpMbps = protocolExtra?.UpMbps;
DownMbps = protocolExtra?.DownMbps;
HopInterval = protocolExtra?.HopInterval ?? string.Empty;
VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
SsMethod = protocolExtra?.SsMethod ?? string.Empty;
WgPublicKey = protocolExtra?.WgPublicKey ?? string.Empty;
WgInterfaceAddress = protocolExtra?.WgInterfaceAddress ?? string.Empty;
WgReserved = protocolExtra?.WgReserved ?? string.Empty;
WgMtu = protocolExtra?.WgMtu ?? 1280;
Uot = protocolExtra?.Uot ?? false;
CongestionControl = protocolExtra?.CongestionControl ?? string.Empty;
InsecureConcurrency = protocolExtra?.InsecureConcurrency > 0 ? protocolExtra.InsecureConcurrency : null;
NaiveQuic = protocolExtra?.NaiveQuic ?? false;
var protocolExtra = SelectedSource?.GetProtocolExtra() ?? new();
var transport = SelectedSource?.GetTransportExtra() ?? new();
Ports = protocolExtra.Ports ?? string.Empty;
AlterId = int.TryParse(protocolExtra.AlterId, out var result) ? result : 0;
Flow = protocolExtra.Flow ?? string.Empty;
SalamanderPass = protocolExtra.SalamanderPass ?? string.Empty;
UpMbps = protocolExtra.UpMbps;
DownMbps = protocolExtra.DownMbps;
HopInterval = protocolExtra.HopInterval ?? string.Empty;
VmessSecurity = protocolExtra.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
VlessEncryption = protocolExtra.VlessEncryption?.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
SsMethod = protocolExtra.SsMethod ?? string.Empty;
WgPublicKey = protocolExtra.WgPublicKey ?? string.Empty;
WgInterfaceAddress = protocolExtra.WgInterfaceAddress ?? string.Empty;
WgReserved = protocolExtra.WgReserved ?? string.Empty;
WgMtu = protocolExtra.WgMtu ?? 1280;
Uot = protocolExtra.Uot ?? false;
CongestionControl = protocolExtra.CongestionControl ?? string.Empty;
InsecureConcurrency = protocolExtra.InsecureConcurrency > 0 ? protocolExtra.InsecureConcurrency : null;
NaiveQuic = protocolExtra.NaiveQuic ?? false;
RawHeaderType = transport.RawHeaderType ?? Global.None;
Host = transport.Host ?? string.Empty;
@@ -318,6 +321,7 @@ public class AddServerViewModel : MyReactiveObject
GrpcMode = transport.GrpcMode.IsNullOrEmpty() ? Global.GrpcGunMode : transport.GrpcMode;
KcpHeaderType = transport.KcpHeaderType.IsNullOrEmpty() ? Global.None : transport.KcpHeaderType;
KcpSeed = transport.KcpSeed ?? string.Empty;
KcpMtu = transport.KcpMtu;
}
private async Task SaveServerAsync()
@@ -381,6 +385,7 @@ public class AddServerViewModel : MyReactiveObject
GrpcMode = GrpcMode.NullIfEmpty(),
KcpHeaderType = KcpHeaderType.NullIfEmpty(),
KcpSeed = KcpSeed.NullIfEmpty(),
KcpMtu = KcpMtu > 0 ? KcpMtu : null,
};
SelectedSource.SetProtocolExtra(SelectedSource.GetProtocolExtra() with