Code clean

pull/4711/head
2dust 2023-12-19 16:49:45 +08:00
parent bd9a4ca094
commit fcdb61bfbf
20 changed files with 160 additions and 157 deletions

View File

@ -40,7 +40,7 @@ namespace v2rayN
return;
}
Global.processJob = new Job();
Global.ProcessJob = new Job();
Logging.Setup();
Init();

View File

@ -4,38 +4,38 @@
{
#region const
public const string githubUrl = "https://github.com";
public const string githubApiUrl = "https://api.github.com/repos";
public const string v2rayWebsiteUrl = @"https://www.v2fly.org/";
public const string GithubUrl = "https://github.com";
public const string GithubApiUrl = "https://api.github.com/repos";
public const string V2rayWebsiteUrl = @"https://www.v2fly.org/";
public const string AboutUrl = @"https://github.com/2dust/v2rayN";
public const string UpdateUrl = AboutUrl + @"/releases";
public const string v2flyCoreUrl = "https://github.com/v2fly/v2ray-core/releases";
public const string xrayCoreUrl = "https://github.com/XTLS/Xray-core/releases";
public const string V2flyCoreUrl = "https://github.com/v2fly/v2ray-core/releases";
public const string XrayCoreUrl = "https://github.com/XTLS/Xray-core/releases";
public const string SagerNetCoreUrl = "https://github.com/SagerNet/v2ray-core/releases";
public const string NUrl = @"https://github.com/2dust/v2rayN/releases";
public const string clashCoreUrl = "https://github.com/Dreamacro/clash/releases";
public const string clashMetaCoreUrl = "https://github.com/MetaCubeX/Clash.Meta/releases";
public const string hysteriaCoreUrl = "https://github.com/apernet/hysteria/releases";
public const string naiveproxyCoreUrl = "https://github.com/klzgrad/naiveproxy/releases";
public const string tuicCoreUrl = "https://github.com/EAimTY/tuic/releases";
public const string singboxCoreUrl = "https://github.com/SagerNet/sing-box/releases";
public const string geoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/{0}.dat";
public const string singboxGeoUrl = "https://github.com/soffchen/sing-{0}/releases/latest/download/{0}.db";
public const string ClashCoreUrl = "https://github.com/Dreamacro/clash/releases";
public const string ClashMetaCoreUrl = "https://github.com/MetaCubeX/Clash.Meta/releases";
public const string HysteriaCoreUrl = "https://github.com/apernet/hysteria/releases";
public const string NaiveproxyCoreUrl = "https://github.com/klzgrad/naiveproxy/releases";
public const string TuicCoreUrl = "https://github.com/EAimTY/tuic/releases";
public const string SingboxCoreUrl = "https://github.com/SagerNet/sing-box/releases";
public const string GeoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/{0}.dat";
public const string SingboxGeoUrl = "https://github.com/soffchen/sing-{0}/releases/latest/download/{0}.db";
public const string SpeedPingTestUrl = @"https://www.google.com/generate_204";
public const string juicityCoreUrl = "https://github.com/juicity/juicity/releases";
public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases";
public const string CustomRoutingListUrl = @"https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/";
public const string PromotionUrl = @"aHR0cHM6Ly85LjIzNDQ1Ni54eXovYWJjLmh0bWw=";
public const string ConfigFileName = "guiNConfig.json";
public const string ConfigDB = "guiNDB.db";
public const string coreConfigFileName = "config.json";
public const string corePreConfigFileName = "configPre.json";
public const string CoreConfigFileName = "config.json";
public const string CorePreConfigFileName = "configPre.json";
public const string v2raySampleClient = "v2rayN.Sample.SampleClientConfig";
public const string V2raySampleClient = "v2rayN.Sample.SampleClientConfig";
public const string SingboxSampleClient = "v2rayN.Sample.SingboxSampleClientConfig";
public const string v2raySampleHttprequestFileName = "v2rayN.Sample.SampleHttprequest";
public const string v2raySampleHttpresponseFileName = "v2rayN.Sample.SampleHttpresponse";
public const string v2raySampleInbound = "v2rayN.Sample.SampleInbound";
public const string V2raySampleHttprequestFileName = "v2rayN.Sample.SampleHttprequest";
public const string V2raySampleHttpresponseFileName = "v2rayN.Sample.SampleHttpresponse";
public const string V2raySampleInbound = "v2rayN.Sample.SampleInbound";
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";
public const string TunSingboxDNSFileName = "v2rayN.Sample.tun_singbox_dns";
@ -49,9 +49,9 @@
public const string DefaultNetwork = "tcp";
public const string TcpHeaderHttp = "http";
public const string None = "none";
public const string agentTag = "proxy";
public const string directTag = "direct";
public const string blockTag = "block";
public const string ProxyTag = "proxy";
public const string DirectTag = "direct";
public const string BlockTag = "block";
public const string StreamSecurity = "tls";
public const string StreamSecurityReality = "reality";
public const string InboundSocks = "socks";
@ -80,7 +80,7 @@
public const string tuicProtocol = "tuic://";
public const string tuicProtocolLite = "tuic";
public const string userEMail = "t@t.tt";
public const string UserEMail = "t@t.tt";
public const string MyRegPath = "Software\\v2rayNGUI";
public const string AutoRunRegPath = @"Software\Microsoft\Windows\CurrentVersion\Run";
public const string AutoRunName = "v2rayNAutoRun";
@ -132,7 +132,7 @@
@"http://cachefly.cachefly.net/10mb.test"
};
public static readonly Dictionary<string, string> userAgentTxt = new()
public static readonly Dictionary<string, string> UserAgentTxt = new()
{
{"chrome","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36" },
{"firefox","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0" },
@ -141,40 +141,40 @@
{"none",""}
};
public static readonly List<string> vmessSecuritys = new() { "aes-128-gcm", "chacha20-poly1305", "auto", "none", "zero" };
public static readonly List<string> ssSecuritys = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "none", "plain" };
public static readonly List<string> ssSecuritysInSagerNet = new() { "none", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305", "aes-128-gcm", "aes-192-gcm", "aes-256-gcm", "chacha20-ietf-poly1305", "xchacha20-ietf-poly1305", "rc4", "rc4-md5", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "aes-128-cfb8", "aes-192-cfb8", "aes-256-cfb8", "aes-128-ofb", "aes-192-ofb", "aes-256-ofb", "bf-cfb", "cast5-cfb", "des-cfb", "idea-cfb", "rc2-cfb", "seed-cfb", "camellia-128-cfb", "camellia-192-cfb", "camellia-256-cfb", "camellia-128-cfb8", "camellia-192-cfb8", "camellia-256-cfb8", "salsa20", "chacha20", "chacha20-ietf", "xchacha20" };
public static readonly List<string> ssSecuritysInXray = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "xchacha20-poly1305", "xchacha20-ietf-poly1305", "none", "plain", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305" };
public static readonly List<string> flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" };
public static readonly List<string> networks = new() { "tcp", "kcp", "ws", "h2", "quic", "grpc" };
public static readonly List<string> kcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" };
public static readonly List<string> coreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" };
public static readonly List<string> coreTypes4VLESS = new() { "Xray", "sing_box" };
public static readonly List<string> domainStrategys = new() { "AsIs", "IPIfNonMatch", "IPOnDemand" };
public static readonly List<string> domainStrategys4Singbox = new() { "ipv4_only", "ipv6_only", "prefer_ipv4", "prefer_ipv6", "" };
public static readonly List<string> domainMatchers = new() { "linear", "mph", "" };
public static readonly List<string> fingerprints = new() { "chrome", "firefox", "safari", "ios", "android", "edge", "360", "qq", "random", "randomized", "" };
public static readonly List<string> userAgent = new() { "chrome", "firefox", "safari", "edge", "none" };
public static readonly List<string> VmessSecuritys = new() { "aes-128-gcm", "chacha20-poly1305", "auto", "none", "zero" };
public static readonly List<string> SsSecuritys = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "none", "plain" };
public static readonly List<string> SsSecuritysInSagerNet = new() { "none", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305", "aes-128-gcm", "aes-192-gcm", "aes-256-gcm", "chacha20-ietf-poly1305", "xchacha20-ietf-poly1305", "rc4", "rc4-md5", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "aes-128-cfb8", "aes-192-cfb8", "aes-256-cfb8", "aes-128-ofb", "aes-192-ofb", "aes-256-ofb", "bf-cfb", "cast5-cfb", "des-cfb", "idea-cfb", "rc2-cfb", "seed-cfb", "camellia-128-cfb", "camellia-192-cfb", "camellia-256-cfb", "camellia-128-cfb8", "camellia-192-cfb8", "camellia-256-cfb8", "salsa20", "chacha20", "chacha20-ietf", "xchacha20" };
public static readonly List<string> SsSecuritysInXray = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "xchacha20-poly1305", "xchacha20-ietf-poly1305", "none", "plain", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305" };
public static readonly List<string> Flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" };
public static readonly List<string> Networks = new() { "tcp", "kcp", "ws", "h2", "quic", "grpc" };
public static readonly List<string> KcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" };
public static readonly List<string> CoreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" };
public static readonly List<string> CoreTypes4VLESS = new() { "Xray", "sing_box" };
public static readonly List<string> DomainStrategys = new() { "AsIs", "IPIfNonMatch", "IPOnDemand" };
public static readonly List<string> DomainStrategys4Singbox = new() { "ipv4_only", "ipv6_only", "prefer_ipv4", "prefer_ipv6", "" };
public static readonly List<string> DomainMatchers = new() { "linear", "mph", "" };
public static readonly List<string> Fingerprints = new() { "chrome", "firefox", "safari", "ios", "android", "edge", "360", "qq", "random", "randomized", "" };
public static readonly List<string> UserAgent = new() { "chrome", "firefox", "safari", "edge", "none" };
public static readonly List<string> allowInsecures = new() { "true", "false", "" };
public static readonly List<string> domainStrategy4Freedoms = new() { "AsIs", "UseIP", "UseIPv4", "UseIPv6", "" };
public static readonly List<string> AllowInsecures = new() { "true", "false", "" };
public static readonly List<string> DomainStrategy4Freedoms = new() { "AsIs", "UseIP", "UseIPv4", "UseIPv6", "" };
public static readonly List<string> Languages = new() { "zh-Hans", "zh-Hant", "en", "fa-Ir", "ru" };
public static readonly List<string> alpns = new() { "h2", "http/1.1", "h2,http/1.1", "h3", "" };
public static readonly List<string> LogLevel = new() { "debug", "info", "warning", "error", "none" };
public static readonly List<string> Alpns = new() { "h2", "http/1.1", "h2,http/1.1", "h3", "" };
public static readonly List<string> LogLevels = new() { "debug", "info", "warning", "error", "none" };
public static readonly List<string> InboundTags = new() { "socks", "http", "socks2", "http2" };
public static readonly List<string> Protocols = new() { "http", "tls", "bittorrent" };
public static readonly List<string> RuleProtocols = new() { "http", "tls", "bittorrent" };
public static readonly List<string> TunMtus = new() { "9000", "1500" };
public static readonly List<string> TunStacks = new() { "gvisor", "system" };
public static readonly List<string> PresetMsgFilters = new() { "proxy", "direct", "block", "" };
public static readonly List<string> SingboxMuxs = new() { "h2mux", "smux", "yamux", "" };
public static readonly List<string> TuicCongestionControl = new() { "cubic", "new_reno", "bbr" };
public static readonly List<string> TuicCongestionControls = new() { "cubic", "new_reno", "bbr" };
#endregion const
#region global variable
public static int statePort { get; set; }
public static Job processJob { get; set; }
public static int StatePort { get; set; }
public static Job ProcessJob { get; set; }
public static bool ShowInTaskbar { get; set; }
public static string ExePathKey { get; set; }

View File

@ -96,7 +96,7 @@ namespace v2rayN.Handler
//路由规则
if (Utils.IsNullOrEmpty(config.routingBasicItem.domainStrategy))
{
config.routingBasicItem.domainStrategy = Global.domainStrategys[0];//"IPIfNonMatch";
config.routingBasicItem.domainStrategy = Global.DomainStrategys[0];//"IPIfNonMatch";
}
//if (Utils.IsNullOrEmpty(config.domainMatcher))
//{
@ -374,7 +374,7 @@ namespace v2rayN.Handler
profileItem.path = profileItem.path.TrimEx();
profileItem.streamSecurity = profileItem.streamSecurity.TrimEx();
if (!Global.vmessSecuritys.Contains(profileItem.security))
if (!Global.VmessSecuritys.Contains(profileItem.security))
{
return -1;
}
@ -715,6 +715,8 @@ namespace v2rayN.Handler
profileItem.address = profileItem.address.TrimEx();
profileItem.id = profileItem.id.TrimEx();
profileItem.network = string.Empty;
if (Utils.IsNullOrEmpty(profileItem.streamSecurity))
{
profileItem.streamSecurity = Global.StreamSecurity;
@ -743,10 +745,11 @@ namespace v2rayN.Handler
profileItem.address = profileItem.address.TrimEx();
profileItem.id = profileItem.id.TrimEx();
profileItem.security = profileItem.security.TrimEx();
profileItem.network = string.Empty;
if (!Global.TuicCongestionControl.Contains(profileItem.headerType))
if (!Global.TuicCongestionControls.Contains(profileItem.headerType))
{
profileItem.headerType = Global.TuicCongestionControl.FirstOrDefault()!;
profileItem.headerType = Global.TuicCongestionControls.FirstOrDefault()!;
}
if (Utils.IsNullOrEmpty(profileItem.streamSecurity))
@ -882,9 +885,9 @@ namespace v2rayN.Handler
profileItem.path = profileItem.path.TrimEx();
profileItem.streamSecurity = profileItem.streamSecurity.TrimEx();
if (!Global.flows.Contains(profileItem.flow))
if (!Global.Flows.Contains(profileItem.flow))
{
profileItem.flow = Global.flows.First();
profileItem.flow = Global.Flows.First();
}
if (profileItem.id.IsNullOrEmpty())
{
@ -936,7 +939,7 @@ namespace v2rayN.Handler
}
}
if (!Utils.IsNullOrEmpty(profileItem.network) && !Global.networks.Contains(profileItem.network))
if (!Utils.IsNullOrEmpty(profileItem.network) && !Global.Networks.Contains(profileItem.network))
{
profileItem.network = Global.DefaultNetwork;
}

View File

@ -226,7 +226,7 @@ namespace v2rayN.Handler
outbound.uuid = node.id;
outbound.alter_id = node.alterId;
if (Global.vmessSecuritys.Contains(node.security))
if (Global.VmessSecuritys.Contains(node.security))
{
outbound.security = node.security;
}
@ -750,7 +750,7 @@ namespace v2rayN.Handler
//}
clash_api = new Clash_Api4Sbox()
{
external_controller = $"{Global.Loopback}:{Global.statePort}",
external_controller = $"{Global.Loopback}:{Global.StatePort}",
store_selected = true
}
};

