mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +08:00
Update V2rayNSharing Util
This commit is contained in:
@@ -6,39 +6,9 @@
|
||||
public class V2rayNSharing
|
||||
{
|
||||
/// <summary>
|
||||
/// 地址
|
||||
/// 链接版本
|
||||
/// </summary>
|
||||
public string add { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 额外 ID
|
||||
/// </summary>
|
||||
public int aid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 伪装域名(HTTP,WS)
|
||||
/// </summary>
|
||||
public string? host { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 用户 ID
|
||||
/// </summary>
|
||||
public string id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 传输协议
|
||||
/// </summary>
|
||||
public string net { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 伪装路径/服务名称
|
||||
/// </summary>
|
||||
public string? path { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 端口
|
||||
/// </summary>
|
||||
public ushort port { get; set; }
|
||||
public int v { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
@@ -46,9 +16,34 @@
|
||||
public string ps { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用 TLS
|
||||
/// 地址
|
||||
/// </summary>
|
||||
public string tls { get; set; } = string.Empty;
|
||||
public string add { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 端口
|
||||
/// </summary>
|
||||
public ushort port { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户 ID
|
||||
/// </summary>
|
||||
public string id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 额外 ID
|
||||
/// </summary>
|
||||
public int aid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 加密方式 (security)
|
||||
/// </summary>
|
||||
public string scy { get; set; } = "auto";
|
||||
|
||||
/// <summary>
|
||||
/// 传输协议
|
||||
/// </summary>
|
||||
public string net { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 伪装类型
|
||||
@@ -56,8 +51,23 @@
|
||||
public string type { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 链接版本
|
||||
/// 伪装域名(HTTP,WS)
|
||||
/// </summary>
|
||||
public int v { get; set; } = 2;
|
||||
public string host { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 伪装路径/服务名称
|
||||
/// </summary>
|
||||
public string path { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用 TLS
|
||||
/// </summary>
|
||||
public string tls { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// serverName
|
||||
/// </summary>
|
||||
public string sni { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -42,19 +42,21 @@ namespace Netch.Servers
|
||||
var server = (VMess)s;
|
||||
|
||||
var vmessJson = JsonSerializer.Serialize(new V2rayNSharing
|
||||
{
|
||||
v = 2,
|
||||
ps = server.Remark,
|
||||
add = server.Hostname,
|
||||
port = server.Port,
|
||||
id = server.UserID,
|
||||
aid = server.AlterID,
|
||||
net = server.TransferProtocol,
|
||||
type = server.FakeType,
|
||||
host = server.Host,
|
||||
path = server.Path,
|
||||
tls = server.TLSSecureType
|
||||
},
|
||||
{
|
||||
v = 2,
|
||||
ps = server.Remark,
|
||||
add = server.Hostname,
|
||||
port = server.Port,
|
||||
scy = server.EncryptMethod,
|
||||
id = server.UserID,
|
||||
aid = server.AlterID,
|
||||
net = server.TransferProtocol,
|
||||
type = server.FakeType,
|
||||
host = server.Host ?? "",
|
||||
path = server.Path ?? "",
|
||||
tls = server.TLSSecureType,
|
||||
sni = server.ServerName ?? ""
|
||||
},
|
||||
new JsonSerializerOptions
|
||||
{
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
@@ -90,18 +92,18 @@ namespace Netch.Servers
|
||||
|
||||
data.Remark = vmess.ps;
|
||||
data.Hostname = vmess.add;
|
||||
data.EncryptMethod = vmess.scy;
|
||||
data.Port = vmess.port;
|
||||
data.UserID = vmess.id;
|
||||
data.AlterID = vmess.aid;
|
||||
data.TransferProtocol = vmess.net;
|
||||
data.FakeType = vmess.type;
|
||||
data.ServerName = vmess.sni;
|
||||
|
||||
if (data.TransferProtocol == "quic")
|
||||
{
|
||||
if (VMessGlobal.QUIC.Contains(vmess.host!))
|
||||
{
|
||||
data.QUICSecure = vmess.host;
|
||||
data.QUICSecret = vmess.path;
|
||||
}
|
||||
data.QUICSecure = vmess.host;
|
||||
data.QUICSecret = vmess.path;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -110,7 +112,6 @@ namespace Netch.Servers
|
||||
}
|
||||
|
||||
data.TLSSecureType = vmess.tls;
|
||||
data.EncryptMethod = "auto"; // V2Ray 加密方式不包括在链接中,主动添加一个
|
||||
|
||||
return new[] { data };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user