mirror of
https://github.com/netchx/netch.git
synced 2026-05-07 22:44:03 +08:00
feat: #431
This commit is contained in:
@@ -34,7 +34,6 @@ namespace Netch.Servers.VLESS
|
||||
|
||||
public class VLESSGlobal
|
||||
{
|
||||
|
||||
public static List<string> TransferProtocols => VMessGlobal.TransferProtocols;
|
||||
|
||||
public static readonly List<string> FakeTypes = new List<string>
|
||||
@@ -42,5 +41,12 @@ namespace Netch.Servers.VLESS
|
||||
"none",
|
||||
"http"
|
||||
};
|
||||
|
||||
public static readonly List<string> TLSSecure = new List<string>
|
||||
{
|
||||
"",
|
||||
"tls",
|
||||
"xtls"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -49,9 +49,10 @@ namespace Netch.Servers.VLESS.VLESSForm
|
||||
_ => null
|
||||
},
|
||||
server.UseMux?.ToString() ?? "");
|
||||
CreateCheckBox("TLSSecure", "TLS Secure",
|
||||
b => server.TLSSecure = b,
|
||||
server.TLSSecure);
|
||||
CreateComboBox("TLSSecure", "TLS Secure",
|
||||
VLESSGlobal.TLSSecure,
|
||||
s => server.TLSSecureType = s,
|
||||
server.TLSSecureType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,9 +58,10 @@ namespace Netch.Servers.VMess.Form
|
||||
_ => null
|
||||
},
|
||||
server.UseMux?.ToString() ?? "");
|
||||
CreateCheckBox("TLSSecure", "TLS Secure",
|
||||
s => server.TLSSecure = s,
|
||||
server.TLSSecure);
|
||||
CreateComboBox("TLSSecure", "TLS Secure",
|
||||
VMessGlobal.TLSSecure,
|
||||
s => server.TLSSecureType = s,
|
||||
server.TLSSecureType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,24 +246,37 @@ namespace Netch.Servers.VMess.Utils
|
||||
{
|
||||
streamSettings.network = server.TransferProtocol;
|
||||
var host = server.Host;
|
||||
if (server.TLSSecure)
|
||||
streamSettings.security = server.TLSSecureType;
|
||||
switch (server.TLSSecureType)
|
||||
{
|
||||
streamSettings.security = "tls";
|
||||
case "tls":
|
||||
{
|
||||
var tlsSettings = new TlsSettings
|
||||
{
|
||||
allowInsecure = Global.Settings.V2RayConfig.AllowInsecure
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
tlsSettings.serverName = host;
|
||||
}
|
||||
|
||||
var tlsSettings = new TlsSettings
|
||||
{
|
||||
allowInsecure = Global.Settings.V2RayConfig.AllowInsecure
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
tlsSettings.serverName = host;
|
||||
streamSettings.tlsSettings = tlsSettings;
|
||||
break;
|
||||
}
|
||||
case "xtls":
|
||||
{
|
||||
var xtlsSettings = new TlsSettings
|
||||
{
|
||||
allowInsecure = Global.Settings.V2RayConfig.AllowInsecure
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
xtlsSettings.serverName = host;
|
||||
}
|
||||
|
||||
streamSettings.tlsSettings = tlsSettings;
|
||||
}
|
||||
else
|
||||
{
|
||||
streamSettings.security = "";
|
||||
streamSettings.xtlsSettings = xtlsSettings;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (server.TransferProtocol)
|
||||
@@ -326,27 +339,13 @@ namespace Netch.Servers.VMess.Utils
|
||||
type = server.FakeType
|
||||
}
|
||||
};
|
||||
if (server.TLSSecure)
|
||||
if (server.TLSSecureType == "tls")
|
||||
{
|
||||
streamSettings.tlsSettings.serverName = server.Hostname;
|
||||
}
|
||||
|
||||
streamSettings.quicSettings = quicSettings;
|
||||
break;
|
||||
case "xtls":
|
||||
streamSettings.security = server.TransferProtocol;
|
||||
|
||||
var xtlsSettings = new TlsSettings
|
||||
{
|
||||
allowInsecure = Global.Settings.V2RayConfig.AllowInsecure
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
xtlsSettings.serverName = host;
|
||||
}
|
||||
|
||||
streamSettings.xtlsSettings = xtlsSettings;
|
||||
break;
|
||||
default:
|
||||
if (server.FakeType == "http")
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Netch.Models;
|
||||
|
||||
@@ -64,7 +65,13 @@ namespace Netch.Servers.VMess
|
||||
/// <summary>
|
||||
/// TLS 底层传输安全
|
||||
/// </summary>
|
||||
public bool TLSSecure { get; set; } = false;
|
||||
[Obsolete]
|
||||
public bool? TLSSecure { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TLS 底层传输安全
|
||||
/// </summary>
|
||||
public string TLSSecureType { get; set; } = VMessGlobal.TLSSecure[0];
|
||||
|
||||
/// <summary>
|
||||
/// Mux 多路复用
|
||||
@@ -114,5 +121,14 @@ namespace Netch.Servers.VMess
|
||||
"dtls",
|
||||
"wireguard"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// TLS 安全类型
|
||||
/// </summary>
|
||||
public static readonly List<string> TLSSecure = new List<string>
|
||||
{
|
||||
"",
|
||||
"tls"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,24 @@ namespace Netch.Servers.VMess
|
||||
|
||||
public Server ParseJObject(in JObject j)
|
||||
{
|
||||
return j.ToObject<VMess>();
|
||||
var server = j.ToObject<VMess>();
|
||||
if (server == null)
|
||||
return null;
|
||||
|
||||
if (server.TLSSecure != null)
|
||||
{
|
||||
if ((bool) server.TLSSecure)
|
||||
{
|
||||
server.TLSSecureType = "tls";
|
||||
server.TLSSecure = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
server.TLSSecure = null;
|
||||
}
|
||||
}
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
public void Edit(Server s)
|
||||
@@ -49,7 +66,7 @@ namespace Netch.Servers.VMess
|
||||
type = server.FakeType,
|
||||
host = server.Host,
|
||||
path = server.Path,
|
||||
tls = server.TLSSecure ? "tls" : ""
|
||||
tls = server.TLSSecure
|
||||
});
|
||||
return "vmess://" + ShareLink.URLSafeBase64Encode(vmessJson);
|
||||
}
|
||||
@@ -97,7 +114,7 @@ namespace Netch.Servers.VMess
|
||||
data.Path = vmess.path;
|
||||
}
|
||||
|
||||
data.TLSSecure = vmess.tls == "tls";
|
||||
data.TLSSecureType = vmess.tls;
|
||||
data.EncryptMethod = "auto"; // V2Ray 加密方式不包括在链接中,主动添加一个
|
||||
|
||||
return CheckServer(data) ? new[] {data} : null;
|
||||
|
||||
Reference in New Issue
Block a user