View File

@ -10,7 +10,7 @@ namespace v2rayN.Handler
{
internal class CoreConfigV2ray
{
private string SampleClient = Global.v2raySampleClient;
private string SampleClient = Global.V2raySampleClient;
private Config _config;
public CoreConfigV2ray(Config config)
@ -145,7 +145,7 @@ namespace v2rayN.Handler
private Inbounds4Ray? GetInbound(InItem inItem, string tag, int offset, bool bSocks)
{
string result = Utils.GetEmbedText(Global.v2raySampleInbound);
string result = Utils.GetEmbedText(Global.V2raySampleInbound);
if (Utils.IsNullOrEmpty(result))
{
return null;
@ -324,8 +324,8 @@ namespace v2rayN.Handler
//远程服务器用户ID
usersItem.id = node.id;
usersItem.alterId = node.alterId;
usersItem.email = Global.userEMail;
if (Global.vmessSecuritys.Contains(node.security))
usersItem.email = Global.UserEMail;
if (Global.VmessSecuritys.Contains(node.security))
{
usersItem.security = node.security;
}
@ -425,7 +425,7 @@ namespace v2rayN.Handler
usersItem = vnextItem.users[0];
}
usersItem.id = node.id;
usersItem.email = Global.userEMail;
usersItem.email = Global.UserEMail;
usersItem.encryption = node.security;
outboundMux(node, outbound, _config.coreBasicItem.muxEnabled);
@ -515,7 +515,7 @@ namespace v2rayN.Handler
{
try
{
useragent = Global.userAgentTxt[_config.coreBasicItem.defUserAgent];
useragent = Global.UserAgentTxt[_config.coreBasicItem.defUserAgent];
}
catch (KeyNotFoundException)
{
@ -672,7 +672,7 @@ namespace v2rayN.Handler
};
//request Host
string request = Utils.GetEmbedText(Global.v2raySampleHttprequestFileName);
string request = Utils.GetEmbedText(Global.V2raySampleHttprequestFileName);
string[] arrHost = host.Split(',');
string host2 = string.Join("\",\"", arrHost);
request = request.Replace("$requestHost$", $"\"{host2}\"");
@ -800,7 +800,7 @@ namespace v2rayN.Handler
Inboundsettings4Ray apiInboundSettings = new();
apiInbound.tag = tag;
apiInbound.listen = Global.Loopback;
apiInbound.port = Global.statePort;
apiInbound.port = Global.StatePort;
apiInbound.protocol = Global.InboundAPIProtocal;
apiInboundSettings.address = Global.Loopback;
apiInbound.settings = apiInboundSettings;
@ -932,18 +932,18 @@ namespace v2rayN.Handler
continue;
}
if (item.configType == EConfigType.Shadowsocks
&& !Global.ssSecuritysInXray.Contains(item.security))
&& !Global.SsSecuritysInXray.Contains(item.security))
{
continue;
}
if (item.configType == EConfigType.VLESS
&& !Global.flows.Contains(item.flow))
&& !Global.Flows.Contains(item.flow))
{
continue;
}
outbound(item, v2rayConfigCopy);
v2rayConfigCopy.outbounds[0].tag = Global.agentTag + inbound.port.ToString();
v2rayConfigCopy.outbounds[0].tag = Global.ProxyTag + inbound.port.ToString();
v2rayConfig.outbounds.Add(v2rayConfigCopy.outbounds[0]);
//rule

View File

@ -35,7 +35,7 @@ namespace v2rayN.Handler
return;
}
string fileName = Utils.GetConfigPath(Global.coreConfigFileName);
string fileName = Utils.GetConfigPath(Global.CoreConfigFileName);
if (CoreConfigHandler.GenerateClientConfig(node, fileName, out string msg, out string content) != 0)
{
ShowMsg(false, msg);
@ -204,11 +204,11 @@ namespace v2rayN.Handler
address = Global.Loopback,
port = node.preSocksPort
};
string fileName2 = Utils.GetConfigPath(Global.corePreConfigFileName);
string fileName2 = Utils.GetConfigPath(Global.CorePreConfigFileName);
if (CoreConfigHandler.GenerateClientConfig(itemSocks, fileName2, out string msg2, out string configStr) == 0)
{
var coreInfo2 = LazyConfig.Instance.GetCoreInfo(ECoreType.sing_box);
var proc2 = RunProcess(node, coreInfo2, $" -c {Global.corePreConfigFileName}", true, ShowMsg);
var proc2 = RunProcess(node, coreInfo2, $" -c {Global.CorePreConfigFileName}", true, ShowMsg);
if (proc2 is not null)
{
_processPre = proc2;
@ -272,7 +272,7 @@ namespace v2rayN.Handler
throw new Exception(p.StandardError.ReadToEnd());
}
Global.processJob.AddProcess(p.Handle);
Global.ProcessJob.AddProcess(p.Handle);
return p.Id;
}
catch (Exception ex)
@ -346,7 +346,7 @@ namespace v2rayN.Handler
throw new Exception(displayLog ? proc.StandardError.ReadToEnd() : "启动进程失败并退出 (Failed to start the process and exited)");
}
Global.processJob.AddProcess(proc.Handle);
Global.ProcessJob.AddProcess(proc.Handle);
return proc;
}
catch (Exception ex)

