Compare commits

...

23 Commits
6.43 ... 6.45

Author SHA1 Message Date
2dust
b57ba6a98b up 6.45 2024-05-18 09:53:15 +08:00
2dust
d748e6eff4 Add destOverride 2024-05-14 15:31:19 +08:00
2dust
315d4b75b2 Optimize code 2024-05-14 13:42:42 +08:00
2dust
31267cbc33 Adjust Scan screen qrcode 2024-05-12 17:07:56 +08:00
2dust
c23379b3b6 Adjust sing-box dns 2024-05-12 15:42:28 +08:00
2dust
568144d6a2 TransitionAssist DisableTransitions 2024-05-12 14:59:23 +08:00
2dust
5857042963 Up 6.44 2024-05-08 13:40:24 +08:00
2dust
28e41dc621 Add open the file location 2024-05-08 11:43:03 +08:00
2dust
baef3b364b Bug fix 2024-05-08 11:42:01 +08:00
2dust
4b9ddb803f Bug fix 2024-05-07 14:15:08 +08:00
2dust
c07c7ad82f Added reminder that a reboot is required to modify settings 2024-05-06 17:19:29 +08:00
2dust
e223b80b95 Merge pull request #5066 from sincereliu/master
Optimize code for better performance
2024-05-06 09:55:30 +08:00
sincere liu
5fe468fa1b Optimize code for better performance 2024-05-05 22:07:51 +08:00
2dust
60068d8d16 Themes migrate 2024-05-05 16:19:47 +08:00
2dust
b6c5b46afe Up PackageReference 2024-05-05 10:10:19 +08:00
2dust
124cbfadb4 Add custom sing-box rule-set support 2024-05-04 13:54:22 +08:00
2dust
8d21f9b900 Bug fix 2024-05-04 13:24:13 +08:00
2dust
398dbbd2e5 Bug fix
https://github.com/2dust/v2rayN/issues/5035
2024-05-03 10:29:32 +08:00
2dust
e9b392d1c0 Optimized sorted storage 2024-04-30 14:44:02 +08:00
2dust
9d7c7e3225 Adjust the experimental and mux of sing-box 2024-04-27 10:05:13 +08:00
2dust
855fd4f0b7 Merge pull request #5026 from GibMeMyPacket/feat/singbox/exp_cachefile
Add `Enable cache file for sing-box`
2024-04-27 09:42:31 +08:00
GibMeMyPacket
807839929d Add Enable cache file for sing-box 2024-04-25 12:07:53 +00:00
2dust
870955fee1 Bug fix 2024-04-11 08:07:21 +08:00
49 changed files with 765 additions and 505 deletions

View File

@@ -11,7 +11,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.26.1" /> <PackageReference Include="Google.Protobuf" Version="3.26.1" />
<PackageReference Include="Grpc.Net.Client" Version="2.62.0" /> <PackageReference Include="Grpc.Net.Client" Version="2.62.0" />
<PackageReference Include="Grpc.Tools" Version="2.62.0"> <PackageReference Include="Grpc.Tools" Version="2.63.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View File

@@ -13,7 +13,7 @@
BaseTheme="Light" BaseTheme="Light"
PrimaryColor="Blue" PrimaryColor="Blue"
SecondaryColor="Lime" /> SecondaryColor="Lime" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" /> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign2.Defaults.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<system:Double x:Key="MenuItemHeight">26</system:Double> <system:Double x:Key="MenuItemHeight">26</system:Double>
<system:Double x:Key="StdFontSize">12</system:Double> <system:Double x:Key="StdFontSize">12</system:Double>
@@ -72,10 +72,10 @@
<Setter Property="FontSize" Value="{DynamicResource StdFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource StdFontSize}" />
<Style.Triggers> <Style.Triggers>
<Trigger Property="IsSelected" Value="true"> <Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}" /> <Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.Primary.Light}" />
</Trigger> </Trigger>
<Trigger Property="IsMouseOver" Value="true"> <Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}" /> <Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.Primary}" />
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>

View File

@@ -1,6 +1,13 @@
using QRCoder; using QRCoder;
using QRCoder.Xaml; using QRCoder.Xaml;
using System.Drawing;
using System.Windows.Interop;
using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using ZXing.Common;
using ZXing.QrCode;
using ZXing.Windows.Compatibility;
using ZXing;
namespace v2rayN namespace v2rayN
{ {
@@ -28,5 +35,70 @@ namespace v2rayN
return null; return null;
} }
} }
public static string ScanScreen(float dpiX, float dpiY)
{
try
{
var left = (int)(SystemParameters.WorkArea.Left);
var top = (int)(SystemParameters.WorkArea.Top);
var width = (int)(SystemParameters.WorkArea.Width / dpiX);
var height = (int)(SystemParameters.WorkArea.Height / dpiY);
using Bitmap fullImage = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(fullImage))
{
g.CopyFromScreen(left, top, 0, 0, fullImage.Size, CopyPixelOperation.SourceCopy);
}
int maxTry = 10;
for (int i = 0; i < maxTry; i++)
{
int marginLeft = (int)((double)fullImage.Width * i / 2.5 / maxTry);
int marginTop = (int)((double)fullImage.Height * i / 2.5 / maxTry);
Rectangle cropRect = new(marginLeft, marginTop, fullImage.Width - marginLeft * 2, fullImage.Height - marginTop * 2);
Bitmap target = new(width, height);
double imageScale = (double)width / (double)cropRect.Width;
using (Graphics g = Graphics.FromImage(target))
{
g.DrawImage(fullImage, new Rectangle(0, 0, target.Width, target.Height),
cropRect,
GraphicsUnit.Pixel);
}
BitmapLuminanceSource source = new(target);
QRCodeReader reader = new();
BinaryBitmap bitmap = new(new HybridBinarizer(source));
var result = reader.decode(bitmap);
if (result != null)
{
return result.Text;
}
else
{
BinaryBitmap bitmap2 = new(new HybridBinarizer(source.invert()));
var result2 = reader.decode(bitmap2);
if (result2 != null)
{
return result2.Text;
}
}
}
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
}
return string.Empty;
}
public static Tuple<float, float> GetDpiXY(Window window)
{
IntPtr hWnd = new WindowInteropHelper(window).EnsureHandle();
Graphics g = Graphics.FromHwnd(hWnd);
return new(96 / g.DpiX, 96 / g.DpiY);
}
} }
} }

View File

