From b5e1a297ae13b899e13a72f21f9921f2afb458dd Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Mon, 18 Nov 2024 16:44:12 +0800
Subject: [PATCH 1/5] Optimize Linux start tun mode
You can choose not to store the password and enter it manually each time
---
v2rayN/ServiceLib/Handler/CoreHandler.cs | 44 +++++++++++++++----
v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx | 2 +-
v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx | 2 +-
.../ViewModels/StatusBarViewModel.cs | 12 ++---
4 files changed, 43 insertions(+), 17 deletions(-)
diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs
index e181eb30..57e94557 100644
--- a/v2rayN/ServiceLib/Handler/CoreHandler.cs
+++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs
@@ -259,7 +259,7 @@ namespace ServiceLib.Handler
return _config.TunModeItem.EnableTun
&& eCoreType == ECoreType.sing_box
&& Utils.IsLinux()
- && _config.TunModeItem.LinuxSudoPwd.IsNotEmpty()
+ //&& _config.TunModeItem.LinuxSudoPwd.IsNotEmpty()
;
}
@@ -275,7 +275,6 @@ namespace ServiceLib.Handler
return null;
}
- var isNeedSudo = mayNeedSudo && IsNeedSudo(coreInfo.CoreType);
try
{
Process proc = new()
@@ -294,14 +293,10 @@ namespace ServiceLib.Handler
}
};
+ var isNeedSudo = mayNeedSudo && IsNeedSudo(coreInfo.CoreType);
if (isNeedSudo)
{
- proc.StartInfo.FileName = $"/bin/sudo";
- proc.StartInfo.Arguments = $"-S {fileName.AppendQuotes()} {string.Format(coreInfo.Arguments, Utils.GetConfigPath(configPath).AppendQuotes())}";
- proc.StartInfo.WorkingDirectory = null;
- proc.StartInfo.StandardInputEncoding = Encoding.UTF8;
- proc.StartInfo.RedirectStandardInput = true;
- Logging.SaveLog(proc.StartInfo.Arguments);
+ await RunProcessAsLinuxRoot(proc, fileName, coreInfo, configPath);
}
var startUpErrorMessage = new StringBuilder();
@@ -326,7 +321,7 @@ namespace ServiceLib.Handler
}
proc.Start();
- if (isNeedSudo)
+ if (isNeedSudo && _config.TunModeItem.LinuxSudoPwd.IsNotEmpty())
{
var pwd = DesUtils.Decrypt(_config.TunModeItem.LinuxSudoPwd);
await Task.Delay(10);
@@ -362,6 +357,37 @@ namespace ServiceLib.Handler
}
}
+ private async Task RunProcessAsLinuxRoot(Process proc, string fileName, CoreInfo coreInfo, string configPath)
+ {
+ var cmdLine = $"{fileName.AppendQuotes()} {string.Format(coreInfo.Arguments, Utils.GetConfigPath(configPath).AppendQuotes())}";
+
+ //Prefer shell scripts
+ var shFilePath = Utils.GetBinPath("run_as_root.sh");
+ File.Delete(shFilePath);
+ var sb = new StringBuilder();
+ sb.AppendLine("#!/bin/sh");
+ sb.AppendLine(cmdLine);
+ await File.WriteAllTextAsync(shFilePath, sb.ToString());
+ await Utils.SetLinuxChmod(shFilePath);
+
+ //Replace command
+ var args = File.Exists(shFilePath) ? shFilePath : cmdLine;
+ if (_config.TunModeItem.LinuxSudoPwd.IsNotEmpty())
+ {
+ proc.StartInfo.FileName = $"/bin/sudo";
+ proc.StartInfo.Arguments = $"-S {args}";
+ }
+ else
+ {
+ proc.StartInfo.FileName = $"/bin/pkexec";
+ proc.StartInfo.Arguments = $"{args}";
+ }
+ proc.StartInfo.WorkingDirectory = null;
+ proc.StartInfo.StandardInputEncoding = Encoding.UTF8;
+ proc.StartInfo.RedirectStandardInput = true;
+ Logging.SaveLog(proc.StartInfo.Arguments);
+ }
+
private async Task KillProcess(Process? proc)
{
if (proc is null)
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
index 9fd66a6e..c281a4ad 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
@@ -1370,7 +1370,7 @@
Linux系统的sudo密码
- 密码已加密且只存储在本地文件中,无密码无法开启Tun
+ 密码已加密且只存储在本地文件中,无密码则每次都要输入
请先在Tun模式设置中设置sudo密码
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
index 0243c1f3..2d18ce2e 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
@@ -1370,7 +1370,7 @@
Linux系統的sudo密碼
- 密碼已加密且只儲存在本機檔案中,無密碼無法開啟Tun
+ 密碼已加密且只儲存在本機檔案中,無密碼則每次都要輸入
請先在Tun模式設定中設定sudo密碼
diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
index 3298f636..89fbefc5 100644
--- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
@@ -416,16 +416,16 @@ namespace ServiceLib.ViewModels
// When running as a non-administrator, reboot to administrator mode
if (EnableTun && AllowEnableTun() == false)
{
- _config.TunModeItem.EnableTun = false;
if (Utils.IsWindows())
{
+ _config.TunModeItem.EnableTun = false;
Locator.Current.GetService()?.RebootAsAdmin();
+ return;
}
- else if (Utils.IsLinux())
- {
- NoticeHandler.Instance.SendMessageAndEnqueue(ResUI.TbSettingsLinuxSudoPasswordIsEmpty);
- }
- return;
+ //else if (Utils.IsLinux())
+ //{
+ // NoticeHandler.Instance.SendMessageAndEnqueue(ResUI.TbSettingsLinuxSudoPasswordIsEmpty);
+ //}
}
await ConfigHandler.SaveConfig(_config);
Locator.Current.GetService()?.Reload();
From 22eb993ebf47a3cb7a09f555f18eeb8932baa2bc Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Mon, 18 Nov 2024 16:51:51 +0800
Subject: [PATCH 2/5] up 7.1.3
---
v2rayN/ServiceLib/ServiceLib.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2rayN/ServiceLib/ServiceLib.csproj b/v2rayN/ServiceLib/ServiceLib.csproj
index d2f0c939..52c068df 100644
--- a/v2rayN/ServiceLib/ServiceLib.csproj
+++ b/v2rayN/ServiceLib/ServiceLib.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 7.1.2
+ 7.1.3
From 294cabcf05a79823f699cb969dd62ec7d3e34ce0 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Mon, 18 Nov 2024 17:14:42 +0800
Subject: [PATCH 3/5] Update README.md
---
README.md | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 1724e118..cfbea558 100644
--- a/README.md
+++ b/README.md
@@ -9,13 +9,19 @@ A GUI client for Windows and Linux, support [Xray core](https://github.com/XTLS/
## How to use
-- If you are new to this, please download v2rayN-With-Core.zip from [releases](https://github.com/2dust/v2rayN/releases)
-- Otherwise please download v2rayN.zip (you will also need to download cores in the bin directory)
-- Run v2rayN.exe
+Check [Release files introduction](https://github.com/2dust/v2rayN/wiki/Release-files-introduction) and select the version you need to download
+### Windows
+- Run `v2rayN.exe`
+### Linux
+- `chmod +x v2rayN` Run `./v2rayN`
+```
+Debian 9+
+Ubuntu 16.04+
+Fedora 30+
+```
## Requirements
-- (6.35 and above)[Microsoft .NET 8.0 Desktop Runtime ](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
-- (6.33 and below)[Microsoft .NET 6.0 Desktop Runtime ](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
+- [Microsoft .NET 8.0 Desktop Runtime ](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
- [Supported cores](https://github.com/2dust/v2rayN/wiki/List-of-supported-cores)
From 945a0add968f0a5971ac286287f8a5c0663cc61c Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Tue, 19 Nov 2024 15:52:08 +0800
Subject: [PATCH 4/5] Code clean
---
v2rayN/AmazTool/Assets/en-US.json | 24 +++++++++----------
v2rayN/AmazTool/Assets/zh-CN.json | 24 +++++++++----------
v2rayN/AmazTool/LocalizationHelper.cs | 4 ++--
v2rayN/AmazTool/UpgradeApp.cs | 2 +-
.../ServiceLib/Handler/StatisticsHandler.cs | 2 ++
.../Handler/SysProxy/ProxySettingOSX.cs | 3 +--
v2rayN/ServiceLib/Models/Config.cs | 1 +
.../Views/AddServerWindow.axaml.cs | 2 +-
.../v2rayN.Desktop/Views/MainWindow.axaml.cs | 2 +-
v2rayN/v2rayN/App.xaml | 2 +-
v2rayN/v2rayN/Views/AddServerWindow.xaml.cs | 2 +-
v2rayN/v2rayN/Views/ClashConnectionsView.xaml | 6 ++---
v2rayN/v2rayN/Views/ClashProxiesView.xaml | 8 +++----
.../Views/RoutingRuleDetailsWindow.xaml | 6 ++---
.../Views/RoutingRuleSettingWindow.xaml | 6 ++---
v2rayN/v2rayN/Views/SubEditWindow.xaml | 6 ++---
16 files changed, 51 insertions(+), 49 deletions(-)
diff --git a/v2rayN/AmazTool/Assets/en-US.json b/v2rayN/AmazTool/Assets/en-US.json
index f4c0f600..8b94e7cb 100644
--- a/v2rayN/AmazTool/Assets/en-US.json
+++ b/v2rayN/AmazTool/Assets/en-US.json
@@ -1,14 +1,14 @@
{
- "Restart_v2rayN": "Start v2rayN, please wait...",
- "Guidelines": "Please run it from the main application.",
- "Upgrade_File_Not_Found": "Upgrade failed, file not found.",
- "In_Progress": "In progress, please wait...",
- "Try_Terminate_Process": "Try to terminate the v2rayN process.",
- "Failed_Terminate_Process": "Failed to terminate the v2rayN.Close it manually,or the upgrade may fail.",
- "Start_Unzipping": "Start extracting the update package.",
- "Success_Unzipping": "Successfully extracted the update package!",
- "Failed_Unzipping": "Failed to extract the update package!",
- "Failed_Upgrade": "Upgrade failed!",
- "Success_Upgrade": "Upgrade success!",
- "Information": "Information"
+ "Restart_v2rayN": "Start v2rayN, please wait...",
+ "Guidelines": "Please run it from the main application.",
+ "Upgrade_File_Not_Found": "Upgrade failed, file not found.",
+ "In_Progress": "In progress, please wait...",
+ "Try_Terminate_Process": "Try to terminate the v2rayN process.",
+ "Failed_Terminate_Process": "Failed to terminate the v2rayN.Close it manually,or the upgrade may fail.",
+ "Start_Unzipping": "Start extracting the update package.",
+ "Success_Unzipping": "Successfully extracted the update package!",
+ "Failed_Unzipping": "Failed to extract the update package!",
+ "Failed_Upgrade": "Upgrade failed!",
+ "Success_Upgrade": "Upgrade success!",
+ "Information": "Information"
}
\ No newline at end of file
diff --git a/v2rayN/AmazTool/Assets/zh-CN.json b/v2rayN/AmazTool/Assets/zh-CN.json
index a6b6a1b7..dd57bcdf 100644
--- a/v2rayN/AmazTool/Assets/zh-CN.json
+++ b/v2rayN/AmazTool/Assets/zh-CN.json
@@ -1,14 +1,14 @@
{
- "Restart_v2rayN": "正在重启,请等待...",
- "Guidelines": "请从主应用运行!",
- "Upgrade_File_Not_Found": "升级失败,文件不存在!",
- "In_Progress": "正在进行中,请等待...",
- "Try_Terminate_Process": "尝试结束 v2rayN 进程...",
- "Failed_Terminate_Process": "请手动关闭正在运行的v2rayN,否则可能升级失败。",
- "Start_Unzipping": "开始解压缩更新包...",
- "Success_Unzipping": "解压缩更新包成功!",
- "Failed_Unzipping": "解压缩更新包失败!",
- "Failed_Upgrade": "升级失败!",
- "Success_Upgrade": "升级成功!",
- "Information": "提示"
+ "Restart_v2rayN": "正在重启,请等待...",
+ "Guidelines": "请从主应用运行!",
+ "Upgrade_File_Not_Found": "升级失败,文件不存在!",
+ "In_Progress": "正在进行中,请等待...",
+ "Try_Terminate_Process": "尝试结束 v2rayN 进程...",
+ "Failed_Terminate_Process": "请手动关闭正在运行的v2rayN,否则可能升级失败。",
+ "Start_Unzipping": "开始解压缩更新包...",
+ "Success_Unzipping": "解压缩更新包成功!",
+ "Failed_Unzipping": "解压缩更新包失败!",
+ "Failed_Upgrade": "升级失败!",
+ "Success_Upgrade": "升级成功!",
+ "Information": "提示"
}
\ No newline at end of file
diff --git a/v2rayN/AmazTool/LocalizationHelper.cs b/v2rayN/AmazTool/LocalizationHelper.cs
index 4af352c6..f10b8e33 100644
--- a/v2rayN/AmazTool/LocalizationHelper.cs
+++ b/v2rayN/AmazTool/LocalizationHelper.cs
@@ -29,7 +29,7 @@ namespace AmazTool
using var stream = assembly.GetManifestResourceStream(resourceName);
if (stream == null) return;
-
+
using StreamReader reader = new(stream);
var json = reader.ReadToEnd();
if (!string.IsNullOrEmpty(json))
@@ -56,4 +56,4 @@ namespace AmazTool
return _languageResources.TryGetValue(key, out var translation) ? translation : key;
}
}
-}
+}
\ No newline at end of file
diff --git a/v2rayN/AmazTool/UpgradeApp.cs b/v2rayN/AmazTool/UpgradeApp.cs
index 98239961..e8ab76f2 100644
--- a/v2rayN/AmazTool/UpgradeApp.cs
+++ b/v2rayN/AmazTool/UpgradeApp.cs
@@ -9,7 +9,7 @@ namespace AmazTool
public static void Upgrade(string fileName)
{
Console.WriteLine($"{LocalizationHelper.GetLocalizedValue("Start_Unzipping")}\n{fileName}");
-
+
Thread.Sleep(9000);
if (!File.Exists(fileName))
diff --git a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs
index 377638cb..e9060cc3 100644
--- a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs
+++ b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs
@@ -9,8 +9,10 @@
private ServerStatItem? _serverStatItem;
private List _lstServerStat;
private Action? _updateFunc;
+
//private StatisticsV2rayService? _statisticsV2Ray;
private StatisticsXrayService? _statisticsXray;
+
private StatisticsSingboxService? _statisticsSingbox;
public List ServerStat => _lstServerStat;
diff --git a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs
index 8ba1e043..6f19ffc8 100644
--- a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs
+++ b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs
@@ -5,6 +5,7 @@
/*
* 仅测试了,MacOS 13.7.1 x86 版本,其他版本有待确认
*/
+
///
/// 应用接口类型
///
@@ -21,14 +22,12 @@
await ExecCmd(lstCmd);
}
-
public static async Task UnsetProxy()
{
var lstCmd = GetUnsetCmds();
await ExecCmd(lstCmd);
}
-
private static async Task ExecCmd(List lstCmd)
{
foreach (var cmd in lstCmd)
diff --git a/v2rayN/ServiceLib/Models/Config.cs b/v2rayN/ServiceLib/Models/Config.cs
index 075f5049..c0abe5c2 100644
--- a/v2rayN/ServiceLib/Models/Config.cs
+++ b/v2rayN/ServiceLib/Models/Config.cs
@@ -20,6 +20,7 @@
case ECoreType.Xray when RunningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5:
case ECoreType.sing_box when RunningCoreType is ECoreType.sing_box or ECoreType.mihomo:
return true;
+
default:
return false;
}
diff --git a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs
index f44d3926..65f79e0e 100644
--- a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs
+++ b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs
@@ -209,7 +209,7 @@ namespace v2rayN.Desktop.Views
this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Extra, v => v.txtExtra.Text).DisposeWith(disposables);
-
+
this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.AllowInsecure, v => v.cmbAllowInsecure.SelectedValue).DisposeWith(disposables);
diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs
index a0ac88f8..eebc9362 100644
--- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs
+++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs
@@ -382,7 +382,7 @@ namespace v2rayN.Desktop.Views
#endregion Event
#region UI
-
+
public void ShowHideWindow(bool? blShow)
{
var bl = blShow ?? !_config.UiItem.ShowInTaskbar;
diff --git a/v2rayN/v2rayN/App.xaml b/v2rayN/v2rayN/App.xaml
index b22ea83b..d78d082c 100644
--- a/v2rayN/v2rayN/App.xaml
+++ b/v2rayN/v2rayN/App.xaml
@@ -1,9 +1,9 @@
diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs
index 3d5985a4..7dd4651d 100644
--- a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs
+++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs
@@ -203,7 +203,7 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Extra, v => v.txtExtra.Text).DisposeWith(disposables);
-
+
this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.AllowInsecure, v => v.cmbAllowInsecure.Text).DisposeWith(disposables);
diff --git a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml
index e5781abe..8ea9ca0b 100644
--- a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml
+++ b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml
@@ -1,11 +1,11 @@
Date: Tue, 19 Nov 2024 16:43:00 +0800
Subject: [PATCH 5/5] Added real IP location display
https://ipapi.co/api/?shell#introduction
---
v2rayN/ServiceLib/Global.cs | 1 +
v2rayN/ServiceLib/Models/IPAPIInfo.cs | 13 +++++++++++++
v2rayN/ServiceLib/Resx/ResUI.Designer.cs | 2 +-
v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx | 2 +-
v2rayN/ServiceLib/Resx/ResUI.resx | 2 +-
v2rayN/ServiceLib/Resx/ResUI.ru.resx | 2 +-
v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx | 2 +-
v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx | 2 +-
v2rayN/ServiceLib/Services/UpdateService.cs | 13 +++++++++++--
9 files changed, 31 insertions(+), 8 deletions(-)
create mode 100644 v2rayN/ServiceLib/Models/IPAPIInfo.cs
diff --git a/v2rayN/ServiceLib/Global.cs b/v2rayN/ServiceLib/Global.cs
index d0b03774..cb2382d4 100644
--- a/v2rayN/ServiceLib/Global.cs
+++ b/v2rayN/ServiceLib/Global.cs
@@ -20,6 +20,7 @@
public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases";
public const string CustomRoutingListUrl = @"https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/";
public const string SingboxRulesetUrl = @"https://raw.githubusercontent.com/2dust/sing-box-rules/rule-set-{0}/{1}.srs";
+ public const string IPAPIUrl = "https://ipapi.co/json";
public const string PromotionUrl = @"aHR0cHM6Ly85LjIzNDQ1Ni54eXovYWJjLmh0bWw=";
public const string ConfigFileName = "guiNConfig.json";
diff --git a/v2rayN/ServiceLib/Models/IPAPIInfo.cs b/v2rayN/ServiceLib/Models/IPAPIInfo.cs
new file mode 100644
index 00000000..07259d95
--- /dev/null
+++ b/v2rayN/ServiceLib/Models/IPAPIInfo.cs
@@ -0,0 +1,13 @@
+namespace ServiceLib.Models
+{
+ internal class IPAPIInfo
+ {
+ public string? ip { get; set; }
+ public string? city { get; set; }
+ public string? region { get; set; }
+ public string? region_code { get; set; }
+ public string? country { get; set; }
+ public string? country_name { get; set; }
+ public string? country_code { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
index a439d7c0..ea43a4ef 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
+++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
@@ -3644,7 +3644,7 @@ namespace ServiceLib.Resx {
}
///
- /// 查找类似 The ping of current service: {0} ms 的本地化字符串。
+ /// 查找类似 The delay : {0} ms, {1} 的本地化字符串。
///
public static string TestMeOutput {
get {
diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
index 937d107f..f940823c 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
@@ -302,7 +302,7 @@
اسکن URL وارد کردن با موفقیت
- پینگ سرویس فعلی: {0} ms
+ پینگ سرویس فعلی: {0} ms, {1}
موفقیت عملیات
diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx
index af6a2c9e..95a85755 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.resx
@@ -302,7 +302,7 @@
Scan import the shared link successfully
- The ping of current service: {0} ms
+ The delay : {0} ms, {1}
Operation success
diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx
index 8758825c..4637717e 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx
@@ -302,7 +302,7 @@
Сканирование URL-адреса импорта успешна.
- Задержка текущего сервера: {0} мс
+ Задержка текущего сервера: {0} мс, {1}
Операция успешна
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
index c281a4ad..61c72dc5 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
@@ -302,7 +302,7 @@
扫描导入分享链接成功
- 当前服务的真连接延迟: {0} ms
+ 当前延迟: {0} ms,{1}
操作成功
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
index 2d18ce2e..3d6e9777 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
@@ -301,7 +301,7 @@
掃描匯入分享链接成功
- 目前服務的真連線延遲: {0} ms
+ 目前延遲: {0} ms,{1}
操作成功
diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs
index 4eafc5c4..6474db7c 100644
--- a/v2rayN/ServiceLib/Services/UpdateService.cs
+++ b/v2rayN/ServiceLib/Services/UpdateService.cs
@@ -244,8 +244,17 @@ namespace ServiceLib.Services
public async Task RunAvailabilityCheck(Action updateFunc)
{
- var time = await new DownloadService().RunAvailabilityCheck(null);
- updateFunc?.Invoke(false, string.Format(ResUI.TestMeOutput, time));
+ var downloadHandle = new DownloadService();
+ var time = await downloadHandle.RunAvailabilityCheck(null);
+ var ip = Global.None;
+ if (time > 0)
+ {
+ var result = await downloadHandle.TryDownloadString(Global.IPAPIUrl, true, "ipapi");
+ var ipInfo = JsonUtils.Deserialize(result);
+ ip = $"({ipInfo?.country}) {ipInfo?.ip}";
+ }
+
+ updateFunc?.Invoke(false, string.Format(ResUI.TestMeOutput, time, ip));
}
#region CheckUpdate private