View File

@ -157,14 +157,14 @@ namespace v2rayN.Handler
{
if (GetCoreType(profileItem, EConfigType.Shadowsocks) == ECoreType.v2fly)
{
return Global.ssSecuritys;
return Global.SsSecuritys;
}
if (GetCoreType(profileItem, EConfigType.Shadowsocks) == ECoreType.Xray)
{
return Global.ssSecuritysInXray;
return Global.SsSecuritysInXray;
}
return Global.ssSecuritysInSagerNet;
return Global.SsSecuritysInSagerNet;
}
public ECoreType GetCoreType(ProfileItem profileItem, EConfigType eConfigType)
@ -212,7 +212,7 @@ namespace v2rayN.Handler
{
coreType = ECoreType.v2rayN,
coreUrl = Global.NUrl,
coreReleaseApiUrl = Global.NUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreReleaseApiUrl = Global.NUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.NUrl + "/download/{0}/v2rayN-32.zip",
coreDownloadUrl64 = Global.NUrl + "/download/{0}/v2rayN.zip",
coreDownloadUrlArm64 = Global.NUrl + "/download/{0}/v2rayN-arm64.zip"
@ -223,11 +223,11 @@ namespace v2rayN.Handler
coreType = ECoreType.v2fly,
coreExes = new List<string> { "wv2ray", "v2ray" },
arguments = "",
coreUrl = Global.v2flyCoreUrl,
coreReleaseApiUrl = Global.v2flyCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreUrl = Global.V2flyCoreUrl,
coreReleaseApiUrl = Global.V2flyCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
match = "V2Ray",
versionArg = "-version",
redirectInfo = true,
@ -239,7 +239,7 @@ namespace v2rayN.Handler
coreExes = new List<string> { "SagerNet", "v2ray" },
arguments = "run",
coreUrl = Global.SagerNetCoreUrl,
coreReleaseApiUrl = Global.SagerNetCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreReleaseApiUrl = Global.SagerNetCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.SagerNetCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.SagerNetCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.SagerNetCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
@ -253,11 +253,11 @@ namespace v2rayN.Handler
coreType = ECoreType.v2fly_v5,
coreExes = new List<string> { "v2ray" },
arguments = "run -c config.json -format jsonv5",
coreUrl = Global.v2flyCoreUrl,
coreReleaseApiUrl = Global.v2flyCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreUrl = Global.V2flyCoreUrl,
coreReleaseApiUrl = Global.V2flyCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.V2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
match = "V2Ray",
versionArg = "version",
redirectInfo = true,
@ -268,11 +268,11 @@ namespace v2rayN.Handler
coreType = ECoreType.Xray,
coreExes = new List<string> { "xray", "wxray" },
arguments = "",
coreUrl = Global.xrayCoreUrl,
coreReleaseApiUrl = Global.xrayCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.xrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
coreDownloadUrl64 = Global.xrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.xrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
coreUrl = Global.XrayCoreUrl,
coreReleaseApiUrl = Global.XrayCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.XrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
coreDownloadUrl64 = Global.XrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
coreDownloadUrlArm64 = Global.XrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
match = "Xray",
versionArg = "-version",
redirectInfo = true,
@ -283,11 +283,11 @@ namespace v2rayN.Handler
coreType = ECoreType.clash,
coreExes = new List<string> { "clash-windows-amd64-v3", "clash-windows-amd64", "clash-windows-386", "clash" },
arguments = "-f config.json",
coreUrl = Global.clashCoreUrl,
coreReleaseApiUrl = Global.clashCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.clashCoreUrl + "/download/{0}/clash-windows-386-{0}.zip",
coreDownloadUrl64 = Global.clashCoreUrl + "/download/{0}/clash-windows-amd64-{0}.zip",
coreDownloadUrlArm64 = Global.clashCoreUrl + "/download/{0}/clash-windows-arm64-{0}.zip",
coreUrl = Global.ClashCoreUrl,
coreReleaseApiUrl = Global.ClashCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.ClashCoreUrl + "/download/{0}/clash-windows-386-{0}.zip",
coreDownloadUrl64 = Global.ClashCoreUrl + "/download/{0}/clash-windows-amd64-{0}.zip",
coreDownloadUrlArm64 = Global.ClashCoreUrl + "/download/{0}/clash-windows-arm64-{0}.zip",
match = "v",
versionArg = "-v",
redirectInfo = true,
@ -298,11 +298,11 @@ namespace v2rayN.Handler
coreType = ECoreType.clash_meta,
coreExes = new List<string> { "Clash.Meta-windows-amd64-compatible", "Clash.Meta-windows-amd64", "Clash.Meta-windows-386", "Clash.Meta", "clash" },
arguments = "-f config.json",
coreUrl = Global.clashMetaCoreUrl,
coreReleaseApiUrl = Global.clashMetaCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.clashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-386-{0}.zip",
coreDownloadUrl64 = Global.clashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-amd64-compatible-{0}.zip",
coreDownloadUrlArm64 = Global.clashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-arm64-{0}.zip",
coreUrl = Global.ClashMetaCoreUrl,
coreReleaseApiUrl = Global.ClashMetaCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.ClashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-386-{0}.zip",
coreDownloadUrl64 = Global.ClashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-amd64-compatible-{0}.zip",
coreDownloadUrlArm64 = Global.ClashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-arm64-{0}.zip",
match = "v",
versionArg = "-v",
redirectInfo = true,
@ -313,11 +313,11 @@ namespace v2rayN.Handler
coreType = ECoreType.hysteria,
coreExes = new List<string> { "hysteria-windows-amd64", "hysteria-windows-386", "hysteria" },
arguments = "",
coreUrl = Global.hysteriaCoreUrl,
coreReleaseApiUrl = Global.hysteriaCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.hysteriaCoreUrl + "/download/{0}/hysteria-windows-386.exe",
coreDownloadUrl64 = Global.hysteriaCoreUrl + "/download/{0}/hysteria-windows-amd64.exe",
coreDownloadUrlArm64 = Global.hysteriaCoreUrl + "/download/{0}/hysteria-windows-arm64.exe",
coreUrl = Global.HysteriaCoreUrl,
coreReleaseApiUrl = Global.HysteriaCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-386.exe",
coreDownloadUrl64 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-amd64.exe",
coreDownloadUrlArm64 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-arm64.exe",
redirectInfo = true,
});
@ -326,7 +326,7 @@ namespace v2rayN.Handler
coreType = ECoreType.naiveproxy,
coreExes = new List<string> { "naiveproxy", "naive" },
arguments = "config.json",
coreUrl = Global.naiveproxyCoreUrl,
coreUrl = Global.NaiveproxyCoreUrl,
redirectInfo = false,
});
@ -335,7 +335,7 @@ namespace v2rayN.Handler
coreType = ECoreType.tuic,
coreExes = new List<string> { "tuic-client", "tuic" },
arguments = "-c config.json",
coreUrl = Global.tuicCoreUrl,
coreUrl = Global.TuicCoreUrl,
redirectInfo = true,
});
@ -344,12 +344,12 @@ namespace v2rayN.Handler
coreType = ECoreType.sing_box,
coreExes = new List<string> { "sing-box-client", "sing-box" },
arguments = "run{0}",
coreUrl = Global.singboxCoreUrl,
coreUrl = Global.SingboxCoreUrl,
redirectInfo = true,
coreReleaseApiUrl = Global.singboxCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.singboxCoreUrl + "/download/{0}/sing-box-{1}-windows-386.zip",
coreDownloadUrl64 = Global.singboxCoreUrl + "/download/{0}/sing-box-{1}-windows-amd64.zip",
coreDownloadUrlArm64 = Global.singboxCoreUrl + "/download/{0}/sing-box-{1}-windows-arm64.zip",
coreReleaseApiUrl = Global.SingboxCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.SingboxCoreUrl + "/download/{0}/sing-box-{1}-windows-386.zip",
coreDownloadUrl64 = Global.SingboxCoreUrl + "/download/{0}/sing-box-{1}-windows-amd64.zip",
coreDownloadUrlArm64 = Global.SingboxCoreUrl + "/download/{0}/sing-box-{1}-windows-arm64.zip",
match = "sing-box",
versionArg = "version",
});
@ -359,7 +359,7 @@ namespace v2rayN.Handler
coreType = ECoreType.juicity,
coreExes = new List<string> { "juicity-client", "juicity" },
arguments = "run -c config.json",
coreUrl = Global.juicityCoreUrl
coreUrl = Global.JuicityCoreUrl
});
coreInfos.Add(new CoreInfo
@ -367,11 +367,11 @@ namespace v2rayN.Handler
coreType = ECoreType.hysteria2,
coreExes = new List<string> { "hysteria-windows-amd64", "hysteria-windows-386", "hysteria" },
arguments = "",
coreUrl = Global.hysteriaCoreUrl,
coreReleaseApiUrl = Global.hysteriaCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl),
coreDownloadUrl32 = Global.hysteriaCoreUrl + "/download/{0}/hysteria-windows-386.exe",
coreDownloadUrl64 = Global.hysteriaCoreUrl + "/download/{0}/hysteria-windows-amd64.exe",
coreDownloadUrlArm64 = Global.hysteriaCoreUrl + "/download/{0}/hysteria-windows-arm64.exe",
coreUrl = Global.HysteriaCoreUrl,
coreReleaseApiUrl = Global.HysteriaCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
coreDownloadUrl32 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-386.exe",
coreDownloadUrl64 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-amd64.exe",
coreDownloadUrlArm64 = Global.HysteriaCoreUrl + "/download/{0}/hysteria-windows-arm64.exe",
redirectInfo = true,
});
}