@@ -18,10 +18,6 @@ using System.Windows;
using System.Windows.Interop; using System.Windows.Interop;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using ZXing;
using ZXing.Common;
using ZXing.QrCode;
using ZXing.Windows.Compatibility;
namespace v2rayN namespace v2rayN
{ {
@@ -57,11 +53,14 @@ namespace v2rayN
/// 取得存储资源 /// 取得存储资源
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static string? LoadResource(string res) public static string? LoadResource(string? res)
{ {
try try
{ {
if (!File.Exists(res)) return null; if (!File.Exists(res))
{
return null;
}
return File.ReadAllText(res); return File.ReadAllText(res);
} }
catch (Exception ex) catch (Exception ex)
@@ -478,7 +477,7 @@ namespace v2rayN
/// 验证Domain地址是否合法 /// 验证Domain地址是否合法
/// </summary> /// </summary>
/// <param name="domain"></param> /// <param name="domain"></param>
public static bool IsDomain(string domain) public static bool IsDomain(string? domain)
{ {
//如果为空 //如果为空
if (IsNullOrEmpty(domain)) if (IsNullOrEmpty(domain))
@@ -741,11 +740,11 @@ namespace v2rayN
return Guid.TryParse(strSrc, out Guid g); return Guid.TryParse(strSrc, out Guid g);
} }
public static void ProcessStart(string fileName) public static void ProcessStart(string fileName, string arguments = "")
{ {
try try
{ {
Process.Start(new ProcessStartInfo(fileName) { UseShellExecute = true }); Process.Start(new ProcessStartInfo(fileName, arguments) { UseShellExecute = true });
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -947,66 +946,6 @@ namespace v2rayN
#endregion TempPath #endregion TempPath
#region scan screen
public static string ScanScreen(float dpiX, float dpiY)
{
try
{
var left = (int)(SystemParameters.WorkArea.Left);
var top = (int)(SystemParameters.WorkArea.Top);
var width = (int)(SystemParameters.WorkArea.Width / dpiX);
var height = (int)(SystemParameters.WorkArea.Height / dpiY);
using Bitmap fullImage = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(fullImage))
{
g.CopyFromScreen(left, top, 0, 0, fullImage.Size, CopyPixelOperation.SourceCopy);
}
int maxTry = 10;
for (int i = 0; i < maxTry; i++)
{
int marginLeft = (int)((double)fullImage.Width * i / 2.5 / maxTry);
int marginTop = (int)((double)fullImage.Height * i / 2.5 / maxTry);
Rectangle cropRect = new(marginLeft, marginTop, fullImage.Width - marginLeft * 2, fullImage.Height - marginTop * 2);
Bitmap target = new(width, height);
double imageScale = (double)width / (double)cropRect.Width;
using (Graphics g = Graphics.FromImage(target))
{
g.DrawImage(fullImage, new Rectangle(0, 0, target.Width, target.Height),
cropRect,
GraphicsUnit.Pixel);
}
BitmapLuminanceSource source = new(target);
BinaryBitmap bitmap = new(new HybridBinarizer(source));
QRCodeReader reader = new();
Result result = reader.decode(bitmap);
if (result != null)
{
string ret = result.Text;
return ret;
}
}
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
}
return string.Empty;
}
public static Tuple<float, float> GetDpiXY(Window window)
{
IntPtr hWnd = new WindowInteropHelper(window).EnsureHandle();
Graphics g = Graphics.FromHwnd(hWnd);
return new(96 / g.DpiX, 96 / g.DpiY);
}
#endregion scan screen
#region #region
/// <summary> /// <summary>

View File

@@ -175,6 +175,7 @@ namespace v2rayN
public static readonly List<string> LogLevels = new() { "debug", "info", "warning", "error", "none" }; 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> InboundTags = new() { "socks", "http", "socks2", "http2" };
public static readonly List<string> RuleProtocols = new() { "http", "tls", "bittorrent" }; public static readonly List<string> RuleProtocols = new() { "http", "tls", "bittorrent" };
public static readonly List<string> destOverrideProtocols = ["http", "tls", "quic", "fakedns", "fakedns+others"];
public static readonly List<string> TunMtus = new() { "1280", "1408", "1500", "9000" }; public static readonly List<string> TunMtus = new() { "1280", "1408", "1500", "9000" };
public static readonly List<string> TunStacks = new() { "gvisor", "system" }; public static readonly List<string> TunStacks = new() { "gvisor", "system" };
public static readonly List<string> PresetMsgFilters = new() { "proxy", "direct", "block", "" }; public static readonly List<string> PresetMsgFilters = new() { "proxy", "direct", "block", "" };

View File

@@ -50,7 +50,6 @@ namespace v2rayN.Handler
{ {
logEnabled = false, logEnabled = false,
loglevel = "warning", loglevel = "warning",
muxEnabled = false, muxEnabled = false,
}; };
} }
@@ -180,7 +179,7 @@ namespace v2rayN.Handler
config.mux4SboxItem = new() config.mux4SboxItem = new()
{ {
protocol = Global.SingboxMuxs[0], protocol = Global.SingboxMuxs[0],
max_connections = 4 max_connections = 8
}; };
} }
@@ -241,103 +240,103 @@ namespace v2rayN.Handler
} }
} }
public static int ImportOldGuiConfig(Config config, string fileName) //public static int ImportOldGuiConfig(Config config, string fileName)
{ //{
var result = Utils.LoadResource(fileName); // var result = Utils.LoadResource(fileName);
if (Utils.IsNullOrEmpty(result)) // if (Utils.IsNullOrEmpty(result))
{ // {
return -1; // return -1;
} // }
var configOld = JsonUtils.Deserialize<ConfigOld>(result); // var configOld = JsonUtils.Deserialize<ConfigOld>(result);
if (configOld == null) // if (configOld == null)
{ // {
return -1; // return -1;
} // }
var subItem = JsonUtils.Deserialize<List<SubItem>>(JsonUtils.Serialize(configOld.subItem)); // var subItem = JsonUtils.Deserialize<List<SubItem>>(JsonUtils.Serialize(configOld.subItem));
foreach (var it in subItem) // foreach (var it in subItem)
{ // {
if (Utils.IsNullOrEmpty(it.id)) // if (Utils.IsNullOrEmpty(it.id))
{ // {
it.id = Utils.GetGUID(false); // it.id = Utils.GetGUID(false);
} // }
SQLiteHelper.Instance.Replace(it); // SQLiteHelper.Instance.Replace(it);
} // }
var profileItems = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(configOld.vmess)); // var profileItems = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(configOld.vmess));
foreach (var it in profileItems) // foreach (var it in profileItems)
{ // {
if (Utils.IsNullOrEmpty(it.indexId)) // if (Utils.IsNullOrEmpty(it.indexId))
{ // {
it.indexId = Utils.GetGUID(false); // it.indexId = Utils.GetGUID(false);
} // }
SQLiteHelper.Instance.Replace(it); // SQLiteHelper.Instance.Replace(it);
} // }
foreach (var it in configOld.routings) // foreach (var it in configOld.routings)
{ // {
if (it.locked) // if (it.locked)
{ // {
continue; // continue;
} // }
var routing = JsonUtils.Deserialize<RoutingItem>(JsonUtils.Serialize(it)); // var routing = JsonUtils.Deserialize<RoutingItem>(JsonUtils.Serialize(it));
foreach (var it2 in it.rules) // foreach (var it2 in it.rules)
{ // {
it2.id = Utils.GetGUID(false); // it2.id = Utils.GetGUID(false);
} // }
routing.ruleNum = it.rules.Count; // routing.ruleNum = it.rules.Count;
routing.ruleSet = JsonUtils.Serialize(it.rules, false); // routing.ruleSet = JsonUtils.Serialize(it.rules, false);
if (Utils.IsNullOrEmpty(routing.id)) // if (Utils.IsNullOrEmpty(routing.id))
{ // {
routing.id = Utils.GetGUID(false); // routing.id = Utils.GetGUID(false);
} // }
SQLiteHelper.Instance.Replace(routing); // SQLiteHelper.Instance.Replace(routing);
} // }
config = JsonUtils.Deserialize<Config>(JsonUtils.Serialize(configOld)); // config = JsonUtils.Deserialize<Config>(JsonUtils.Serialize(configOld));
if (config.coreBasicItem == null) // if (config.coreBasicItem == null)
{ // {
config.coreBasicItem = new() // config.coreBasicItem = new()
{ // {
logEnabled = configOld.logEnabled, // logEnabled = configOld.logEnabled,
loglevel = configOld.loglevel, // loglevel = configOld.loglevel,
muxEnabled = configOld.muxEnabled, // muxEnabled = configOld.muxEnabled,
}; // };
} // }
if (config.routingBasicItem == null) // if (config.routingBasicItem == null)
{ // {
config.routingBasicItem = new() // config.routingBasicItem = new()
{ // {
enableRoutingAdvanced = configOld.enableRoutingAdvanced, // enableRoutingAdvanced = configOld.enableRoutingAdvanced,
domainStrategy = configOld.domainStrategy // domainStrategy = configOld.domainStrategy
}; // };
} // }
if (config.guiItem == null) // if (config.guiItem == null)
{ // {
config.guiItem = new() // config.guiItem = new()
{ // {
enableStatistics = configOld.enableStatistics, // enableStatistics = configOld.enableStatistics,
keepOlderDedupl = configOld.keepOlderDedupl, // keepOlderDedupl = configOld.keepOlderDedupl,
ignoreGeoUpdateCore = configOld.ignoreGeoUpdateCore, // ignoreGeoUpdateCore = configOld.ignoreGeoUpdateCore,
autoUpdateInterval = configOld.autoUpdateInterval, // autoUpdateInterval = configOld.autoUpdateInterval,
checkPreReleaseUpdate = configOld.checkPreReleaseUpdate, // checkPreReleaseUpdate = configOld.checkPreReleaseUpdate,
enableSecurityProtocolTls13 = configOld.enableSecurityProtocolTls13, // enableSecurityProtocolTls13 = configOld.enableSecurityProtocolTls13,
trayMenuServersLimit = configOld.trayMenuServersLimit, // trayMenuServersLimit = configOld.trayMenuServersLimit,
}; // };
} // }
GetDefaultServer(config); // GetDefaultServer(config);
GetDefaultRouting(config); // GetDefaultRouting(config);
SaveConfig(config); // SaveConfig(config);
LoadConfig(ref config); // LoadConfig(ref config);
return 0; // return 0;
} //}
#endregion ConfigHandler #endregion ConfigHandler

View File

