Fix TLSSecureType "none" value

This commit is contained in:
ChsBuffer
2021-02-16 18:53:07 +08:00
parent 04afea7d1c
commit eac456b3a8
3 changed files with 39 additions and 42 deletions

View File

@@ -76,7 +76,6 @@ namespace Netch.Servers.V2ray.Utils
};
if (mode.BypassChina)
{
switch (mode.Type)
{
case 0:
@@ -93,12 +92,9 @@ namespace Netch.Servers.V2ray.Utils
directRuleObject.domain.Add("geosite:cn");
break;
}
}
if (mode.Type is 0 or 1 or 2)
{
blockRuleObject.ip.Add("geoip:private");
}
v2rayConfig.routing = new Routing
{
@@ -109,14 +105,10 @@ namespace Netch.Servers.V2ray.Utils
{
bool ipResult, domainResult;
if (!(ipResult = rulesItem.ip.Any()))
{
rulesItem.ip = null;
}
if (!(domainResult = rulesItem.domain.Any()))
{
rulesItem.domain = null;
}
return ipResult || domainResult;
}
@@ -152,12 +144,12 @@ namespace Netch.Servers.V2ray.Utils
{
outbound.settings.servers = new List<ServersItem>
{
new ServersItem
new()
{
users = socks5.Auth()
? new List<SocksUsersItem>
{
new SocksUsersItem
new()
{
user = socks5.Username,
pass = socks5.Password,
@@ -245,11 +237,11 @@ namespace Netch.Servers.V2ray.Utils
v2rayConfig.outbounds = new List<Outbounds>
{
outbound,
new Outbounds
new()
{
tag = "direct", protocol = "freedom"
},
new Outbounds
new()
{
tag = "block", protocol = "blackhole"
}
@@ -267,7 +259,7 @@ namespace Netch.Servers.V2ray.Utils
{
streamSettings.network = server.TransferProtocol;
if ((streamSettings.security = server.TLSSecureType) != "")
if ((streamSettings.security = server.TLSSecureType) != "none")
{
var tlsSettings = new TlsSettings
{
@@ -341,11 +333,9 @@ namespace Netch.Servers.V2ray.Utils
}
};
if (server.TLSSecureType != "")
{
if (server.TLSSecureType != "none")
// tls or xtls
streamSettings.tlsSettings.serverName = server.Hostname;
}
streamSettings.quicSettings = quicSettings;
break;

View File

@@ -16,36 +16,34 @@ namespace Netch.Servers.VLESS
public override string EncryptMethod { get; set; } = "none";
/// <summary>
/// 传输协议
/// 传输协议
/// </summary>
public override string TransferProtocol { get; set; } = VLESSGlobal.TransferProtocols[0];
/// <summary>
/// 伪装类型
/// 伪装类型
/// </summary>
public override string FakeType { get; set; } = VLESSGlobal.FakeTypes[0];
/// <summary>
///
/// </summary>
public string Flow { get; set; }
}
public class VLESSGlobal
{
public static List<string> TransferProtocols => VMessGlobal.TransferProtocols;
public static readonly List<string> FakeTypes = new List<string>
public static readonly List<string> FakeTypes = new()
{
"none",
"http"
};
public static readonly List<string> TLSSecure = new List<string>
public static readonly List<string> TLSSecure = new()
{
"",
"none",
"tls",
"xtls"
};
public static List<string> TransferProtocols => VMessGlobal.TransferProtocols;
}
}

View File

@@ -5,13 +5,14 @@ namespace Netch.Servers.VMess
{
public class VMess : Server
{
private string _tlsSecureType = VMessGlobal.TLSSecure[0];
public VMess()
{
Type = "VMess";
}
/// <summary>
/// 用户 ID
/// 用户 ID
/// </summary>
public string UserID { get; set; }
@@ -25,14 +26,13 @@ namespace Netch.Servers.VMess
/// </summary>
public virtual string EncryptMethod { get; set; } = VMessGlobal.EncryptMethods[0];
/// <summary>
/// 传输协议
/// 传输协议
/// </summary>
public virtual string TransferProtocol { get; set; } = VMessGlobal.TransferProtocols[0];
/// <summary>
/// 伪装类型
/// 伪装类型
/// </summary>
public virtual string FakeType { get; set; } = VMessGlobal.FakeTypes[0];
@@ -52,29 +52,38 @@ namespace Netch.Servers.VMess
public string Path { get; set; }
/// <summary>
/// QUIC 加密方式
/// QUIC 加密方式
/// </summary>
public string QUICSecure { get; set; } = VMessGlobal.QUIC[0];
/// <summary>
/// QUIC 加密密钥
/// QUIC 加密密钥
/// </summary>
public string QUICSecret { get; set; } = string.Empty;
/// <summary>
/// TLS 底层传输安全
/// TLS 底层传输安全
/// </summary>
public string TLSSecureType { get; set; } = VMessGlobal.TLSSecure[0];
public string TLSSecureType
{
get => _tlsSecureType;
set
{
if (value == "")
value = "none";
_tlsSecureType = value;
}
}
/// <summary>
/// Mux 多路复用
/// Mux 多路复用
/// </summary>
public bool? UseMux { get; set; } = false;
}
public class VMessGlobal
{
public static readonly List<string> EncryptMethods = new List<string>
public static readonly List<string> EncryptMethods = new()
{
"auto",
"none",
@@ -82,7 +91,7 @@ namespace Netch.Servers.VMess
"chacha20-poly1305"
};
public static readonly List<string> QUIC = new List<string>
public static readonly List<string> QUIC = new()
{
"none",
"aes-128-gcm",
@@ -90,9 +99,9 @@ namespace Netch.Servers.VMess
};
/// <summary>
/// V2Ray 传输协议
/// V2Ray 传输协议
/// </summary>
public static readonly List<string> TransferProtocols = new List<string>
public static readonly List<string> TransferProtocols = new()
{
"tcp",
"kcp",
@@ -102,9 +111,9 @@ namespace Netch.Servers.VMess
};
/// <summary>
/// V2Ray 伪装类型
/// V2Ray 伪装类型
/// </summary>
public static readonly List<string> FakeTypes = new List<string>
public static readonly List<string> FakeTypes = new()
{
"none",
"http",
@@ -116,11 +125,11 @@ namespace Netch.Servers.VMess
};
/// <summary>
/// TLS 安全类型
/// TLS 安全类型
/// </summary>
public static readonly List<string> TLSSecure = new List<string>
public static readonly List<string> TLSSecure = new()
{
"",
"none",
"tls"
};
}