From ec756ee943a6f8f2a50f35dc7f3f3a2536d58c62 Mon Sep 17 00:00:00 2001 From: qiopgh <30387662+qiopgh@users.noreply.github.com> Date: Tue, 28 Feb 2023 22:08:15 +0800 Subject: [PATCH 1/7] Update tun_singbox_dns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为tun做dns分流 --- v2rayN/v2rayN/Sample/tun_singbox_dns | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/v2rayN/v2rayN/Sample/tun_singbox_dns b/v2rayN/v2rayN/Sample/tun_singbox_dns index c37b1248..2c1c690d 100644 --- a/v2rayN/v2rayN/Sample/tun_singbox_dns +++ b/v2rayN/v2rayN/Sample/tun_singbox_dns @@ -1,5 +1,10 @@ { "servers": [ + { + "tag": "out_dns", + "address": "8.8.8.8", + "detour": "proxy" + }, { "tag": "local", "address": "223.5.5.5", @@ -11,6 +16,11 @@ } ], "rules": [ + { + "geosite": "cn", + "server": "local", + "disable_cache": true + }, { "geosite": "category-ads-all", "server": "block", @@ -18,4 +28,4 @@ } ], "strategy": "ipv4_only" - } \ No newline at end of file + } From 947a7aa7dfb07427d2ae87546bba061d0248bf62 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 3 Mar 2023 10:15:39 +0800 Subject: [PATCH 2/7] Modify blacklist rules --- v2rayN/v2rayN/Sample/custom_routing_black | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/v2rayN/v2rayN/Sample/custom_routing_black b/v2rayN/v2rayN/Sample/custom_routing_black index 9005c944..3fbd928a 100644 --- a/v2rayN/v2rayN/Sample/custom_routing_black +++ b/v2rayN/v2rayN/Sample/custom_routing_black @@ -14,7 +14,14 @@ { "outboundTag": "proxy", "ip": [ - "geoip:telegram" + "geoip:cloudflare", + "geoip:cloudfront", + "geoip:facebook", + "geoip:fastly", + "geoip:google", + "geoip:netflix", + "geoip:telegram", + "geoip:twitter" ], "domain": [ "geosite:gfw", From 285f91e9e810934c9072c0d6d5b33b22ce8ca5c1 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 3 Mar 2023 10:16:04 +0800 Subject: [PATCH 3/7] bug fixes --- v2rayN/v2rayN/Handler/ConfigHandler.cs | 2 +- .../ViewModels/RoutingRuleSettingViewModel.cs | 21 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index 8d3776de..55ffed3f 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -959,7 +959,7 @@ namespace v2rayN.Handler var existItem = lstOriSub?.FirstOrDefault(t => CompareProfileItem(t, profileItem, true)); if (existItem != null) { - profileItem = existItem; + profileItem.indexId = existItem.indexId; } //filter if (!Utils.IsNullOrEmpty(subFilter)) diff --git a/v2rayN/v2rayN/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/RoutingRuleSettingViewModel.cs index 9766b3cd..f1bc5ebf 100644 --- a/v2rayN/v2rayN/ViewModels/RoutingRuleSettingViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/RoutingRuleSettingViewModel.cs @@ -299,7 +299,7 @@ namespace v2rayN.ViewModels UI.Show(ResUI.OperationSuccess); } } - private void ImportRulesFromUrl() + private async Task ImportRulesFromUrl() { var url = SelectedRouting.url; if (Utils.IsNullOrEmpty(url)) @@ -308,19 +308,16 @@ namespace v2rayN.ViewModels return; } - Task.Run(async () => + DownloadHandle downloadHandle = new DownloadHandle(); + string result = await downloadHandle.TryDownloadString(url, true, ""); + if (AddBatchRoutingRules(SelectedRouting, result) == 0) { - DownloadHandle downloadHandle = new DownloadHandle(); - string result = await downloadHandle.DownloadStringAsync(url, false, ""); - if (AddBatchRoutingRules(SelectedRouting, result) == 0) + Application.Current.Dispatcher.Invoke((Action)(() => { - Application.Current.Dispatcher.Invoke((Action)(() => - { - RefreshRulesItems(); - })); - UI.Show(ResUI.OperationSuccess); - } - }); + RefreshRulesItems(); + })); + UI.Show(ResUI.OperationSuccess); + } } private int AddBatchRoutingRules(RoutingItem routingItem, string clipboardData) { From b1eeb648a76d8c5049f285c8b2e18cc43177e58f Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 4 Mar 2023 08:36:57 +0800 Subject: [PATCH 4/7] Adjust style for icon --- v2rayN/v2rayN/Views/MainWindow.xaml | 46 +++++++++++++++---- .../Views/RoutingRuleSettingWindow.xaml | 20 ++++++-- v2rayN/v2rayN/Views/RoutingSettingWindow.xaml | 10 +++- v2rayN/v2rayN/Views/SubSettingWindow.xaml | 25 ++++++++-- 4 files changed, 81 insertions(+), 20 deletions(-) diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml b/v2rayN/v2rayN/Views/MainWindow.xaml index 9d0a2b11..1cb9c647 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml +++ b/v2rayN/v2rayN/Views/MainWindow.xaml @@ -53,7 +53,10 @@ - + @@ -99,7 +102,10 @@ - + @@ -131,7 +137,10 @@ - + @@ -169,7 +178,10 @@ - + @@ -180,7 +192,10 @@ - + @@ -221,7 +236,10 @@ - + @@ -235,7 +253,10 @@ Click="menuPromotion_Click"> - + @@ -249,7 +270,10 @@ Click="menuClose_Click"> - + @@ -352,7 +376,7 @@ Height="30" Margin="4,0" Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"> - + @@ -724,6 +749,7 @@ @@ -735,6 +761,7 @@ @@ -746,6 +773,7 @@ diff --git a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml index d8e482b8..9709fc1c 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml @@ -32,28 +32,40 @@ Style="{StaticResource MaterialDesignToolBar}"> diff --git a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml index e19e7008..c40e1d64 100644 --- a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml @@ -39,7 +39,10 @@ - + @@ -54,7 +57,10 @@ - + diff --git a/v2rayN/v2rayN/Views/SubSettingWindow.xaml b/v2rayN/v2rayN/Views/SubSettingWindow.xaml index 3cd1ebba..6e2242ed 100644 --- a/v2rayN/v2rayN/Views/SubSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/SubSettingWindow.xaml @@ -33,28 +33,40 @@ Style="{StaticResource MaterialDesignToolBar}"> @@ -63,7 +75,10 @@ Click="menuClose_Click" IsCancel="True"> - + From d4921535f28d72dbec106185a38525cdabdd0c98 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 4 Mar 2023 08:43:44 +0800 Subject: [PATCH 5/7] Add lock for db --- v2rayN/v2rayN/Base/SqliteHelper.cs | 25 ++++++++++++++++------ v2rayN/v2rayN/Handler/ProfileExHandler.cs | 4 ++-- v2rayN/v2rayN/Handler/StatisticsHandler.cs | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/v2rayN/v2rayN/Base/SqliteHelper.cs b/v2rayN/v2rayN/Base/SqliteHelper.cs index 4b6a2c3c..60c60811 100644 --- a/v2rayN/v2rayN/Base/SqliteHelper.cs +++ b/v2rayN/v2rayN/Base/SqliteHelper.cs @@ -9,8 +9,9 @@ namespace v2rayN.Base private static readonly Lazy _instance = new(() => new()); public static SqliteHelper Instance => _instance.Value; private string _connstr; - public SQLiteConnection _db; - public SQLiteAsyncConnection _dbAsync; + private SQLiteConnection _db; + private SQLiteAsyncConnection _dbAsync; + private static readonly object objLock = new(); public SqliteHelper() { @@ -34,7 +35,10 @@ namespace v2rayN.Base } public int Replace(object model) { - return _db.InsertOrReplace(model); + lock (objLock) + { + return _db.InsertOrReplace(model); + } } public async Task Replacesync(object model) { @@ -43,7 +47,10 @@ namespace v2rayN.Base public int Update(object model) { - return _db.Update(model); + lock (objLock) + { + return _db.Update(model); + } } public async Task UpdateAsync(object model) { @@ -51,12 +58,18 @@ namespace v2rayN.Base } public int UpdateAll(IEnumerable models) { - return _db.UpdateAll(models); + lock (objLock) + { + return _db.UpdateAll(models); + } } public int Delete(object model) { - return _db.Delete(model); + lock (objLock) + { + return _db.Delete(model); + } } public async Task DeleteAsync(object model) { diff --git a/v2rayN/v2rayN/Handler/ProfileExHandler.cs b/v2rayN/v2rayN/Handler/ProfileExHandler.cs index b230b330..902b8817 100644 --- a/v2rayN/v2rayN/Handler/ProfileExHandler.cs +++ b/v2rayN/v2rayN/Handler/ProfileExHandler.cs @@ -24,7 +24,7 @@ namespace v2rayN.Handler _lstProfileEx = new(SqliteHelper.Instance.Table()); - Task.Run(async () => + Task.Run(() => { while (true) { @@ -35,7 +35,7 @@ namespace v2rayN.Handler var item = _lstProfileEx.FirstOrDefault(t => t.indexId == id); if (item is not null) { - await SqliteHelper.Instance.Replacesync(item); + SqliteHelper.Instance.Replace(item); } } Thread.Sleep(1000 * 60); diff --git a/v2rayN/v2rayN/Handler/StatisticsHandler.cs b/v2rayN/v2rayN/Handler/StatisticsHandler.cs index fbd1eabc..8f95f22d 100644 --- a/v2rayN/v2rayN/Handler/StatisticsHandler.cs +++ b/v2rayN/v2rayN/Handler/StatisticsHandler.cs @@ -162,7 +162,7 @@ namespace v2rayN.Handler todayDown = 0, dateNow = ticks }; - _ = SqliteHelper.Instance.Replacesync(_serverStatItem); + SqliteHelper.Instance.Replace(_serverStatItem); _lstServerStat.Add(_serverStatItem); } } From eebc16bcdd962ea7b9a72056fb0c230c14202106 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 4 Mar 2023 08:51:29 +0800 Subject: [PATCH 6/7] Minimize windows when auto-hide is enabled --- v2rayN/v2rayN/Views/MainWindow.xaml.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index 9be80b66..f477c5fd 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -191,6 +191,11 @@ namespace v2rayN.Views this.Title = $"{Utils.GetVersion()} - {(IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}"; spEnableTun.Visibility = IsAdministrator ? Visibility.Visible : Visibility.Collapsed; + + if (_config.uiItem.autoHideStartup) + { + WindowState = WindowState.Minimized; + } } #region Event From 69050bfe4110c096b07d977b58daf32485b6f07a Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 4 Mar 2023 08:52:03 +0800 Subject: [PATCH 7/7] up 6.15 --- v2rayN/v2rayN/v2rayN.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2rayN/v2rayN/v2rayN.csproj b/v2rayN/v2rayN/v2rayN.csproj index 405266e0..704d0b5f 100644 --- a/v2rayN/v2rayN/v2rayN.csproj +++ b/v2rayN/v2rayN/v2rayN.csproj @@ -10,7 +10,7 @@ enable v2rayN.ico Copyright © 2017-2023 (GPLv3) - 6.14 + 6.15