@@ -54,7 +54,7 @@ namespace v2rayN.Handler
GenDns(node, singboxConfig); GenDns(node, singboxConfig);
GenStatistic(singboxConfig); GenExperimental(singboxConfig);
ConvertGeo2Ruleset(singboxConfig); ConvertGeo2Ruleset(singboxConfig);
@@ -111,7 +111,8 @@ namespace v2rayN.Handler
{ {
try try
{ {
singboxConfig.inbounds.Clear(); var listen = "::";
singboxConfig.inbounds = [];
if (!_config.tunModeItem.enableTun || (_config.tunModeItem.enableTun && _config.tunModeItem.enableExInbound)) if (!_config.tunModeItem.enableTun || (_config.tunModeItem.enableTun && _config.tunModeItem.enableExInbound))
{ {
@@ -146,11 +147,11 @@ namespace v2rayN.Handler
if (_config.inbound[0].newPort4LAN) if (_config.inbound[0].newPort4LAN)
{ {
var inbound3 = GetInbound(inbound, EInboundProtocol.socks2, true); var inbound3 = GetInbound(inbound, EInboundProtocol.socks2, true);
inbound3.listen = "::"; inbound3.listen = listen;
singboxConfig.inbounds.Add(inbound3); singboxConfig.inbounds.Add(inbound3);
var inbound4 = GetInbound(inbound, EInboundProtocol.http2, false); var inbound4 = GetInbound(inbound, EInboundProtocol.http2, false);
inbound4.listen = "::"; inbound4.listen = listen;
singboxConfig.inbounds.Add(inbound4); singboxConfig.inbounds.Add(inbound4);
//auth //auth
@@ -162,8 +163,8 @@ namespace v2rayN.Handler
} }
else else
{ {
inbound.listen = "::"; inbound.listen = listen;
inbound2.listen = "::"; inbound2.listen = listen;
} }
} }
} }
@@ -337,16 +338,16 @@ namespace v2rayN.Handler
{ {
try try
{ {
//if (_config.coreBasicItem.muxEnabled) if (_config.coreBasicItem.muxEnabled && !Utils.IsNullOrEmpty(_config.mux4SboxItem.protocol))
//{ {
// var mux = new Multiplex4Sbox() var mux = new Multiplex4Sbox()
// { {
// enabled = true, enabled = true,
// protocol = _config.mux4SboxItem.protocol, protocol = _config.mux4SboxItem.protocol,
// max_connections = _config.mux4SboxItem.max_connections, max_connections = _config.mux4SboxItem.max_connections,
// }; };
// outbound.multiplex = mux; outbound.multiplex = mux;
//} }
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -539,24 +540,38 @@ namespace v2rayN.Handler
{ {
try try
{ {
var dnsOutbound = "dns_out";
if (!_config.inbound[0].sniffingEnabled)
{
singboxConfig.route.rules.Add(new()
{
port = [53],
network = "udp",
outbound = dnsOutbound
});
}
if (_config.tunModeItem.enableTun) if (_config.tunModeItem.enableTun)
{ {
singboxConfig.route.auto_detect_interface = true; singboxConfig.route.auto_detect_interface = true;
var tunRules = JsonUtils.Deserialize<List<Rule4Sbox>>(Utils.GetEmbedText(Global.TunSingboxRulesFileName)); var tunRules = JsonUtils.Deserialize<List<Rule4Sbox>>(Utils.GetEmbedText(Global.TunSingboxRulesFileName));
if (tunRules != null)
{
singboxConfig.route.rules.AddRange(tunRules); singboxConfig.route.rules.AddRange(tunRules);
}
GenRoutingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe); GenRoutingDirectExe(out List<string> lstDnsExe, out List<string> lstDirectExe);
singboxConfig.route.rules.Add(new() singboxConfig.route.rules.Add(new()
{ {
port = new() { 53 }, port = new() { 53 },
outbound = "dns_out", outbound = dnsOutbound,
process_name = lstDnsExe process_name = lstDnsExe
}); });
singboxConfig.route.rules.Add(new() singboxConfig.route.rules.Add(new()
{ {
outbound = "direct", outbound = Global.DirectTag,
process_name = lstDirectExe process_name = lstDirectExe
}); });
} }
@@ -796,24 +811,9 @@ namespace v2rayN.Handler
{ {
return 0; return 0;
} }
//Add the dns of the remote server domain
if (dns4Sbox.rules is null)
{
dns4Sbox.rules = new();
}
dns4Sbox.servers.Add(new()
{
tag = "local_local",
address = "223.5.5.5",
detour = "direct"
});
dns4Sbox.rules.Add(new()
{
server = "local_local",
outbound = "any"
});
singboxConfig.dns = dns4Sbox; singboxConfig.dns = dns4Sbox;
GenDnsDomains(singboxConfig);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -822,30 +822,55 @@ namespace v2rayN.Handler
return 0; return 0;
} }
private int GenStatistic(SingboxConfig singboxConfig) private int GenDnsDomains(SingboxConfig singboxConfig)
{
var dns4Sbox = singboxConfig.dns ?? new();
dns4Sbox.servers ??= [];
dns4Sbox.rules ??= [];
var lstDomain = singboxConfig.outbounds
.Where(t => !Utils.IsNullOrEmpty(t.server) && Utils.IsDomain(t.server))
.Select(t => t.server)
.ToList();
if (lstDomain != null && lstDomain.Count > 0)
{
var tag = "local_local";
dns4Sbox.servers.Insert(0, new()
{
tag = tag,
address = "223.5.5.5",
detour = Global.DirectTag,
});
dns4Sbox.rules.Insert(0, new()
{
server = tag,
domain = lstDomain
});
}
singboxConfig.dns = dns4Sbox;
return 0;
}
private int GenExperimental(SingboxConfig singboxConfig)
{ {
if (_config.guiItem.enableStatistics) if (_config.guiItem.enableStatistics)
{ {
singboxConfig.experimental = new Experimental4Sbox() singboxConfig.experimental ??= new Experimental4Sbox();
{ singboxConfig.experimental.clash_api = new Clash_Api4Sbox()
cache_file = new CacheFile4Sbox()
{
enabled = true
},
//v2ray_api = new V2ray_Api4Sbox()
//{
// listen = $"{Global.Loopback}:{Global.StatePort}",
// stats = new Stats4Sbox()
// {
// enabled = true,
// }
//},
clash_api = new Clash_Api4Sbox()
{ {
external_controller = $"{Global.Loopback}:{LazyConfig.Instance.StatePort}", external_controller = $"{Global.Loopback}:{LazyConfig.Instance.StatePort}",
}
}; };
} }
if (_config.coreBasicItem.enableCacheFile4Sbox)
{
singboxConfig.experimental ??= new Experimental4Sbox();
singboxConfig.experimental.cache_file = new CacheFile4Sbox()
{
enabled = true
};
}
return 0; return 0;
} }
@@ -885,9 +910,35 @@ namespace v2rayN.Handler
ruleSets.AddRange(dnsRule.rule_set); ruleSets.AddRange(dnsRule.rule_set);
} }
//load custom ruleset file
List<Ruleset4Sbox> customRulesets = [];
if (_config.routingBasicItem.enableRoutingAdvanced)
{
var routing = ConfigHandler.GetDefaultRouting(_config);
if (!Utils.IsNullOrEmpty(routing.customRulesetPath4Singbox))
{
var result = Utils.LoadResource(routing.customRulesetPath4Singbox);
if (!Utils.IsNullOrEmpty(result))
{
customRulesets = (JsonUtils.Deserialize<List<Ruleset4Sbox>>(result) ?? [])
.Where(t => t.tag != null)
.Where(t => t.type != null)
.Where(t => t.format != null)
.ToList();
}
}
}
//Add ruleset srs //Add ruleset srs
singboxConfig.route.rule_set = []; singboxConfig.route.rule_set = [];
foreach (var item in new HashSet<string>(ruleSets)) foreach (var item in new HashSet<string>(ruleSets))
{
var customRuleset = customRulesets.FirstOrDefault(t => t.tag != null && t.tag.Equals(item));
if (customRuleset != null)
{
singboxConfig.route.rule_set.Add(customRuleset);
}
else
{ {
singboxConfig.route.rule_set.Add(new() singboxConfig.route.rule_set.Add(new()
{ {
@@ -898,6 +949,7 @@ namespace v2rayN.Handler
download_detour = Global.ProxyTag download_detour = Global.ProxyTag
}); });
} }
}
return 0; return 0;
} }
@@ -1039,12 +1091,18 @@ namespace v2rayN.Handler
singboxConfig.route.rules.Add(rule); singboxConfig.route.rules.Add(rule);
} }
GenDns(new(), singboxConfig); GenDnsDomains(singboxConfig);
var dnsServer = singboxConfig.dns?.servers.FirstOrDefault(); //var dnsServer = singboxConfig.dns?.servers.FirstOrDefault();
if (dnsServer != null) //if (dnsServer != null)
{ //{
dnsServer.detour = singboxConfig.route.rules.LastOrDefault()?.outbound; // dnsServer.detour = singboxConfig.route.rules.LastOrDefault()?.outbound;
} //}
//var dnsRule = singboxConfig.dns?.rules.Where(t => t.outbound != null).FirstOrDefault();
//if (dnsRule != null)
//{
// singboxConfig.dns.rules = [];
// singboxConfig.dns.rules.Add(dnsRule);
//}
//msg = string.Format(ResUI.SuccessfulConfiguration"), node.getSummary()); //msg = string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
return 0; return 0;

View File

@@ -98,7 +98,8 @@ namespace v2rayN.Handler
{ {
try try
{ {
v2rayConfig.inbounds = new List<Inbounds4Ray>(); var listen = "0.0.0.0";
v2rayConfig.inbounds = [];
Inbounds4Ray? inbound = GetInbound(_config.inbound[0], EInboundProtocol.socks, true); Inbounds4Ray? inbound = GetInbound(_config.inbound[0], EInboundProtocol.socks, true);
v2rayConfig.inbounds.Add(inbound); v2rayConfig.inbounds.Add(inbound);
@@ -112,11 +113,11 @@ namespace v2rayN.Handler
if (_config.inbound[0].newPort4LAN) if (_config.inbound[0].newPort4LAN)
{ {
var inbound3 = GetInbound(_config.inbound[0], EInboundProtocol.socks2, true); var inbound3 = GetInbound(_config.inbound[0], EInboundProtocol.socks2, true);
inbound3.listen = "0.0.0.0"; inbound3.listen = listen;
v2rayConfig.inbounds.Add(inbound3); v2rayConfig.inbounds.Add(inbound3);
var inbound4 = GetInbound(_config.inbound[0], EInboundProtocol.http2, false); var inbound4 = GetInbound(_config.inbound[0], EInboundProtocol.http2, false);
inbound4.listen = "0.0.0.0"; inbound4.listen = listen;
v2rayConfig.inbounds.Add(inbound4); v2rayConfig.inbounds.Add(inbound4);
//auth //auth
@@ -131,8 +132,8 @@ namespace v2rayN.Handler
} }
else else
{ {
inbound.listen = "0.0.0.0"; inbound.listen = listen;
inbound2.listen = "0.0.0.0"; inbound2.listen = listen;
} }
} }
} }
@@ -143,24 +144,25 @@ namespace v2rayN.Handler
return 0; return 0;
} }
private Inbounds4Ray? GetInbound(InItem inItem, EInboundProtocol protocol, bool bSocks) private Inbounds4Ray GetInbound(InItem inItem, EInboundProtocol protocol, bool bSocks)
{ {
string result = Utils.GetEmbedText(Global.V2raySampleInbound); string result = Utils.GetEmbedText(Global.V2raySampleInbound);
if (Utils.IsNullOrEmpty(result)) if (Utils.IsNullOrEmpty(result))
{ {
return null; return new();
} }
var inbound = JsonUtils.Deserialize<Inbounds4Ray>(result); var inbound = JsonUtils.Deserialize<Inbounds4Ray>(result);
if (inbound == null) if (inbound == null)
{ {
return null; return new();
} }
inbound.tag = protocol.ToString(); inbound.tag = protocol.ToString();
inbound.port = inItem.localPort + (int)protocol; inbound.port = inItem.localPort + (int)protocol;
inbound.protocol = bSocks ? EInboundProtocol.socks.ToString() : EInboundProtocol.http.ToString(); inbound.protocol = bSocks ? EInboundProtocol.socks.ToString() : EInboundProtocol.http.ToString();
inbound.settings.udp = inItem.udpEnabled; inbound.settings.udp = inItem.udpEnabled;
inbound.sniffing.enabled = inItem.sniffingEnabled; inbound.sniffing.enabled = inItem.sniffingEnabled;
inbound.sniffing.destOverride = inItem.destOverride;
inbound.sniffing.routeOnly = inItem.routeOnly; inbound.sniffing.routeOnly = inItem.routeOnly;
return inbound; return inbound;

View File

@@ -7,7 +7,7 @@ namespace v2rayN.Handler
internal class ProfileExHandler internal class ProfileExHandler
{ {
private static readonly Lazy<ProfileExHandler> _instance = new(() => new()); private static readonly Lazy<ProfileExHandler> _instance = new(() => new());
private ConcurrentBag<ProfileExItem> _lstProfileEx; private ConcurrentBag<ProfileExItem> _lstProfileEx = [];
private Queue<string> _queIndexIds = new(); private Queue<string> _queIndexIds = new();
public ConcurrentBag<ProfileExItem> ProfileExs => _lstProfileEx; public ConcurrentBag<ProfileExItem> ProfileExs => _lstProfileEx;
public static ProfileExHandler Instance => _instance.Value; public static ProfileExHandler Instance => _instance.Value;
@@ -15,6 +15,15 @@ namespace v2rayN.Handler
public ProfileExHandler() public ProfileExHandler()
{ {
Init(); Init();
Task.Run(async () =>
{
while (true)
{
SaveQueueIndexIds();
await Task.Delay(1000 * 600);
}
});
} }
private void Init() private void Init()
@@ -22,24 +31,6 @@ namespace v2rayN.Handler
SQLiteHelper.Instance.Execute($"delete from ProfileExItem where indexId not in ( select indexId from ProfileItem )"); SQLiteHelper.Instance.Execute($"delete from ProfileExItem where indexId not in ( select indexId from ProfileItem )");
_lstProfileEx = new(SQLiteHelper.Instance.Table<ProfileExItem>()); _lstProfileEx = new(SQLiteHelper.Instance.Table<ProfileExItem>());
Task.Run(async () =>
{
while (true)
{
var cnt = _queIndexIds.Count;
for (int i = 0; i < cnt; i++)
{
var id = _queIndexIds.Dequeue();
var item = _lstProfileEx.FirstOrDefault(t => t.indexId == id);
if (item is not null)
{
SQLiteHelper.Instance.Replace(item);
}
}
await Task.Delay(1000 * 60);
}
});
} }
private void IndexIdEnqueue(string indexId) private void IndexIdEnqueue(string indexId)
@@ -50,6 +41,49 @@ namespace v2rayN.Handler
} }
} }
private void SaveQueueIndexIds()
{
var cnt = _queIndexIds.Count;
if (cnt > 0)
{
var lstExists = SQLiteHelper.Instance.Table<ProfileExItem>();
List<ProfileExItem> lstInserts = [];
List<ProfileExItem> lstUpdates = [];
for (int i = 0; i < cnt; i++)
{
var id = _queIndexIds.Dequeue();
var item = lstExists.FirstOrDefault(t => t.indexId == id);
var itemNew = _lstProfileEx?.FirstOrDefault(t => t.indexId == id);
if (itemNew is null)
{
continue;
}
if (item is not null)
{
lstUpdates.Add(itemNew);
}
else
{
lstInserts.Add(itemNew);
}
}
try
{
if (lstInserts.Count() > 0)
SQLiteHelper.Instance.InsertAll(lstInserts);
if (lstUpdates.Count() > 0)
SQLiteHelper.Instance.UpdateAll(lstUpdates);
}
catch (Exception ex)
{
Logging.SaveLog("ProfileExHandler", ex);
}
}
}
private void AddProfileEx(string indexId, ref ProfileExItem? profileEx) private void AddProfileEx(string indexId, ref ProfileExItem? profileEx)
{ {
profileEx = new() profileEx = new()
@@ -73,11 +107,7 @@ namespace v2rayN.Handler
{ {
try try
{ {
//foreach (var item in _lstProfileEx) SaveQueueIndexIds();
//{
// SQLiteHelper.Instance.Replace(item);
//}
SQLiteHelper.Instance.UpdateAll(_lstProfileEx);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -264,7 +264,12 @@ namespace v2rayN.Handler
private static string GetIpv6(string address) private static string GetIpv6(string address)
{ {
return Utils.IsIpv6(address) ? $"[{address}]" : address; if (Utils.IsIpv6(address))
{
// 检查地址是否已经被方括号包围,如果没有,则添加方括号
return address.StartsWith('[') && address.EndsWith(']') ? address : $"[{address}]";
}
return address; // 如果不是IPv6地址直接返回原地址
} }
private static int GetStdTransport(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery) private static int GetStdTransport(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)

View File

@@ -33,6 +33,8 @@ namespace v2rayN.Models
public string defUserAgent { get; set; } public string defUserAgent { get; set; }
public bool enableFragment { get; set; } public bool enableFragment { get; set; }
public bool enableCacheFile4Sbox { get; set; } = true;
} }
[Serializable] [Serializable]
@@ -45,8 +47,8 @@ namespace v2rayN.Models
public bool udpEnabled { get; set; } public bool udpEnabled { get; set; }
public bool sniffingEnabled { get; set; } = true; public bool sniffingEnabled { get; set; } = true;
public List<string>? destOverride { get; set; } = ["http", "tls"];
public bool routeOnly { get; set; } public bool routeOnly { get; set; }
public bool allowLANConn { get; set; } public bool allowLANConn { get; set; }
public bool newPort4LAN { get; set; } public bool newPort4LAN { get; set; }
@@ -180,13 +182,8 @@ namespace v2rayN.Models
[Serializable] [Serializable]
public class RoutingBasicItem public class RoutingBasicItem
{ {
/// <summary>
/// 域名解析策略
/// </summary>
public string domainStrategy { get; set; } public string domainStrategy { get; set; }
public string domainStrategy4Singbox { get; set; } public string domainStrategy4Singbox { get; set; }
public string domainMatcher { get; set; } public string domainMatcher { get; set; }
public string routingIndexId { get; set; } public string routingIndexId { get; set; }
public bool enableRoutingAdvanced { get; set; } public bool enableRoutingAdvanced { get; set; }

View File

@@ -15,6 +15,7 @@ namespace v2rayN.Models
public bool enabled { get; set; } = true; public bool enabled { get; set; } = true;
public bool locked { get; set; } public bool locked { get; set; }
public string customIcon { get; set; } public string customIcon { get; set; }
public string customRulesetPath4Singbox { get; set; }
public string domainStrategy { get; set; } public string domainStrategy { get; set; }
public string domainStrategy4Singbox { get; set; } public string domainStrategy4Singbox { get; set; }
public int sort { get; set; } public int sort { get; set; }

View File

@@ -7,7 +7,7 @@
public List<Inbound4Sbox> inbounds { get; set; } public List<Inbound4Sbox> inbounds { get; set; }
public List<Outbound4Sbox> outbounds { get; set; } public List<Outbound4Sbox> outbounds { get; set; }
public Route4Sbox route { get; set; } public Route4Sbox route { get; set; }
public Experimental4Sbox experimental { get; set; } public Experimental4Sbox? experimental { get; set; }
} }
public class Log4Sbox public class Log4Sbox
@@ -41,14 +41,14 @@
[Serializable] [Serializable]
public class Rule4Sbox public class Rule4Sbox
{ {
public string outbound { get; set; } public string? outbound { get; set; }
public string server { get; set; } public string? server { get; set; }
public bool? disable_cache { get; set; } public bool? disable_cache { get; set; }
public List<string>? inbound { get; set; } public List<string>? inbound { get; set; }
public List<string>? protocol { get; set; } public List<string>? protocol { get; set; }
public string type { get; set; } public string? type { get; set; }
public string mode { get; set; } public string? mode { get; set; }
public string network { get; set; } public string? network { get; set; }
public bool? ip_is_private { get; set; } public bool? ip_is_private { get; set; }
public List<int>? port { get; set; } public List<int>? port { get; set; }
public List<string>? port_range { get; set; } public List<string>? port_range { get; set; }
@@ -95,7 +95,7 @@
{ {
public string type { get; set; } public string type { get; set; }
public string tag { get; set; } public string tag { get; set; }
public string server { get; set; } public string? server { get; set; }
public int? server_port { get; set; } public int? server_port { get; set; }
public string uuid { get; set; } public string uuid { get; set; }
public string security { get; set; } public string security { get; set; }
@@ -238,7 +238,9 @@
public string? tag { get; set; } public string? tag { get; set; }
public string? type { get; set; } public string? type { get; set; }
public string? format { get; set; } public string? format { get; set; }
public string? path { get; set; }
public string? url { get; set; } public string? url { get; set; }
public string? download_detour { get; set; } public string? download_detour { get; set; }
public string? update_interval { get; set; }
} }
} }

View File

@@ -195,7 +195,7 @@ namespace v2rayN.Models
public class Sniffing4Ray public class Sniffing4Ray
{ {
public bool enabled { get; set; } public bool enabled { get; set; }
public List<string> destOverride { get; set; } public List<string>? destOverride { get; set; }
public bool routeOnly { get; set; } public bool routeOnly { get; set; }
} }

View File

@@ -411,6 +411,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Custom the rule-set of sing-box 的本地化字符串。
/// </summary>
public static string LvCustomRulesetPath4Singbox {
get {
return ResourceManager.GetString("LvCustomRulesetPath4Singbox", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Enabled Update 的本地化字符串。 /// 查找类似 Enabled Update 的本地化字符串。
/// </summary> /// </summary>
@@ -969,6 +978,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Open the storage location 的本地化字符串。
/// </summary>
public static string menuOpenTheFileLocation {
get {
return ResourceManager.GetString("menuOpenTheFileLocation", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Option Setting 的本地化字符串。 /// 查找类似 Option Setting 的本地化字符串。
/// </summary> /// </summary>
@@ -1572,6 +1590,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Successful operation. Click the settings menu to reboot the app. 的本地化字符串。
/// </summary>
public static string NeedRebootTips {
get {
return ResourceManager.GetString("NeedRebootTips", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Non-VMess or ss protocol 的本地化字符串。 /// 查找类似 Non-VMess or ss protocol 的本地化字符串。
/// </summary> /// </summary>
@@ -2608,6 +2635,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Enable cache file for sing-box (ruleset files) 的本地化字符串。
/// </summary>
public static string TbSettingsEnableCacheFile4Sbox {
get {
return ResourceManager.GetString("TbSettingsEnableCacheFile4Sbox", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Check for pre-release updates 的本地化字符串。 /// 查找类似 Check for pre-release updates 的本地化字符串。
/// </summary> /// </summary>

View File

@@ -1003,4 +1003,7 @@
<data name="TbSettingsEnableHWA" xml:space="preserve"> <data name="TbSettingsEnableHWA" xml:space="preserve">
<value>فعال‌سازی شتاب‌دهنده سخت‌افزاری (نیاز به راه‌اندازی مجدد)</value> <value>فعال‌سازی شتاب‌دهنده سخت‌افزاری (نیاز به راه‌اندازی مجدد)</value>
</data> </data>
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
<value>فعال کردن کش فایل مجموعه قوانین برای sing-box</value>
</data>
</root> </root>

View File

@@ -1207,4 +1207,16 @@
<data name="TbSettingsEnableFragment" xml:space="preserve"> <data name="TbSettingsEnableFragment" xml:space="preserve">
<value>Enable fragment</value> <value>Enable fragment</value>
</data> </data>
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
<value>Enable cache file for sing-box (ruleset files)</value>
</data>
<data name="LvCustomRulesetPath4Singbox" xml:space="preserve">
<value>Custom the rule-set of sing-box</value>
</data>
<data name="NeedRebootTips" xml:space="preserve">
<value>Successful operation. Click the settings menu to reboot the app.</value>
</data>
<data name="menuOpenTheFileLocation" xml:space="preserve">
<value>Open the storage location</value>
</data>
</root> </root>

View File

@@ -1204,4 +1204,16 @@
<data name="TbSettingsEnableFragmentTips" xml:space="preserve"> <data name="TbSettingsEnableFragmentTips" xml:space="preserve">
<value>使用Xray且非Tun模式启用和分组前置代理冲突</value> <value>使用Xray且非Tun模式启用和分组前置代理冲突</value>
</data> </data>
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
<value>启用sing-box规则集文件的缓存文件</value>
</data>
<data name="LvCustomRulesetPath4Singbox" xml:space="preserve">
<value>自定义sing-box rule-set</value>
</data>
<data name="NeedRebootTips" xml:space="preserve">
<value>操作成功。请点击设置菜单重启应用。</value>
</data>
<data name="menuOpenTheFileLocation" xml:space="preserve">
<value>打开存储所在的位置</value>
</data>
</root> </root>

View File

@@ -1177,4 +1177,16 @@
<data name="TbSettingsEnableFragmentTips" xml:space="preserve"> <data name="TbSettingsEnableFragmentTips" xml:space="preserve">
<value>使用Xray且非Tun模式啟用和分組前置代理衝突</value> <value>使用Xray且非Tun模式啟用和分組前置代理衝突</value>
</data> </data>
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
<value>啟用sing-box規則集文件的緩存文件</value>
</data>
<data name="LvCustomRulesetPath4Singbox" xml:space="preserve">
<value>自訂sing-box rule-set</value>
</data>
<data name="NeedRebootTips" xml:space="preserve">
<value>操作成功。 請點選設定選單重啟應用程式。</value>
</data>
<data name="menuOpenTheFileLocation" xml:space="preserve">
<value>打開儲存所在的位置</value>
</data>
</root> </root>

View File

@@ -4,56 +4,7 @@
"error": "Verror.log", "error": "Verror.log",
"loglevel": "warning" "loglevel": "warning"
}, },
"inbounds": [{ "inbounds": [],
"tag": "tag1",
"port": 10808,
"protocol": "socks",
"listen": "127.0.0.1",
"settings": {
"auth": "noauth",
"udp": true
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
},
{
"tag": "tag2",
"port": 10809,
"protocol": "http",
"listen": "127.0.0.1",
"settings": {
"allowTransparent": false
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
},
{
"tag": "tag3",
"port": 10809,
"protocol": "http",
"listen": "127.0.0.1",
"settings": {
"allowTransparent": false
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [{ "outbounds": [{
"tag": "proxy", "tag": "proxy",
"protocol": "vmess", "protocol": "vmess",

View File

@@ -3,14 +3,7 @@
"level": "debug", "level": "debug",
"timestamp": true "timestamp": true
}, },
"inbounds": [ "inbounds": [],
{
"type": "socks",
"tag": "socks",
"listen": "127.0.0.1",
"listen_port": 10000
}
],
"outbounds": [ "outbounds": [
{ {
"type": "vless", "type": "vless",

View File

@@ -30,5 +30,6 @@
], ],
"server": "block" "server": "block"
} }
] ],
"final": "local"
} }

View File

@@ -30,5 +30,6 @@
], ],
"server": "block" "server": "block"
} }
] ],
"final": "local"
} }

View File

@@ -56,7 +56,7 @@ namespace v2rayN.ViewModels
SaveServer(); SaveServer();
}); });
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark); Utils.SetDarkBorder(view, _config.uiItem.followSystemTheme ? !Utils.IsLightTheme() : _config.uiItem.colorModeDark);
} }
private void SaveServer() private void SaveServer()

View File

@@ -44,7 +44,7 @@ namespace v2rayN.ViewModels
SaveServer(); SaveServer();
}); });
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark); Utils.SetDarkBorder(view, _config.uiItem.followSystemTheme ? !Utils.IsLightTheme() : _config.uiItem.colorModeDark);
} }
private void SaveServer() private void SaveServer()

