Support for xtls-rprx-origin and xtls-rprx-direct

This commit is contained in:
TomZz 2023-03-20 11:39:17 +08:00
parent d6d364906f
commit c3f27e43e9
5 changed files with 46 additions and 2 deletions

View file

@ -43,6 +43,7 @@
public const string directTag = "direct";
public const string blockTag = "block";
public const string StreamSecurity = "tls";
public const string StreamSecurityXtls = "xtls";
public const string StreamSecurityReality = "reality";
public const string InboundSocks = "socks";
public const string InboundHttp = "http";
@ -92,7 +93,7 @@
public static readonly List<string> ssSecuritys = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "none", "plain" };
public static readonly List<string> ssSecuritysInSagerNet = new() { "none", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305", "aes-128-gcm", "aes-192-gcm", "aes-256-gcm", "chacha20-ietf-poly1305", "xchacha20-ietf-poly1305", "rc4", "rc4-md5", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "aes-128-cfb8", "aes-192-cfb8", "aes-256-cfb8", "aes-128-ofb", "aes-192-ofb", "aes-256-ofb", "bf-cfb", "cast5-cfb", "des-cfb", "idea-cfb", "rc2-cfb", "seed-cfb", "camellia-128-cfb", "camellia-192-cfb", "camellia-256-cfb", "camellia-128-cfb8", "camellia-192-cfb8", "camellia-256-cfb8", "salsa20", "chacha20", "chacha20-ietf", "xchacha20" };
public static readonly List<string> ssSecuritysInXray = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "xchacha20-poly1305", "xchacha20-ietf-poly1305", "none", "plain", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305" };
public static readonly List<string> flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" };
public static readonly List<string> flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443", "xtls-rprx-direct", "xtls-rprx-origin" };
public static readonly List<string> networks = new() { "tcp", "kcp", "ws", "h2", "quic", "grpc" };
public static readonly List<string> kcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" };
public static readonly List<string> coreTypes = new() { "v2fly", "SagerNet", "Xray", "v2fly_v5" };

View file

@ -473,7 +473,16 @@ namespace v2rayN.Handler
outbound.mux.concurrency = -1;
}
}
else if (node.streamSecurity == Global.StreamSecurityXtls)
{
if (!Utils.IsNullOrEmpty(node.flow))
{
usersItem.flow = node.flow;
outbound.mux.enabled = false;
outbound.mux.concurrency = -1;
}
}
outbound.protocol = Global.vlessProtocolLite;
outbound.settings.servers = null;
}
@ -574,6 +583,23 @@ namespace v2rayN.Handler
streamSettings.realitySettings = realitySettings;
}
//if Xtls
if (node.streamSecurity == Global.StreamSecurityXtls)
{
streamSettings.security = node.streamSecurity;
TlsSettings xtlsSettings = new()
{
fingerprint = node.fingerprint.IsNullOrEmpty() ? config.coreBasicItem.defFingerprint : node.fingerprint,
serverName = sni,
publicKey = node.publicKey,
shortId = node.shortId,
spiderX = node.spiderX,
};
streamSettings.xtlsSettings = xtlsSettings;
}
//streamSettings
switch (node.GetNetwork())
{
@ -1193,6 +1219,12 @@ namespace v2rayN.Handler
{
profileItem.streamSecurity = Global.StreamSecurity;
}
//xtls
if (outbound?.streamSettings?.security == Global.StreamSecurityXtls)
{
profileItem.streamSecurity = Global.StreamSecurityXtls;
}
}
catch (Exception ex)
{
@ -1320,6 +1352,11 @@ namespace v2rayN.Handler
{
profileItem.streamSecurity = Global.StreamSecurity;
}
//xtls
if (inbound.streamSettings?.security == Global.StreamSecurityXtls)
{
profileItem.streamSecurity = Global.StreamSecurityXtls;
}
}
catch (Exception ex)
{

View file

@ -104,7 +104,7 @@ namespace v2rayN.Mode
public int trayMenuServersLimit { get; set; } = 20;
public bool enableHWA { get; set; } = true;
public bool enableHWA { get; set; } = false;
}
[Serializable]

View file

@ -392,6 +392,7 @@ namespace v2rayN.Mode
/// VLESS only
/// </summary>
public TlsSettings realitySettings { get; set; }
public TlsSettings xtlsSettings { get; set; }
/// <summary>
/// grpc
/// </summary>

View file

@ -76,6 +76,7 @@ namespace v2rayN.Views
case EConfigType.VLESS:
gridVLESS.Visibility = Visibility.Visible;
cmbStreamSecurity.Items.Add(Global.StreamSecurityReality);
cmbStreamSecurity.Items.Add(Global.StreamSecurityXtls);
Global.flows.ForEach(it =>
{
cmbFlow5.Items.Add(it);
@ -172,6 +173,10 @@ namespace v2rayN.Views
gridTlsMore.Visibility = Visibility.Hidden;
}
else if (security == Global.StreamSecurity)
{
gridRealityMore.Visibility = Visibility.Hidden;
gridTlsMore.Visibility = Visibility.Visible;
} else if (security == Global.StreamSecurityXtls)
{
gridRealityMore.Visibility = Visibility.Hidden;
gridTlsMore.Visibility = Visibility.Visible;