Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
559ffcbab5 | ||
|
|
80ed8346be | ||
|
|
a49455f330 | ||
|
|
c3de6f6d02 | ||
|
|
ee416b1bf2 | ||
|
|
784928ffc8 | ||
|
|
609360a1d0 | ||
|
|
18ce2f7b1c | ||
|
|
78625d82ae | ||
|
|
2ca34fb9ad | ||
|
|
f5f944aa50 | ||
|
|
83b4ab83d1 | ||
|
|
34f63f9006 | ||
|
|
b74188d904 | ||
|
|
51576b54c3 | ||
|
|
0d5a9fcf4a | ||
|
|
b0c5f74edb | ||
|
|
1ac7661593 | ||
|
|
caa2c523f4 | ||
|
|
7b9f1e6788 | ||
|
|
86f3ed29f9 | ||
|
|
655d411afe | ||
|
|
f5deb8e168 | ||
|
|
fcdb61bfbf | ||
|
|
bd9a4ca094 | ||
|
|
e2657e746d | ||
|
|
6f5a174231 |
16
.github/workflows/build.yml
vendored
16
.github/workflows/build.yml
vendored
@@ -18,13 +18,13 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 删除工作流运行
|
||||
uses: Mattraks/delete-workflow-runs@v2
|
||||
with:
|
||||
token: ${{ github.token }}
|
||||
repository: ${{ github.repository }}
|
||||
retain_days: 0
|
||||
keep_minimum_runs: 1
|
||||
# - name: 删除工作流运行
|
||||
# uses: Mattraks/delete-workflow-runs@v2
|
||||
# with:
|
||||
# token: ${{ github.token }}
|
||||
# repository: ${{ github.repository }}
|
||||
# retain_days: 0
|
||||
# keep_minimum_runs: 1
|
||||
|
||||
- name: Build
|
||||
run: cd v2rayN &&
|
||||
@@ -58,4 +58,4 @@ jobs:
|
||||
# * This is an automated deployment of GitHub Actions, the change log should be updated manually soon
|
||||
|
||||
# ## 更新日志
|
||||
# * 这是 GitHub Actions 自动化部署,更新日志应该很快会手动更新
|
||||
# * 这是 GitHub Actions 自动化部署,更新日志应该很快会手动更新
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.25.1" />
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.59.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.59.0">
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.60.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.60.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -34,6 +34,12 @@
|
||||
Left="8"
|
||||
Right="8"
|
||||
Top="8" />
|
||||
<Thickness
|
||||
x:Key="OutlinedTextBoxDefaultPadding"
|
||||
Bottom="12"
|
||||
Left="16"
|
||||
Right="12"
|
||||
Top="12" />
|
||||
<Style
|
||||
x:Key="ModuleTitle"
|
||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||
@@ -129,6 +135,7 @@
|
||||
BasedOn="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||
TargetType="{x:Type TextBox}">
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize}" />
|
||||
<Setter Property="Padding" Value="{StaticResource OutlinedTextBoxDefaultPadding}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="MyGroupBox"
|
||||
@@ -142,6 +149,13 @@
|
||||
TargetType="{x:Type ListBoxItem}">
|
||||
<Setter Property="Margin" Value="-2,0" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="MyOutlinedTextComboBox"
|
||||
BasedOn="{StaticResource MaterialDesignOutlinedComboBox}"
|
||||
TargetType="{x:Type ComboBox}">
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize}" />
|
||||
<Setter Property="Padding" Value="{StaticResource OutlinedTextBoxDefaultPadding}" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -40,7 +40,7 @@ namespace v2rayN
|
||||
return;
|
||||
}
|
||||
|
||||
Global.processJob = new Job();
|
||||
Global.ProcessJob = new Job();
|
||||
|
||||
Logging.Setup();
|
||||
Init();
|
||||
|
||||
@@ -1,47 +1,50 @@
|
||||
namespace v2rayN
|
||||
using v2rayN.Mode;
|
||||
|
||||
namespace v2rayN
|
||||
{
|
||||
internal class Global
|
||||
{
|
||||
#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 MihomoCoreUrl = "https://github.com/MetaCubeX/mihomo/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 v2raySampleClient = "v2rayN.Sample.SampleClientConfig";
|
||||
public const string CoreConfigFileName = "config.json";
|
||||
public const string CorePreConfigFileName = "configPre.json";
|
||||
public const string CoreSpeedtestConfigFileName = "configSpeedtest.json";
|
||||
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 V2raySampleOutbound = "v2rayN.Sample.SampleOutbound";
|
||||
public const string SingboxSampleOutbound = "v2rayN.Sample.SingboxSampleOutbound";
|
||||
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";
|
||||
|
||||
public const string TunSingboxDNSFileName = "v2rayN.Sample.tun_singbox_dns";
|
||||
public const string TunSingboxInboundFileName = "v2rayN.Sample.tun_singbox_inbound";
|
||||
public const string TunSingboxRulesFileName = "v2rayN.Sample.tun_singbox_rules";
|
||||
|
||||
public const string DNSV2rayNormalFileName = "v2rayN.Sample.dns_v2ray_normal";
|
||||
public const string DNSSingboxNormalFileName = "v2rayN.Sample.dns_singbox_normal";
|
||||
|
||||
@@ -49,9 +52,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";
|
||||
@@ -61,24 +64,10 @@
|
||||
public const string Loopback = "127.0.0.1";
|
||||
public const string InboundAPITagName = "api";
|
||||
public const string InboundAPIProtocal = "dokodemo-door";
|
||||
public const string HttpProtocol = "http://";
|
||||
public const string HttpsProtocol = "https://";
|
||||
|
||||
public const string vmessProtocol = "vmess://";
|
||||
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 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";
|
||||
@@ -130,7 +119,7 @@
|
||||
@"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" },
|
||||
{"firefox","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0" },
|
||||
@@ -139,39 +128,64 @@
|
||||
{"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 const string Hysteria2ProtocolShare = "hy2://";
|
||||
|
||||
public static readonly List<string> allowInsecures = new() { "true", "false", "" };
|
||||
public static readonly List<string> domainStrategy4Freedoms = new() { "AsIs", "UseIP", "UseIPv4", "UseIPv6", "" };
|
||||
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> 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> 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> 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; }
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace v2rayN.Handler
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
public static int LoadConfig(ref Config config)
|
||||
public static int LoadConfig(ref Config? config)
|
||||
{
|
||||
//载入配置文件
|
||||
string result = Utils.LoadResource(Utils.GetConfigPath(configRes));
|
||||
var result = Utils.LoadResource(Utils.GetConfigPath(configRes));
|
||||
if (!Utils.IsNullOrEmpty(result))
|
||||
{
|
||||
//转成Json
|
||||
@@ -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))
|
||||
//{
|
||||
@@ -214,7 +214,7 @@ namespace v2rayN.Handler
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
public static int SaveConfig(ref Config config, bool reload = true)
|
||||
public static int SaveConfig(Config config, bool reload = true)
|
||||
{
|
||||
ToJsonFile(config);
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
public static int ImportOldGuiConfig(ref Config config, string fileName)
|
||||
public static int ImportOldGuiConfig(Config config, string fileName)
|
||||
{
|
||||
string result = Utils.LoadResource(fileName);
|
||||
if (Utils.IsNullOrEmpty(result))
|
||||
@@ -343,9 +343,9 @@ namespace v2rayN.Handler
|
||||
};
|
||||
}
|
||||
|
||||
GetDefaultServer(ref config);
|
||||
GetDefaultRouting(ref config);
|
||||
SaveConfig(ref config);
|
||||
GetDefaultServer(config);
|
||||
GetDefaultRouting(config);
|
||||
SaveConfig(config);
|
||||
LoadConfig(ref config);
|
||||
|
||||
return 0;
|
||||
@@ -361,7 +361,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddServer(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.VMess;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -383,7 +383,7 @@ namespace v2rayN.Handler
|
||||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
|
||||
SqliteHelper.Instance.UpdateAll(indexs);
|
||||
RemoveServerViaSubid(ref config, subid, false);
|
||||
RemoveServerViaSubid(config, subid, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -414,7 +414,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public static int CopyServer(ref Config config, List<ProfileItem> indexs)
|
||||
public static int CopyServer(Config config, List<ProfileItem> indexs)
|
||||
{
|
||||
foreach (var it in indexs)
|
||||
{
|
||||
@@ -431,13 +431,13 @@ namespace v2rayN.Handler
|
||||
if (profileItem.configType == EConfigType.Custom)
|
||||
{
|
||||
profileItem.address = Utils.GetConfigPath(profileItem.address);
|
||||
if (AddCustomServer(ref config, profileItem, false) == 0)
|
||||
if (AddCustomServer(config, profileItem, false) == 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddServerCommon(ref config, profileItem, true);
|
||||
AddServerCommon(config, profileItem, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,7 +450,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public static int SetDefaultServerIndex(ref Config config, string? indexId)
|
||||
public static int SetDefaultServerIndex(Config config, string? indexId)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(indexId))
|
||||
{
|
||||
@@ -476,18 +476,18 @@ namespace v2rayN.Handler
|
||||
}
|
||||
if (lstProfile.Count > 0)
|
||||
{
|
||||
return SetDefaultServerIndex(ref config, lstProfile.Where(t => t.port > 0).FirstOrDefault()?.indexId);
|
||||
return SetDefaultServerIndex(config, lstProfile.Where(t => t.port > 0).FirstOrDefault()?.indexId);
|
||||
}
|
||||
return SetDefaultServerIndex(ref config, SqliteHelper.Instance.Table<ProfileItem>().Where(t => t.port > 0).Select(t => t.indexId).FirstOrDefault());
|
||||
return SetDefaultServerIndex(config, SqliteHelper.Instance.Table<ProfileItem>().Where(t => t.port > 0).Select(t => t.indexId).FirstOrDefault());
|
||||
}
|
||||
|
||||
public static ProfileItem? GetDefaultServer(ref Config config)
|
||||
public static ProfileItem? GetDefaultServer(Config config)
|
||||
{
|
||||
var item = LazyConfig.Instance.GetProfileItem(config.indexId);
|
||||
if (item is null)
|
||||
{
|
||||
var item2 = SqliteHelper.Instance.Table<ProfileItem>().FirstOrDefault();
|
||||
SetDefaultServerIndex(ref config, item2?.indexId);
|
||||
SetDefaultServerIndex(config, item2?.indexId);
|
||||
return item2;
|
||||
}
|
||||
|
||||
@@ -502,7 +502,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="index"></param>
|
||||
/// <param name="eMove"></param>
|
||||
/// <returns></returns>
|
||||
public static int MoveServer(ref Config config, ref List<ProfileItem> lstProfile, int index, EMove eMove, int pos = -1)
|
||||
public static int MoveServer(Config config, ref List<ProfileItem> lstProfile, int index, EMove eMove, int pos = -1)
|
||||
{
|
||||
int count = lstProfile.Count;
|
||||
if (index < 0 || index > lstProfile.Count - 1)
|
||||
@@ -574,7 +574,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddCustomServer(ref Config config, ProfileItem profileItem, bool blDelete)
|
||||
public static int AddCustomServer(Config config, ProfileItem profileItem, bool blDelete)
|
||||
{
|
||||
var fileName = profileItem.address;
|
||||
if (!File.Exists(fileName))
|
||||
@@ -606,7 +606,7 @@ namespace v2rayN.Handler
|
||||
profileItem.remarks = $"import custom@{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}";
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, true);
|
||||
AddServerCommon(config, profileItem, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -617,7 +617,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int EditCustomServer(ref Config config, ProfileItem profileItem)
|
||||
public static int EditCustomServer(Config config, ProfileItem profileItem)
|
||||
{
|
||||
if (SqliteHelper.Instance.Update(profileItem) > 0)
|
||||
{
|
||||
@@ -637,7 +637,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddShadowsocksServer(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddShadowsocksServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.Shadowsocks;
|
||||
|
||||
@@ -654,7 +654,7 @@ namespace v2rayN.Handler
|
||||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -665,13 +665,13 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddSocksServer(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddSocksServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.Socks;
|
||||
|
||||
profileItem.address = profileItem.address.TrimEx();
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -682,7 +682,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddTrojanServer(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddTrojanServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.Trojan;
|
||||
|
||||
@@ -697,7 +697,7 @@ namespace v2rayN.Handler
|
||||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -708,13 +708,15 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddHysteria2Server(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddHysteria2Server(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.Hysteria2;
|
||||
profileItem.coreType = ECoreType.sing_box;
|
||||
|
||||
profileItem.address = profileItem.address.TrimEx();
|
||||
profileItem.id = profileItem.id.TrimEx();
|
||||
profileItem.network = string.Empty;
|
||||
|
||||
if (Utils.IsNullOrEmpty(profileItem.streamSecurity))
|
||||
{
|
||||
profileItem.streamSecurity = Global.StreamSecurity;
|
||||
@@ -724,12 +726,51 @@ namespace v2rayN.Handler
|
||||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int SortServers(ref Config config, string subId, string colName, bool asc)
|
||||
/// <summary>
|
||||
/// Add or edit server
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddTuicServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.Tuic;
|
||||
profileItem.coreType = ECoreType.sing_box;
|
||||
|
||||
profileItem.address = profileItem.address.TrimEx();
|
||||
profileItem.id = profileItem.id.TrimEx();
|
||||
profileItem.security = profileItem.security.TrimEx();
|
||||
profileItem.network = string.Empty;
|
||||
|
||||
if (!Global.TuicCongestionControls.Contains(profileItem.headerType))
|
||||
{
|
||||
profileItem.headerType = Global.TuicCongestionControls.FirstOrDefault()!;
|
||||
}
|
||||
|
||||
if (Utils.IsNullOrEmpty(profileItem.streamSecurity))
|
||||
{
|
||||
profileItem.streamSecurity = Global.StreamSecurity;
|
||||
}
|
||||
if (Utils.IsNullOrEmpty(profileItem.alpn))
|
||||
{
|
||||
profileItem.alpn = "h3";
|
||||
}
|
||||
if (profileItem.id.IsNullOrEmpty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int SortServers(Config config, string subId, string colName, bool asc)
|
||||
{
|
||||
var lstModel = LazyConfig.Instance.ProfileItems(subId, "");
|
||||
if (lstModel.Count <= 0)
|
||||
@@ -831,7 +872,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddVlessServer(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddVlessServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.VLESS;
|
||||
|
||||
@@ -844,16 +885,16 @@ 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())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -882,7 +923,7 @@ namespace v2rayN.Handler
|
||||
return new Tuple<int, int>(lstProfile.Count, lstKeep.Count);
|
||||
}
|
||||
|
||||
public static int AddServerCommon(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddServerCommon(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configVersion = 2;
|
||||
|
||||
@@ -898,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;
|
||||
}
|
||||
@@ -983,7 +1024,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="clipboardData"></param>
|
||||
/// <param name="subid"></param>
|
||||
/// <returns>成功导入的数量</returns>
|
||||
private static int AddBatchServers(ref Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
private static int AddBatchServers(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(clipboardData))
|
||||
{
|
||||
@@ -994,7 +1035,7 @@ namespace v2rayN.Handler
|
||||
//remove sub items
|
||||
if (isSub && !Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
RemoveServerViaSubid(ref config, subid, isSub);
|
||||
RemoveServerViaSubid(config, subid, isSub);
|
||||
subFilter = LazyConfig.Instance.GetSubItem(subid)?.filter ?? "";
|
||||
}
|
||||
|
||||
@@ -1010,9 +1051,9 @@ namespace v2rayN.Handler
|
||||
foreach (string str in arrData)
|
||||
{
|
||||
//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(config, str) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
@@ -1060,27 +1101,31 @@ namespace v2rayN.Handler
|
||||
|
||||
if (profileItem.configType == EConfigType.VMess)
|
||||
{
|
||||
addStatus = AddServer(ref config, profileItem, false);
|
||||
addStatus = AddServer(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.Shadowsocks)
|
||||
{
|
||||
addStatus = AddShadowsocksServer(ref config, profileItem, false);
|
||||
addStatus = AddShadowsocksServer(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.Socks)
|
||||
{
|
||||
addStatus = AddSocksServer(ref config, profileItem, false);
|
||||
addStatus = AddSocksServer(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.Trojan)
|
||||
{
|
||||
addStatus = AddTrojanServer(ref config, profileItem, false);
|
||||
addStatus = AddTrojanServer(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.VLESS)
|
||||
{
|
||||
addStatus = AddVlessServer(ref config, profileItem, false);
|
||||
addStatus = AddVlessServer(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.Hysteria2)
|
||||
{
|
||||
addStatus = AddHysteria2Server(ref config, profileItem, false);
|
||||
addStatus = AddHysteria2Server(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.Tuic)
|
||||
{
|
||||
addStatus = AddTuicServer(config, profileItem, false);
|
||||
}
|
||||
|
||||
if (addStatus == 0)
|
||||
@@ -1099,7 +1144,7 @@ namespace v2rayN.Handler
|
||||
return countServers;
|
||||
}
|
||||
|
||||
private static int AddBatchServers4Custom(ref Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
private static int AddBatchServers4Custom(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(clipboardData))
|
||||
{
|
||||
@@ -1135,7 +1180,7 @@ namespace v2rayN.Handler
|
||||
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.yaml");
|
||||
File.WriteAllText(fileName, clipboardData);
|
||||
|
||||
profileItem.coreType = ECoreType.clash;
|
||||
profileItem.coreType = ECoreType.mihomo;
|
||||
profileItem.address = fileName;
|
||||
profileItem.remarks = "clash_custom";
|
||||
}
|
||||
@@ -1172,7 +1217,7 @@ namespace v2rayN.Handler
|
||||
|
||||
if (isSub && !Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
RemoveServerViaSubid(ref config, subid, isSub);
|
||||
RemoveServerViaSubid(config, subid, isSub);
|
||||
}
|
||||
if (isSub && lstOriSub?.Count == 1)
|
||||
{
|
||||
@@ -1186,7 +1231,7 @@ namespace v2rayN.Handler
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (AddCustomServer(ref config, profileItem, true) == 0)
|
||||
if (AddCustomServer(config, profileItem, true) == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -1196,7 +1241,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
private static int AddBatchServers4SsSIP008(ref Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
private static int AddBatchServers4SsSIP008(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(clipboardData))
|
||||
{
|
||||
@@ -1205,7 +1250,7 @@ namespace v2rayN.Handler
|
||||
|
||||
if (isSub && !Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
RemoveServerViaSubid(ref config, subid, isSub);
|
||||
RemoveServerViaSubid(config, subid, isSub);
|
||||
}
|
||||
|
||||
//SsSIP008
|
||||
@@ -1235,7 +1280,7 @@ namespace v2rayN.Handler
|
||||
};
|
||||
ssItem.subid = subid;
|
||||
ssItem.isSub = isSub;
|
||||
if (AddShadowsocksServer(ref config, ssItem) == 0)
|
||||
if (AddShadowsocksServer(config, ssItem) == 0)
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
@@ -1247,7 +1292,7 @@ namespace v2rayN.Handler
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int AddBatchServers(ref Config config, string clipboardData, string subid, bool isSub)
|
||||
public static int AddBatchServers(Config config, string clipboardData, string subid, bool isSub)
|
||||
{
|
||||
List<ProfileItem>? lstOriSub = null;
|
||||
if (isSub && !Utils.IsNullOrEmpty(subid))
|
||||
@@ -1258,26 +1303,26 @@ namespace v2rayN.Handler
|
||||
var counter = 0;
|
||||
if (Utils.IsBase64String(clipboardData))
|
||||
{
|
||||
counter = AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
|
||||
counter = AddBatchServers(config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
|
||||
}
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = AddBatchServers(ref config, clipboardData, subid, isSub, lstOriSub);
|
||||
counter = AddBatchServers(config, clipboardData, subid, isSub, lstOriSub);
|
||||
}
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
|
||||
counter = AddBatchServers(config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
|
||||
}
|
||||
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = AddBatchServers4SsSIP008(ref config, clipboardData, subid, isSub, lstOriSub);
|
||||
counter = AddBatchServers4SsSIP008(config, clipboardData, subid, isSub, lstOriSub);
|
||||
}
|
||||
|
||||
//maybe other sub
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = AddBatchServers4Custom(ref config, clipboardData, subid, isSub, lstOriSub);
|
||||
counter = AddBatchServers4Custom(config, clipboardData, subid, isSub, lstOriSub);
|
||||
}
|
||||
|
||||
return counter;
|
||||
@@ -1293,7 +1338,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddSubItem(ref Config config, string url)
|
||||
public static int AddSubItem(Config config, string url)
|
||||
{
|
||||
//already exists
|
||||
if (SqliteHelper.Instance.Table<SubItem>().Where(e => e.url == url).Count() > 0)
|
||||
@@ -1308,10 +1353,10 @@ namespace v2rayN.Handler
|
||||
url = url
|
||||
};
|
||||
|
||||
return AddSubItem(ref config, subItem);
|
||||
return AddSubItem(config, subItem);
|
||||
}
|
||||
|
||||
public static int AddSubItem(ref Config config, SubItem subItem)
|
||||
public static int AddSubItem(Config config, SubItem subItem)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(subItem.id))
|
||||
{
|
||||
@@ -1343,7 +1388,7 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="subid"></param>
|
||||
/// <returns></returns>
|
||||
public static int RemoveServerViaSubid(ref Config config, string subid, bool isSub)
|
||||
public static int RemoveServerViaSubid(Config config, string subid, bool isSub)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
@@ -1366,7 +1411,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int DeleteSubItem(ref Config config, string id)
|
||||
public static int DeleteSubItem(Config config, string id)
|
||||
{
|
||||
var item = LazyConfig.Instance.GetSubItem(id);
|
||||
if (item is null)
|
||||
@@ -1374,7 +1419,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
SqliteHelper.Instance.Delete(item);
|
||||
RemoveServerViaSubid(ref config, id, false);
|
||||
RemoveServerViaSubid(config, id, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1394,7 +1439,7 @@ namespace v2rayN.Handler
|
||||
|
||||
#region Routing
|
||||
|
||||
public static int SaveRoutingItem(ref Config config, RoutingItem item)
|
||||
public static int SaveRoutingItem(Config config, RoutingItem item)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(item.id))
|
||||
{
|
||||
@@ -1529,7 +1574,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int SetDefaultRouting(ref Config config, RoutingItem routingItem)
|
||||
public static int SetDefaultRouting(Config config, RoutingItem routingItem)
|
||||
{
|
||||
if (SqliteHelper.Instance.Table<RoutingItem>().Where(t => t.id == routingItem.id).Count() > 0)
|
||||
{
|
||||
@@ -1541,20 +1586,20 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static RoutingItem GetDefaultRouting(ref Config config)
|
||||
public static RoutingItem GetDefaultRouting(Config config)
|
||||
{
|
||||
var item = LazyConfig.Instance.GetRoutingItem(config.routingBasicItem.routingIndexId);
|
||||
if (item is null)
|
||||
{
|
||||
var item2 = SqliteHelper.Instance.Table<RoutingItem>().FirstOrDefault(t => t.locked == false);
|
||||
SetDefaultRouting(ref config, item2);
|
||||
SetDefaultRouting(config, item2);
|
||||
return item2;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static int InitBuiltinRouting(ref Config config, bool blImportAdvancedRules = false)
|
||||
public static int InitBuiltinRouting(Config config, bool blImportAdvancedRules = false)
|
||||
{
|
||||
var items = LazyConfig.Instance.RoutingItems();
|
||||
if (blImportAdvancedRules || items.Count <= 0)
|
||||
@@ -1589,11 +1634,11 @@ namespace v2rayN.Handler
|
||||
|
||||
if (!blImportAdvancedRules)
|
||||
{
|
||||
SetDefaultRouting(ref config, item2);
|
||||
SetDefaultRouting(config, item2);
|
||||
}
|
||||
}
|
||||
|
||||
if (GetLockedRoutingItem(ref config) == null)
|
||||
if (GetLockedRoutingItem(config) == null)
|
||||
{
|
||||
var item1 = new RoutingItem()
|
||||
{
|
||||
@@ -1606,7 +1651,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static RoutingItem GetLockedRoutingItem(ref Config config)
|
||||
public static RoutingItem GetLockedRoutingItem(Config config)
|
||||
{
|
||||
return SqliteHelper.Instance.Table<RoutingItem>().FirstOrDefault(it => it.locked == true);
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ namespace v2rayN.Handler
|
||||
|
||||
case ECoreType.clash:
|
||||
case ECoreType.clash_meta:
|
||||
case ECoreType.mihomo:
|
||||
//remove the original
|
||||
var indexPort = fileContent.FindIndex(t => t.Contains("port:"));
|
||||
if (indexPort >= 0)
|
||||
@@ -149,10 +150,26 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static string GenerateClientSpeedtestConfigString(Config config, List<ServerTestItem> selecteds, out string msg)
|
||||
public static int GenerateClientSpeedtestConfig(Config config, string fileName, List<ServerTestItem> selecteds, ECoreType coreType, out string msg)
|
||||
{
|
||||
var coreConfigV2ray = new CoreConfigV2ray(config);
|
||||
return coreConfigV2ray.GenerateClientSpeedtestConfigString(selecteds, out msg);
|
||||
if (coreType == ECoreType.sing_box)
|
||||
{
|
||||
if ((new CoreConfigSingbox(config)).GenerateClientSpeedtestConfig(selecteds, out SingboxConfig? singboxConfig, out msg) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
Utils.ToJsonFile(singboxConfig, fileName, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((new CoreConfigV2ray(config)).GenerateClientSpeedtestConfig(selecteds, out V2rayConfig? v2rayConfig, out msg) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
Utils.ToJsonFile(v2rayConfig, fileName, false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using v2rayN.Base;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using v2rayN.Base;
|
||||
using v2rayN.Mode;
|
||||
using v2rayN.Resx;
|
||||
|
||||
@@ -6,7 +8,6 @@ namespace v2rayN.Handler
|
||||
{
|
||||
internal class CoreConfigSingbox
|
||||
{
|
||||
private string SampleClient = Global.SingboxSampleClient;
|
||||
private Config _config;
|
||||
|
||||
public CoreConfigSingbox(Config config)
|
||||
@@ -28,7 +29,7 @@ namespace v2rayN.Handler
|
||||
|
||||
msg = ResUI.InitialConfiguration;
|
||||
|
||||
string result = Utils.GetEmbedText(SampleClient);
|
||||
string result = Utils.GetEmbedText(Global.SingboxSampleClient);
|
||||
if (Utils.IsNullOrEmpty(result))
|
||||
{
|
||||
msg = ResUI.FailedGetDefaultConfiguration;
|
||||
@@ -42,17 +43,19 @@ namespace v2rayN.Handler
|
||||
return -1;
|
||||
}
|
||||
|
||||
log(singboxConfig);
|
||||
GenLog(singboxConfig);
|
||||
|
||||
inbound(singboxConfig);
|
||||
GenInbounds(singboxConfig);
|
||||
|
||||
outbound(node, singboxConfig);
|
||||
GenOutbound(node, singboxConfig.outbounds[0]);
|
||||
|
||||
routing(singboxConfig);
|
||||
GenMoreOutbounds(node, singboxConfig);
|
||||
|
||||
dns(node, singboxConfig);
|
||||
GenRouting(singboxConfig);
|
||||
|
||||
statistic(singboxConfig);
|
||||
GenDns(node, singboxConfig);
|
||||
|
||||
GenStatistic(singboxConfig);
|
||||
|
||||
msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
}
|
||||
@@ -65,7 +68,9 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int log(SingboxConfig singboxConfig)
|
||||
#region private gen function
|
||||
|
||||
private int GenLog(SingboxConfig singboxConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -101,9 +106,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
#region inbound private
|
||||
|
||||
private int inbound(SingboxConfig singboxConfig)
|
||||
private int GenInbounds(SingboxConfig singboxConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -126,7 +129,7 @@ namespace v2rayN.Handler
|
||||
|
||||
if (_config.routingBasicItem.enableRoutingAdvanced)
|
||||
{
|
||||
var routing = ConfigHandler.GetDefaultRouting(ref _config);
|
||||
var routing = ConfigHandler.GetDefaultRouting(_config);
|
||||
if (!Utils.IsNullOrEmpty(routing.domainStrategy4Singbox))
|
||||
{
|
||||
inbound.domain_strategy = routing.domainStrategy4Singbox;
|
||||
@@ -179,6 +182,10 @@ namespace v2rayN.Handler
|
||||
tunInbound.mtu = _config.tunModeItem.mtu;
|
||||
tunInbound.strict_route = _config.tunModeItem.strictRoute;
|
||||
tunInbound.stack = _config.tunModeItem.stack;
|
||||
if (_config.tunModeItem.enableIPv6Address == false)
|
||||
{
|
||||
tunInbound.inet6_address = null;
|
||||
}
|
||||
|
||||
singboxConfig.inbounds.Add(tunInbound);
|
||||
}
|
||||
@@ -199,34 +206,20 @@ namespace v2rayN.Handler
|
||||
return inbound;
|
||||
}
|
||||
|
||||
#endregion inbound private
|
||||
|
||||
#region outbound private
|
||||
|
||||
private int outbound(ProfileItem node, SingboxConfig singboxConfig)
|
||||
private int GenOutbound(ProfileItem node, Outbound4Sbox outbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_config.tunModeItem.enableTun)
|
||||
{
|
||||
singboxConfig.outbounds.Add(new()
|
||||
{
|
||||
type = "dns",
|
||||
tag = "dns_out"
|
||||
});
|
||||
}
|
||||
|
||||
var outbound = singboxConfig.outbounds[0];
|
||||
outbound.server = node.address;
|
||||
outbound.server_port = node.port;
|
||||
|
||||
if (node.configType == EConfigType.VMess)
|
||||
{
|
||||
outbound.type = Global.vmessProtocolLite;
|
||||
outbound.type = Global.ProtocolTypes[EConfigType.VMess];
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -235,20 +228,20 @@ namespace v2rayN.Handler
|
||||
outbound.security = Global.DefaultSecurity;
|
||||
}
|
||||
|
||||
outboundMux(node, outbound);
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
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.password = node.id;
|
||||
|
||||
outboundMux(node, outbound);
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
else if (node.configType == EConfigType.Socks)
|
||||
{
|
||||
outbound.type = Global.socksProtocolLite;
|
||||
outbound.type = Global.ProtocolTypes[EConfigType.Socks];
|
||||
|
||||
outbound.version = "5";
|
||||
if (!Utils.IsNullOrEmpty(node.security)
|
||||
@@ -260,7 +253,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
else if (node.configType == EConfigType.VLESS)
|
||||
{
|
||||
outbound.type = Global.vlessProtocolLite;
|
||||
outbound.type = Global.ProtocolTypes[EConfigType.VLESS];
|
||||
|
||||
outbound.uuid = node.id;
|
||||
|
||||
@@ -268,7 +261,7 @@ namespace v2rayN.Handler
|
||||
|
||||
if (Utils.IsNullOrEmpty(node.flow))
|
||||
{
|
||||
outboundMux(node, outbound);
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -277,27 +270,37 @@ namespace v2rayN.Handler
|
||||
}
|
||||
else if (node.configType == EConfigType.Trojan)
|
||||
{
|
||||
outbound.type = Global.trojanProtocolLite;
|
||||
outbound.type = Global.ProtocolTypes[EConfigType.Trojan];
|
||||
|
||||
outbound.password = node.id;
|
||||
|
||||
outboundMux(node, outbound);
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
else if (node.configType == EConfigType.Hysteria2)
|
||||
{
|
||||
outbound.type = Global.hysteria2ProtocolLite;
|
||||
outbound.type = Global.ProtocolTypes[EConfigType.Hysteria2];
|
||||
|
||||
outbound.password = node.id;
|
||||
|
||||
outbound.up_mbps = _config.hysteriaItem.up_mbps > 0 ? _config.hysteriaItem.up_mbps : null;
|
||||
outbound.down_mbps = _config.hysteriaItem.down_mbps > 0 ? _config.hysteriaItem.down_mbps : null;
|
||||
|
||||
outboundMux(node, outbound);
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
else if (node.configType == EConfigType.Tuic)
|
||||
{
|
||||
outbound.type = Global.ProtocolTypes[EConfigType.Tuic];
|
||||
|
||||
outbound.uuid = node.id;
|
||||
outbound.password = node.security;
|
||||
outbound.congestion_control = node.headerType;
|
||||
|
||||
GenOutboundMux(node, outbound);
|
||||
}
|
||||
|
||||
outboundTls(node, outbound);
|
||||
GenOutboundTls(node, outbound);
|
||||
|
||||
outboundTransport(node, outbound);
|
||||
GenOutboundTransport(node, outbound);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -306,7 +309,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int outboundMux(ProfileItem node, Outbound4Sbox outbound)
|
||||
private int GenOutboundMux(ProfileItem node, Outbound4Sbox outbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -331,7 +334,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int outboundTls(ProfileItem node, Outbound4Sbox outbound)
|
||||
private int GenOutboundTls(ProfileItem node, Outbound4Sbox outbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -381,7 +384,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int outboundTransport(ProfileItem node, Outbound4Sbox outbound)
|
||||
private int GenOutboundTransport(ProfileItem node, Outbound4Sbox outbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -433,11 +436,60 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion outbound private
|
||||
private int GenMoreOutbounds(ProfileItem node, SingboxConfig singboxConfig)
|
||||
{
|
||||
if (node.subid.IsNullOrEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
try
|
||||
{
|
||||
var subItem = LazyConfig.Instance.GetSubItem(node.subid);
|
||||
if (subItem is null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#region routing rule private
|
||||
//current proxy
|
||||
var outbound = singboxConfig.outbounds[0];
|
||||
var txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
|
||||
|
||||
private int routing(SingboxConfig singboxConfig)
|
||||
//Previous proxy
|
||||
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);
|
||||
if (prevNode is not null
|
||||
&& prevNode.configType != EConfigType.Custom)
|
||||
{
|
||||
var prevOutbound = Utils.FromJson<Outbound4Sbox>(txtOutbound);
|
||||
GenOutbound(prevNode, prevOutbound);
|
||||
prevOutbound.tag = $"{Global.ProxyTag}2";
|
||||
singboxConfig.outbounds.Add(prevOutbound);
|
||||
|
||||
outbound.detour = prevOutbound.tag;
|
||||
}
|
||||
|
||||
//Next proxy
|
||||
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile!);
|
||||
if (nextNode is not null
|
||||
&& nextNode.configType != EConfigType.Custom)
|
||||
{
|
||||
var nextOutbound = Utils.FromJson<Outbound4Sbox>(txtOutbound);
|
||||
GenOutbound(nextNode, nextOutbound);
|
||||
nextOutbound.tag = Global.ProxyTag;
|
||||
singboxConfig.outbounds.Insert(0, nextOutbound);
|
||||
|
||||
outbound.tag = $"{Global.ProxyTag}1";
|
||||
nextOutbound.detour = outbound.tag;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int GenRouting(SingboxConfig singboxConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -448,7 +500,7 @@ namespace v2rayN.Handler
|
||||
var tunRules = Utils.FromJson<List<Rule4Sbox>>(Utils.GetEmbedText(Global.TunSingboxRulesFileName));
|
||||
singboxConfig.route.rules.AddRange(tunRules);
|
||||
|
||||
routingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe);
|
||||
GenRoutingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe);
|
||||
singboxConfig.route.rules.Add(new()
|
||||
{
|
||||
port = new() { 53 },
|
||||
@@ -465,7 +517,7 @@ namespace v2rayN.Handler
|
||||
|
||||
if (_config.routingBasicItem.enableRoutingAdvanced)
|
||||
{
|
||||
var routing = ConfigHandler.GetDefaultRouting(ref _config);
|
||||
var routing = ConfigHandler.GetDefaultRouting(_config);
|
||||
if (routing != null)
|
||||
{
|
||||
var rules = Utils.FromJson<List<RulesItem>>(routing.ruleSet);
|
||||
@@ -473,20 +525,20 @@ namespace v2rayN.Handler
|
||||
{
|
||||
if (item.enabled)
|
||||
{
|
||||
routingUserRule(item, singboxConfig.route.rules);
|
||||
GenRoutingUserRule(item, singboxConfig.route.rules);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var lockedItem = ConfigHandler.GetLockedRoutingItem(ref _config);
|
||||
var lockedItem = ConfigHandler.GetLockedRoutingItem(_config);
|
||||
if (lockedItem != null)
|
||||
{
|
||||
var rules = Utils.FromJson<List<RulesItem>>(lockedItem.ruleSet);
|
||||
foreach (var item in rules!)
|
||||
{
|
||||
routingUserRule(item, singboxConfig.route.rules);
|
||||
GenRoutingUserRule(item, singboxConfig.route.rules);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -498,7 +550,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void routingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe)
|
||||
private void GenRoutingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe)
|
||||
{
|
||||
lstDnsExe = new();
|
||||
lstDirectExe = new();
|
||||
@@ -524,7 +576,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
private int routingUserRule(RulesItem item, List<Rule4Sbox> rules)
|
||||
private int GenRoutingUserRule(RulesItem item, List<Rule4Sbox> rules)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -565,7 +617,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
foreach (var it in item.domain)
|
||||
{
|
||||
parseV2Domain(it, rule);
|
||||
ParseV2Domain(it, rule);
|
||||
}
|
||||
rules.Add(rule);
|
||||
hasDomainIp = true;
|
||||
@@ -575,7 +627,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
foreach (var it in item.ip)
|
||||
{
|
||||
parseV2Address(it, rule2);
|
||||
ParseV2Address(it, rule2);
|
||||
}
|
||||
rules.Add(rule2);
|
||||
hasDomainIp = true;
|
||||
@@ -600,7 +652,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void parseV2Domain(string domain, Rule4Sbox rule)
|
||||
private void ParseV2Domain(string domain, Rule4Sbox rule)
|
||||
{
|
||||
if (domain.StartsWith("ext:") || domain.StartsWith("ext-domain:"))
|
||||
{
|
||||
@@ -640,7 +692,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
private void parseV2Address(string address, Rule4Sbox rule)
|
||||
private void ParseV2Address(string address, Rule4Sbox rule)
|
||||
{
|
||||
if (address.StartsWith("ext:") || address.StartsWith("ext-ip:"))
|
||||
{
|
||||
@@ -662,11 +714,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
#endregion routing rule private
|
||||
|
||||
#region dns private
|
||||
|
||||
private int dns(ProfileItem node, SingboxConfig singboxConfig)
|
||||
private int GenDns(ProfileItem node, SingboxConfig singboxConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -722,30 +770,181 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion dns private
|
||||
|
||||
private int statistic(SingboxConfig singboxConfig)
|
||||
private int GenStatistic(SingboxConfig singboxConfig)
|
||||
{
|
||||
if (_config.guiItem.enableStatistics)
|
||||
{
|
||||
singboxConfig.experimental = new Experimental4Sbox()
|
||||
{
|
||||
//cache_file = new CacheFile4Sbox()
|
||||
//{
|
||||
// enabled = true
|
||||
//},
|
||||
//v2ray_api = new V2ray_Api4Sbox()
|
||||
//{
|
||||
// listen = $"{Global.Loopback}:{Global.statePort}",
|
||||
// listen = $"{Global.Loopback}:{Global.StatePort}",
|
||||
// stats = new Stats4Sbox()
|
||||
// {
|
||||
// enabled = true,
|
||||
// }
|
||||
//}
|
||||
//},
|
||||
clash_api = new Clash_Api4Sbox()
|
||||
{
|
||||
external_controller = $"{Global.Loopback}:{Global.statePort}",
|
||||
store_selected = true
|
||||
external_controller = $"{Global.Loopback}:{Global.StatePort}",
|
||||
}
|
||||
};
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion private gen function
|
||||
|
||||
#region Gen speedtest config
|
||||
|
||||
public int GenerateClientSpeedtestConfig(List<ServerTestItem> selecteds, out SingboxConfig? singboxConfig, out string msg)
|
||||
{
|
||||
singboxConfig = null;
|
||||
try
|
||||
{
|
||||
if (_config == null)
|
||||
{
|
||||
msg = ResUI.CheckServerSettings;
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg = ResUI.InitialConfiguration;
|
||||
|
||||
string result = Utils.GetEmbedText(Global.SingboxSampleClient);
|
||||
string txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
|
||||
if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
|
||||
{
|
||||
msg = ResUI.FailedGetDefaultConfiguration;
|
||||
return -1;
|
||||
}
|
||||
|
||||
singboxConfig = Utils.FromJson<SingboxConfig>(result);
|
||||
if (singboxConfig == null)
|
||||
{
|
||||
msg = ResUI.FailedGenDefaultConfiguration;
|
||||
return -1;
|
||||
}
|
||||
List<IPEndPoint> lstIpEndPoints = new();
|
||||
List<TcpConnectionInformation> lstTcpConns = new();
|
||||
try
|
||||
{
|
||||
lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners());
|
||||
lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners());
|
||||
lstTcpConns.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
}
|
||||
|
||||
GenLog(singboxConfig);
|
||||
GenDns(new(), singboxConfig);
|
||||
singboxConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts.
|
||||
singboxConfig.outbounds.RemoveAt(0);
|
||||
|
||||
int httpPort = LazyConfig.Instance.GetLocalPort("speedtest");
|
||||
|
||||
foreach (var it in selecteds)
|
||||
{
|
||||
if (it.configType == EConfigType.Custom)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (it.port <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (it.configType is EConfigType.VMess or EConfigType.VLESS)
|
||||
{
|
||||
var item2 = LazyConfig.Instance.GetProfileItem(it.indexId);
|
||||
if (item2 is null || Utils.IsNullOrEmpty(item2.id) || !Utils.IsGuidByParse(item2.id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//find unuse port
|
||||
var port = httpPort;
|
||||
for (int k = httpPort; k < Global.MaxPort; k++)
|
||||
{
|
||||
if (lstIpEndPoints?.FindIndex(_it => _it.Port == k) >= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (lstTcpConns?.FindIndex(_it => _it.LocalEndPoint.Port == k) >= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//found
|
||||
port = k;
|
||||
httpPort = port + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
//Port In Used
|
||||
if (lstIpEndPoints?.FindIndex(_it => _it.Port == port) >= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
it.port = port;
|
||||
it.allowTest = true;
|
||||
|
||||
//inbound
|
||||
Inbound4Sbox inbound = new()
|
||||
{
|
||||
listen = Global.Loopback,
|
||||
listen_port = port,
|
||||
type = Global.InboundHttp
|
||||
};
|
||||
inbound.tag = Global.InboundHttp + inbound.listen_port.ToString();
|
||||
singboxConfig.inbounds.Add(inbound);
|
||||
|
||||
//outbound
|
||||
var item = LazyConfig.Instance.GetProfileItem(it.indexId);
|
||||
if (item is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item.configType == EConfigType.Shadowsocks
|
||||
&& !Global.SsSecuritysInXray.Contains(item.security))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item.configType == EConfigType.VLESS
|
||||
&& !Global.Flows.Contains(item.flow))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var outbound = Utils.FromJson<Outbound4Sbox>(txtOutbound);
|
||||
GenOutbound(item, outbound);
|
||||
outbound.tag = Global.ProxyTag + inbound.listen_port.ToString();
|
||||
singboxConfig.outbounds.Add(outbound);
|
||||
|
||||
//rule
|
||||
Rule4Sbox rule = new()
|
||||
{
|
||||
inbound = new List<string> { inbound.tag },
|
||||
outbound = outbound.tag
|
||||
};
|
||||
singboxConfig.route.rules.Add(rule);
|
||||
}
|
||||
|
||||
//msg = string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
msg = ResUI.FailedGenDefaultConfiguration;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Gen speedtest config
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ namespace v2rayN.Handler
|
||||
{
|
||||
internal class CoreConfigV2ray
|
||||
{
|
||||
private string SampleClient = Global.v2raySampleClient;
|
||||
private Config _config;
|
||||
|
||||
public CoreConfigV2ray(Config config)
|
||||
@@ -32,7 +31,7 @@ namespace v2rayN.Handler
|
||||
|
||||
msg = ResUI.InitialConfiguration;
|
||||
|
||||
string result = Utils.GetEmbedText(SampleClient);
|
||||
string result = Utils.GetEmbedText(Global.V2raySampleClient);
|
||||
if (Utils.IsNullOrEmpty(result))
|
||||
{
|
||||
msg = ResUI.FailedGetDefaultConfiguration;
|
||||
@@ -46,17 +45,19 @@ namespace v2rayN.Handler
|
||||
return -1;
|
||||
}
|
||||
|
||||
log(v2rayConfig);
|
||||
GenLog(v2rayConfig);
|
||||
|
||||
inbound(v2rayConfig);
|
||||
GenInbounds(v2rayConfig);
|
||||
|
||||
routing(v2rayConfig);
|
||||
GenRouting(v2rayConfig);
|
||||
|
||||
outbound(node, v2rayConfig);
|
||||
GenOutbound(node, v2rayConfig.outbounds[0]);
|
||||
|
||||
dns(v2rayConfig);
|
||||
GenMoreOutbounds(node, v2rayConfig);
|
||||
|
||||
statistic(v2rayConfig);
|
||||
GenDns(v2rayConfig);
|
||||
|
||||
GenStatistic(v2rayConfig);
|
||||
|
||||
msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
}
|
||||
@@ -69,7 +70,9 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int log(V2rayConfig v2rayConfig)
|
||||
#region private gen function
|
||||
|
||||
private int GenLog(V2rayConfig v2rayConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -94,7 +97,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int inbound(V2rayConfig v2rayConfig)
|
||||
private int GenInbounds(V2rayConfig v2rayConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -145,7 +148,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;
|
||||
@@ -166,7 +169,7 @@ namespace v2rayN.Handler
|
||||
return inbound;
|
||||
}
|
||||
|
||||
private int routing(V2rayConfig v2rayConfig)
|
||||
private int GenRouting(V2rayConfig v2rayConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -177,7 +180,7 @@ namespace v2rayN.Handler
|
||||
|
||||
if (_config.routingBasicItem.enableRoutingAdvanced)
|
||||
{
|
||||
var routing = ConfigHandler.GetDefaultRouting(ref _config);
|
||||
var routing = ConfigHandler.GetDefaultRouting(_config);
|
||||
if (routing != null)
|
||||
{
|
||||
if (!Utils.IsNullOrEmpty(routing.domainStrategy))
|
||||
@@ -190,21 +193,21 @@ namespace v2rayN.Handler
|
||||
if (item.enabled)
|
||||
{
|
||||
var item2 = Utils.FromJson<RulesItem4Ray>(Utils.ToJson(item));
|
||||
routingUserRule(item2, v2rayConfig);
|
||||
GenRoutingUserRule(item2, v2rayConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var lockedItem = ConfigHandler.GetLockedRoutingItem(ref _config);
|
||||
var lockedItem = ConfigHandler.GetLockedRoutingItem(_config);
|
||||
if (lockedItem != null)
|
||||
{
|
||||
var rules = Utils.FromJson<List<RulesItem>>(lockedItem.ruleSet);
|
||||
foreach (var item in rules)
|
||||
{
|
||||
var item2 = Utils.FromJson<RulesItem4Ray>(Utils.ToJson(item));
|
||||
routingUserRule(item2, v2rayConfig);
|
||||
GenRoutingUserRule(item2, v2rayConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,7 +220,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int routingUserRule(RulesItem4Ray rules, V2rayConfig v2rayConfig)
|
||||
private int GenRoutingUserRule(RulesItem4Ray rules, V2rayConfig v2rayConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -291,11 +294,10 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int outbound(ProfileItem node, V2rayConfig v2rayConfig)
|
||||
private int GenOutbound(ProfileItem node, Outbounds4Ray outbound)
|
||||
{
|
||||
try
|
||||
{
|
||||
Outbounds4Ray outbound = v2rayConfig.outbounds[0];
|
||||
if (node.configType == EConfigType.VMess)
|
||||
{
|
||||
VnextItem4Ray vnextItem;
|
||||
@@ -324,8 +326,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;
|
||||
}
|
||||
@@ -334,9 +336,9 @@ namespace v2rayN.Handler
|
||||
usersItem.security = Global.DefaultSecurity;
|
||||
}
|
||||
|
||||
outboundMux(node, outbound, _config.coreBasicItem.muxEnabled);
|
||||
GenOutboundMux(node, outbound, _config.coreBasicItem.muxEnabled);
|
||||
|
||||
outbound.protocol = Global.vmessProtocolLite;
|
||||
outbound.protocol = Global.ProtocolTypes[EConfigType.VMess];
|
||||
outbound.settings.servers = null;
|
||||
}
|
||||
else if (node.configType == EConfigType.Shadowsocks)
|
||||
@@ -359,9 +361,9 @@ namespace v2rayN.Handler
|
||||
serversItem.ota = false;
|
||||
serversItem.level = 1;
|
||||
|
||||
outboundMux(node, outbound, false);
|
||||
GenOutboundMux(node, outbound, false);
|
||||
|
||||
outbound.protocol = Global.ssProtocolLite;
|
||||
outbound.protocol = Global.ProtocolTypes[EConfigType.Shadowsocks];
|
||||
outbound.settings.vnext = null;
|
||||
}
|
||||
else if (node.configType == EConfigType.Socks)
|
||||
@@ -394,9 +396,9 @@ namespace v2rayN.Handler
|
||||
serversItem.users = new List<SocksUsersItem4Ray>() { socksUsersItem };
|
||||
}
|
||||
|
||||
outboundMux(node, outbound, false);
|
||||
GenOutboundMux(node, outbound, false);
|
||||
|
||||
outbound.protocol = Global.socksProtocolLite;
|
||||
outbound.protocol = Global.ProtocolTypes[EConfigType.Socks];
|
||||
outbound.settings.vnext = null;
|
||||
}
|
||||
else if (node.configType == EConfigType.VLESS)
|
||||
@@ -425,10 +427,10 @@ 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);
|
||||
GenOutboundMux(node, outbound, _config.coreBasicItem.muxEnabled);
|
||||
|
||||
if (node.streamSecurity == Global.StreamSecurityReality
|
||||
|| node.streamSecurity == Global.StreamSecurity)
|
||||
@@ -437,15 +439,15 @@ namespace v2rayN.Handler
|
||||
{
|
||||
usersItem.flow = node.flow;
|
||||
|
||||
outboundMux(node, outbound, false);
|
||||
GenOutboundMux(node, outbound, false);
|
||||
}
|
||||
}
|
||||
if (node.streamSecurity == Global.StreamSecurityReality && Utils.IsNullOrEmpty(node.flow))
|
||||
{
|
||||
outboundMux(node, outbound, _config.coreBasicItem.muxEnabled);
|
||||
GenOutboundMux(node, outbound, _config.coreBasicItem.muxEnabled);
|
||||
}
|
||||
|
||||
outbound.protocol = Global.vlessProtocolLite;
|
||||
outbound.protocol = Global.ProtocolTypes[EConfigType.VLESS];
|
||||
outbound.settings.servers = null;
|
||||
}
|
||||
else if (node.configType == EConfigType.Trojan)
|
||||
@@ -467,12 +469,12 @@ namespace v2rayN.Handler
|
||||
serversItem.ota = false;
|
||||
serversItem.level = 1;
|
||||
|
||||
outboundMux(node, outbound, false);
|
||||
GenOutboundMux(node, outbound, false);
|
||||
|
||||
outbound.protocol = Global.trojanProtocolLite;
|
||||
outbound.protocol = Global.ProtocolTypes[EConfigType.Trojan];
|
||||
outbound.settings.vnext = null;
|
||||
}
|
||||
boundStreamSettings(node, outbound.streamSettings);
|
||||
GenBoundStreamSettings(node, outbound.streamSettings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -481,7 +483,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int outboundMux(ProfileItem node, Outbounds4Ray outbound, bool enabled)
|
||||
private int GenOutboundMux(ProfileItem node, Outbounds4Ray outbound, bool enabled)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -503,7 +505,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int boundStreamSettings(ProfileItem node, StreamSettings4Ray streamSettings)
|
||||
private int GenBoundStreamSettings(ProfileItem node, StreamSettings4Ray streamSettings)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -515,7 +517,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
try
|
||||
{
|
||||
useragent = Global.userAgentTxt[_config.coreBasicItem.defUserAgent];
|
||||
useragent = Global.UserAgentTxts[_config.coreBasicItem.defUserAgent];
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
@@ -672,7 +674,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}\"");
|
||||
@@ -700,7 +702,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int dns(V2rayConfig v2rayConfig)
|
||||
private int GenDns(V2rayConfig v2rayConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -772,7 +774,7 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int statistic(V2rayConfig v2rayConfig)
|
||||
private int GenStatistic(V2rayConfig v2rayConfig)
|
||||
{
|
||||
if (_config.guiItem.enableStatistics)
|
||||
{
|
||||
@@ -800,7 +802,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;
|
||||
@@ -822,34 +824,99 @@ namespace v2rayN.Handler
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig)
|
||||
{
|
||||
if (node.subid.IsNullOrEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
try
|
||||
{
|
||||
var subItem = LazyConfig.Instance.GetSubItem(node.subid);
|
||||
if (subItem is null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//current proxy
|
||||
var outbound = v2rayConfig.outbounds[0];
|
||||
var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
|
||||
|
||||
//Previous proxy
|
||||
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);
|
||||
if (prevNode is not null
|
||||
&& prevNode.configType != EConfigType.Custom
|
||||
&& prevNode.configType != EConfigType.Hysteria2
|
||||
&& prevNode.configType != EConfigType.Tuic)
|
||||
{
|
||||
var prevOutbound = Utils.FromJson<Outbounds4Ray>(txtOutbound);
|
||||
GenOutbound(prevNode, prevOutbound);
|
||||
prevOutbound.tag = $"{Global.ProxyTag}2";
|
||||
v2rayConfig.outbounds.Add(prevOutbound);
|
||||
|
||||
outbound.streamSettings.sockopt = new()
|
||||
{
|
||||
dialerProxy = prevOutbound.tag
|
||||
};
|
||||
}
|
||||
|
||||
//Next proxy
|
||||
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile!);
|
||||
if (nextNode is not null
|
||||
&& nextNode.configType != EConfigType.Custom
|
||||
&& nextNode.configType != EConfigType.Hysteria2
|
||||
&& nextNode.configType != EConfigType.Tuic)
|
||||
{
|
||||
var nextOutbound = Utils.FromJson<Outbounds4Ray>(txtOutbound);
|
||||
GenOutbound(nextNode, nextOutbound);
|
||||
nextOutbound.tag = Global.ProxyTag;
|
||||
v2rayConfig.outbounds.Insert(0, nextOutbound);
|
||||
|
||||
outbound.tag = $"{Global.ProxyTag}1";
|
||||
nextOutbound.streamSettings.sockopt = new()
|
||||
{
|
||||
dialerProxy = outbound.tag
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion private gen function
|
||||
|
||||
#region Gen speedtest config
|
||||
|
||||
public string GenerateClientSpeedtestConfigString(List<ServerTestItem> selecteds, out string msg)
|
||||
public int GenerateClientSpeedtestConfig(List<ServerTestItem> selecteds, out V2rayConfig? v2rayConfig, out string msg)
|
||||
{
|
||||
v2rayConfig = null;
|
||||
try
|
||||
{
|
||||
if (_config == null)
|
||||
{
|
||||
msg = ResUI.CheckServerSettings;
|
||||
return "";
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg = ResUI.InitialConfiguration;
|
||||
|
||||
Config configCopy = Utils.DeepCopy(_config);
|
||||
|
||||
string result = Utils.GetEmbedText(SampleClient);
|
||||
if (Utils.IsNullOrEmpty(result))
|
||||
string result = Utils.GetEmbedText(Global.V2raySampleClient);
|
||||
string txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
|
||||
if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
|
||||
{
|
||||
msg = ResUI.FailedGetDefaultConfiguration;
|
||||
return "";
|
||||
return -1;
|
||||
}
|
||||
|
||||
V2rayConfig? v2rayConfig = Utils.FromJson<V2rayConfig>(result);
|
||||
v2rayConfig = Utils.FromJson<V2rayConfig>(result);
|
||||
if (v2rayConfig == null)
|
||||
{
|
||||
msg = ResUI.FailedGenDefaultConfiguration;
|
||||
return "";
|
||||
return -1;
|
||||
}
|
||||
List<IPEndPoint> lstIpEndPoints = new();
|
||||
List<TcpConnectionInformation> lstTcpConns = new();
|
||||
@@ -864,8 +931,9 @@ namespace v2rayN.Handler
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
}
|
||||
|
||||
log(v2rayConfig);
|
||||
GenLog(v2rayConfig);
|
||||
v2rayConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts.
|
||||
v2rayConfig.outbounds.RemoveAt(0);
|
||||
|
||||
int httpPort = LazyConfig.Instance.GetLocalPort("speedtest");
|
||||
|
||||
@@ -925,45 +993,45 @@ namespace v2rayN.Handler
|
||||
v2rayConfig.inbounds.Add(inbound);
|
||||
|
||||
//outbound
|
||||
V2rayConfig? v2rayConfigCopy = Utils.FromJson<V2rayConfig>(result);
|
||||
var item = LazyConfig.Instance.GetProfileItem(it.indexId);
|
||||
if (item is null)
|
||||
{
|
||||
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();
|
||||
v2rayConfig.outbounds.Add(v2rayConfigCopy.outbounds[0]);
|
||||
var outbound = Utils.FromJson<Outbounds4Ray>(txtOutbound);
|
||||
GenOutbound(item, outbound);
|
||||
outbound.tag = Global.ProxyTag + inbound.port.ToString();
|
||||
v2rayConfig.outbounds.Add(outbound);
|
||||
|
||||
//rule
|
||||
RulesItem4Ray rule = new()
|
||||
{
|
||||
inboundTag = new List<string> { inbound.tag },
|
||||
outboundTag = v2rayConfigCopy.outbounds[0].tag,
|
||||
outboundTag = outbound.tag,
|
||||
type = "field"
|
||||
};
|
||||
v2rayConfig.routing.rules.Add(rule);
|
||||
}
|
||||
|
||||
//msg = string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
|
||||
return Utils.ToJson(v2rayConfig);
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
msg = ResUI.FailedGenDefaultConfiguration;
|
||||
return "";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ namespace v2rayN.Handler
|
||||
|
||||
public void LoadCore()
|
||||
{
|
||||
var node = ConfigHandler.GetDefaultServer(ref _config);
|
||||
var node = ConfigHandler.GetDefaultServer(_config);
|
||||
if (node == null)
|
||||
{
|
||||
ShowMsg(false, ResUI.CheckServerSettings);
|
||||
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);
|
||||
@@ -67,18 +67,19 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
public int LoadCoreConfigString(List<ServerTestItem> _selecteds)
|
||||
public int LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds)
|
||||
{
|
||||
int pid = -1;
|
||||
string configStr = CoreConfigHandler.GenerateClientSpeedtestConfigString(_config, _selecteds, out string msg);
|
||||
if (configStr == "")
|
||||
var coreType = selecteds.Exists(t => t.configType == EConfigType.Hysteria2 || t.configType == EConfigType.Tuic) ? ECoreType.sing_box : ECoreType.Xray;
|
||||
string configPath = Utils.GetConfigPath(Global.CoreSpeedtestConfigFileName);
|
||||
if (CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType, out string msg) != 0)
|
||||
{
|
||||
ShowMsg(false, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMsg(false, msg);
|
||||
pid = CoreStartViaString(configStr);
|
||||
pid = CoreStartSpeedtest(configPath, coreType);
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
@@ -115,7 +116,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
foreach (string vName in it.coreExes)
|
||||
{
|
||||
Process[] existing = Process.GetProcessesByName(vName);
|
||||
var existing = Process.GetProcessesByName(vName);
|
||||
foreach (Process p in existing)
|
||||
{
|
||||
string? path = p.MainModule?.FileName;
|
||||
@@ -138,7 +139,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
try
|
||||
{
|
||||
Process _p = Process.GetProcessById(pid);
|
||||
var _p = Process.GetProcessById(pid);
|
||||
KillProcess(_p);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -204,11 +205,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;
|
||||
@@ -218,62 +219,21 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
private int CoreStartViaString(string configStr)
|
||||
private int CoreStartSpeedtest(string configPath, ECoreType coreType)
|
||||
{
|
||||
ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
|
||||
|
||||
ShowMsg(false, configPath);
|
||||
try
|
||||
{
|
||||
var coreInfo = LazyConfig.Instance.GetCoreInfo(ECoreType.Xray);
|
||||
string fileName = CoreFindexe(coreInfo);
|
||||
if (fileName == "") return -1;
|
||||
|
||||
Process p = new()
|
||||
var coreInfo = LazyConfig.Instance.GetCoreInfo(coreType);
|
||||
var proc = RunProcess(new(), coreInfo, $" -c {Global.CoreSpeedtestConfigFileName}", true, ShowMsg);
|
||||
if (proc is null)
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = fileName,
|
||||
Arguments = "-config stdin:",
|
||||
WorkingDirectory = Utils.GetConfigPath(),
|
||||
UseShellExecute = false,
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true,
|
||||
StandardOutputEncoding = Encoding.UTF8,
|
||||
StandardErrorEncoding = Encoding.UTF8
|
||||
}
|
||||
};
|
||||
p.OutputDataReceived += (sender, e) =>
|
||||
{
|
||||
if (!String.IsNullOrEmpty(e.Data))
|
||||
{
|
||||
string msg = e.Data + Environment.NewLine;
|
||||
ShowMsg(false, msg);
|
||||
}
|
||||
};
|
||||
p.ErrorDataReceived += (sender, e) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(e.Data))
|
||||
{
|
||||
string msg = e.Data + Environment.NewLine;
|
||||
ShowMsg(false, msg);
|
||||
}
|
||||
};
|
||||
p.Start();
|
||||
p.BeginOutputReadLine();
|
||||
p.BeginErrorReadLine();
|
||||
|
||||
p.StandardInput.Write(configStr);
|
||||
p.StandardInput.Close();
|
||||
|
||||
if (p.WaitForExit(1000))
|
||||
{
|
||||
throw new Exception(p.StandardError.ReadToEnd());
|
||||
return -1;
|
||||
}
|
||||
|
||||
Global.processJob.AddProcess(p.Handle);
|
||||
return p.Id;
|
||||
return proc.Id;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -302,7 +262,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
Process proc = new()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
StartInfo = new()
|
||||
{
|
||||
FileName = fileName,
|
||||
Arguments = string.Format(coreInfo.arguments, configPath),
|
||||
@@ -346,7 +306,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)
|
||||
@@ -358,16 +318,20 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
private void KillProcess(Process p)
|
||||
private void KillProcess(Process? proc)
|
||||
{
|
||||
if (proc is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
p.CloseMainWindow();
|
||||
p.WaitForExit(100);
|
||||
if (!p.HasExited)
|
||||
proc.CloseMainWindow();
|
||||
proc.WaitForExit(100);
|
||||
if (!proc.HasExited)
|
||||
{
|
||||
p.Kill();
|
||||
p.WaitForExit(100);
|
||||
proc.Kill();
|
||||
proc.WaitForExit(100);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using v2rayN.Base;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using v2rayN.Base;
|
||||
using v2rayN.Mode;
|
||||
|
||||
namespace v2rayN.Handler
|
||||
@@ -129,6 +130,15 @@ namespace v2rayN.Handler
|
||||
return SqliteHelper.Instance.Table<ProfileItem>().FirstOrDefault(it => it.indexId == indexId);
|
||||
}
|
||||
|
||||
public ProfileItem? GetProfileItemViaRemarks(string remarks)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(remarks))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return SqliteHelper.Instance.Table<ProfileItem>().FirstOrDefault(it => it.remarks == remarks);
|
||||
}
|
||||
|
||||
public List<RoutingItem> RoutingItems()
|
||||
{
|
||||
return SqliteHelper.Instance.Table<RoutingItem>().Where(it => it.locked == false).OrderBy(t => t.sort).ToList();
|
||||
@@ -157,14 +167,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)
|
||||
@@ -195,13 +205,13 @@ namespace v2rayN.Handler
|
||||
return coreInfos!.FirstOrDefault(t => t.coreType == coreType);
|
||||
}
|
||||
|
||||
public List<CoreInfo>? GetCoreInfos()
|
||||
public List<CoreInfo> GetCoreInfos()
|
||||
{
|
||||
if (coreInfos == null)
|
||||
{
|
||||
InitCoreInfo();
|
||||
}
|
||||
return coreInfos;
|
||||
return coreInfos!;
|
||||
}
|
||||
|
||||
private void InitCoreInfo()
|
||||
@@ -212,7 +222,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 +233,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 +249,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 +263,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,
|
||||
@@ -267,12 +277,12 @@ 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",
|
||||
arguments = "run {0}",
|
||||
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 +293,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,26 +308,37 @@ 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,
|
||||
});
|
||||
|
||||
coreInfos.Add(new CoreInfo
|
||||
{
|
||||
coreType = ECoreType.mihomo,
|
||||
coreExes = new List<string> { $"mihomo-windows-amd64{(Avx2.X64.IsSupported ? "" : "-compatible")}", "mihomo-windows-amd64-compatible", "mihomo-windows-amd64", "mihomo-windows-386", "mihomo", "clash" },
|
||||
arguments = "-f config.yaml",
|
||||
coreUrl = Global.MihomoCoreUrl,
|
||||
coreReleaseApiUrl = Global.MihomoCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl),
|
||||
match = "Mihomo",
|
||||
redirectInfo = true,
|
||||
});
|
||||
|
||||
coreInfos.Add(new CoreInfo
|
||||
{
|
||||
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 +347,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 +356,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,
|
||||
});
|
||||
|
||||
@@ -343,13 +364,13 @@ namespace v2rayN.Handler
|
||||
{
|
||||
coreType = ECoreType.sing_box,
|
||||
coreExes = new List<string> { "sing-box-client", "sing-box" },
|
||||
arguments = "run{0}",
|
||||
coreUrl = Global.singboxCoreUrl,
|
||||
arguments = "run {0} --disable-color",
|
||||
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 +380,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 +388,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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace v2rayN.Handler
|
||||
return null;
|
||||
}
|
||||
|
||||
var item = ConfigHandler.GetDefaultRouting(ref config);
|
||||
var item = ConfigHandler.GetDefaultRouting(config);
|
||||
if (item == null || Utils.IsNullOrEmpty(item.customIcon) || !File.Exists(item.customIcon))
|
||||
{
|
||||
return null;
|
||||
@@ -183,7 +183,7 @@ namespace v2rayN.Handler
|
||||
Utils.SaveLog("subscription" + msg);
|
||||
});
|
||||
item.updateTime = updateTime;
|
||||
ConfigHandler.AddSubItem(ref config, item);
|
||||
ConfigHandler.AddSubItem(config, item);
|
||||
|
||||
await Task.Delay(5000);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
private void AddProfileEx(string indexId, ref ProfileExItem profileEx)
|
||||
private void AddProfileEx(string indexId, ref ProfileExItem? profileEx)
|
||||
{
|
||||
profileEx = new()
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace v2rayN.Handler
|
||||
EConfigType.Trojan => ShareTrojan(item),
|
||||
EConfigType.VLESS => ShareVLESS(item),
|
||||
EConfigType.Hysteria2 => ShareHysteria2(item),
|
||||
EConfigType.Tuic => ShareTuic(item),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
@@ -67,7 +68,7 @@ namespace v2rayN.Handler
|
||||
|
||||
url = Utils.ToJson(vmessQRCode);
|
||||
url = Utils.Base64Encode(url);
|
||||
url = $"{Global.vmessProtocol}{url}";
|
||||
url = $"{Global.ProtocolShares[EConfigType.VMess]}{url}";
|
||||
|
||||
return url;
|
||||
}
|
||||
@@ -90,7 +91,7 @@ namespace v2rayN.Handler
|
||||
//new Sip002
|
||||
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
||||
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
|
||||
url = $"{Global.ssProtocol}{url}{remark}";
|
||||
url = $"{Global.ProtocolShares[EConfigType.Shadowsocks]}{url}{remark}";
|
||||
return url;
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ namespace v2rayN.Handler
|
||||
//new
|
||||
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
|
||||
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
|
||||
url = $"{Global.socksProtocol}{url}{remark}";
|
||||
url = $"{Global.ProtocolShares[EConfigType.Socks]}{url}{remark}";
|
||||
return url;
|
||||
}
|
||||
|
||||
@@ -131,7 +132,7 @@ namespace v2rayN.Handler
|
||||
item.id,
|
||||
GetIpv6(item.address),
|
||||
item.port);
|
||||
url = $"{Global.trojanProtocol}{url}{query}{remark}";
|
||||
url = $"{Global.ProtocolShares[EConfigType.Trojan]}{url}{query}{remark}";
|
||||
return url;
|
||||
}
|
||||
|
||||
@@ -159,7 +160,7 @@ namespace v2rayN.Handler
|
||||
item.id,
|
||||
GetIpv6(item.address),
|
||||
item.port);
|
||||
url = $"{Global.vlessProtocol}{url}{query}{remark}";
|
||||
url = $"{Global.ProtocolShares[EConfigType.VLESS]}{url}{query}{remark}";
|
||||
return url;
|
||||
}
|
||||
|
||||
@@ -188,7 +189,36 @@ namespace v2rayN.Handler
|
||||
item.id,
|
||||
GetIpv6(item.address),
|
||||
item.port);
|
||||
url = $"{Global.hysteria2Protocol}{url}{query}{remark}";
|
||||
url = $"{Global.ProtocolShares[EConfigType.Hysteria2]}{url}{query}{remark}";
|
||||
return url;
|
||||
}
|
||||
|
||||
private static string ShareTuic(ProfileItem item)
|
||||
{
|
||||
string url = string.Empty;
|
||||
string remark = string.Empty;
|
||||
if (!Utils.IsNullOrEmpty(item.remarks))
|
||||
{
|
||||
remark = "#" + Utils.UrlEncode(item.remarks);
|
||||
}
|
||||
var dicQuery = new Dictionary<string, string>();
|
||||
if (!Utils.IsNullOrEmpty(item.sni))
|
||||
{
|
||||
dicQuery.Add("sni", item.sni);
|
||||
}
|
||||
if (!Utils.IsNullOrEmpty(item.alpn))
|
||||
{
|
||||
dicQuery.Add("alpn", Utils.UrlEncode(item.alpn));
|
||||
}
|
||||
dicQuery.Add("congestion_control", item.headerType);
|
||||
|
||||
string query = "?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray());
|
||||
|
||||
url = string.Format("{0}@{1}:{2}",
|
||||
$"{item.id}:{item.security}",
|
||||
GetIpv6(item.address),
|
||||
item.port);
|
||||
url = $"{Global.ProtocolShares[EConfigType.Tuic]}{url}{query}{remark}";
|
||||
return url;
|
||||
}
|
||||
|
||||
@@ -329,7 +359,7 @@ namespace v2rayN.Handler
|
||||
return null;
|
||||
}
|
||||
|
||||
if (result.StartsWith(Global.vmessProtocol))
|
||||
if (result.StartsWith(Global.ProtocolShares[EConfigType.VMess]))
|
||||
{
|
||||
int indexSplit = result.IndexOf("?");
|
||||
if (indexSplit > 0)
|
||||
@@ -341,7 +371,7 @@ namespace v2rayN.Handler
|
||||
profileItem = ResolveVmess(result, out msg);
|
||||
}
|
||||
}
|
||||
else if (result.StartsWith(Global.ssProtocol))
|
||||
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Shadowsocks]))
|
||||
{
|
||||
msg = ResUI.ConfigurationFormatIncorrect;
|
||||
|
||||
@@ -357,7 +387,7 @@ namespace v2rayN.Handler
|
||||
|
||||
profileItem.configType = EConfigType.Shadowsocks;
|
||||
}
|
||||
else if (result.StartsWith(Global.socksProtocol))
|
||||
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Socks]))
|
||||
{
|
||||
msg = ResUI.ConfigurationFormatIncorrect;
|
||||
|
||||
@@ -373,22 +403,26 @@ namespace v2rayN.Handler
|
||||
|
||||
profileItem.configType = EConfigType.Socks;
|
||||
}
|
||||
else if (result.StartsWith(Global.trojanProtocol))
|
||||
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Trojan]))
|
||||
{
|
||||
msg = ResUI.ConfigurationFormatIncorrect;
|
||||
|
||||
profileItem = ResolveTrojan(result);
|
||||
}
|
||||
else if (result.StartsWith(Global.vlessProtocol))
|
||||
else if (result.StartsWith(Global.ProtocolShares[EConfigType.VLESS]))
|
||||
{
|
||||
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;
|
||||
|
||||
profileItem = ResolveHysteria2(result);
|
||||
}
|
||||
else if (result.StartsWith(Global.ProtocolShares[EConfigType.Tuic]))
|
||||
{
|
||||
profileItem = ResolveTuic(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = ResUI.NonvmessOrssProtocol;
|
||||
@@ -413,7 +447,7 @@ namespace v2rayN.Handler
|
||||
configType = EConfigType.VMess
|
||||
};
|
||||
|
||||
result = result[Global.vmessProtocol.Length..];
|
||||
result = result[Global.ProtocolShares[EConfigType.VMess].Length..];
|
||||
result = Utils.Base64Decode(result);
|
||||
|
||||
//转成Json
|
||||
@@ -461,7 +495,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
configType = EConfigType.VMess
|
||||
};
|
||||
result = result[Global.vmessProtocol.Length..];
|
||||
result = result[Global.ProtocolShares[EConfigType.VMess].Length..];
|
||||
int indexSplit = result.IndexOf("?");
|
||||
if (indexSplit > 0)
|
||||
{
|
||||
@@ -678,7 +712,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
configType = EConfigType.Socks
|
||||
};
|
||||
result = result[Global.socksProtocol.Length..];
|
||||
result = result[Global.ProtocolShares[EConfigType.Socks].Length..];
|
||||
//remark
|
||||
int indexRemark = result.IndexOf("#");
|
||||
if (indexRemark > 0)
|
||||
@@ -815,6 +849,32 @@ namespace v2rayN.Handler
|
||||
return item;
|
||||
}
|
||||
|
||||
private static ProfileItem ResolveTuic(string result)
|
||||
{
|
||||
ProfileItem item = new()
|
||||
{
|
||||
configType = EConfigType.Tuic
|
||||
};
|
||||
|
||||
Uri url = new(result);
|
||||
|
||||
item.address = url.IdnHost;
|
||||
item.port = url.Port;
|
||||
item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped);
|
||||
var userInfoParts = url.UserInfo.Split(new[] { ':' }, 2);
|
||||
if (userInfoParts.Length == 2)
|
||||
{
|
||||
item.id = userInfoParts[0];
|
||||
item.security = userInfoParts[1];
|
||||
}
|
||||
|
||||
var query = HttpUtility.ParseQueryString(url.Query);
|
||||
ResolveStdTransport(query, ref item);
|
||||
item.headerType = query["congestion_control"] ?? "";
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private static int ResolveStdTransport(NameValueCollection query, ref ProfileItem item)
|
||||
{
|
||||
item.flow = query["flow"] ?? "";
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace v2rayN.Handler
|
||||
_selecteds = new List<ServerTestItem>();
|
||||
foreach (var it in selecteds)
|
||||
{
|
||||
if (it.configType == EConfigType.Custom || it.configType == EConfigType.Hysteria2)
|
||||
if (it.configType == EConfigType.Custom)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
string msg = string.Empty;
|
||||
|
||||
pid = _coreHandler.LoadCoreConfigString(_selecteds);
|
||||
pid = _coreHandler.LoadCoreConfigSpeedtest(_selecteds);
|
||||
if (pid < 0)
|
||||
{
|
||||
UpdateFunc("", ResUI.FailedToRunCore);
|
||||
@@ -196,7 +196,10 @@ namespace v2rayN.Handler
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (pid > 0) _coreHandler.CoreStopPid(pid);
|
||||
if (pid > 0)
|
||||
{
|
||||
_coreHandler.CoreStopPid(pid);
|
||||
}
|
||||
ProfileExHandler.Instance.SaveTo();
|
||||
}
|
||||
|
||||
@@ -211,7 +214,7 @@ namespace v2rayN.Handler
|
||||
// _selecteds = _selecteds.OrderBy(t => t.delay).ToList();
|
||||
//}
|
||||
|
||||
pid = _coreHandler.LoadCoreConfigString(_selecteds);
|
||||
pid = _coreHandler.LoadCoreConfigSpeedtest(_selecteds);
|
||||
if (pid < 0)
|
||||
{
|
||||
UpdateFunc("", ResUI.FailedToRunCore);
|
||||
@@ -268,7 +271,7 @@ namespace v2rayN.Handler
|
||||
private async Task RunSpeedTestMulti()
|
||||
{
|
||||
int pid = -1;
|
||||
pid = _coreHandler.LoadCoreConfigString(_selecteds);
|
||||
pid = _coreHandler.LoadCoreConfigSpeedtest(_selecteds);
|
||||
if (pid < 0)
|
||||
{
|
||||
UpdateFunc("", ResUI.FailedToRunCore);
|
||||
|
||||
@@ -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);
|
||||
@@ -143,14 +143,12 @@ namespace v2rayN.Handler
|
||||
{
|
||||
return defaultPort;
|
||||
}
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
TcpListener l = new(IPAddress.Loopback, 0);
|
||||
l.Start();
|
||||
int port = ((IPEndPoint)l.LocalEndpoint).Port;
|
||||
l.Stop();
|
||||
return port;
|
||||
}
|
||||
|
||||
TcpListener l = new(IPAddress.Loopback, 0);
|
||||
l.Start();
|
||||
int port = ((IPEndPoint)l.LocalEndpoint).Port;
|
||||
l.Stop();
|
||||
return port;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace v2rayN.Handler
|
||||
internal class StatisticsV2ray
|
||||
{
|
||||
private Mode.Config _config;
|
||||
private GrpcChannel _channel;
|
||||
private StatsService.StatsServiceClient _client;
|
||||
private GrpcChannel? _channel;
|
||||
private StatsService.StatsServiceClient? _client;
|
||||
private bool _exitFlag;
|
||||
private Action<ServerSpeedItem> _updateFunc;
|
||||
|
||||
@@ -26,10 +26,17 @@ namespace v2rayN.Handler
|
||||
|
||||
private void GrpcInit()
|
||||
{
|
||||
if (_channel == null)
|
||||
if (_channel is null)
|
||||
{
|
||||
_channel = GrpcChannel.ForAddress($"{Global.httpProtocol}{Global.Loopback}:{Global.statePort}");
|
||||
_client = new StatsService.StatsServiceClient(_channel);
|
||||
try
|
||||
{
|
||||
_channel = GrpcChannel.ForAddress($"{Global.HttpProtocol}{Global.Loopback}:{Global.StatePort}");
|
||||
_client = new StatsService.StatsServiceClient(_channel);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +51,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_channel.State == ConnectivityState.Ready)
|
||||
if (_channel?.State == ConnectivityState.Ready)
|
||||
{
|
||||
QueryStatsResponse? res = null;
|
||||
try
|
||||
@@ -87,7 +94,7 @@ namespace v2rayN.Handler
|
||||
name = nStr[1];
|
||||
type = nStr[3];
|
||||
|
||||
if (name == Global.agentTag)
|
||||
if (name == Global.ProxyTag)
|
||||
{
|
||||
if (type == "uplink")
|
||||
{
|
||||
@@ -98,7 +105,7 @@ namespace v2rayN.Handler
|
||||
server.proxyDown = value;
|
||||
}
|
||||
}
|
||||
else if (name == Global.directTag)
|
||||
else if (name == Global.DirectTag)
|
||||
{
|
||||
if (type == "uplink")
|
||||
{
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace v2rayN.Handler
|
||||
else if (type == ESysProxyType.Pac)
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace v2rayN.Handler
|
||||
//_updateFunc(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
|
||||
continue;
|
||||
}
|
||||
if (!url.StartsWith(Global.httpsProtocol) && !url.StartsWith(Global.httpProtocol))
|
||||
if (!url.StartsWith(Global.HttpsProtocol) && !url.StartsWith(Global.HttpProtocol))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -271,7 +271,7 @@ namespace v2rayN.Handler
|
||||
_updateFunc(false, $"{hashCode}{result}");
|
||||
}
|
||||
|
||||
int ret = ConfigHandler.AddBatchServers(ref config, result, id, true);
|
||||
int ret = ConfigHandler.AddBatchServers(config, result, id, true);
|
||||
if (ret <= 0)
|
||||
{
|
||||
Utils.SaveLog("FailedImportSubscription");
|
||||
@@ -296,8 +296,8 @@ namespace v2rayN.Handler
|
||||
await UpdateGeoFile("geosite", _config, update);
|
||||
await UpdateGeoFile("geoip", _config, update);
|
||||
|
||||
await UpdateGeoFile4Singbox("geosite", _config, false, update);
|
||||
await UpdateGeoFile4Singbox("geoip", _config, true, update);
|
||||
//await UpdateGeoFile4Singbox("geosite", _config, false, update);
|
||||
//await UpdateGeoFile4Singbox("geoip", _config, true, update);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
@@ -164,6 +164,7 @@ namespace v2rayN.Mode
|
||||
public string stack { get; set; }
|
||||
public int mtu { get; set; }
|
||||
public bool enableExInbound { get; set; }
|
||||
public bool enableIPv6Address { get; set; } = true;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
Socks = 4,
|
||||
VLESS = 5,
|
||||
Trojan = 6,
|
||||
Hysteria2 = 7
|
||||
Hysteria2 = 7,
|
||||
Tuic = 8
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
v2fly_v5 = 4,
|
||||
clash = 11,
|
||||
clash_meta = 12,
|
||||
mihomo = 13,
|
||||
hysteria = 21,
|
||||
naiveproxy = 22,
|
||||
tuic = 23,
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace v2rayN.Mode
|
||||
case EConfigType.VLESS:
|
||||
case EConfigType.Trojan:
|
||||
case EConfigType.Hysteria2:
|
||||
case EConfigType.Tuic:
|
||||
summary += string.Format("{0}({1}:{2})", remarks, addr, port);
|
||||
break;
|
||||
|
||||
@@ -78,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;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
public string? domain_strategy { get; set; }
|
||||
public string interface_name { get; set; }
|
||||
public string inet4_address { get; set; }
|
||||
public string inet6_address { get; set; }
|
||||
public string? inet6_address { get; set; }
|
||||
public int? mtu { get; set; }
|
||||
public bool? auto_route { get; set; }
|
||||
public bool? strict_route { get; set; }
|
||||
@@ -105,10 +105,11 @@
|
||||
public int? recv_window_conn { get; set; }
|
||||
public int? recv_window { get; set; }
|
||||
public bool? disable_mtu_discovery { get; set; }
|
||||
public string detour { get; set; }
|
||||
public string? detour { get; set; }
|
||||
public string method { get; set; }
|
||||
public string username { get; set; }
|
||||
public string password { get; set; }
|
||||
public string congestion_control { get; set; }
|
||||
public string? version { get; set; }
|
||||
public string? network { get; set; }
|
||||
public string packet_encoding { get; set; }
|
||||
@@ -179,8 +180,9 @@
|
||||
|
||||
public class Experimental4Sbox
|
||||
{
|
||||
public V2ray_Api4Sbox v2ray_api { get; set; }
|
||||
public Clash_Api4Sbox clash_api { get; set; }
|
||||
public CacheFile4Sbox? cache_file { get; set; }
|
||||
public V2ray_Api4Sbox? v2ray_api { get; set; }
|
||||
public Clash_Api4Sbox? clash_api { get; set; }
|
||||
}
|
||||
|
||||
public class V2ray_Api4Sbox
|
||||
@@ -191,8 +193,8 @@
|
||||
|
||||
public class Clash_Api4Sbox
|
||||
{
|
||||
public string external_controller { get; set; }
|
||||
public bool store_selected { get; set; }
|
||||
public string? external_controller { get; set; }
|
||||
public bool? store_selected { get; set; }
|
||||
}
|
||||
|
||||
public class Stats4Sbox
|
||||
@@ -209,4 +211,12 @@
|
||||
public string inet4_range { get; set; }
|
||||
public string inet6_range { get; set; }
|
||||
}
|
||||
|
||||
public class CacheFile4Sbox
|
||||
{
|
||||
public bool enabled { get; set; }
|
||||
public string? path { get; set; }
|
||||
public string? cache_id { get; set; }
|
||||
public bool? store_fakeip { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -27,5 +27,9 @@ namespace v2rayN.Mode
|
||||
public long updateTime { get; set; }
|
||||
|
||||
public string? convertTarget { get; set; }
|
||||
|
||||
public string? prevProfile { get; set; }
|
||||
|
||||
public string? nextProfile { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -451,6 +451,11 @@ namespace v2rayN.Mode
|
||||
/// grpc
|
||||
/// </summary>
|
||||
public GrpcSettings4Ray grpcSettings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// sockopt
|
||||
/// </summary>
|
||||
public Sockopt4Ray? sockopt { get; set; }
|
||||
}
|
||||
|
||||
public class TlsSettings4Ray
|
||||
@@ -632,4 +637,9 @@ namespace v2rayN.Mode
|
||||
/// </summary>
|
||||
public string pass { get; set; }
|
||||
}
|
||||
|
||||
public class Sockopt4Ray
|
||||
{
|
||||
public string? dialerProxy { get; set; }
|
||||
}
|
||||
}
|
||||
774
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
774
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -148,7 +148,7 @@
|
||||
<value>Failed to generate default configuration file</value>
|
||||
</data>
|
||||
<data name="FailedGetDefaultConfiguration" xml:space="preserve">
|
||||
<value> Failed to get the default configuration</value>
|
||||
<value>Failed to get the default configuration</value>
|
||||
</data>
|
||||
<data name="FailedImportedCustomServer" xml:space="preserve">
|
||||
<value>Failed to import custom configuration server</value>
|
||||
@@ -175,13 +175,13 @@
|
||||
<value>Please fill in the user ID</value>
|
||||
</data>
|
||||
<data name="IncorrectClientConfiguration" xml:space="preserve">
|
||||
<value> is not the correct client configuration file, please check</value>
|
||||
<value>Is not the correct client configuration file, please check</value>
|
||||
</data>
|
||||
<data name="Incorrectconfiguration" xml:space="preserve">
|
||||
<value> is not the correct configuration, please check</value>
|
||||
<value>Is not the correct configuration, please check</value>
|
||||
</data>
|
||||
<data name="IncorrectServerConfiguration" xml:space="preserve">
|
||||
<value> is not the correct server configuration file, please check</value>
|
||||
<value>Is not the correct server configuration file, please check</value>
|
||||
</data>
|
||||
<data name="InitialConfiguration" xml:space="preserve">
|
||||
<value>Initial Configuration</value>
|
||||
@@ -250,7 +250,7 @@
|
||||
<value>Invalid subscription content</value>
|
||||
</data>
|
||||
<data name="MsgUnpacking" xml:space="preserve">
|
||||
<value>is unpacking...</value>
|
||||
<value>Is unpacking......</value>
|
||||
</data>
|
||||
<data name="MsgUpdateSubscriptionEnd" xml:space="preserve">
|
||||
<value>Update subscription end</value>
|
||||
@@ -268,7 +268,7 @@
|
||||
<value>Non-VMess or ss protocol</value>
|
||||
</data>
|
||||
<data name="NonVmessService" xml:space="preserve">
|
||||
<value> non-standard service, this feature is invalid</value>
|
||||
<value>Non-standard service, this feature is invalid</value>
|
||||
</data>
|
||||
<data name="NotFoundCore" xml:space="preserve">
|
||||
<value>The Core file (file name: {1}) was not found under the folder ({0}), please download and put it in the folder, download address: {2}</value>
|
||||
@@ -277,7 +277,7 @@
|
||||
<value>Scan completed, no valid QR code found</value>
|
||||
</data>
|
||||
<data name="OperationFailed" xml:space="preserve">
|
||||
<value> operation failed, please check and retry</value>
|
||||
<value>Operation failed, please check and retry</value>
|
||||
</data>
|
||||
<data name="PleaseFillRemarks" xml:space="preserve">
|
||||
<value>Please Fill Remarks</value>
|
||||
@@ -308,10 +308,10 @@
|
||||
{0}</value>
|
||||
</data>
|
||||
<data name="SuccessfullyImportedCustomServer" xml:space="preserve">
|
||||
<value>Custom configuration server imported successfully.</value>
|
||||
<value>Custom configuration server imported successfully</value>
|
||||
</data>
|
||||
<data name="SuccessfullyImportedServerViaClipboard" xml:space="preserve">
|
||||
<value>{0} servers have been imported from clipboard.</value>
|
||||
<value>{0} servers have been imported from clipboard</value>
|
||||
</data>
|
||||
<data name="SuccessfullyImportedServerViaScan" xml:space="preserve">
|
||||
<value>Scan import URL successfully</value>
|
||||
@@ -1082,7 +1082,7 @@
|
||||
<value>Enable hardware acceleration(Require restart)</value>
|
||||
</data>
|
||||
<data name="SpeedtestingWait" xml:space="preserve">
|
||||
<value>Waiting for testing</value>
|
||||
<value>Waiting for testing......</value>
|
||||
</data>
|
||||
<data name="TipDisplayLog" xml:space="preserve">
|
||||
<value>Please turn off when there is an abnormal disconnection</value>
|
||||
@@ -1097,7 +1097,7 @@
|
||||
<value>More urls, separated by commas;Subscription conversion will be invalid</value>
|
||||
</data>
|
||||
<data name="SpeedDisplayText" xml:space="preserve">
|
||||
<value>{0}:{1}/s↑ | {2}/s↓</value>
|
||||
<value>{0} : {1}/s↑ | {2}/s↓</value>
|
||||
</data>
|
||||
<data name="LvAutoUpdateInterval" xml:space="preserve">
|
||||
<value>Automatic update interval(minutes)</value>
|
||||
@@ -1147,4 +1147,25 @@
|
||||
<data name="TbSettingsUseSystemHosts" xml:space="preserve">
|
||||
<value>Use System Hosts</value>
|
||||
</data>
|
||||
<data name="menuAddTuicServer" xml:space="preserve">
|
||||
<value>Add [Tuic] server</value>
|
||||
</data>
|
||||
<data name="TbHeaderType8" xml:space="preserve">
|
||||
<value>Congestion control</value>
|
||||
</data>
|
||||
<data name="LvPrevProfile" xml:space="preserve">
|
||||
<value>Previous proxy remakrs</value>
|
||||
</data>
|
||||
<data name="LvNextProfile" xml:space="preserve">
|
||||
<value>Next proxy remarks</value>
|
||||
</data>
|
||||
<data name="LvPrevProfileTip" xml:space="preserve">
|
||||
<value>Please make sure the remarks exists and is unique</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableExInbound" xml:space="preserve">
|
||||
<value>Enable additional Inbound</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
<value>Enable IPv6 Address</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1082,7 +1082,7 @@
|
||||
<value>启用硬件加速(需重启)</value>
|
||||
</data>
|
||||
<data name="SpeedtestingWait" xml:space="preserve">
|
||||
<value>等待测试中...</value>
|
||||
<value>等待测试中......</value>
|
||||
</data>
|
||||
<data name="TipDisplayLog" xml:space="preserve">
|
||||
<value>当有异常断流时请关闭</value>
|
||||
@@ -1144,4 +1144,25 @@
|
||||
<data name="TbSettingsUseSystemHosts" xml:space="preserve">
|
||||
<value>使用系统hosts</value>
|
||||
</data>
|
||||
<data name="menuAddTuicServer" xml:space="preserve">
|
||||
<value>添加[Tuic]服务器</value>
|
||||
</data>
|
||||
<data name="TbHeaderType8" xml:space="preserve">
|
||||
<value>拥塞控制算法</value>
|
||||
</data>
|
||||
<data name="LvPrevProfile" xml:space="preserve">
|
||||
<value>前置代理别名</value>
|
||||
</data>
|
||||
<data name="LvNextProfile" xml:space="preserve">
|
||||
<value>落地代理別名</value>
|
||||
</data>
|
||||
<data name="LvPrevProfileTip" xml:space="preserve">
|
||||
<value>请确保别名存在并唯一</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableExInbound" xml:space="preserve">
|
||||
<value>启用额外监听端口</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
<value>启用IPv6</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1082,7 +1082,7 @@
|
||||
<value>啟用硬體加速(需重啟)</value>
|
||||
</data>
|
||||
<data name="SpeedtestingWait" xml:space="preserve">
|
||||
<value>等待測試中...</value>
|
||||
<value>等待測試中......</value>
|
||||
</data>
|
||||
<data name="TipDisplayLog" xml:space="preserve">
|
||||
<value>當有異常斷流時請關閉</value>
|
||||
@@ -1135,4 +1135,22 @@
|
||||
<data name="TbRoutingRuleIP" xml:space="preserve">
|
||||
<value>IP 或 IP CIDR</value>
|
||||
</data>
|
||||
</root>
|
||||
<data name="menuAddTuicServer" xml:space="preserve">
|
||||
<value>新增[Tuic]伺服器</value>
|
||||
</data>
|
||||
<data name="LvPrevProfile" xml:space="preserve">
|
||||
<value>前置代理別名</value>
|
||||
</data>
|
||||
<data name="LvNextProfile" xml:space="preserve">
|
||||
<value>落地代理別名</value>
|
||||
</data>
|
||||
<data name="LvPrevProfileTip" xml:space="preserve">
|
||||
<value>請確保別名存在並且唯一</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableExInbound" xml:space="preserve">
|
||||
<value>啟用額外監聽端口</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
<value>啟用IPv6</value>
|
||||
</data>
|
||||
</root>
|
||||
34
v2rayN/v2rayN/Sample/SampleOutbound
Normal file
34
v2rayN/v2rayN/Sample/SampleOutbound
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "tcp"
|
||||
},
|
||||
"mux": {
|
||||
"enabled": false
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,18 @@
|
||||
{
|
||||
"type": "block",
|
||||
"tag": "block"
|
||||
},
|
||||
{
|
||||
"tag": "dns_out",
|
||||
"type": "dns"
|
||||
}
|
||||
],
|
||||
"route": {
|
||||
"rules": []
|
||||
"rules": [
|
||||
{
|
||||
"protocol": [ "dns" ],
|
||||
"outbound": "dns_out"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
6
v2rayN/v2rayN/Sample/SingboxSampleOutbound
Normal file
6
v2rayN/v2rayN/Sample/SingboxSampleOutbound
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"type": "vless",
|
||||
"tag": "proxy",
|
||||
"server": "",
|
||||
"server_port": 443
|
||||
}
|
||||
@@ -24,5 +24,9 @@
|
||||
"geoip:private",
|
||||
"geoip:cn"
|
||||
]
|
||||
},
|
||||
{
|
||||
"port": "0-65535",
|
||||
"outboundTag": "proxy"
|
||||
}
|
||||
]
|
||||
@@ -1,8 +1,4 @@
|
||||
[
|
||||
{
|
||||
"inbound": [ "dns_in" ],
|
||||
"outbound": "dns_out"
|
||||
},
|
||||
{
|
||||
"protocol": [ "dns" ],
|
||||
"outbound": "dns_out"
|
||||
|
||||
@@ -12,7 +12,6 @@ using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
@@ -881,13 +880,13 @@ namespace v2rayN
|
||||
if (blFull)
|
||||
{
|
||||
return string.Format("v2rayN - V{0} - {1}",
|
||||
FileVersionInfo.GetVersionInfo(location).FileVersion.ToString(),
|
||||
FileVersionInfo.GetVersionInfo(location).FileVersion?.ToString(),
|
||||
File.GetLastWriteTime(location).ToString("yyyy/MM/dd"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Format("v2rayN/{0}",
|
||||
FileVersionInfo.GetVersionInfo(location).FileVersion.ToString());
|
||||
FileVersionInfo.GetVersionInfo(location).FileVersion?.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -898,22 +897,26 @@ namespace v2rayN
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 深度拷贝
|
||||
/// DeepCopy
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static T DeepCopy<T>(T obj)
|
||||
{
|
||||
object retval;
|
||||
MemoryStream ms = new MemoryStream();
|
||||
BinaryFormatter bf = new BinaryFormatter();
|
||||
//序列化成流
|
||||
bf.Serialize(ms, obj);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
//反序列化成对象
|
||||
retval = bf.Deserialize(ms);
|
||||
return (T)retval;
|
||||
return FromJson<T>(ToJson(obj, false))!;
|
||||
|
||||
// object retval;
|
||||
// MemoryStream ms = new();
|
||||
//#pragma warning disable SYSLIB0011 // 类型或成员已过时
|
||||
// BinaryFormatter bf = new();
|
||||
//#pragma warning restore SYSLIB0011 // 类型或成员已过时
|
||||
// //序列化成流
|
||||
// bf.Serialize(ms, obj);
|
||||
// ms.Seek(0, SeekOrigin.Begin);
|
||||
// //反序列化成对象
|
||||
// retval = bf.Deserialize(ms);
|
||||
// return (T)retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace v2rayN.ViewModels
|
||||
item.preSocksPort = SelectedSource.preSocksPort;
|
||||
}
|
||||
|
||||
if (ConfigHandler.EditCustomServer(ref _config, item) == 0)
|
||||
if (ConfigHandler.EditCustomServer(_config, item) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_view.DialogResult = true;
|
||||
@@ -122,7 +122,7 @@ namespace v2rayN.ViewModels
|
||||
var item = LazyConfig.Instance.GetProfileItem(SelectedSource.indexId);
|
||||
item ??= SelectedSource;
|
||||
item.address = fileName;
|
||||
if (ConfigHandler.AddCustomServer(ref _config, item, false) == 0)
|
||||
if (ConfigHandler.AddCustomServer(_config, item, false) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.SuccessfullyImportedCustomServer);
|
||||
if (!Utils.IsNullOrEmpty(item.indexId))
|
||||
|
||||
@@ -127,27 +127,31 @@ namespace v2rayN.ViewModels
|
||||
switch (item.configType)
|
||||
{
|
||||
case EConfigType.VMess:
|
||||
ret = ConfigHandler.AddServer(ref _config, item);
|
||||
ret = ConfigHandler.AddServer(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.Shadowsocks:
|
||||
ret = ConfigHandler.AddShadowsocksServer(ref _config, item);
|
||||
ret = ConfigHandler.AddShadowsocksServer(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.Socks:
|
||||
ret = ConfigHandler.AddSocksServer(ref _config, item);
|
||||
ret = ConfigHandler.AddSocksServer(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.VLESS:
|
||||
ret = ConfigHandler.AddVlessServer(ref _config, item);
|
||||
ret = ConfigHandler.AddVlessServer(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.Trojan:
|
||||
ret = ConfigHandler.AddTrojanServer(ref _config, item);
|
||||
ret = ConfigHandler.AddTrojanServer(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.Hysteria2:
|
||||
ret = ConfigHandler.AddHysteria2Server(ref _config, item);
|
||||
ret = ConfigHandler.AddHysteria2Server(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.Tuic:
|
||||
ret = ConfigHandler.AddTuicServer(_config, item);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ namespace v2rayN.ViewModels
|
||||
public ReactiveCommand<Unit, Unit> AddSocksServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddTrojanServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddHysteria2ServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddTuicServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddCustomServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddServerViaClipboardCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddServerViaScanCmd { get; }
|
||||
@@ -147,7 +148,7 @@ namespace v2rayN.ViewModels
|
||||
//CheckUpdate
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateNCmd { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateV2flyCoreCmd { get; }
|
||||
//public ReactiveCommand<Unit, Unit> CheckUpdateV2flyCoreCmd { get; }
|
||||
|
||||
//public ReactiveCommand<Unit, Unit> CheckUpdateSagerNetCoreCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateXrayCoreCmd { get; }
|
||||
@@ -345,6 +346,10 @@ namespace v2rayN.ViewModels
|
||||
{
|
||||
EditServer(true, EConfigType.Hysteria2);
|
||||
});
|
||||
AddTuicServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
EditServer(true, EConfigType.Tuic);
|
||||
});
|
||||
AddCustomServerCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
EditServer(true, EConfigType.Custom);
|
||||
@@ -504,10 +509,10 @@ namespace v2rayN.ViewModels
|
||||
{
|
||||
CheckUpdateN();
|
||||
});
|
||||
CheckUpdateV2flyCoreCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
CheckUpdateCore(ECoreType.v2fly_v5);
|
||||
});
|
||||
//CheckUpdateV2flyCoreCmd = ReactiveCommand.Create(() =>
|
||||
//{
|
||||
// CheckUpdateCore(ECoreType.v2fly_v5);
|
||||
//});
|
||||
//CheckUpdateSagerNetCoreCmd = ReactiveCommand.Create(() =>
|
||||
//{
|
||||
// CheckUpdateCore(ECoreType.SagerNet);
|
||||
@@ -566,7 +571,7 @@ namespace v2rayN.ViewModels
|
||||
|
||||
private void Init()
|
||||
{
|
||||
ConfigHandler.InitBuiltinRouting(ref _config);
|
||||
ConfigHandler.InitBuiltinRouting(_config);
|
||||
ConfigHandler.InitBuiltinDNS(_config);
|
||||
_coreHandler = new CoreHandler(_config, UpdateHandler);
|
||||
Locator.CurrentMutable.RegisterLazySingleton(() => _coreHandler, typeof(CoreHandler));
|
||||
@@ -629,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)
|
||||
{
|
||||
@@ -732,7 +737,7 @@ namespace v2rayN.ViewModels
|
||||
Utils.SaveLog("MyAppExit Begin");
|
||||
|
||||
StorageUI();
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
|
||||
//HttpProxyHandle.CloseHttpAgent(config);
|
||||
if (blWindowsShutDown)
|
||||
@@ -852,7 +857,7 @@ namespace v2rayN.ViewModels
|
||||
RefreshServersMenu();
|
||||
|
||||
//display running server
|
||||
var running = ConfigHandler.GetDefaultServer(ref _config);
|
||||
var running = ConfigHandler.GetDefaultServer(_config);
|
||||
if (running != null)
|
||||
{
|
||||
var runningSummary = running.GetSummary();
|
||||
@@ -990,7 +995,7 @@ namespace v2rayN.ViewModels
|
||||
public void AddServerViaClipboard()
|
||||
{
|
||||
var clipboardData = Utils.GetClipboardData();
|
||||
int ret = ConfigHandler.AddBatchServers(ref _config, clipboardData!, _subId, false);
|
||||
int ret = ConfigHandler.AddBatchServers(_config, clipboardData!, _subId, false);
|
||||
if (ret > 0)
|
||||
{
|
||||
InitSubscriptionView();
|
||||
@@ -1017,7 +1022,7 @@ namespace v2rayN.ViewModels
|
||||
}
|
||||
else
|
||||
{
|
||||
int ret = ConfigHandler.AddBatchServers(ref _config, result, _subId, false);
|
||||
int ret = ConfigHandler.AddBatchServers(_config, result, _subId, false);
|
||||
if (ret > 0)
|
||||
{
|
||||
InitSubscriptionView();
|
||||
@@ -1064,7 +1069,7 @@ namespace v2rayN.ViewModels
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ConfigHandler.CopyServer(ref _config, lstSelecteds) == 0)
|
||||
if (ConfigHandler.CopyServer(_config, lstSelecteds) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
@@ -1097,7 +1102,7 @@ namespace v2rayN.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.SetDefaultServerIndex(ref _config, indexId) == 0)
|
||||
if (ConfigHandler.SetDefaultServerIndex(_config, indexId) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
Reload();
|
||||
@@ -1153,7 +1158,7 @@ namespace v2rayN.ViewModels
|
||||
|
||||
_dicHeaderSort.TryAdd(colName, true);
|
||||
_dicHeaderSort.TryGetValue(colName, out bool asc);
|
||||
if (ConfigHandler.SortServers(ref _config, _subId, colName, asc) != 0)
|
||||
if (ConfigHandler.SortServers(_config, _subId, colName, asc) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1163,7 +1168,7 @@ namespace v2rayN.ViewModels
|
||||
|
||||
public void TestServerAvailability()
|
||||
{
|
||||
var item = ConfigHandler.GetDefaultServer(ref _config);
|
||||
var item = ConfigHandler.GetDefaultServer(_config);
|
||||
if (item == null || item.configType == EConfigType.Custom)
|
||||
{
|
||||
return;
|
||||
@@ -1217,7 +1222,7 @@ namespace v2rayN.ViewModels
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ConfigHandler.MoveServer(ref _config, ref _lstProfile, index, eMove) == 0)
|
||||
if (ConfigHandler.MoveServer(_config, ref _lstProfile, index, eMove) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
}
|
||||
@@ -1228,7 +1233,7 @@ namespace v2rayN.ViewModels
|
||||
var targetIndex = _profileItems.IndexOf(targetItem);
|
||||
if (startIndex >= 0 && targetIndex >= 0 && startIndex != targetIndex)
|
||||
{
|
||||
if (ConfigHandler.MoveServer(ref _config, ref _lstProfile, startIndex, EMove.Position, targetIndex) == 0)
|
||||
if (ConfigHandler.MoveServer(_config, ref _lstProfile, startIndex, EMove.Position, targetIndex) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
}
|
||||
@@ -1358,7 +1363,7 @@ namespace v2rayN.ViewModels
|
||||
var ret = (new RoutingSettingWindow()).ShowDialog();
|
||||
if (ret == true)
|
||||
{
|
||||
ConfigHandler.InitBuiltinRouting(ref _config);
|
||||
ConfigHandler.InitBuiltinRouting(_config);
|
||||
RefreshRoutingsMenu();
|
||||
//RefreshServers();
|
||||
Reload();
|
||||
@@ -1409,7 +1414,7 @@ namespace v2rayN.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
var ret = ConfigHandler.ImportOldGuiConfig(ref _config, fileName);
|
||||
var ret = ConfigHandler.ImportOldGuiConfig(_config, fileName);
|
||||
if (ret == 0)
|
||||
{
|
||||
RefreshRoutingsMenu();
|
||||
@@ -1495,7 +1500,7 @@ namespace v2rayN.ViewModels
|
||||
{
|
||||
_coreHandler.LoadCore();
|
||||
|
||||
//ConfigHandler.SaveConfig(ref _config, false);
|
||||
//ConfigHandler.SaveConfig(_config, false);
|
||||
|
||||
ChangeSystemProxyStatus(_config.sysProxyType, false);
|
||||
});
|
||||
@@ -1510,7 +1515,7 @@ namespace v2rayN.ViewModels
|
||||
|
||||
private void CloseV2ray()
|
||||
{
|
||||
ConfigHandler.SaveConfig(ref _config, false);
|
||||
ConfigHandler.SaveConfig(_config, false);
|
||||
|
||||
ChangeSystemProxyStatus(ESysProxyType.ForcedClear, false);
|
||||
|
||||
@@ -1531,7 +1536,7 @@ namespace v2rayN.ViewModels
|
||||
ChangeSystemProxyStatus(type, true);
|
||||
|
||||
SystemProxySelected = (int)_config.sysProxyType;
|
||||
ConfigHandler.SaveConfig(ref _config, false);
|
||||
ConfigHandler.SaveConfig(_config, false);
|
||||
}
|
||||
|
||||
private void ChangeSystemProxyStatus(ESysProxyType type, bool blChange)
|
||||
@@ -1599,7 +1604,7 @@ namespace v2rayN.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.SetDefaultRouting(ref _config, item) == 0)
|
||||
if (ConfigHandler.SetDefaultRouting(_config, item) == 0)
|
||||
{
|
||||
_noticeHandler?.SendMessage(ResUI.TipChangeRouting, true);
|
||||
Reload();
|
||||
@@ -1705,7 +1710,7 @@ namespace v2rayN.ViewModels
|
||||
{
|
||||
_config.uiItem.colorModeDark = ColorModeDark;
|
||||
ModifyTheme(ColorModeDark);
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1716,11 +1721,15 @@ namespace v2rayN.ViewModels
|
||||
if (_config.uiItem.followSystemTheme != FollowSystemTheme)
|
||||
{
|
||||
_config.uiItem.followSystemTheme = FollowSystemTheme;
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
if (FollowSystemTheme)
|
||||
{
|
||||
ModifyTheme(!Utils.IsLightTheme());
|
||||
}
|
||||
else
|
||||
{
|
||||
ModifyTheme(ColorModeDark);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1740,7 +1749,7 @@ namespace v2rayN.ViewModels
|
||||
{
|
||||
_config.uiItem.colorPrimaryName = SelectedSwatch?.Name;
|
||||
ChangePrimaryColor(SelectedSwatch.ExemplarHue.Color);
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1758,7 +1767,7 @@ namespace v2rayN.ViewModels
|
||||
Application.Current.Resources["StdFontSize2"] = size + 2;
|
||||
Application.Current.Resources["StdFontSizeMsg"] = size - 1;
|
||||
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1771,7 +1780,7 @@ namespace v2rayN.ViewModels
|
||||
{
|
||||
_config.uiItem.currentLanguage = CurrentLanguage;
|
||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ namespace v2rayN.ViewModels
|
||||
[Reactive] public bool TunStrictRoute { get; set; }
|
||||
[Reactive] public string TunStack { get; set; }
|
||||
[Reactive] public int TunMtu { get; set; }
|
||||
[Reactive] public bool TunEnableExInbound { get; set; }
|
||||
[Reactive] public bool TunEnableIPv6Address { get; set; }
|
||||
|
||||
#endregion Tun mode
|
||||
|
||||
@@ -174,6 +176,8 @@ namespace v2rayN.ViewModels
|
||||
TunStrictRoute = _config.tunModeItem.strictRoute;
|
||||
TunStack = _config.tunModeItem.stack;
|
||||
TunMtu = _config.tunModeItem.mtu;
|
||||
TunEnableExInbound = _config.tunModeItem.enableExInbound;
|
||||
TunEnableIPv6Address = _config.tunModeItem.enableIPv6Address;
|
||||
|
||||
#endregion Tun mode
|
||||
|
||||
@@ -319,11 +323,13 @@ namespace v2rayN.ViewModels
|
||||
_config.tunModeItem.strictRoute = TunStrictRoute;
|
||||
_config.tunModeItem.stack = TunStack;
|
||||
_config.tunModeItem.mtu = TunMtu;
|
||||
_config.tunModeItem.enableExInbound = TunEnableExInbound;
|
||||
_config.tunModeItem.enableIPv6Address = TunEnableIPv6Address;
|
||||
|
||||
//coreType
|
||||
SaveCoreType();
|
||||
|
||||
if (ConfigHandler.SaveConfig(ref _config) == 0)
|
||||
if (ConfigHandler.SaveConfig(_config) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_view.DialogResult = true;
|
||||
@@ -367,6 +373,7 @@ namespace v2rayN.ViewModels
|
||||
break;
|
||||
|
||||
case 7:
|
||||
case 8:
|
||||
continue;
|
||||
}
|
||||
item.coreType = (ECoreType)Enum.Parse(typeof(ECoreType), type);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace v2rayN.ViewModels
|
||||
item.ruleNum = _rules.Count;
|
||||
item.ruleSet = Utils.ToJson(_rules, false);
|
||||
|
||||
if (ConfigHandler.SaveRoutingItem(ref _config, item) == 0)
|
||||
if (ConfigHandler.SaveRoutingItem(_config, item) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_view.DialogResult = true;
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace v2rayN.ViewModels
|
||||
_view = view;
|
||||
SelectedSource = new();
|
||||
|
||||
ConfigHandler.InitBuiltinRouting(ref _config);
|
||||
ConfigHandler.InitBuiltinRouting(_config);
|
||||
|
||||
enableRoutingAdvanced = _config.routingBasicItem.enableRoutingAdvanced;
|
||||
domainStrategy = _config.routingBasicItem.domainStrategy;
|
||||
@@ -134,7 +134,7 @@ namespace v2rayN.ViewModels
|
||||
|
||||
private void BindingLockedData()
|
||||
{
|
||||
_lockedItem = ConfigHandler.GetLockedRoutingItem(ref _config);
|
||||
_lockedItem = ConfigHandler.GetLockedRoutingItem(_config);
|
||||
if (_lockedItem != null)
|
||||
{
|
||||
_lockedRules = Utils.FromJson<List<RulesItem>>(_lockedItem.ruleSet);
|
||||
@@ -164,7 +164,7 @@ namespace v2rayN.ViewModels
|
||||
|
||||
_lockedItem.ruleSet = Utils.ToJson(_lockedRules, false);
|
||||
|
||||
ConfigHandler.SaveRoutingItem(ref _config, _lockedItem);
|
||||
ConfigHandler.SaveRoutingItem(_config, _lockedItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace v2rayN.ViewModels
|
||||
|
||||
EndBindingLockedData();
|
||||
|
||||
if (ConfigHandler.SaveConfig(ref _config) == 0)
|
||||
if (ConfigHandler.SaveConfig(_config) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_view.DialogResult = true;
|
||||
@@ -289,7 +289,7 @@ namespace v2rayN.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.SetDefaultRouting(ref _config, item) == 0)
|
||||
if (ConfigHandler.SetDefaultRouting(_config, item) == 0)
|
||||
{
|
||||
RefreshRoutingItems();
|
||||
IsModified = true;
|
||||
@@ -298,7 +298,7 @@ namespace v2rayN.ViewModels
|
||||
|
||||
private void RoutingAdvancedImportRules()
|
||||
{
|
||||
if (ConfigHandler.InitBuiltinRouting(ref _config, true) == 0)
|
||||
if (ConfigHandler.InitBuiltinRouting(_config, true) == 0)
|
||||
{
|
||||
RefreshRoutingItems();
|
||||
IsModified = true;
|
||||
|
||||
@@ -69,9 +69,11 @@ namespace v2rayN.ViewModels
|
||||
item.sort = SelectedSource.sort;
|
||||
item.filter = SelectedSource.filter;
|
||||
item.convertTarget = SelectedSource.convertTarget;
|
||||
item.prevProfile = SelectedSource.prevProfile;
|
||||
item.nextProfile = SelectedSource.nextProfile;
|
||||
}
|
||||
|
||||
if (ConfigHandler.AddSubItem(ref _config, item) == 0)
|
||||
if (ConfigHandler.AddSubItem(_config, item) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_view.DialogResult = true;
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace v2rayN.ViewModels
|
||||
|
||||
foreach (var it in SelectedSources)
|
||||
{
|
||||
ConfigHandler.DeleteSubItem(ref _config, it?.id);
|
||||
ConfigHandler.DeleteSubItem(_config, it?.id);
|
||||
}
|
||||
RefreshSubItems();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
|
||||
@@ -97,17 +97,17 @@
|
||||
Grid.Row="2"
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Vertical">
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
x:Name="btnBrowse"
|
||||
Width="100"
|
||||
Margin="2,0,8,0"
|
||||
Width="80"
|
||||
Margin="2,0"
|
||||
Content="{x:Static resx:ResUI.TbBrowse}"
|
||||
Style="{StaticResource DefButton}" />
|
||||
<Button
|
||||
x:Name="btnEdit"
|
||||
Width="100"
|
||||
Margin="2,2,8,0"
|
||||
Width="80"
|
||||
Margin="2,0"
|
||||
Content="{x:Static resx:ResUI.TbEdit}"
|
||||
Style="{StaticResource DefButton}" />
|
||||
</StackPanel>
|
||||
@@ -126,9 +126,8 @@
|
||||
Width="200"
|
||||
Margin="4"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="{DynamicResource StdFontSize}"
|
||||
MaxDropDownHeight="1000"
|
||||
Style="{StaticResource MaterialDesignOutlinedComboBox}" />
|
||||
Style="{StaticResource MyOutlinedTextComboBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="4"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
});
|
||||
@@ -126,6 +126,20 @@ namespace v2rayN.Views
|
||||
cmbFingerprint.IsEnabled = false;
|
||||
cmbFingerprint.Text = string.Empty;
|
||||
break;
|
||||
|
||||
case EConfigType.Tuic:
|
||||
gridTuic.Visibility = Visibility.Visible;
|
||||
sepa2.Visibility = Visibility.Collapsed;
|
||||
gridTransport.Visibility = Visibility.Collapsed;
|
||||
cmbCoreType.IsEnabled = false;
|
||||
cmbFingerprint.IsEnabled = false;
|
||||
cmbFingerprint.Text = string.Empty;
|
||||
|
||||
Global.TuicCongestionControls.ForEach(it =>
|
||||
{
|
||||
cmbHeaderType8.Items.Add(it);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
gridTlsMore.Visibility = Visibility.Hidden;
|
||||
@@ -169,6 +183,12 @@ namespace v2rayN.Views
|
||||
case EConfigType.Hysteria2:
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId7.Text).DisposeWith(disposables);
|
||||
break;
|
||||
|
||||
case EConfigType.Tuic:
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId8.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity8.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.headerType, v => v.cmbHeaderType8.Text).DisposeWith(disposables);
|
||||
break;
|
||||
}
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.network, v => v.cmbNetwork.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.headerType, v => v.cmbHeaderType.Text).DisposeWith(disposables);
|
||||
@@ -249,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);
|
||||
});
|
||||
|
||||
@@ -30,14 +30,14 @@ namespace v2rayN.Views
|
||||
|
||||
ViewModel = new DNSSettingViewModel(this);
|
||||
|
||||
Global.domainStrategy4Freedoms.ForEach(it =>
|
||||
Global.DomainStrategy4Freedoms.ForEach(it =>
|
||||
{
|
||||
cmbdomainStrategy4Freedom.Items.Add(it);
|
||||
});
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.Bind(ViewModel, vm=>vm.useSystemHosts, v=>v.togUseSystemHosts.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.useSystemHosts, v => v.togUseSystemHosts.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.domainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.normalDNS, v => v.txtnormalDNS.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.normalDNS2, v => v.txtnormalDNS2.Text).DisposeWith(disposables);
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace v2rayN.Views
|
||||
{
|
||||
_config.globalHotkeys = _TextBoxKeyEventItem.Values.ToList();
|
||||
|
||||
if (ConfigHandler.SaveConfig(ref _config, false) == 0)
|
||||
if (ConfigHandler.SaveConfig(_config, false) == 0)
|
||||
{
|
||||
HotkeyHandler.Instance.ReLoad();
|
||||
this.DialogResult = true;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<reactiveui:ReactiveWindow
|
||||
x:Class="v2rayN.Views.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:reactiveui="http://reactiveui.net"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:tb="clr-namespace:H.NotifyIcon;assembly=H.NotifyIcon.Wpf"
|
||||
xmlns:base="clr-namespace:v2rayN.Base"
|
||||
xmlns:conv="clr-namespace:v2rayN.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:v2rayN.Views"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:reactiveui="http://reactiveui.net"
|
||||
xmlns:resx="clr-namespace:v2rayN.Resx"
|
||||
xmlns:tb="clr-namespace:H.NotifyIcon;assembly=H.NotifyIcon.Wpf"
|
||||
xmlns:vms="clr-namespace:v2rayN.ViewModels"
|
||||
xmlns:local="clr-namespace:v2rayN.Views"
|
||||
Title="v2rayN"
|
||||
Width="900"
|
||||
Height="700"
|
||||
@@ -87,6 +87,10 @@
|
||||
x:Name="menuAddHysteria2Server"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="{x:Static resx:ResUI.menuAddHysteria2Server}" />
|
||||
<MenuItem
|
||||
x:Name="menuAddTuicServer"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="{x:Static resx:ResUI.menuAddTuicServer}" />
|
||||
<Separator Margin="-40,5" />
|
||||
<MenuItem
|
||||
x:Name="menuAddServerViaClipboard"
|
||||
@@ -212,11 +216,11 @@
|
||||
x:Name="menuCheckUpdateN"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="V2rayN" />
|
||||
<MenuItem
|
||||
<!--<MenuItem
|
||||
x:Name="menuCheckUpdateV2flyCore"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="V2fly v5 Core" />
|
||||
<!--<MenuItem
|
||||
<MenuItem
|
||||
x:Name="menuCheckUpdateSagerNetCore"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="SagerNet Core" />-->
|
||||
@@ -751,6 +755,10 @@
|
||||
</DataGrid>
|
||||
<GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" />
|
||||
<local:MsgView Grid.Row="2" />
|
||||
<materialDesign:Snackbar
|
||||
x:Name="MainSnackbar"
|
||||
Grid.Row="2"
|
||||
MessageQueue="{materialDesign:MessageQueue}" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
<tb:TaskbarIcon
|
||||
@@ -861,7 +869,6 @@
|
||||
</ContextMenu>
|
||||
</tb:TaskbarIcon.ContextMenu>
|
||||
</tb:TaskbarIcon>
|
||||
<materialDesign:Snackbar x:Name="MainSnackbar" MessageQueue="{materialDesign:MessageQueue}" />
|
||||
</Grid>
|
||||
</materialDesign:DialogHost>
|
||||
</reactiveui:ReactiveWindow>
|
||||
@@ -87,6 +87,7 @@ namespace v2rayN.Views
|
||||
this.BindCommand(ViewModel, vm => vm.AddSocksServerCmd, v => v.menuAddSocksServer).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.AddTrojanServerCmd, v => v.menuAddTrojanServer).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.AddHysteria2ServerCmd, v => v.menuAddHysteria2Server).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.AddTuicServerCmd, v => v.menuAddTuicServer).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.AddCustomServerCmd, v => v.menuAddCustomServer).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.AddServerViaClipboardCmd, v => v.menuAddServerViaClipboard).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.AddServerViaScanCmd, v => v.menuAddServerViaScan).DisposeWith(disposables);
|
||||
@@ -139,7 +140,7 @@ namespace v2rayN.Views
|
||||
|
||||
//checkupdate
|
||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateNCmd, v => v.menuCheckUpdateN).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateV2flyCoreCmd, v => v.menuCheckUpdateV2flyCore).DisposeWith(disposables);
|
||||
//this.BindCommand(ViewModel, vm => vm.CheckUpdateV2flyCoreCmd, v => v.menuCheckUpdateV2flyCore).DisposeWith(disposables);
|
||||
//this.BindCommand(ViewModel, vm => vm.CheckUpdateSagerNetCoreCmd, v => v.menuCheckUpdateSagerNetCore).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateXrayCoreCmd, v => v.menuCheckUpdateXrayCore).DisposeWith(disposables);
|
||||
//this.BindCommand(ViewModel, vm => vm.CheckUpdateClashCoreCmd, v => v.menuCheckUpdateClashCore).DisposeWith(disposables);
|
||||
@@ -540,12 +541,12 @@ namespace v2rayN.Views
|
||||
private void AddHelpMenuItem()
|
||||
{
|
||||
var coreInfos = LazyConfig.Instance.GetCoreInfos();
|
||||
foreach (var it in coreInfos)
|
||||
foreach (var it in coreInfos
|
||||
.Where(t => t.coreType != ECoreType.v2fly
|
||||
&& t.coreType != ECoreType.clash
|
||||
&& t.coreType != ECoreType.clash_meta
|
||||
&& t.coreType != ECoreType.hysteria))
|
||||
{
|
||||
if (it.coreType == ECoreType.v2fly)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var item = new MenuItem()
|
||||
{
|
||||
Tag = it.coreUrl.Replace(@"/releases", ""),
|
||||
|
||||
@@ -805,6 +805,8 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@@ -857,6 +859,34 @@
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="5"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsEnableExInbound}" />
|
||||
<ToggleButton
|
||||
x:Name="togEnableExInbound"
|
||||
Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="6"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsEnableIPv6Address}" />
|
||||
<ToggleButton
|
||||
x:Name="togEnableIPv6Address"
|
||||
Grid.Row="6"
|
||||
Grid.Column="1"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
HorizontalAlignment="Left" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
|
||||
@@ -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);
|
||||
@@ -186,6 +186,8 @@ namespace v2rayN.Views
|
||||
this.Bind(ViewModel, vm => vm.TunStrictRoute, v => v.togStrictRoute.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunStack, v => v.cmbStack.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunMtu, v => v.cmbMtu.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunEnableExInbound, v => v.togEnableExInbound.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunEnableIPv6Address, v => v.togEnableIPv6Address.IsChecked).DisposeWith(disposables);
|
||||
|
||||
this.Bind(ViewModel, vm => vm.CoreType1, v => v.cmbCoreType1.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.CoreType2, v => v.cmbCoreType2.Text).DisposeWith(disposables);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
@@ -132,7 +132,7 @@ namespace v2rayN.Views
|
||||
private void btnBrowse_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
var openFileDialog1 = new OpenFileDialog();
|
||||
openFileDialog1.Filter = "PNG|*.png";
|
||||
openFileDialog1.Filter = "PNG,ICO|*.png;*.ico";
|
||||
openFileDialog1.ShowDialog();
|
||||
|
||||
txtCustomIcon.Text = openFileDialog1.FileName;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<reactiveui:ReactiveWindow
|
||||
x:Class="v2rayN.Views.SubEditWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:conv="clr-namespace:v2rayN.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:reactiveui="http://reactiveui.net"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:conv="clr-namespace:v2rayN.Converters"
|
||||
xmlns:resx="clr-namespace:v2rayN.Resx"
|
||||
xmlns:vms="clr-namespace:v2rayN.ViewModels"
|
||||
Title="{x:Static resx:ResUI.menuSubSetting}"
|
||||
@@ -30,17 +30,38 @@
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<DockPanel Margin="8">
|
||||
<Grid
|
||||
Margin="8"
|
||||
HorizontalAlignment="Center"
|
||||
DockPanel.Dock="Bottom">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200" />
|
||||
<ColumnDefinition Width="200" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="btnSave"
|
||||
Grid.Column="0"
|
||||
Margin="4"
|
||||
Content="{x:Static resx:ResUI.TbConfirm}"
|
||||
Cursor="Hand"
|
||||
Style="{StaticResource DefButton}" />
|
||||
<Button
|
||||
x:Name="btnCancel"
|
||||
Grid.Column="1"
|
||||
Margin="4"
|
||||
Click="btnCancel_Click"
|
||||
Content="{x:Static resx:ResUI.TbCancel}"
|
||||
Cursor="Hand"
|
||||
IsCancel="true"
|
||||
Style="{StaticResource DefButton}" />
|
||||
</Grid>
|
||||
<ScrollViewer
|
||||
materialDesign:ScrollViewerAssist.IsAutoHideEnabled="True"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
|
||||
<ScrollViewer
|
||||
materialDesign:ScrollViewerAssist.IsAutoHideEnabled="True"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<Grid Margin="8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
@@ -51,6 +72,8 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@@ -209,9 +232,8 @@
|
||||
Grid.Column="1"
|
||||
Margin="4"
|
||||
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.LvConvertTargetTip}"
|
||||
FontSize="{DynamicResource StdFontSize}"
|
||||
MaxDropDownHeight="1000"
|
||||
Style="{StaticResource MaterialDesignOutlinedComboBox}" />
|
||||
Style="{StaticResource MyOutlinedTextComboBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="8"
|
||||
@@ -229,32 +251,43 @@
|
||||
VerticalAlignment="Top"
|
||||
AcceptsReturn="True"
|
||||
Style="{StaticResource MyOutlinedTextBox}" />
|
||||
</Grid>
|
||||
<Grid
|
||||
Grid.Row="1"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200" />
|
||||
<ColumnDefinition Width="200" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="btnSave"
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="9"
|
||||
Grid.Column="0"
|
||||
Margin="4"
|
||||
Content="{x:Static resx:ResUI.TbConfirm}"
|
||||
Cursor="Hand"
|
||||
Style="{StaticResource DefButton}" />
|
||||
<Button
|
||||
x:Name="btnCancel"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.LvPrevProfile}" />
|
||||
<TextBox
|
||||
x:Name="txtPrevProfile"
|
||||
Grid.Row="9"
|
||||
Grid.Column="1"
|
||||
Width="400"
|
||||
Margin="4"
|
||||
Click="btnCancel_Click"
|
||||
Content="{x:Static resx:ResUI.TbCancel}"
|
||||
Cursor="Hand"
|
||||
IsCancel="true"
|
||||
Style="{StaticResource DefButton}" />
|
||||
VerticalAlignment="Top"
|
||||
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.LvPrevProfileTip}"
|
||||
AcceptsReturn="True"
|
||||
Style="{StaticResource MyOutlinedTextBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="10"
|
||||
Grid.Column="0"
|
||||
Margin="4"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.LvNextProfile}" />
|
||||
<TextBox
|
||||
x:Name="txtNextProfile"
|
||||
Grid.Row="10"
|
||||
Grid.Column="1"
|
||||
Width="400"
|
||||
Margin="4"
|
||||
VerticalAlignment="Top"
|
||||
materialDesign:HintAssist.Hint="{x:Static resx:ResUI.LvPrevProfileTip}"
|
||||
AcceptsReturn="True"
|
||||
Style="{StaticResource MyOutlinedTextBox}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</ScrollViewer>
|
||||
</DockPanel>
|
||||
</reactiveui:ReactiveWindow>
|
||||
@@ -43,6 +43,8 @@ namespace v2rayN.Views
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.sort, v => v.txtSort.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.filter, v => v.txtFilter.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.convertTarget, v => v.cmbConvertTarget.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.prevProfile, v => v.txtPrevProfile.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedSource.nextProfile, v => v.txtNextProfile.Text).DisposeWith(disposables);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
});
|
||||
|
||||
@@ -9,28 +9,29 @@
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
|
||||
<Copyright>Copyright © 2017-2023 (GPLv3)</Copyright>
|
||||
<FileVersion>6.31</FileVersion>
|
||||
<Copyright>Copyright © 2017-2024 (GPLv3)</Copyright>
|
||||
<FileVersion>6.33</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Downloader" Version="3.0.6" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
|
||||
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.118" />
|
||||
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.124" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="QRCoder.Xaml" Version="1.4.3" />
|
||||
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
|
||||
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
||||
<PackageReference Include="ZXing.Net.Bindings.Windows.Compatibility" Version="0.16.12" />
|
||||
<PackageReference Include="ReactiveUI.Fody" Version="19.5.1" />
|
||||
<PackageReference Include="ReactiveUI.Fody" Version="19.5.39" />
|
||||
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />
|
||||
<PackageReference Include="ReactiveUI.WPF" Version="19.5.1" />
|
||||
<PackageReference Include="Splat.NLog" Version="14.8.6" />
|
||||
<PackageReference Include="ReactiveUI.WPF" Version="19.5.39" />
|
||||
<PackageReference Include="Splat.NLog" Version="14.8.12" />
|
||||
<PackageReference Include="System.Reactive" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="app.manifest" />
|
||||
<EmbeddedResource Include="Sample\SingboxSampleOutbound" />
|
||||
<EmbeddedResource Include="Sample\SingboxSampleClientConfig">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
@@ -63,8 +64,9 @@
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Sample\SampleInbound">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Sample\tun_singbox_rules">
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Sample\SampleOutbound" />
|
||||
<EmbeddedResource Include="Sample\tun_singbox_rules">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Sample\tun_singbox_inbound">
|
||||
|
||||
Reference in New Issue
Block a user