View File

@@ -56,7 +56,7 @@ namespace v2rayN.ViewModels
tunDNS2 = Utils.GetEmbedText(Global.TunSingboxDNSFileName); tunDNS2 = Utils.GetEmbedText(Global.TunSingboxDNSFileName);
}); });
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark); Utils.SetDarkBorder(view, _config.uiItem.followSystemTheme ? !Utils.IsLightTheme() : _config.uiItem.colorModeDark);
} }
private void SaveSetting() private void SaveSetting()

View File

@@ -143,7 +143,8 @@ namespace v2rayN.ViewModels
public ReactiveCommand<Unit, Unit> GlobalHotkeySettingCmd { get; } public ReactiveCommand<Unit, Unit> GlobalHotkeySettingCmd { get; }
public ReactiveCommand<Unit, Unit> RebootAsAdminCmd { get; } public ReactiveCommand<Unit, Unit> RebootAsAdminCmd { get; }
public ReactiveCommand<Unit, Unit> ClearServerStatisticsCmd { get; } public ReactiveCommand<Unit, Unit> ClearServerStatisticsCmd { get; }
public ReactiveCommand<Unit, Unit> ImportOldGuiConfigCmd { get; } public ReactiveCommand<Unit, Unit> OpenTheFileLocationCmd { get; }
//public ReactiveCommand<Unit, Unit> ImportOldGuiConfigCmd { get; }
//CheckUpdate //CheckUpdate
public ReactiveCommand<Unit, Unit> CheckUpdateNCmd { get; } public ReactiveCommand<Unit, Unit> CheckUpdateNCmd { get; }
@@ -503,10 +504,14 @@ namespace v2rayN.ViewModels
_statistics?.ClearAllServerStatistics(); _statistics?.ClearAllServerStatistics();
RefreshServers(); RefreshServers();
}); });
ImportOldGuiConfigCmd = ReactiveCommand.Create(() => OpenTheFileLocationCmd = ReactiveCommand.Create(() =>
{ {
ImportOldGuiConfig(); Utils.ProcessStart("Explorer", $"/select,{Utils.GetConfigPath()}");
}); });
//ImportOldGuiConfigCmd = ReactiveCommand.Create(() =>
//{
// ImportOldGuiConfig();
//});
//CheckUpdate //CheckUpdate
CheckUpdateNCmd = ReactiveCommand.Create(() => CheckUpdateNCmd = ReactiveCommand.Create(() =>
@@ -1021,10 +1026,10 @@ namespace v2rayN.ViewModels
{ {
ShowHideWindow(false); ShowHideWindow(false);
var dpiXY = Utils.GetDpiXY(Application.Current.MainWindow); var dpiXY = QRCodeHelper.GetDpiXY(Application.Current.MainWindow);
string result = await Task.Run(() => string result = await Task.Run(() =>
{ {
return Utils.ScanScreen(dpiXY.Item1, dpiXY.Item2); return QRCodeHelper.ScanScreen(dpiXY.Item1, dpiXY.Item2);
}); });
ShowHideWindow(true); ShowHideWindow(true);
@@ -1422,32 +1427,32 @@ namespace v2rayN.ViewModels
catch { } catch { }
} }
private void ImportOldGuiConfig() //private void ImportOldGuiConfig()
{ //{
if (UI.OpenFileDialog(out string fileName, // if (UI.OpenFileDialog(out string fileName,
"guiNConfig|*.json|All|*.*") != true) // "guiNConfig|*.json|All|*.*") != true)
{ // {
return; // return;
} // }
if (Utils.IsNullOrEmpty(fileName)) // if (Utils.IsNullOrEmpty(fileName))
{ // {
return; // return;
} // }
var ret = ConfigHandler.ImportOldGuiConfig(_config, fileName); // var ret = ConfigHandler.ImportOldGuiConfig(_config, fileName);
if (ret == 0) // if (ret == 0)
{ // {
RefreshRoutingsMenu(); // RefreshRoutingsMenu();
InitSubscriptionView(); // InitSubscriptionView();
RefreshServers(); // RefreshServers();
Reload(); // Reload();
_noticeHandler?.Enqueue(ResUI.OperationSuccess); // _noticeHandler?.Enqueue(ResUI.OperationSuccess);
} // }
else // else
{ // {
_noticeHandler?.Enqueue(ResUI.OperationFailed); // _noticeHandler?.Enqueue(ResUI.OperationFailed);
} // }
} //}
#endregion Setting #endregion Setting
@@ -1847,7 +1852,7 @@ namespace v2rayN.ViewModels
{ {
var theme = _paletteHelper.GetTheme(); var theme = _paletteHelper.GetTheme();
theme.SetBaseTheme(isDarkTheme ? Theme.Dark : Theme.Light); theme.SetBaseTheme(isDarkTheme ? BaseTheme.Dark : BaseTheme.Light);
_paletteHelper.SetTheme(theme); _paletteHelper.SetTheme(theme);
Utils.SetDarkBorder(Application.Current.MainWindow, isDarkTheme); Utils.SetDarkBorder(Application.Current.MainWindow, isDarkTheme);

View File

@@ -20,6 +20,7 @@ namespace v2rayN.ViewModels
[Reactive] public int localPort { get; set; } [Reactive] public int localPort { get; set; }
[Reactive] public bool udpEnabled { get; set; } [Reactive] public bool udpEnabled { get; set; }
[Reactive] public bool sniffingEnabled { get; set; } [Reactive] public bool sniffingEnabled { get; set; }
public IList<string> destOverride { get; set; }
[Reactive] public bool routeOnly { get; set; } [Reactive] public bool routeOnly { get; set; }
[Reactive] public bool allowLANConn { get; set; } [Reactive] public bool allowLANConn { get; set; }
[Reactive] public bool newPort4LAN { get; set; } [Reactive] public bool newPort4LAN { get; set; }
@@ -32,6 +33,7 @@ namespace v2rayN.ViewModels
[Reactive] public string defFingerprint { get; set; } [Reactive] public string defFingerprint { get; set; }
[Reactive] public string defUserAgent { get; set; } [Reactive] public string defUserAgent { get; set; }
[Reactive] public string mux4SboxProtocol { get; set; } [Reactive] public string mux4SboxProtocol { get; set; }
[Reactive] public bool enableCacheFile4Sbox { get; set; }
[Reactive] public int hyUpMbps { get; set; } [Reactive] public int hyUpMbps { get; set; }
[Reactive] public int hyDownMbps { get; set; } [Reactive] public int hyDownMbps { get; set; }
[Reactive] public bool enableFragment { get; set; } [Reactive] public bool enableFragment { get; set; }
@@ -63,9 +65,9 @@ namespace v2rayN.ViewModels
[Reactive] public bool EnableCheckPreReleaseUpdate { get; set; } [Reactive] public bool EnableCheckPreReleaseUpdate { get; set; }
[Reactive] public bool EnableDragDropSort { get; set; } [Reactive] public bool EnableDragDropSort { get; set; }
[Reactive] public bool DoubleClick2Activate { get; set; } [Reactive] public bool DoubleClick2Activate { get; set; }
[Reactive] public int autoUpdateInterval { get; set; } [Reactive] public int AutoUpdateInterval { get; set; }
[Reactive] public int trayMenuServersLimit { get; set; } [Reactive] public int TrayMenuServersLimit { get; set; }
[Reactive] public string currentFontFamily { get; set; } [Reactive] public string CurrentFontFamily { get; set; }
[Reactive] public int SpeedTestTimeout { get; set; } [Reactive] public int SpeedTestTimeout { get; set; }
[Reactive] public string SpeedTestUrl { get; set; } [Reactive] public string SpeedTestUrl { get; set; }
[Reactive] public string SpeedPingTestUrl { get; set; } [Reactive] public string SpeedPingTestUrl { get; set; }
@@ -128,6 +130,7 @@ namespace v2rayN.ViewModels
defFingerprint = _config.coreBasicItem.defFingerprint; defFingerprint = _config.coreBasicItem.defFingerprint;
defUserAgent = _config.coreBasicItem.defUserAgent; defUserAgent = _config.coreBasicItem.defUserAgent;
mux4SboxProtocol = _config.mux4SboxItem.protocol; mux4SboxProtocol = _config.mux4SboxItem.protocol;
enableCacheFile4Sbox = _config.coreBasicItem.enableCacheFile4Sbox;
hyUpMbps = _config.hysteriaItem.up_mbps; hyUpMbps = _config.hysteriaItem.up_mbps;
hyDownMbps = _config.hysteriaItem.down_mbps; hyDownMbps = _config.hysteriaItem.down_mbps;
enableFragment = _config.coreBasicItem.enableFragment; enableFragment = _config.coreBasicItem.enableFragment;
@@ -159,9 +162,9 @@ namespace v2rayN.ViewModels
EnableCheckPreReleaseUpdate = _config.guiItem.checkPreReleaseUpdate; EnableCheckPreReleaseUpdate = _config.guiItem.checkPreReleaseUpdate;
EnableDragDropSort = _config.uiItem.enableDragDropSort; EnableDragDropSort = _config.uiItem.enableDragDropSort;
DoubleClick2Activate = _config.uiItem.doubleClick2Activate; DoubleClick2Activate = _config.uiItem.doubleClick2Activate;
autoUpdateInterval = _config.guiItem.autoUpdateInterval; AutoUpdateInterval = _config.guiItem.autoUpdateInterval;
trayMenuServersLimit = _config.guiItem.trayMenuServersLimit; TrayMenuServersLimit = _config.guiItem.trayMenuServersLimit;
currentFontFamily = _config.uiItem.currentFontFamily; CurrentFontFamily = _config.uiItem.currentFontFamily;
SpeedTestTimeout = _config.speedTestItem.speedTestTimeout; SpeedTestTimeout = _config.speedTestItem.speedTestTimeout;
SpeedTestUrl = _config.speedTestItem.speedTestUrl; SpeedTestUrl = _config.speedTestItem.speedTestUrl;
SpeedPingTestUrl = _config.speedTestItem.speedPingTestUrl; SpeedPingTestUrl = _config.speedTestItem.speedPingTestUrl;
@@ -194,7 +197,7 @@ namespace v2rayN.ViewModels
SaveSetting(); SaveSetting();
}); });
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark); Utils.SetDarkBorder(view, _config.uiItem.followSystemTheme ? !Utils.IsLightTheme() : _config.uiItem.colorModeDark);
} }
private void InitCoreType() private void InitCoreType()
@@ -257,6 +260,10 @@ namespace v2rayN.ViewModels
_noticeHandler?.Enqueue(ResUI.FillLocalListeningPort); _noticeHandler?.Enqueue(ResUI.FillLocalListeningPort);
return; return;
} }
var needReboot = (EnableStatistics != _config.guiItem.enableStatistics
|| EnableDragDropSort != _config.uiItem.enableDragDropSort
|| EnableHWA != _config.guiItem.enableHWA
|| CurrentFontFamily != _config.uiItem.currentFontFamily);
//if (Utile.IsNullOrEmpty(Kcpmtu.ToString()) || !Utile.IsNumeric(Kcpmtu.ToString()) //if (Utile.IsNullOrEmpty(Kcpmtu.ToString()) || !Utile.IsNumeric(Kcpmtu.ToString())
// || Utile.IsNullOrEmpty(Kcptti.ToString()) || !Utile.IsNumeric(Kcptti.ToString()) // || Utile.IsNullOrEmpty(Kcptti.ToString()) || !Utile.IsNumeric(Kcptti.ToString())
@@ -273,6 +280,7 @@ namespace v2rayN.ViewModels
_config.inbound[0].localPort = localPort; _config.inbound[0].localPort = localPort;
_config.inbound[0].udpEnabled = udpEnabled; _config.inbound[0].udpEnabled = udpEnabled;
_config.inbound[0].sniffingEnabled = sniffingEnabled; _config.inbound[0].sniffingEnabled = sniffingEnabled;
_config.inbound[0].destOverride = destOverride?.ToList();
_config.inbound[0].routeOnly = routeOnly; _config.inbound[0].routeOnly = routeOnly;
_config.inbound[0].allowLANConn = allowLANConn; _config.inbound[0].allowLANConn = allowLANConn;
_config.inbound[0].newPort4LAN = newPort4LAN; _config.inbound[0].newPort4LAN = newPort4LAN;
@@ -289,6 +297,7 @@ namespace v2rayN.ViewModels
_config.coreBasicItem.defFingerprint = defFingerprint; _config.coreBasicItem.defFingerprint = defFingerprint;
_config.coreBasicItem.defUserAgent = defUserAgent; _config.coreBasicItem.defUserAgent = defUserAgent;
_config.mux4SboxItem.protocol = mux4SboxProtocol; _config.mux4SboxItem.protocol = mux4SboxProtocol;
_config.coreBasicItem.enableCacheFile4Sbox = enableCacheFile4Sbox;
_config.hysteriaItem.up_mbps = hyUpMbps; _config.hysteriaItem.up_mbps = hyUpMbps;
_config.hysteriaItem.down_mbps = hyDownMbps; _config.hysteriaItem.down_mbps = hyDownMbps;
_config.coreBasicItem.enableFragment = enableFragment; _config.coreBasicItem.enableFragment = enableFragment;
@@ -312,12 +321,12 @@ namespace v2rayN.ViewModels
_config.uiItem.enableUpdateSubOnlyRemarksExist = EnableUpdateSubOnlyRemarksExist; _config.uiItem.enableUpdateSubOnlyRemarksExist = EnableUpdateSubOnlyRemarksExist;
_config.guiItem.enableSecurityProtocolTls13 = EnableSecurityProtocolTls13; _config.guiItem.enableSecurityProtocolTls13 = EnableSecurityProtocolTls13;
_config.uiItem.autoHideStartup = AutoHideStartup; _config.uiItem.autoHideStartup = AutoHideStartup;
_config.guiItem.autoUpdateInterval = autoUpdateInterval; _config.guiItem.autoUpdateInterval = AutoUpdateInterval;
_config.guiItem.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate; _config.guiItem.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate;
_config.uiItem.enableDragDropSort = EnableDragDropSort; _config.uiItem.enableDragDropSort = EnableDragDropSort;
_config.uiItem.doubleClick2Activate = DoubleClick2Activate; _config.uiItem.doubleClick2Activate = DoubleClick2Activate;
_config.guiItem.trayMenuServersLimit = trayMenuServersLimit; _config.guiItem.trayMenuServersLimit = TrayMenuServersLimit;
_config.uiItem.currentFontFamily = currentFontFamily; _config.uiItem.currentFontFamily = CurrentFontFamily;
_config.speedTestItem.speedTestTimeout = SpeedTestTimeout; _config.speedTestItem.speedTestTimeout = SpeedTestTimeout;
_config.speedTestItem.speedTestUrl = SpeedTestUrl; _config.speedTestItem.speedTestUrl = SpeedTestUrl;
_config.speedTestItem.speedPingTestUrl = SpeedPingTestUrl; _config.speedTestItem.speedPingTestUrl = SpeedPingTestUrl;
@@ -339,8 +348,15 @@ namespace v2rayN.ViewModels
SaveCoreType(); SaveCoreType();
if (ConfigHandler.SaveConfig(_config) == 0) if (ConfigHandler.SaveConfig(_config) == 0)
{
if (needReboot)
{
_noticeHandler?.Enqueue(ResUI.NeedRebootTips);
}
else
{ {
_noticeHandler?.Enqueue(ResUI.OperationSuccess); _noticeHandler?.Enqueue(ResUI.OperationSuccess);
}
_view.DialogResult = true; _view.DialogResult = true;
} }
else else

