mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-02 21:28:51 +00:00
Code clean
This commit is contained in:
parent
fcdb61bfbf
commit
f5deb8e168
8 changed files with 63 additions and 57 deletions
|
@ -1,4 +1,6 @@
|
||||||
namespace v2rayN
|
using v2rayN.Mode;
|
||||||
|
|
||||||
|
namespace v2rayN
|
||||||
{
|
{
|
||||||
internal class Global
|
internal class Global
|
||||||
{
|
{
|
||||||
|
@ -30,18 +32,15 @@
|
||||||
public const string ConfigDB = "guiNDB.db";
|
public const string ConfigDB = "guiNDB.db";
|
||||||
public const string CoreConfigFileName = "config.json";
|
public const string CoreConfigFileName = "config.json";
|
||||||
public const string CorePreConfigFileName = "configPre.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 SingboxSampleClient = "v2rayN.Sample.SingboxSampleClientConfig";
|
||||||
public const string V2raySampleHttprequestFileName = "v2rayN.Sample.SampleHttprequest";
|
public const string V2raySampleHttprequestFileName = "v2rayN.Sample.SampleHttprequest";
|
||||||
public const string V2raySampleHttpresponseFileName = "v2rayN.Sample.SampleHttpresponse";
|
public const string V2raySampleHttpresponseFileName = "v2rayN.Sample.SampleHttpresponse";
|
||||||
public const string V2raySampleInbound = "v2rayN.Sample.SampleInbound";
|
public const string V2raySampleInbound = "v2rayN.Sample.SampleInbound";
|
||||||
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";
|
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";
|
||||||
|
|
||||||
public const string TunSingboxDNSFileName = "v2rayN.Sample.tun_singbox_dns";
|
public const string TunSingboxDNSFileName = "v2rayN.Sample.tun_singbox_dns";
|
||||||
public const string TunSingboxInboundFileName = "v2rayN.Sample.tun_singbox_inbound";
|
public const string TunSingboxInboundFileName = "v2rayN.Sample.tun_singbox_inbound";
|
||||||
public const string TunSingboxRulesFileName = "v2rayN.Sample.tun_singbox_rules";
|
public const string TunSingboxRulesFileName = "v2rayN.Sample.tun_singbox_rules";
|
||||||
|
|
||||||
public const string DNSV2rayNormalFileName = "v2rayN.Sample.dns_v2ray_normal";
|
public const string DNSV2rayNormalFileName = "v2rayN.Sample.dns_v2ray_normal";
|
||||||
public const string DNSSingboxNormalFileName = "v2rayN.Sample.dns_singbox_normal";
|
public const string DNSSingboxNormalFileName = "v2rayN.Sample.dns_singbox_normal";
|
||||||
|
|
||||||
|
@ -61,24 +60,8 @@
|
||||||
public const string Loopback = "127.0.0.1";
|
public const string Loopback = "127.0.0.1";
|
||||||
public const string InboundAPITagName = "api";
|
public const string InboundAPITagName = "api";
|
||||||
public const string InboundAPIProtocal = "dokodemo-door";
|
public const string InboundAPIProtocal = "dokodemo-door";
|
||||||
|
public const string HttpProtocol = "http://";
|
||||||
public const string vmessProtocol = "vmess://";
|
public const string HttpsProtocol = "https://";
|
||||||
public const string vmessProtocolLite = "vmess";
|
|
||||||
public const string ssProtocol = "ss://";
|
|
||||||
public const string ssProtocolLite = "shadowsocks";
|
|
||||||
public const string socksProtocol = "socks://";
|
|
||||||
public const string socksProtocolLite = "socks";
|
|
||||||
public const string httpProtocol = "http://";
|
|
||||||
public const string httpsProtocol = "https://";
|
|
||||||
public const string vlessProtocol = "vless://";
|
|
||||||
public const string vlessProtocolLite = "vless";
|
|
||||||
public const string trojanProtocol = "trojan://";
|
|
||||||
public const string trojanProtocolLite = "trojan";
|
|
||||||
public const string hysteria2Protocol = "hysteria2://";
|
|
||||||
public const string hysteria2Protocol2 = "hy2://";
|
|
||||||
public const string hysteria2ProtocolLite = "hysteria2";
|
|
||||||
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 MyRegPath = "Software\\v2rayNGUI";
|
||||||
|
@ -132,7 +115,7 @@
|
||||||
@"http://cachefly.cachefly.net/10mb.test"
|
@"http://cachefly.cachefly.net/10mb.test"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly Dictionary<string, string> UserAgentTxt = new()
|
public static readonly Dictionary<string, string> UserAgentTxts = 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" },
|
{"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" },
|
{"firefox","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0" },
|
||||||
|
@ -141,6 +124,29 @@
|
||||||
{"none",""}
|
{"none",""}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public const string Hysteria2ProtocolShare = "hy2://";
|
||||||
|
public static readonly Dictionary<EConfigType, string> ProtocolShares = new()
|
||||||
|
{
|
||||||
|
{EConfigType.VMess,"vmess://"},
|
||||||
|
{EConfigType.Shadowsocks,"ss://"},
|
||||||
|
{EConfigType.Socks,"socks://"},
|
||||||
|
{EConfigType.VLESS,"vless://"},
|
||||||
|
{EConfigType.Trojan,"trojan://"},
|
||||||
|
{EConfigType.Hysteria2,"hysteria2://"},
|
||||||
|
{EConfigType.Tuic,"tuic://"}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static readonly Dictionary<EConfigType, string> ProtocolTypes = new()
|
||||||
|
{
|
||||||
|
{EConfigType.VMess,"vmess"},
|
||||||
|
{EConfigType.Shadowsocks,"shadowsocks"},
|
||||||
|
{EConfigType.Socks,"socks"},
|
||||||
|
{EConfigType.VLESS,"vless"},
|
||||||
|
{EConfigType.Trojan,"trojan"},
|
||||||
|
{EConfigType.Hysteria2,"hysteria2"},
|
||||||
|
{EConfigType.Tuic,"tuic"}
|
||||||
|
};
|
||||||
|
|
||||||
public static readonly List<string> VmessSecuritys = new() { "aes-128-gcm", "chacha20-poly1305", "auto", "none", "zero" };
|
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> 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> 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" };
|
||||||
|
|
|
@ -1051,7 +1051,7 @@ namespace v2rayN.Handler
|
||||||
foreach (string str in arrData)
|
foreach (string str in arrData)
|
||||||
{
|
{
|
||||||
//maybe sub
|
//maybe sub
|
||||||
if (!isSub && (str.StartsWith(Global.httpsProtocol) || str.StartsWith(Global.httpProtocol)))
|
if (!isSub && (str.StartsWith(Global.HttpsProtocol) || str.StartsWith(Global.HttpProtocol)))
|
||||||
{
|
{
|
||||||
if (AddSubItem(ref config, str) == 0)
|
if (AddSubItem(ref config, str) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -222,7 +222,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
if (node.configType == EConfigType.VMess)
|
if (node.configType == EConfigType.VMess)
|
||||||
{
|
{
|
||||||
outbound.type = Global.vmessProtocolLite;
|
outbound.type = Global.ProtocolTypes[EConfigType.VMess];
|
||||||
|
|
||||||
outbound.uuid = node.id;
|
outbound.uuid = node.id;
|
||||||
outbound.alter_id = node.alterId;
|
outbound.alter_id = node.alterId;
|
||||||
|
@ -239,7 +239,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else if (node.configType == EConfigType.Shadowsocks)
|
else if (node.configType == EConfigType.Shadowsocks)
|
||||||
{
|
{
|
||||||
outbound.type = Global.ssProtocolLite;
|
outbound.type = Global.ProtocolTypes[EConfigType.Shadowsocks];
|
||||||
|
|
||||||
outbound.method = LazyConfig.Instance.GetShadowsocksSecuritys(node).Contains(node.security) ? node.security : "none";
|
outbound.method = LazyConfig.Instance.GetShadowsocksSecuritys(node).Contains(node.security) ? node.security : "none";
|
||||||
outbound.password = node.id;
|
outbound.password = node.id;
|
||||||
|
@ -248,7 +248,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else if (node.configType == EConfigType.Socks)
|
else if (node.configType == EConfigType.Socks)
|
||||||
{
|
{
|
||||||
outbound.type = Global.socksProtocolLite;
|
outbound.type = Global.ProtocolTypes[EConfigType.Socks];
|
||||||
|
|
||||||
outbound.version = "5";
|
outbound.version = "5";
|
||||||
if (!Utils.IsNullOrEmpty(node.security)
|
if (!Utils.IsNullOrEmpty(node.security)
|
||||||
|
@ -260,7 +260,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else if (node.configType == EConfigType.VLESS)
|
else if (node.configType == EConfigType.VLESS)
|
||||||
{
|
{
|
||||||
outbound.type = Global.vlessProtocolLite;
|
outbound.type = Global.ProtocolTypes[EConfigType.VLESS];
|
||||||
|
|
||||||
outbound.uuid = node.id;
|
outbound.uuid = node.id;
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else if (node.configType == EConfigType.Trojan)
|
else if (node.configType == EConfigType.Trojan)
|
||||||
{
|
{
|
||||||
outbound.type = Global.trojanProtocolLite;
|
outbound.type = Global.ProtocolTypes[EConfigType.Trojan];
|
||||||
|
|
||||||
outbound.password = node.id;
|
outbound.password = node.id;
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else if (node.configType == EConfigType.Hysteria2)
|
else if (node.configType == EConfigType.Hysteria2)
|
||||||
{
|
{
|
||||||
outbound.type = Global.hysteria2ProtocolLite;
|
outbound.type = Global.ProtocolTypes[EConfigType.Hysteria2];
|
||||||
|
|
||||||
outbound.password = node.id;
|
outbound.password = node.id;
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else if (node.configType == EConfigType.Tuic)
|
else if (node.configType == EConfigType.Tuic)
|
||||||
{
|
{
|
||||||
outbound.type = Global.tuicProtocolLite;
|
outbound.type = Global.ProtocolTypes[EConfigType.Tuic];
|
||||||
|
|
||||||
outbound.uuid = node.id;
|
outbound.uuid = node.id;
|
||||||
outbound.password = node.security;
|
outbound.password = node.security;
|
||||||
|
|
|
@ -336,7 +336,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
outboundMux(node, outbound, _config.coreBasicItem.muxEnabled);
|
outboundMux(node, outbound, _config.coreBasicItem.muxEnabled);
|
||||||
|
|
||||||
outbound.protocol = Global.vmessProtocolLite;
|
outbound.protocol = Global.ProtocolTypes[EConfigType.VMess];
|
||||||
outbound.settings.servers = null;
|
outbound.settings.servers = null;
|
||||||
}
|
}
|
||||||
else if (node.configType == EConfigType.Shadowsocks)
|
else if (node.configType == EConfigType.Shadowsocks)
|
||||||
|
@ -361,7 +361,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
outboundMux(node, outbound, false);
|
outboundMux(node, outbound, false);
|
||||||
|
|
||||||
outbound.protocol = Global.ssProtocolLite;
|
outbound.protocol = Global.ProtocolTypes[EConfigType.Shadowsocks];
|
||||||
outbound.settings.vnext = null;
|
outbound.settings.vnext = null;
|
||||||
}
|
}
|
||||||
else if (node.configType == EConfigType.Socks)
|
else if (node.configType == EConfigType.Socks)
|
||||||
|
@ -396,7 +396,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
outboundMux(node, outbound, false);
|
outboundMux(node, outbound, false);
|
||||||
|
|
||||||
outbound.protocol = Global.socksProtocolLite;
|
outbound.protocol = Global.ProtocolTypes[EConfigType.Socks];
|
||||||
outbound.settings.vnext = null;
|
outbound.settings.vnext = null;
|
||||||
}
|
}
|
||||||
else if (node.configType == EConfigType.VLESS)
|
else if (node.configType == EConfigType.VLESS)
|
||||||
|
@ -445,7 +445,7 @@ namespace v2rayN.Handler
|
||||||
outboundMux(node, outbound, _config.coreBasicItem.muxEnabled);
|
outboundMux(node, outbound, _config.coreBasicItem.muxEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
outbound.protocol = Global.vlessProtocolLite;
|
outbound.protocol = Global.ProtocolTypes[EConfigType.VLESS];
|
||||||
outbound.settings.servers = null;
|
outbound.settings.servers = null;
|
||||||
}
|
}
|
||||||
else if (node.configType == EConfigType.Trojan)
|
else if (node.configType == EConfigType.Trojan)
|
||||||
|
@ -469,7 +469,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
outboundMux(node, outbound, false);
|
outboundMux(node, outbound, false);
|
||||||
|
|
||||||
outbound.protocol = Global.trojanProtocolLite;
|
outbound.protocol = Global.ProtocolTypes[EConfigType.Trojan];
|
||||||
outbound.settings.vnext = null;
|
outbound.settings.vnext = null;
|
||||||
}
|
}
|
||||||
boundStreamSettings(node, outbound.streamSettings);
|
boundStreamSettings(node, outbound.streamSettings);
|
||||||
|
@ -515,7 +515,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
useragent = Global.UserAgentTxt[_config.coreBasicItem.defUserAgent];
|
useragent = Global.UserAgentTxts[_config.coreBasicItem.defUserAgent];
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException)
|
catch (KeyNotFoundException)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
url = Utils.ToJson(vmessQRCode);
|
url = Utils.ToJson(vmessQRCode);
|
||||||
url = Utils.Base64Encode(url);
|
url = Utils.Base64Encode(url);
|
||||||
url = $"{Global.vmessProtocol}{url}";
|
url = $"{Global.ProtocolShares[EConfigType.VMess]}{url}";
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ namespace v2rayN.Handler
|
||||||
//new Sip002
|
//new Sip002
|
||||||
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
||||||
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
|
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
|
||||||
url = $"{Global.ssProtocol}{url}{remark}";
|
url = $"{Global.ProtocolShares[EConfigType.Shadowsocks]}{url}{remark}";
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ namespace v2rayN.Handler
|
||||||
//new
|
//new
|
||||||
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
||||||
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
|
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
|
||||||
url = $"{Global.socksProtocol}{url}{remark}";
|
url = $"{Global.ProtocolShares[EConfigType.Socks]}{url}{remark}";
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ namespace v2rayN.Handler
|
||||||
item.id,
|
item.id,
|
||||||
GetIpv6(item.address),
|
GetIpv6(item.address),
|
||||||
item.port);
|
item.port);
|
||||||
url = $"{Global.trojanProtocol}{url}{query}{remark}";
|
url = $"{Global.ProtocolShares[EConfigType.Trojan]}{url}{query}{remark}";
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ namespace v2rayN.Handler
|
||||||
item.id,
|
item.id,
|
||||||
GetIpv6(item.address),
|
GetIpv6(item.address),
|
||||||
item.port);
|
item.port);
|
||||||
url = $"{Global.vlessProtocol}{url}{query}{remark}";
|
url = $"{Global.ProtocolShares[EConfigType.VLESS]}{url}{query}{remark}";
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ namespace v2rayN.Handler
|
||||||
item.id,
|
item.id,
|
||||||
GetIpv6(item.address),
|
GetIpv6(item.address),
|
||||||
item.port);
|
item.port);
|
||||||
url = $"{Global.hysteria2Protocol}{url}{query}{remark}";
|
url = $"{Global.ProtocolShares[EConfigType.Hysteria2]}{url}{query}{remark}";
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ namespace v2rayN.Handler
|
||||||
$"{item.id}:{item.security}",
|
$"{item.id}:{item.security}",
|
||||||
GetIpv6(item.address),
|
GetIpv6(item.address),
|
||||||
item.port);
|
item.port);
|
||||||
url = $"{Global.tuicProtocol}{url}{query}{remark}";
|
url = $"{Global.ProtocolShares[EConfigType.Tuic]}{url}{query}{remark}";
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ namespace v2rayN.Handler
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.StartsWith(Global.vmessProtocol))
|
if (result.StartsWith(Global.ProtocolShares[EConfigType.VMess]))
|
||||||
{
|
{
|
||||||
int indexSplit = result.IndexOf("?");
|
int indexSplit = result.IndexOf("?");
|
||||||
if (indexSplit > 0)
|
if (indexSplit > 0)
|
||||||
|
@ -371,7 +371,7 @@ namespace v2rayN.Handler
|
||||||
profileItem = ResolveVmess(result, out msg);
|
profileItem = ResolveVmess(result, out msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (result.StartsWith(Global.ssProtocol))
|
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Shadowsocks]))
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
profileItem.configType = EConfigType.Shadowsocks;
|
profileItem.configType = EConfigType.Shadowsocks;
|
||||||
}
|
}
|
||||||
else if (result.StartsWith(Global.socksProtocol))
|
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Socks]))
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
|
|
||||||
|
@ -403,23 +403,23 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
profileItem.configType = EConfigType.Socks;
|
profileItem.configType = EConfigType.Socks;
|
||||||
}
|
}
|
||||||
else if (result.StartsWith(Global.trojanProtocol))
|
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Trojan]))
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
|
|
||||||
profileItem = ResolveTrojan(result);
|
profileItem = ResolveTrojan(result);
|
||||||
}
|
}
|
||||||
else if (result.StartsWith(Global.vlessProtocol))
|
else if (result.StartsWith(Global.ProtocolShares[EConfigType.VLESS]))
|
||||||
{
|
{
|
||||||
profileItem = ResolveStdVLESS(result);
|
profileItem = ResolveStdVLESS(result);
|
||||||
}
|
}
|
||||||
else if (result.StartsWith(Global.hysteria2Protocol) || result.StartsWith(Global.hysteria2Protocol2))
|
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Hysteria2]) || result.StartsWith(Global.Hysteria2ProtocolShare))
|
||||||
{
|
{
|
||||||
msg = ResUI.ConfigurationFormatIncorrect;
|
msg = ResUI.ConfigurationFormatIncorrect;
|
||||||
|
|
||||||
profileItem = ResolveHysteria2(result);
|
profileItem = ResolveHysteria2(result);
|
||||||
}
|
}
|
||||||
else if (result.StartsWith(Global.tuicProtocol))
|
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Tuic]))
|
||||||
{
|
{
|
||||||
profileItem = ResolveTuic(result);
|
profileItem = ResolveTuic(result);
|
||||||
}
|
}
|
||||||
|
@ -447,7 +447,7 @@ namespace v2rayN.Handler
|
||||||
configType = EConfigType.VMess
|
configType = EConfigType.VMess
|
||||||
};
|
};
|
||||||
|
|
||||||
result = result[Global.vmessProtocol.Length..];
|
result = result[Global.ProtocolShares[EConfigType.VMess].Length..];
|
||||||
result = Utils.Base64Decode(result);
|
result = Utils.Base64Decode(result);
|
||||||
|
|
||||||
//转成Json
|
//转成Json
|
||||||
|
@ -495,7 +495,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
configType = EConfigType.VMess
|
configType = EConfigType.VMess
|
||||||
};
|
};
|
||||||
result = result[Global.vmessProtocol.Length..];
|
result = result[Global.ProtocolShares[EConfigType.VMess].Length..];
|
||||||
int indexSplit = result.IndexOf("?");
|
int indexSplit = result.IndexOf("?");
|
||||||
if (indexSplit > 0)
|
if (indexSplit > 0)
|
||||||
{
|
{
|
||||||
|
@ -712,7 +712,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
configType = EConfigType.Socks
|
configType = EConfigType.Socks
|
||||||
};
|
};
|
||||||
result = result[Global.socksProtocol.Length..];
|
result = result[Global.ProtocolShares[EConfigType.Socks].Length..];
|
||||||
//remark
|
//remark
|
||||||
int indexRemark = result.IndexOf("#");
|
int indexRemark = result.IndexOf("#");
|
||||||
if (indexRemark > 0)
|
if (indexRemark > 0)
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
if (_channel == null)
|
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);
|
_client = new StatsService.StatsServiceClient(_channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace v2rayN.Handler
|
||||||
else if (type == ESysProxyType.Pac)
|
else if (type == ESysProxyType.Pac)
|
||||||
{
|
{
|
||||||
PacHandler.Start(Utils.GetConfigPath(), port, portPac);
|
PacHandler.Start(Utils.GetConfigPath(), port, portPac);
|
||||||
var strProxy = $"{Global.httpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
|
var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
|
||||||
ProxySetting.SetProxy(strProxy, "", 4); // use pac script url for auto-config proxy
|
ProxySetting.SetProxy(strProxy, "", 4); // use pac script url for auto-config proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ namespace v2rayN.Handler
|
||||||
//_updateFunc(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
|
//_updateFunc(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!url.StartsWith(Global.httpsProtocol) && !url.StartsWith(Global.httpProtocol))
|
if (!url.StartsWith(Global.HttpsProtocol) && !url.StartsWith(Global.HttpProtocol))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue