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