View File

@@ -62,7 +62,7 @@ namespace v2rayN.ViewModels
SaveRules(); SaveRules();
}); });
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark); Utils.SetDarkBorder(view, _config.uiItem.followSystemTheme ? !Utils.IsLightTheme() : _config.uiItem.colorModeDark);
} }
private void SaveRules() private void SaveRules()

View File

@@ -115,7 +115,7 @@ namespace v2rayN.ViewModels
SaveRouting(); SaveRouting();
}); });
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark); Utils.SetDarkBorder(view, _config.uiItem.followSystemTheme ? !Utils.IsLightTheme() : _config.uiItem.colorModeDark);
} }
public void RefreshRulesItems() public void RefreshRulesItems()

View File

@@ -126,7 +126,7 @@ namespace v2rayN.ViewModels
SaveRouting(); SaveRouting();
}); });
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark); Utils.SetDarkBorder(view, _config.uiItem.followSystemTheme ? !Utils.IsLightTheme() : _config.uiItem.colorModeDark);
} }
#region locked #region locked
@@ -192,6 +192,7 @@ namespace v2rayN.ViewModels
remarks = item.remarks, remarks = item.remarks,
url = item.url, url = item.url,
customIcon = item.customIcon, customIcon = item.customIcon,
customRulesetPath4Singbox = item.customRulesetPath4Singbox,
sort = item.sort, sort = item.sort,
}; };
_routingItems.Add(it); _routingItems.Add(it);