View File

@ -29,7 +29,7 @@ namespace v2rayN.Handler
_updateFunc = update;
Init();
Global.statePort = GetFreePort();
Global.StatePort = GetFreePort();
_statisticsV2Ray = new StatisticsV2ray(config, UpdateServerStat);
_statisticsSingbox = new StatisticsSingbox(config, UpdateServerStat);

View File

@ -27,7 +27,7 @@ namespace v2rayN.Handler
try
{
url = $"ws://{Global.Loopback}:{Global.statePort}/traffic";
url = $"ws://{Global.Loopback}:{Global.StatePort}/traffic";
if (webSocket == null)
{

View File

@ -28,7 +28,7 @@ namespace v2rayN.Handler
{
if (_channel == null)
{
_channel = GrpcChannel.ForAddress($"{Global.httpProtocol}{Global.Loopback}:{Global.statePort}");
_channel = GrpcChannel.ForAddress($"{Global.httpProtocol}{Global.Loopback}:{Global.StatePort}");
_client = new StatsService.StatsServiceClient(_channel);
}
}
@ -87,7 +87,7 @@ namespace v2rayN.Handler
name = nStr[1];
type = nStr[3];
if (name == Global.agentTag)
if (name == Global.ProxyTag)
{
if (type == "uplink")
{
@ -98,7 +98,7 @@ namespace v2rayN.Handler
server.proxyDown = value;
}
}
else if (name == Global.directTag)
else if (name == Global.DirectTag)
{
if (type == "uplink")
{

View File

@ -553,7 +553,7 @@ namespace v2rayN.Handler
{
_config = config;
_updateFunc = update;
var url = string.Format(Global.geoUrl, geoName);
var url = string.Format(Global.GeoUrl, geoName);
DownloadHandle downloadHandle = new();
downloadHandle.UpdateCompleted += (sender2, args) =>
@ -600,7 +600,7 @@ namespace v2rayN.Handler
{
_config = config;
_updateFunc = update;
var url = string.Format(Global.singboxGeoUrl, geoName);
var url = string.Format(Global.SingboxGeoUrl, geoName);
DownloadHandle downloadHandle = new();
downloadHandle.UpdateCompleted += async (sender2, args) =>

View File

@ -79,7 +79,7 @@ namespace v2rayN.Mode
public string GetNetwork()
{
if (Utils.IsNullOrEmpty(network) || !Global.networks.Contains(network))
if (Utils.IsNullOrEmpty(network) || !Global.Networks.Contains(network))
{
return Global.DefaultNetwork;
}

View File

@ -634,8 +634,8 @@ namespace v2rayN.ViewModels
return;
}
SpeedProxyDisplay = string.Format(ResUI.SpeedDisplayText, Global.agentTag, Utils.HumanFy(update.proxyUp), Utils.HumanFy(update.proxyDown));
SpeedDirectDisplay = string.Format(ResUI.SpeedDisplayText, Global.directTag, Utils.HumanFy(update.directUp), Utils.HumanFy(update.directDown));
SpeedProxyDisplay = string.Format(ResUI.SpeedDisplayText, Global.ProxyTag, Utils.HumanFy(update.proxyUp), Utils.HumanFy(update.proxyDown));
SpeedDirectDisplay = string.Format(ResUI.SpeedDisplayText, Global.DirectTag, Utils.HumanFy(update.directUp), Utils.HumanFy(update.directDown));
if (update.proxyUp + update.proxyDown > 0)
{

View File

@ -45,7 +45,7 @@ namespace v2rayN.ViewModels
if (rulesItem.id.IsNullOrEmpty())
{
rulesItem.id = Utils.GetGUID(false);
rulesItem.outboundTag = Global.agentTag;
rulesItem.outboundTag = Global.ProxyTag;
rulesItem.enabled = true;
SelectedSource = rulesItem;
}

View File

@ -35,14 +35,14 @@ namespace v2rayN.Views
if (profileItem.configType == EConfigType.VLESS)
{
Global.coreTypes4VLESS.ForEach(it =>
Global.CoreTypes4VLESS.ForEach(it =>
{
cmbCoreType.Items.Add(it);
});
}
else
{
Global.coreTypes.ForEach(it =>
Global.CoreTypes.ForEach(it =>
{
cmbCoreType.Items.Add(it);
});
@ -52,20 +52,20 @@ namespace v2rayN.Views
cmbStreamSecurity.Items.Add(string.Empty);
cmbStreamSecurity.Items.Add(Global.StreamSecurity);
Global.networks.ForEach(it =>
Global.Networks.ForEach(it =>
{
cmbNetwork.Items.Add(it);
});
Global.fingerprints.ForEach(it =>
Global.Fingerprints.ForEach(it =>
{
cmbFingerprint.Items.Add(it);
cmbFingerprint2.Items.Add(it);
});
Global.allowInsecures.ForEach(it =>
Global.AllowInsecures.ForEach(it =>
{
cmbAllowInsecure.Items.Add(it);
});
Global.alpns.ForEach(it =>
Global.Alpns.ForEach(it =>
{
cmbAlpn.Items.Add(it);
});
@ -74,7 +74,7 @@ namespace v2rayN.Views
{
case EConfigType.VMess:
gridVMess.Visibility = Visibility.Visible;
Global.vmessSecuritys.ForEach(it =>
Global.VmessSecuritys.ForEach(it =>
{
cmbSecurity.Items.Add(it);
});
@ -99,7 +99,7 @@ namespace v2rayN.Views
case EConfigType.VLESS:
gridVLESS.Visibility = Visibility.Visible;
cmbStreamSecurity.Items.Add(Global.StreamSecurityReality);
Global.flows.ForEach(it =>
Global.Flows.ForEach(it =>
{
cmbFlow5.Items.Add(it);
});
@ -112,7 +112,7 @@ namespace v2rayN.Views
case EConfigType.Trojan:
gridTrojan.Visibility = Visibility.Visible;
cmbStreamSecurity.Items.Add(Global.StreamSecurityReality);
Global.flows.ForEach(it =>
Global.Flows.ForEach(it =>
{
cmbFlow6.Items.Add(it);
});
@ -135,7 +135,7 @@ namespace v2rayN.Views
cmbFingerprint.IsEnabled = false;
cmbFingerprint.Text = string.Empty;
Global.TuicCongestionControl.ForEach(it =>
Global.TuicCongestionControls.ForEach(it =>
{
cmbHeaderType8.Items.Add(it);
});
@ -269,7 +269,7 @@ namespace v2rayN.Views
else if (network is "kcp" or "quic")
{
cmbHeaderType.Items.Add(Global.None);
Global.kcpHeaderTypes.ForEach(it =>
Global.KcpHeaderTypes.ForEach(it =>
{
cmbHeaderType.Items.Add(it);
});

View File

@ -30,7 +30,7 @@ namespace v2rayN.Views
ViewModel = new DNSSettingViewModel(this);
Global.domainStrategy4Freedoms.ForEach(it =>
Global.DomainStrategy4Freedoms.ForEach(it =>
{
cmbdomainStrategy4Freedom.Items.Add(it);
});

View File

@ -38,15 +38,15 @@ namespace v2rayN.Views
{
cmbsystemProxyAdvancedProtocol.Items.Add(it);
});
Global.LogLevel.ForEach(it =>
Global.LogLevels.ForEach(it =>
{
cmbloglevel.Items.Add(it);
});
Global.fingerprints.ForEach(it =>
Global.Fingerprints.ForEach(it =>
{
cmbdefFingerprint.Items.Add(it);
});
Global.userAgent.ForEach(it =>
Global.UserAgent.ForEach(it =>
{
cmbdefUserAgent.Items.Add(it);
});
@ -63,7 +63,7 @@ namespace v2rayN.Views
{
cmbStack.Items.Add(it);
});
Global.coreTypes.ForEach(it =>
Global.CoreTypes.ForEach(it =>
{
cmbCoreType1.Items.Add(it);
cmbCoreType2.Items.Add(it);

View File

@ -29,10 +29,10 @@ namespace v2rayN.Views
clbInboundTag.SelectionChanged += ClbInboundTag_SelectionChanged;
ViewModel = new RoutingRuleDetailsViewModel(rulesItem, this);
cmbOutboundTag.Items.Add(Global.agentTag);
cmbOutboundTag.Items.Add(Global.directTag);
cmbOutboundTag.Items.Add(Global.blockTag);
Global.Protocols.ForEach(it =>
cmbOutboundTag.Items.Add(Global.ProxyTag);
cmbOutboundTag.Items.Add(Global.DirectTag);
cmbOutboundTag.Items.Add(Global.BlockTag);
Global.RuleProtocols.ForEach(it =>
{
clbProtocol.Items.Add(it);
});

View File

@ -31,12 +31,12 @@ namespace v2rayN.Views
lstRules.MouseDoubleClick += LstRules_MouseDoubleClick;
ViewModel = new RoutingRuleSettingViewModel(routingItem, this);
Global.domainStrategys.ForEach(it =>
Global.DomainStrategys.ForEach(it =>
{
cmbdomainStrategy.Items.Add(it);
});
cmbdomainStrategy.Items.Add(string.Empty);
Global.domainStrategys4Singbox.ForEach(it =>
Global.DomainStrategys4Singbox.ForEach(it =>
{
cmbdomainStrategy4Singbox.Items.Add(it);
});

View File

@ -31,15 +31,15 @@ namespace v2rayN.Views
ViewModel = new RoutingSettingViewModel(this);
Global.domainStrategys.ForEach(it =>
Global.DomainStrategys.ForEach(it =>
{
cmbdomainStrategy.Items.Add(it);
});
Global.domainMatchers.ForEach(it =>
Global.DomainMatchers.ForEach(it =>
{
cmbdomainMatcher.Items.Add(it);
});
Global.domainStrategys4Singbox.ForEach(it =>
Global.DomainStrategys4Singbox.ForEach(it =>
{
cmbdomainStrategy4Singbox.Items.Add(it);
});