mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-08 05:25:01 +03:00
Remove vnext (#10132)
This commit is contained in:
@@ -50,8 +50,6 @@ public class CoreConfigV2rayServiceTests
|
|||||||
await headers["Set-Cookie"]!.AsArray()
|
await headers["Set-Cookie"]!.AsArray()
|
||||||
.Select(item => item!.GetValue<string>())
|
.Select(item => item!.GetValue<string>())
|
||||||
.Should().BeEquivalentTo(["a=1", "b=2"]);
|
.Should().BeEquivalentTo(["a=1", "b=2"]);
|
||||||
await outbound.settings.servers.Should().BeNull();
|
|
||||||
await outbound.settings.vnext.Should().BeNull();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -714,6 +712,5 @@ public class CoreConfigV2rayServiceTests
|
|||||||
var proxyOutbound = cfg!.outbounds.FirstOrDefault(o => o.tag == Global.ProxyTag);
|
var proxyOutbound = cfg!.outbounds.FirstOrDefault(o => o.tag == Global.ProxyTag);
|
||||||
await proxyOutbound.Should().NotBeNull();
|
await proxyOutbound.Should().NotBeNull();
|
||||||
await proxyOutbound!.protocol.Should().BeEqualTo("shadowsocks");
|
await proxyOutbound!.protocol.Should().BeEqualTo("shadowsocks");
|
||||||
await proxyOutbound.settings.servers.Should().NotBeNull();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,8 +75,6 @@ public class Inboundsettings4Ray
|
|||||||
|
|
||||||
public string? address { get; set; }
|
public string? address { get; set; }
|
||||||
|
|
||||||
public List<UsersItem4Ray>? clients { get; set; }
|
|
||||||
|
|
||||||
public string? decryption { get; set; }
|
public string? decryption { get; set; }
|
||||||
|
|
||||||
public bool? allowTransparent { get; set; }
|
public bool? allowTransparent { get; set; }
|
||||||
@@ -96,21 +94,6 @@ public class Inboundsettings4Ray
|
|||||||
public List<string>? dns { get; set; }
|
public List<string>? dns { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UsersItem4Ray
|
|
||||||
{
|
|
||||||
public string? id { get; set; }
|
|
||||||
|
|
||||||
public int? alterId { get; set; }
|
|
||||||
|
|
||||||
public string? email { get; set; }
|
|
||||||
|
|
||||||
public string? security { get; set; }
|
|
||||||
|
|
||||||
public string? encryption { get; set; }
|
|
||||||
|
|
||||||
public string? flow { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Sniffing4Ray
|
public class Sniffing4Ray
|
||||||
{
|
{
|
||||||
public bool enabled { get; set; }
|
public bool enabled { get; set; }
|
||||||
@@ -137,10 +120,6 @@ public class Outbounds4Ray
|
|||||||
|
|
||||||
public class Outboundsettings4Ray
|
public class Outboundsettings4Ray
|
||||||
{
|
{
|
||||||
public List<VnextItem4Ray>? vnext { get; set; }
|
|
||||||
|
|
||||||
public List<ServersItem4Ray>? servers { get; set; }
|
|
||||||
|
|
||||||
public Response4Ray? response { get; set; }
|
public Response4Ray? response { get; set; }
|
||||||
|
|
||||||
public int? userLevel { get; set; }
|
public int? userLevel { get; set; }
|
||||||
@@ -174,29 +153,16 @@ public class Outboundsettings4Ray
|
|||||||
public int? version { get; set; }
|
public int? version { get; set; }
|
||||||
|
|
||||||
public List<string>? remoteDNS { get; set; }
|
public List<string>? remoteDNS { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
public class WireguardPeer4Ray
|
public string? id { get; set; }
|
||||||
{
|
|
||||||
public string endpoint { get; set; }
|
|
||||||
public string publicKey { get; set; }
|
|
||||||
public string? preSharedKey { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class VnextItem4Ray
|
public int? alterId { get; set; }
|
||||||
{
|
|
||||||
public string address { get; set; }
|
|
||||||
|
|
||||||
public int port { get; set; }
|
public string? security { get; set; }
|
||||||
|
|
||||||
public List<UsersItem4Ray> users { get; set; }
|
public string? encryption { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
public class ServersItem4Ray
|
public string? flow { get; set; }
|
||||||
{
|
|
||||||
public string email { get; set; }
|
|
||||||
|
|
||||||
public string address { get; set; }
|
|
||||||
|
|
||||||
public string? method { get; set; }
|
public string? method { get; set; }
|
||||||
|
|
||||||
@@ -204,24 +170,14 @@ public class ServersItem4Ray
|
|||||||
|
|
||||||
public string? password { get; set; }
|
public string? password { get; set; }
|
||||||
|
|
||||||
public int port { get; set; }
|
|
||||||
|
|
||||||
public int? level { get; set; }
|
|
||||||
|
|
||||||
public string flow { get; set; }
|
|
||||||
|
|
||||||
public bool? uot { get; set; }
|
public bool? uot { get; set; }
|
||||||
|
|
||||||
public List<SocksUsersItem4Ray> users { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SocksUsersItem4Ray
|
public class WireguardPeer4Ray
|
||||||
{
|
{
|
||||||
public string user { get; set; }
|
public string endpoint { get; set; }
|
||||||
|
public string publicKey { get; set; }
|
||||||
public string pass { get; set; }
|
public string? preSharedKey { get; set; }
|
||||||
|
|
||||||
public int? level { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Mux4Ray
|
public class Mux4Ray
|
||||||
|
|||||||
@@ -2,28 +2,14 @@
|
|||||||
"tag": "proxy",
|
"tag": "proxy",
|
||||||
"protocol": "vmess",
|
"protocol": "vmess",
|
||||||
"settings": {
|
"settings": {
|
||||||
"vnext": [
|
"address": "v2ray.cool",
|
||||||
{
|
"port": 10086,
|
||||||
"address": "v2ray.cool",
|
"id": "a3482e88-686a-4a58-8126-99c9df64b7bf",
|
||||||
"port": 10086,
|
"security": "auto",
|
||||||
"users": [
|
"method": "chacha20",
|
||||||
{
|
"ota": false,
|
||||||
"id": "a3482e88-686a-4a58-8126-99c9df64b7bf",
|
"password": "123456",
|
||||||
"security": "auto"
|
"level": 1
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"servers": [
|
|
||||||
{
|
|
||||||
"address": "v2ray.cool",
|
|
||||||
"method": "chacha20",
|
|
||||||
"ota": false,
|
|
||||||
"password": "123456",
|
|
||||||
"port": 10086,
|
|
||||||
"level": 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"streamSettings": {
|
"streamSettings": {
|
||||||
"network": "tcp"
|
"network": "tcp"
|
||||||
|
|||||||
@@ -282,9 +282,8 @@ public partial class CoreConfigV2rayService
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var outboundAddress = outbound.settings?.servers?.FirstOrDefault()?.address
|
var outboundAddress = outbound.settings?.address?.ToString()
|
||||||
?? outbound.settings?.vnext?.FirstOrDefault()?.address
|
?? outbound.settings?.peers?.FirstOrDefault()?.endpoint
|
||||||
?? outbound.settings?.address?.ToString()
|
|
||||||
?? string.Empty;
|
?? string.Empty;
|
||||||
|
|
||||||
if (outboundAddress.Equals("localhost", StringComparison.OrdinalIgnoreCase))
|
if (outboundAddress.Equals("localhost", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|||||||
@@ -69,166 +69,88 @@ public partial class CoreConfigV2rayService
|
|||||||
{
|
{
|
||||||
var protocolExtra = _node.GetProtocolExtra();
|
var protocolExtra = _node.GetProtocolExtra();
|
||||||
var muxEnabled = _node.MuxEnabled ?? false;
|
var muxEnabled = _node.MuxEnabled ?? false;
|
||||||
|
var outboundSettings = outbound.settings;
|
||||||
switch (_node.ConfigType)
|
switch (_node.ConfigType)
|
||||||
{
|
{
|
||||||
case EConfigType.VMess:
|
case EConfigType.VMess:
|
||||||
{
|
{
|
||||||
VnextItem4Ray vnextItem;
|
outboundSettings.address = _node.Address;
|
||||||
if (outbound.settings.vnext.Count <= 0)
|
outboundSettings.port = _node.Port;
|
||||||
{
|
outboundSettings.id = _node.Password;
|
||||||
vnextItem = new VnextItem4Ray();
|
outboundSettings.alterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
|
||||||
outbound.settings.vnext.Add(vnextItem);
|
outboundSettings.email = Global.UserEMail;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vnextItem = outbound.settings.vnext.First();
|
|
||||||
}
|
|
||||||
vnextItem.address = _node.Address;
|
|
||||||
vnextItem.port = _node.Port;
|
|
||||||
|
|
||||||
UsersItem4Ray usersItem;
|
|
||||||
if (vnextItem.users.Count <= 0)
|
|
||||||
{
|
|
||||||
usersItem = new UsersItem4Ray();
|
|
||||||
vnextItem.users.Add(usersItem);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
usersItem = vnextItem.users.First();
|
|
||||||
}
|
|
||||||
|
|
||||||
usersItem.id = _node.Password;
|
|
||||||
usersItem.alterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
|
|
||||||
usersItem.email = Global.UserEMail;
|
|
||||||
if (Global.VmessSecurities.Contains(protocolExtra.VmessSecurity))
|
if (Global.VmessSecurities.Contains(protocolExtra.VmessSecurity))
|
||||||
{
|
{
|
||||||
usersItem.security = protocolExtra.VmessSecurity;
|
outboundSettings.security = protocolExtra.VmessSecurity;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usersItem.security = Global.DefaultSecurity;
|
outboundSettings.security = Global.DefaultSecurity;
|
||||||
}
|
}
|
||||||
|
|
||||||
FillOutboundMux(outbound, muxEnabled, muxEnabled);
|
FillOutboundMux(outbound, muxEnabled, muxEnabled);
|
||||||
|
|
||||||
outbound.settings.servers = null;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EConfigType.Shadowsocks:
|
case EConfigType.Shadowsocks:
|
||||||
{
|
{
|
||||||
ServersItem4Ray serversItem;
|
outboundSettings.address = _node.Address;
|
||||||
if (outbound.settings.servers.Count <= 0)
|
outboundSettings.port = _node.Port;
|
||||||
{
|
outboundSettings.password = _node.Password;
|
||||||
serversItem = new ServersItem4Ray();
|
outboundSettings.method = AppManager.Instance.GetShadowsocksSecurities(_node).Contains(protocolExtra.SsMethod)
|
||||||
outbound.settings.servers.Add(serversItem);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
serversItem = outbound.settings.servers.First();
|
|
||||||
}
|
|
||||||
serversItem.address = _node.Address;
|
|
||||||
serversItem.port = _node.Port;
|
|
||||||
serversItem.password = _node.Password;
|
|
||||||
serversItem.method = AppManager.Instance.GetShadowsocksSecurities(_node).Contains(protocolExtra.SsMethod)
|
|
||||||
? protocolExtra.SsMethod : "none";
|
? protocolExtra.SsMethod : "none";
|
||||||
serversItem.uot = protocolExtra.Uot == true ? true : null;
|
outboundSettings.uot = protocolExtra.Uot == true ? true : null;
|
||||||
|
|
||||||
serversItem.ota = false;
|
outboundSettings.ota = false;
|
||||||
serversItem.level = 1;
|
outboundSettings.level = 1;
|
||||||
|
|
||||||
FillOutboundMux(outbound);
|
FillOutboundMux(outbound);
|
||||||
|
|
||||||
outbound.settings.vnext = null;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EConfigType.SOCKS:
|
case EConfigType.SOCKS:
|
||||||
{
|
{
|
||||||
ServersItem4Ray serversItem;
|
outboundSettings.address = _node.Address;
|
||||||
if (outbound.settings.servers.Count <= 0)
|
outboundSettings.port = _node.Port;
|
||||||
{
|
|
||||||
serversItem = new ServersItem4Ray();
|
|
||||||
outbound.settings.servers.Add(serversItem);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
serversItem = outbound.settings.servers.First();
|
|
||||||
}
|
|
||||||
serversItem.address = _node.Address;
|
|
||||||
serversItem.port = _node.Port;
|
|
||||||
serversItem.method = null;
|
|
||||||
serversItem.password = null;
|
|
||||||
|
|
||||||
if (_node.Username.IsNotEmpty()
|
if (_node.Username.IsNotEmpty()
|
||||||
&& _node.Password.IsNotEmpty())
|
&& _node.Password.IsNotEmpty())
|
||||||
{
|
{
|
||||||
SocksUsersItem4Ray socksUsersItem = new()
|
outboundSettings.user = _node.Username;
|
||||||
{
|
outboundSettings.pass = _node.Password;
|
||||||
user = _node.Username ?? "",
|
outboundSettings.level = 1;
|
||||||
pass = _node.Password,
|
outboundSettings.email = Global.UserEMail;
|
||||||
level = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
serversItem.users = new List<SocksUsersItem4Ray>() { socksUsersItem };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FillOutboundMux(outbound);
|
FillOutboundMux(outbound);
|
||||||
|
|
||||||
outbound.settings.vnext = null;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EConfigType.HTTP:
|
case EConfigType.HTTP:
|
||||||
{
|
{
|
||||||
outbound.settings.address = _node.Address;
|
outboundSettings.address = _node.Address;
|
||||||
outbound.settings.port = _node.Port;
|
outboundSettings.port = _node.Port;
|
||||||
|
|
||||||
if (protocolExtra.HttpHeaders.IsNotEmpty())
|
if (protocolExtra.HttpHeaders.IsNotEmpty())
|
||||||
{
|
{
|
||||||
outbound.settings.headers = JsonUtils.ParseJson(protocolExtra.HttpHeaders);
|
outboundSettings.headers = JsonUtils.ParseJson(protocolExtra.HttpHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_node.Username.IsNotEmpty()
|
if (_node.Username.IsNotEmpty()
|
||||||
&& _node.Password.IsNotEmpty())
|
&& _node.Password.IsNotEmpty())
|
||||||
{
|
{
|
||||||
outbound.settings.user = _node.Username;
|
outboundSettings.user = _node.Username;
|
||||||
outbound.settings.pass = _node.Password;
|
outboundSettings.pass = _node.Password;
|
||||||
outbound.settings.level = 1;
|
outboundSettings.level = 1;
|
||||||
outbound.settings.email = Global.UserEMail;
|
outboundSettings.email = Global.UserEMail;
|
||||||
}
|
}
|
||||||
|
|
||||||
FillOutboundMux(outbound);
|
FillOutboundMux(outbound);
|
||||||
|
|
||||||
outbound.settings.vnext = null;
|
|
||||||
outbound.settings.servers = null;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EConfigType.VLESS:
|
case EConfigType.VLESS:
|
||||||
{
|
{
|
||||||
VnextItem4Ray vnextItem;
|
outboundSettings.address = _node.Address;
|
||||||
if (outbound.settings.vnext?.Count <= 0)
|
outboundSettings.port = _node.Port;
|
||||||
{
|
outboundSettings.id = _node.Password;
|
||||||
vnextItem = new VnextItem4Ray();
|
outboundSettings.email = Global.UserEMail;
|
||||||
outbound.settings.vnext.Add(vnextItem);
|
outboundSettings.encryption = protocolExtra.VlessEncryption;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vnextItem = outbound.settings.vnext.First();
|
|
||||||
}
|
|
||||||
vnextItem.address = _node.Address;
|
|
||||||
vnextItem.port = _node.Port;
|
|
||||||
|
|
||||||
UsersItem4Ray usersItem;
|
|
||||||
if (vnextItem.users.Count <= 0)
|
|
||||||
{
|
|
||||||
usersItem = new UsersItem4Ray();
|
|
||||||
vnextItem.users.Add(usersItem);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
usersItem = vnextItem.users.First();
|
|
||||||
}
|
|
||||||
usersItem.id = _node.Password;
|
|
||||||
usersItem.email = Global.UserEMail;
|
|
||||||
usersItem.encryption = protocolExtra.VlessEncryption;
|
|
||||||
|
|
||||||
if (protocolExtra.Flow.IsNullOrEmpty())
|
if (protocolExtra.Flow.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
@@ -236,46 +158,28 @@ public partial class CoreConfigV2rayService
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usersItem.flow = protocolExtra.Flow;
|
outboundSettings.flow = protocolExtra.Flow;
|
||||||
FillOutboundMux(outbound, false, muxEnabled);
|
FillOutboundMux(outbound, false, muxEnabled);
|
||||||
}
|
}
|
||||||
outbound.settings.servers = null;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EConfigType.Trojan:
|
case EConfigType.Trojan:
|
||||||
{
|
{
|
||||||
ServersItem4Ray serversItem;
|
outboundSettings.address = _node.Address;
|
||||||
if (outbound.settings.servers.Count <= 0)
|
outboundSettings.port = _node.Port;
|
||||||
{
|
outboundSettings.password = _node.Password;
|
||||||
serversItem = new ServersItem4Ray();
|
|
||||||
outbound.settings.servers.Add(serversItem);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
serversItem = outbound.settings.servers.First();
|
|
||||||
}
|
|
||||||
serversItem.address = _node.Address;
|
|
||||||
serversItem.port = _node.Port;
|
|
||||||
serversItem.password = _node.Password;
|
|
||||||
|
|
||||||
serversItem.ota = false;
|
outboundSettings.ota = false;
|
||||||
serversItem.level = 1;
|
outboundSettings.level = 1;
|
||||||
|
|
||||||
FillOutboundMux(outbound);
|
FillOutboundMux(outbound);
|
||||||
|
|
||||||
outbound.settings.vnext = null;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EConfigType.Hysteria2:
|
case EConfigType.Hysteria2:
|
||||||
{
|
{
|
||||||
outbound.settings = new()
|
outboundSettings.address = _node.Address;
|
||||||
{
|
outboundSettings.port = _node.Port;
|
||||||
version = 2,
|
outboundSettings.version = 2;
|
||||||
address = _node.Address,
|
|
||||||
port = _node.Port,
|
|
||||||
vnext = null,
|
|
||||||
servers = null,
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EConfigType.WireGuard:
|
case EConfigType.WireGuard:
|
||||||
@@ -301,8 +205,6 @@ public partial class CoreConfigV2rayService
|
|||||||
peers = [peer],
|
peers = [peer],
|
||||||
};
|
};
|
||||||
outbound.settings = setting;
|
outbound.settings = setting;
|
||||||
outbound.settings.vnext = null;
|
|
||||||
outbound.settings.servers = null;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user