View File

@@ -40,7 +40,7 @@ namespace v2rayN.ViewModels
SaveSub(); SaveSub();
}); });
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark); Utils.SetDarkBorder(view, _config.uiItem.followSystemTheme ? !Utils.IsLightTheme() : _config.uiItem.colorModeDark);
} }
private void SaveSub() private void SaveSub()

View File

@@ -62,7 +62,7 @@ namespace v2rayN.ViewModels
SubShare(); SubShare();
}, canEditRemove); }, canEditRemove);
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark); Utils.SetDarkBorder(view, _config.uiItem.followSystemTheme ? !Utils.IsLightTheme() : _config.uiItem.colorModeDark);
} }
public void RefreshSubItems() public void RefreshSubItems()

View File

@@ -88,6 +88,7 @@
Style="{StaticResource ToolbarTextBlock}"> Style="{StaticResource ToolbarTextBlock}">
<Hyperlink Click="linkDnsObjectDoc_Click"> <Hyperlink Click="linkDnsObjectDoc_Click">
<TextBlock Text="{x:Static resx:ResUI.TbDnsObjectDoc}" /> <TextBlock Text="{x:Static resx:ResUI.TbDnsObjectDoc}" />
<materialDesign:PackIcon Kind="Link" />
</Hyperlink> </Hyperlink>
</TextBlock> </TextBlock>
<Button <Button
@@ -120,6 +121,7 @@
Style="{StaticResource ToolbarTextBlock}"> Style="{StaticResource ToolbarTextBlock}">
<Hyperlink Click="linkDnsSingboxObjectDoc_Click"> <Hyperlink Click="linkDnsSingboxObjectDoc_Click">
<TextBlock Text="{x:Static resx:ResUI.TbDnsSingboxObjectDoc}" /> <TextBlock Text="{x:Static resx:ResUI.TbDnsSingboxObjectDoc}" />
<materialDesign:PackIcon Kind="Link" />
</Hyperlink> </Hyperlink>
</TextBlock> </TextBlock>
<Button <Button

View File

@@ -51,7 +51,7 @@ namespace v2rayN.Views
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e) private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
{ {
Utils.ProcessStart("https://www.v2fly.org/config/dns.html#dnsobject"); Utils.ProcessStart("https://xtls.github.io/config/dns.html#dnsobject");
} }
private void linkDnsSingboxObjectDoc_Click(object sender, RoutedEventArgs e) private void linkDnsSingboxObjectDoc_Click(object sender, RoutedEventArgs e)

View File

@@ -39,7 +39,7 @@ namespace v2rayN.Views
HotkeyHandler.Instance.IsPause = true; HotkeyHandler.Instance.IsPause = true;
this.Closing += (s, e) => HotkeyHandler.Instance.IsPause = false; this.Closing += (s, e) => HotkeyHandler.Instance.IsPause = false;
Utils.SetDarkBorder(this, _config.uiItem.colorModeDark); Utils.SetDarkBorder(this, _config.uiItem.followSystemTheme ? !Utils.IsLightTheme() : _config.uiItem.colorModeDark);
InitData(); InitData();
} }

View File

@@ -15,6 +15,7 @@
Title="v2rayN" Title="v2rayN"
Width="900" Width="900"
Height="700" Height="700"
MinWidth="900"
x:TypeArguments="vms:MainWindowViewModel" x:TypeArguments="vms:MainWindowViewModel"
Background="{DynamicResource MaterialDesignPaper}" Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}" FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
@@ -37,6 +38,7 @@
<materialDesign:DialogHost <materialDesign:DialogHost
Identifier="RootDialog" Identifier="RootDialog"
materialDesign:TransitionAssist.DisableTransitions="True"
SnackbarMessageQueue="{Binding ElementName=MainSnackbar, Path=MessageQueue}" SnackbarMessageQueue="{Binding ElementName=MainSnackbar, Path=MessageQueue}"
Style="{StaticResource MaterialDesignEmbeddedDialogHost}"> Style="{StaticResource MaterialDesignEmbeddedDialogHost}">
<Grid> <Grid>
@@ -190,9 +192,13 @@
Header="{x:Static resx:ResUI.menuClearServerStatistics}" /> Header="{x:Static resx:ResUI.menuClearServerStatistics}" />
<Separator Margin="-40,5" /> <Separator Margin="-40,5" />
<MenuItem <MenuItem
x:Name="menuOpenTheFileLocation"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuOpenTheFileLocation}" />
<!--<MenuItem
x:Name="menuImportOldGuiConfig" x:Name="menuImportOldGuiConfig"
Height="{StaticResource MenuItemHeight}" Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuImportOldGuiConfig}" /> Header="{x:Static resx:ResUI.menuImportOldGuiConfig}" />-->
</MenuItem> </MenuItem>
</Menu> </Menu>
<Separator /> <Separator />
@@ -669,9 +675,9 @@
<Style BasedOn="{StaticResource MaterialDesignDataGridCell}" TargetType="DataGridCell"> <Style BasedOn="{StaticResource MaterialDesignDataGridCell}" TargetType="DataGridCell">
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding isActive}" Value="True"> <DataTrigger Binding="{Binding isActive}" Value="True">
<Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}" /> <Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.Primary.Light}" />
<Setter Property="Foreground" Value="Black" /> <Setter Property="Foreground" Value="Black" />
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueLightBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.Primary.Light}" />
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>

View File

@@ -138,7 +138,8 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.GlobalHotkeySettingCmd, v => v.menuGlobalHotkeySetting).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.GlobalHotkeySettingCmd, v => v.menuGlobalHotkeySetting).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.RebootAsAdminCmd, v => v.menuRebootAsAdmin).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.RebootAsAdminCmd, v => v.menuRebootAsAdmin).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ImportOldGuiConfigCmd, v => v.menuImportOldGuiConfig).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.OpenTheFileLocationCmd, v => v.menuOpenTheFileLocation).DisposeWith(disposables);
//this.BindCommand(ViewModel, vm => vm.ImportOldGuiConfigCmd, v => v.menuImportOldGuiConfig).DisposeWith(disposables);
//check update //check update
this.BindCommand(ViewModel, vm => vm.CheckUpdateNCmd, v => v.menuCheckUpdateN).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.CheckUpdateNCmd, v => v.menuCheckUpdateN).DisposeWith(disposables);

View File

@@ -17,7 +17,6 @@
<TextBlock <TextBlock
Margin="8,0" Margin="8,0"
VerticalAlignment="Center" VerticalAlignment="Center"
Foreground="{DynamicResource PrimaryHueLightBrush}"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.MsgInformationTitle}" /> Text="{x:Static resx:ResUI.MsgInformationTitle}" />
<ComboBox <ComboBox

View File

@@ -68,6 +68,7 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@@ -118,12 +119,22 @@
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsSniffingEnabled}" /> Text="{x:Static resx:ResUI.TbSettingsSniffingEnabled}" />
<ToggleButton <StackPanel
x:Name="togsniffingEnabled"
Grid.Row="2" Grid.Row="2"
Grid.Column="1" Grid.Column="1"
Grid.ColumnSpan="2"
Orientation="Horizontal">
<ToggleButton
x:Name="togsniffingEnabled"
Margin="{StaticResource SettingItemMargin}" Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" /> HorizontalAlignment="Left" />
<ListBox
x:Name="clbdestOverride"
Margin="4"
HorizontalAlignment="Left"
FontSize="{DynamicResource StdFontSize}"
Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" />
</StackPanel>
<TextBlock <TextBlock
Grid.Row="3" Grid.Row="3"
@@ -314,10 +325,24 @@
Margin="{StaticResource SettingItemMargin}" Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsEnableCacheFile4Sbox}" />
<ToggleButton
x:Name="togenableCacheFile4Sbox"
Grid.Row="15"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="16"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsHysteriaBandwidth}" /> Text="{x:Static resx:ResUI.TbSettingsHysteriaBandwidth}" />
<StackPanel <StackPanel
Grid.Row="15" Grid.Row="16"
Grid.Column="1" Grid.Column="1"
Orientation="Horizontal"> Orientation="Horizontal">
@@ -336,7 +361,7 @@
</StackPanel> </StackPanel>
<TextBlock <TextBlock
Grid.Row="16" Grid.Row="17"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource SettingItemMargin}" Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center" VerticalAlignment="Center"
@@ -344,12 +369,12 @@
Text="{x:Static resx:ResUI.TbSettingsEnableFragment}" /> Text="{x:Static resx:ResUI.TbSettingsEnableFragment}" />
<ToggleButton <ToggleButton
x:Name="togenableFragment" x:Name="togenableFragment"
Grid.Row="16" Grid.Row="17"
Grid.Column="1" Grid.Column="1"
Margin="{StaticResource SettingItemMargin}" Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" /> HorizontalAlignment="Left" />
<TextBlock <TextBlock
Grid.Row="16" Grid.Row="17"
Grid.Column="3" Grid.Column="3"
Margin="{StaticResource SettingItemMargin}" Margin="{StaticResource SettingItemMargin}"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"

View File

@@ -30,9 +30,19 @@ namespace v2rayN.Views
this.Owner = Application.Current.MainWindow; this.Owner = Application.Current.MainWindow;
_config = LazyConfig.Instance.GetConfig(); _config = LazyConfig.Instance.GetConfig();
var lstFonts = GetFonts(Utils.GetFontsPath());
ViewModel = new OptionSettingViewModel(this); ViewModel = new OptionSettingViewModel(this);
clbdestOverride.SelectionChanged += ClbdestOverride_SelectionChanged;
Global.destOverrideProtocols.ForEach(it =>
{
clbdestOverride.Items.Add(it);
});
_config.inbound[0].destOverride?.ForEach(it =>
{
clbdestOverride.SelectedItems.Add(it);
});
Global.IEProxyProtocols.ForEach(it => Global.IEProxyProtocols.ForEach(it =>
{ {
cmbsystemProxyAdvancedProtocol.Items.Add(it); cmbsystemProxyAdvancedProtocol.Items.Add(it);
@@ -89,14 +99,91 @@ namespace v2rayN.Views
cmbSubConvertUrl.Items.Add(it); cmbSubConvertUrl.Items.Add(it);
}); });
//fill fonts lstFonts.ForEach(it => { cmbcurrentFontFamily.Items.Add(it); });
cmbcurrentFontFamily.Items.Add(string.Empty);
this.WhenActivated(disposables =>
{
this.Bind(ViewModel, vm => vm.localPort, v => v.txtlocalPort.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.udpEnabled, v => v.togudpEnabled.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.sniffingEnabled, v => v.togsniffingEnabled.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.routeOnly, v => v.togrouteOnly.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.allowLANConn, v => v.togAllowLANConn.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.newPort4LAN, v => v.togNewPort4LAN.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.newPort4LAN, v => v.txtuser.IsEnabled).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.newPort4LAN, v => v.txtpass.IsEnabled).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.user, v => v.txtuser.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.pass, v => v.txtpass.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.muxEnabled, v => v.togmuxEnabled.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.logEnabled, v => v.toglogEnabled.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.loglevel, v => v.cmbloglevel.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defAllowInsecure, v => v.togdefAllowInsecure.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defFingerprint, v => v.cmbdefFingerprint.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defUserAgent, v => v.cmbdefUserAgent.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.mux4SboxProtocol, v => v.cmbmux4SboxProtocol.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.enableCacheFile4Sbox, v => v.togenableCacheFile4Sbox.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.hyUpMbps, v => v.txtUpMbps.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.hyDownMbps, v => v.txtDownMbps.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.enableFragment, v => v.togenableFragment.IsChecked).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.Kcpmtu, v => v.txtKcpmtu.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.Kcptti, v => v.txtKcptti.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.KcpuplinkCapacity, v => v.txtKcpuplinkCapacity.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.KcpdownlinkCapacity, v => v.txtKcpdownlinkCapacity.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.KcpreadBufferSize, v => v.txtKcpreadBufferSize.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.KcpwriteBufferSize, v => v.txtKcpwriteBufferSize.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.Kcpcongestion, v => v.togKcpcongestion.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoRun, v => v.togAutoRun.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableStatistics, v => v.togEnableStatistics.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.KeepOlderDedupl, v => v.togKeepOlderDedupl.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.IgnoreGeoUpdateCore, v => v.togIgnoreGeoUpdateCore.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableAutoAdjustMainLvColWidth, v => v.togEnableAutoAdjustMainLvColWidth.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableUpdateSubOnlyRemarksExist, v => v.togEnableUpdateSubOnlyRemarksExist.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableSecurityProtocolTls13, v => v.togEnableSecurityProtocolTls13.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoHideStartup, v => v.togAutoHideStartup.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableCheckPreReleaseUpdate, v => v.togEnableCheckPreReleaseUpdate.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableDragDropSort, v => v.togEnableDragDropSort.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.DoubleClick2Activate, v => v.togDoubleClick2Activate.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoUpdateInterval, v => v.txtautoUpdateInterval.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.TrayMenuServersLimit, v => v.txttrayMenuServersLimit.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentFontFamily, v => v.cmbcurrentFontFamily.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SpeedTestTimeout, v => v.cmbSpeedTestTimeout.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SpeedTestUrl, v => v.cmbSpeedTestUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SpeedPingTestUrl, v => v.cmbSpeedPingTestUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableHWA, v => v.togEnableHWA.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SubConvertUrl, v => v.cmbSubConvertUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.systemProxyAdvancedProtocol, v => v.cmbsystemProxyAdvancedProtocol.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.systemProxyExceptions, v => v.txtsystemProxyExceptions.Text).DisposeWith(disposables);
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);
this.Bind(ViewModel, vm => vm.CoreType3, v => v.cmbCoreType3.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CoreType4, v => v.cmbCoreType4.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CoreType5, v => v.cmbCoreType5.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CoreType6, v => v.cmbCoreType6.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
});
}
private List<string> GetFonts(string path)
{
var lstFonts = new List<string>();
try try
{ {
string[] searchPatterns = { "*.ttf", "*.ttc" }; string[] searchPatterns = { "*.ttf", "*.ttc" };
var files = new List<string>(); var files = new List<string>();
foreach (var pattern in searchPatterns) foreach (var pattern in searchPatterns)
{ {
files.AddRange(Directory.GetFiles(Utils.GetFontsPath(), pattern)); files.AddRange(Directory.GetFiles(path, pattern));
} }
var culture = _config.uiItem.currentLanguage == Global.Languages[0] ? "zh-cn" : "en-us"; var culture = _config.uiItem.currentLanguage == Global.Languages[0] ? "zh-cn" : "en-us";
var culture2 = "en-us"; var culture2 = "en-us";
@@ -123,7 +210,7 @@ namespace v2rayN.Views
continue; continue;
} }
} }
cmbcurrentFontFamily.Items.Add(fontFamily); lstFonts.Add(fontFamily);
break; break;
} }
} }
@@ -133,77 +220,12 @@ namespace v2rayN.Views
{ {
Logging.SaveLog("fill fonts error", ex); Logging.SaveLog("fill fonts error", ex);
} }
cmbcurrentFontFamily.Items.Add(string.Empty); return lstFonts;
}
this.WhenActivated(disposables => private void ClbdestOverride_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{ {
this.Bind(ViewModel, vm => vm.localPort, v => v.txtlocalPort.Text).DisposeWith(disposables); ViewModel.destOverride = clbdestOverride.SelectedItems.Cast<string>().ToList();
this.Bind(ViewModel, vm => vm.udpEnabled, v => v.togudpEnabled.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.sniffingEnabled, v => v.togsniffingEnabled.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.routeOnly, v => v.togrouteOnly.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.allowLANConn, v => v.togAllowLANConn.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.newPort4LAN, v => v.togNewPort4LAN.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.newPort4LAN, v => v.txtuser.IsEnabled).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.newPort4LAN, v => v.txtpass.IsEnabled).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.user, v => v.txtuser.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.pass, v => v.txtpass.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.muxEnabled, v => v.togmuxEnabled.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.logEnabled, v => v.toglogEnabled.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.loglevel, v => v.cmbloglevel.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defAllowInsecure, v => v.togdefAllowInsecure.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defFingerprint, v => v.cmbdefFingerprint.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defUserAgent, v => v.cmbdefUserAgent.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.mux4SboxProtocol, v => v.cmbmux4SboxProtocol.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.hyUpMbps, v => v.txtUpMbps.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.hyDownMbps, v => v.txtDownMbps.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.enableFragment, v => v.togenableFragment.IsChecked).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.Kcpmtu, v => v.txtKcpmtu.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.Kcptti, v => v.txtKcptti.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.KcpuplinkCapacity, v => v.txtKcpuplinkCapacity.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.KcpdownlinkCapacity, v => v.txtKcpdownlinkCapacity.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.KcpreadBufferSize, v => v.txtKcpreadBufferSize.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.KcpwriteBufferSize, v => v.txtKcpwriteBufferSize.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.Kcpcongestion, v => v.togKcpcongestion.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoRun, v => v.togAutoRun.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableStatistics, v => v.togEnableStatistics.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.KeepOlderDedupl, v => v.togKeepOlderDedupl.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.IgnoreGeoUpdateCore, v => v.togIgnoreGeoUpdateCore.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableAutoAdjustMainLvColWidth, v => v.togEnableAutoAdjustMainLvColWidth.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableUpdateSubOnlyRemarksExist, v => v.togEnableUpdateSubOnlyRemarksExist.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableSecurityProtocolTls13, v => v.togEnableSecurityProtocolTls13.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoHideStartup, v => v.togAutoHideStartup.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableCheckPreReleaseUpdate, v => v.togEnableCheckPreReleaseUpdate.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableDragDropSort, v => v.togEnableDragDropSort.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.DoubleClick2Activate, v => v.togDoubleClick2Activate.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.autoUpdateInterval, v => v.txtautoUpdateInterval.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.trayMenuServersLimit, v => v.txttrayMenuServersLimit.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.currentFontFamily, v => v.cmbcurrentFontFamily.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SpeedTestTimeout, v => v.cmbSpeedTestTimeout.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SpeedTestUrl, v => v.cmbSpeedTestUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SpeedPingTestUrl, v => v.cmbSpeedPingTestUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableHWA, v => v.togEnableHWA.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SubConvertUrl, v => v.cmbSubConvertUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.systemProxyAdvancedProtocol, v => v.cmbsystemProxyAdvancedProtocol.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.systemProxyExceptions, v => v.txtsystemProxyExceptions.Text).DisposeWith(disposables);
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);
this.Bind(ViewModel, vm => vm.CoreType3, v => v.cmbCoreType3.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CoreType4, v => v.cmbCoreType4.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CoreType5, v => v.cmbCoreType5.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CoreType6, v => v.cmbCoreType6.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
});
} }
} }
} }

View File

@@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:v2rayN.Converters" xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveui="http://reactiveui.net" xmlns:reactiveui="http://reactiveui.net"
xmlns:resx="clr-namespace:v2rayN.Resx" xmlns:resx="clr-namespace:v2rayN.Resx"
@@ -83,6 +84,7 @@
Style="{StaticResource ToolbarTextBlock}"> Style="{StaticResource ToolbarTextBlock}">
<Hyperlink Click="linkRuleobjectDoc_Click"> <Hyperlink Click="linkRuleobjectDoc_Click">
<TextBlock Text="{x:Static resx:ResUI.TbRuleobjectDoc}" /> <TextBlock Text="{x:Static resx:ResUI.TbRuleobjectDoc}" />
<materialDesign:PackIcon Kind="Link" />
</Hyperlink> </Hyperlink>
</TextBlock> </TextBlock>

View File

@@ -83,7 +83,7 @@ namespace v2rayN.Views
private void linkRuleobjectDoc_Click(object sender, RoutedEventArgs e) private void linkRuleobjectDoc_Click(object sender, RoutedEventArgs e)
{ {
Utils.ProcessStart("https://www.v2fly.org/config/routing.html#ruleobject"); Utils.ProcessStart("https://xtls.github.io/config/routing.html#ruleobject");
} }
} }
} }

View File

@@ -114,11 +114,16 @@
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.LvRemarks}" /> Text="{x:Static resx:ResUI.LvRemarks}" />
<StackPanel
Grid.Row="0"
Grid.Column="1"
Orientation="Horizontal">
<TextBox <TextBox
x:Name="txtRemarks" x:Name="txtRemarks"
Grid.Row="0" Grid.Row="0"
Grid.Column="1" Grid.Column="1"
Width="400" Width="300"
Margin="4" Margin="4"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
@@ -126,6 +131,20 @@
Style="{StaticResource DefTextBox}" Style="{StaticResource DefTextBox}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<TextBlock
Margin="4"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.LvSort}" />
<TextBox
x:Name="txtSort"
Width="100"
Margin="4"
HorizontalAlignment="Left"
AcceptsReturn="True"
Style="{StaticResource DefTextBox}" />
</StackPanel>
<TextBlock <TextBlock
Grid.Row="1" Grid.Row="1"
Grid.Column="0" Grid.Column="0"
@@ -190,11 +209,11 @@
Style="{StaticResource DefTextBox}" Style="{StaticResource DefTextBox}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<Button <Button
x:Name="btnBrowse" x:Name="btnBrowseCustomIcon"
Grid.Row="3" Grid.Row="3"
Grid.Column="2" Grid.Column="2"
Margin="2,0,8,0" Margin="2,0,8,0"
Click="btnBrowse_Click" Click="btnBrowseCustomIcon_Click"
Content="{x:Static resx:ResUI.TbBrowse}" Content="{x:Static resx:ResUI.TbBrowse}"
Style="{StaticResource DefButton}" /> Style="{StaticResource DefButton}" />
@@ -203,17 +222,30 @@
Grid.Column="0" Grid.Column="0"
Margin="4" Margin="4"
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}">
Text="{x:Static resx:ResUI.LvSort}" /> <Hyperlink Click="linkCustomRulesetPath4Singbox">
<TextBlock Text="{x:Static resx:ResUI.LvCustomRulesetPath4Singbox}" />
<materialDesign:PackIcon Kind="Link" />
</Hyperlink>
</TextBlock>
<TextBox <TextBox
x:Name="txtSort" x:Name="txtCustomRulesetPath4Singbox"
Grid.Row="4" Grid.Row="4"
Grid.Column="1" Grid.Column="1"
Width="200" Width="600"
Margin="4" Margin="4"
HorizontalAlignment="Left" VerticalAlignment="Top"
AcceptsReturn="True" AcceptsReturn="True"
Style="{StaticResource DefTextBox}" /> Style="{StaticResource DefTextBox}"
TextWrapping="Wrap" />
<Button
x:Name="btnBrowseCustomRulesetPath4Singbox"
Grid.Row="4"
Grid.Column="2"
Margin="2,0,8,0"
Click="btnBrowseCustomRulesetPath4Singbox_Click"
Content="{x:Static resx:ResUI.TbBrowse}"
Style="{StaticResource DefButton}" />
</Grid> </Grid>
<TabControl x:Name="tabAdvanced"> <TabControl x:Name="tabAdvanced">

View File

@@ -51,6 +51,7 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.SelectedRouting.url, v => v.txtUrl.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedRouting.url, v => v.txtUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedRouting.customIcon, v => v.txtCustomIcon.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedRouting.customIcon, v => v.txtCustomIcon.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedRouting.customRulesetPath4Singbox, v => v.txtCustomRulesetPath4Singbox.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedRouting.sort, v => v.txtSort.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedRouting.sort, v => v.txtSort.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.RuleAddCmd, v => v.menuRuleAdd).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.RuleAddCmd, v => v.menuRuleAdd).DisposeWith(disposables);
@@ -128,7 +129,7 @@ namespace v2rayN.Views
lstRules.SelectAll(); lstRules.SelectAll();
} }
private void btnBrowse_Click(object sender, System.Windows.RoutedEventArgs e) private void btnBrowseCustomIcon_Click(object sender, System.Windows.RoutedEventArgs e)
{ {
if (UI.OpenFileDialog(out string fileName, if (UI.OpenFileDialog(out string fileName,
"PNG,ICO|*.png;*.ico") != true) "PNG,ICO|*.png;*.ico") != true)
@@ -138,5 +139,21 @@ namespace v2rayN.Views
txtCustomIcon.Text = fileName; txtCustomIcon.Text = fileName;
} }
private void btnBrowseCustomRulesetPath4Singbox_Click(object sender, RoutedEventArgs e)
{
if (UI.OpenFileDialog(out string fileName,
"Config|*.json|All|*.*") != true)
{
return;
}
txtCustomRulesetPath4Singbox.Text = fileName;
}
private void linkCustomRulesetPath4Singbox(object sender, RoutedEventArgs e)
{
Utils.ProcessStart("https://github.com/2dust/v2rayCustomRoutingList/blob/master/singbox_custom_ruleset_example.json");
}
} }
} }

View File

@@ -90,6 +90,7 @@
Style="{StaticResource ToolbarTextBlock}"> Style="{StaticResource ToolbarTextBlock}">
<Hyperlink Click="linkdomainStrategy_Click"> <Hyperlink Click="linkdomainStrategy_Click">
<TextBlock Text="{x:Static resx:ResUI.TbdomainStrategy}" /> <TextBlock Text="{x:Static resx:ResUI.TbdomainStrategy}" />
<materialDesign:PackIcon Kind="Link" />
</Hyperlink> </Hyperlink>
</TextBlock> </TextBlock>
<ComboBox <ComboBox
@@ -115,6 +116,7 @@
Style="{StaticResource ToolbarTextBlock}"> Style="{StaticResource ToolbarTextBlock}">
<Hyperlink Click="linkdomainStrategy4Singbox_Click"> <Hyperlink Click="linkdomainStrategy4Singbox_Click">
<TextBlock Text="{x:Static resx:ResUI.TbdomainStrategy4Singbox}" /> <TextBlock Text="{x:Static resx:ResUI.TbdomainStrategy4Singbox}" />
<materialDesign:PackIcon Kind="Link" />
</Hyperlink> </Hyperlink>
</TextBlock> </TextBlock>
<ComboBox <ComboBox
@@ -199,9 +201,9 @@
<Style BasedOn="{StaticResource MaterialDesignDataGridCell}" TargetType="DataGridCell"> <Style BasedOn="{StaticResource MaterialDesignDataGridCell}" TargetType="DataGridCell">
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding isActive}" Value="True"> <DataTrigger Binding="{Binding isActive}" Value="True">
<Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}" /> <Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.Primary.Light}" />
<Setter Property="Foreground" Value="Black" /> <Setter Property="Foreground" Value="Black" />
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueLightBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.Primary.Light}" />
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>

View File

@@ -127,7 +127,7 @@ namespace v2rayN.Views
private void linkdomainStrategy_Click(object sender, System.Windows.RoutedEventArgs e) private void linkdomainStrategy_Click(object sender, System.Windows.RoutedEventArgs e)
{ {
Utils.ProcessStart("https://www.v2fly.org/config/routing.html"); Utils.ProcessStart("https://xtls.github.io/config/routing.html");
} }
private void linkdomainStrategy4Singbox_Click(object sender, RoutedEventArgs e) private void linkdomainStrategy4Singbox_Click(object sender, RoutedEventArgs e)

View File

@@ -23,7 +23,10 @@
TextOptions.TextRenderingMode="Auto" TextOptions.TextRenderingMode="Auto"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
mc:Ignorable="d"> mc:Ignorable="d">
<materialDesign:DialogHost Identifier="SubDialog" Style="{StaticResource MaterialDesignEmbeddedDialogHost}"> <materialDesign:DialogHost
materialDesign:TransitionAssist.DisableTransitions="True"
Identifier="SubDialog"
Style="{StaticResource MaterialDesignEmbeddedDialogHost}">
<DockPanel> <DockPanel>
<ToolBarTray DockPanel.Dock="Top"> <ToolBarTray DockPanel.Dock="Top">
<ToolBar <ToolBar

View File

@@ -10,22 +10,22 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>v2rayN.ico</ApplicationIcon> <ApplicationIcon>v2rayN.ico</ApplicationIcon>
<Copyright>Copyright © 2017-2024 (GPLv3)</Copyright> <Copyright>Copyright © 2017-2024 (GPLv3)</Copyright>
<FileVersion>6.43</FileVersion> <FileVersion>6.45</FileVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion> <SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Downloader" Version="3.0.6" /> <PackageReference Include="Downloader" Version="3.0.6" />
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" /> <PackageReference Include="MaterialDesignThemes" Version="5.0.0" />
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.124" /> <PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.131" />
<PackageReference Include="QRCoder.Xaml" Version="1.4.3" /> <PackageReference Include="QRCoder.Xaml" Version="1.5.1" />
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" /> <PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
<PackageReference Include="TaskScheduler" Version="2.10.1" /> <PackageReference Include="TaskScheduler" Version="2.11.0" />
<PackageReference Include="ZXing.Net.Bindings.Windows.Compatibility" Version="0.16.12" /> <PackageReference Include="ZXing.Net.Bindings.Windows.Compatibility" Version="0.16.12" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" /> <PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" /> <PackageReference Include="ReactiveUI.Validation" Version="4.0.9" />
<PackageReference Include="ReactiveUI.WPF" Version="19.6.1" /> <PackageReference Include="ReactiveUI.WPF" Version="20.0.1" />
<PackageReference Include="Splat.NLog" Version="14.8.12" /> <PackageReference Include="Splat.NLog" Version="15.1.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>