diff --git a/LICENSE b/LICENSE index 94a9ed02..bfbc868f 100644 --- a/LICENSE +++ b/LICENSE @@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Copyright (C) + Copyright (C) 2019-Present 2dust This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Copyright (C) + v2rayN Copyright (C) 2019-Present 2dust This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/README.md b/README.md index 9ece02d5..4d728c9b 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,18 @@ # v2rayN -A GUI client for Windows, Linux and macOS, support [Xray](https://github.com/XTLS/Xray-core) and [sing-box](https://github.com/SagerNet/sing-box/releases) and [others](https://github.com/2dust/v2rayN/wiki/List-of-supported-cores) +A GUI client for Windows, Linux and macOS, support [Xray](https://github.com/XTLS/Xray-core) +and [sing-box](https://github.com/SagerNet/sing-box) +and [others](https://github.com/2dust/v2rayN/wiki/List-of-supported-cores) [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/2dust/v2rayN)](https://github.com/2dust/v2rayN/commits/master) [![CodeFactor](https://www.codefactor.io/repository/github/2dust/v2rayn/badge)](https://www.codefactor.io/repository/github/2dust/v2rayn) [![GitHub Releases](https://img.shields.io/github/downloads/2dust/v2rayN/latest/total?logo=github)](https://github.com/2dust/v2rayN/releases) [![Chat on Telegram](https://img.shields.io/badge/Chat%20on-Telegram-brightgreen.svg)](https://t.me/v2rayn) - ## How to use Read the [Wiki](https://github.com/2dust/v2rayN/wiki) for details. ## Telegram Channel + [github_2dust](https://t.me/github_2dust) diff --git a/v2rayN/AmazTool/Program.cs b/v2rayN/AmazTool/Program.cs index d71c25c2..4df39682 100644 --- a/v2rayN/AmazTool/Program.cs +++ b/v2rayN/AmazTool/Program.cs @@ -5,21 +5,83 @@ internal static class Program [STAThread] private static void Main(string[] args) { - if (args.Length == 0) + try { - Console.WriteLine(Resx.Resource.Guidelines); - Thread.Sleep(5000); - return; - } + // If no arguments are provided, display usage guidelines and exit + if (args.Length == 0) + { + ShowHelp(); + return; + } - var argData = Uri.UnescapeDataString(string.Join(" ", args)); - if (argData.Equals("rebootas")) + // Log all arguments for debugging purposes + foreach (var arg in args) + { + Console.WriteLine(arg); + } + + // Parse command based on first argument + switch (args[0].ToLowerInvariant()) + { + case "rebootas": + // Handle application restart + HandleRebootAsync(); + break; + + case "help": + case "--help": + case "-h": + case "/?": + // Display help information + ShowHelp(); + break; + + default: + // Default behavior: handle as upgrade data + // Maintain backward compatibility with existing usage pattern + var argData = Uri.UnescapeDataString(string.Join(" ", args)); + HandleUpgrade(argData); + break; + } + } + catch (Exception ex) { - Thread.Sleep(1000); - Utils.StartV2RayN(); - return; + // Global exception handling + Console.WriteLine($"An error occurred: {ex.Message}"); + Console.WriteLine("Press any key to exit..."); + Console.ReadKey(); } + } - UpgradeApp.Upgrade(argData); + /// + /// Display help information and usage guidelines + /// + private static void ShowHelp() + { + Console.WriteLine(Resx.Resource.Guidelines); + Console.WriteLine("Available commands:"); + Console.WriteLine(" rebootas - Restart the application"); + Console.WriteLine(" help - Display this help information"); + Thread.Sleep(5000); + } + + /// + /// Handle application restart + /// + private static void HandleRebootAsync() + { + Console.WriteLine("Restarting application..."); + Thread.Sleep(1000); + Utils.StartV2RayN(); + } + + /// + /// Handle application upgrade with the provided data + /// + /// Data for the upgrade process + private static void HandleUpgrade(string upgradeData) + { + Console.WriteLine("Upgrading application..."); + UpgradeApp.Upgrade(upgradeData); } } diff --git a/v2rayN/Directory.Build.props b/v2rayN/Directory.Build.props index 8dcfcaaa..78438651 100644 --- a/v2rayN/Directory.Build.props +++ b/v2rayN/Directory.Build.props @@ -1,7 +1,7 @@ - 7.11.3 + 7.12.5 diff --git a/v2rayN/Directory.Packages.props b/v2rayN/Directory.Packages.props index b269cbe7..e9c8d492 100644 --- a/v2rayN/Directory.Packages.props +++ b/v2rayN/Directory.Packages.props @@ -5,10 +5,10 @@ false - - - - + + + + @@ -18,8 +18,8 @@ - - + + diff --git a/v2rayN/ServiceLib/Enums/EViewAction.cs b/v2rayN/ServiceLib/Enums/EViewAction.cs index 75142925..a72e8765 100644 --- a/v2rayN/ServiceLib/Enums/EViewAction.cs +++ b/v2rayN/ServiceLib/Enums/EViewAction.cs @@ -20,6 +20,7 @@ public enum EViewAction BrowseServer, ImportRulesFromFile, InitSettingFont, + PasswordInput, SubEditWindow, RoutingRuleSettingWindow, RoutingRuleDetailsWindow, diff --git a/v2rayN/ServiceLib/Global.cs b/v2rayN/ServiceLib/Global.cs index 78459920..68908b27 100644 --- a/v2rayN/ServiceLib/Global.cs +++ b/v2rayN/ServiceLib/Global.cs @@ -8,9 +8,7 @@ public class Global public const string GithubUrl = "https://github.com"; public const string GithubApiUrl = "https://api.github.com/repos"; public const string GeoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/{0}.dat"; - public const string SpeedPingTestUrl = @"https://www.google.com/generate_204"; public const string SingboxRulesetUrl = @"https://raw.githubusercontent.com/2dust/sing-box-rules/rule-set-{0}/{1}.srs"; - public const string IPAPIUrl = "https://api.ip.sb/geoip"; public const string PromotionUrl = @"aHR0cHM6Ly85LjIzNDQ1Ni54eXovYWJjLmh0bWw="; public const string ConfigFileName = "guiNConfig.json"; @@ -519,5 +517,15 @@ public class Global @"https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb" ]; + public static readonly List IPAPIUrls = + [ + @"https://speed.cloudflare.com/meta", + @"https://api.ip.sb/geoip", + @"https://api-ipv4.ip.sb/geoip", + @"https://api-ipv6.ip.sb/geoip", + @"https://api.ipapi.is", + @"" + ]; + #endregion const } diff --git a/v2rayN/ServiceLib/Handler/AppHandler.cs b/v2rayN/ServiceLib/Handler/AppHandler.cs index 0b8054f1..ad9a4029 100644 --- a/v2rayN/ServiceLib/Handler/AppHandler.cs +++ b/v2rayN/ServiceLib/Handler/AppHandler.cs @@ -9,7 +9,6 @@ public sealed class AppHandler private int? _statePort; private int? _statePort2; private Job? _processJob; - private bool? _isAdministrator; public static AppHandler Instance => _instance.Value; public Config Config => _config; @@ -31,14 +30,7 @@ public sealed class AppHandler } } - public bool IsAdministrator - { - get - { - _isAdministrator ??= Utils.IsAdministrator(); - return _isAdministrator.Value; - } - } + public string LinuxSudoPwd { get; set; } #endregion Property diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index a23b1c67..6a25b56f 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -122,7 +122,7 @@ public class ConfigHandler } if (config.SpeedTestItem.SpeedPingTestUrl.IsNullOrEmpty()) { - config.SpeedTestItem.SpeedPingTestUrl = Global.SpeedPingTestUrl; + config.SpeedTestItem.SpeedPingTestUrl = Global.SpeedPingTestUrls.First(); } if (config.SpeedTestItem.MixedConcurrencyCount < 1) { @@ -799,8 +799,11 @@ public class ConfigHandler { return -1; } + var lstServerStat = (config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? []; var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs(); var lstProfile = (from t in lstModel + join t2 in lstServerStat on t.IndexId equals t2.IndexId into t2b + from t22 in t2b.DefaultIfEmpty() join t3 in lstProfileExs on t.IndexId equals t3.IndexId into t3b from t33 in t3b.DefaultIfEmpty() select new ProfileItemModel @@ -815,7 +818,11 @@ public class ConfigHandler StreamSecurity = t.StreamSecurity, Delay = t33?.Delay ?? 0, Speed = t33?.Speed ?? 0, - Sort = t33?.Sort ?? 0 + Sort = t33?.Sort ?? 0, + TodayDown = (t22?.TodayDown ?? 0).ToString("D16"), + TodayUp = (t22?.TodayUp ?? 0).ToString("D16"), + TotalDown = (t22?.TotalDown ?? 0).ToString("D16"), + TotalUp = (t22?.TotalUp ?? 0).ToString("D16"), }).ToList(); Enum.TryParse(colName, true, out EServerColName name); @@ -833,6 +840,10 @@ public class ConfigHandler EServerColName.DelayVal => lstProfile.OrderBy(t => t.Delay).ToList(), EServerColName.SpeedVal => lstProfile.OrderBy(t => t.Speed).ToList(), EServerColName.SubRemarks => lstProfile.OrderBy(t => t.Subid).ToList(), + EServerColName.TodayDown => lstProfile.OrderBy(t => t.TodayDown).ToList(), + EServerColName.TodayUp => lstProfile.OrderBy(t => t.TodayUp).ToList(), + EServerColName.TotalDown => lstProfile.OrderBy(t => t.TotalDown).ToList(), + EServerColName.TotalUp => lstProfile.OrderBy(t => t.TotalUp).ToList(), _ => lstProfile }; } @@ -849,6 +860,10 @@ public class ConfigHandler EServerColName.DelayVal => lstProfile.OrderByDescending(t => t.Delay).ToList(), EServerColName.SpeedVal => lstProfile.OrderByDescending(t => t.Speed).ToList(), EServerColName.SubRemarks => lstProfile.OrderByDescending(t => t.Subid).ToList(), + EServerColName.TodayDown => lstProfile.OrderByDescending(t => t.TodayDown).ToList(), + EServerColName.TodayUp => lstProfile.OrderByDescending(t => t.TodayUp).ToList(), + EServerColName.TotalDown => lstProfile.OrderByDescending(t => t.TotalDown).ToList(), + EServerColName.TotalUp => lstProfile.OrderByDescending(t => t.TotalUp).ToList(), _ => lstProfile }; } diff --git a/v2rayN/ServiceLib/Handler/ConnectionHandler.cs b/v2rayN/ServiceLib/Handler/ConnectionHandler.cs new file mode 100644 index 00000000..3cfc6020 --- /dev/null +++ b/v2rayN/ServiceLib/Handler/ConnectionHandler.cs @@ -0,0 +1,42 @@ +namespace ServiceLib.Handler; + +public class ConnectionHandler +{ + private static readonly Lazy _instance = new(() => new()); + public static ConnectionHandler Instance => _instance.Value; + + public async Task RunAvailabilityCheck() + { + var downloadHandle = new DownloadService(); + var time = await downloadHandle.RunAvailabilityCheck(null); + var ip = time > 0 ? await GetIPInfo(downloadHandle) ?? Global.None : Global.None; + + return string.Format(ResUI.TestMeOutput, time, ip); + } + + private async Task GetIPInfo(DownloadService downloadHandle) + { + var url = AppHandler.Instance.Config.SpeedTestItem.IPAPIUrl; + if (url.IsNullOrEmpty()) + { + return null; + } + + var result = await downloadHandle.TryDownloadString(url, true, ""); + if (result == null) + { + return null; + } + + var ipInfo = JsonUtils.Deserialize(result); + if (ipInfo == null) + { + return null; + } + + var ip = ipInfo.ip ?? ipInfo.clientIp ?? ipInfo.ip_addr ?? ipInfo.query; + var country = ipInfo.country_code ?? ipInfo.country ?? ipInfo.countryCode ?? ipInfo.location?.country_code; + + return $"({country ?? "unknown"}) {ip}"; + } +} diff --git a/v2rayN/ServiceLib/Handler/CoreAdminHandler.cs b/v2rayN/ServiceLib/Handler/CoreAdminHandler.cs new file mode 100644 index 00000000..7fd07262 --- /dev/null +++ b/v2rayN/ServiceLib/Handler/CoreAdminHandler.cs @@ -0,0 +1,126 @@ +using System.Diagnostics; +using System.Text; +using CliWrap; + +namespace ServiceLib.Handler; + +public class CoreAdminHandler +{ + private static readonly Lazy _instance = new(() => new()); + public static CoreAdminHandler Instance => _instance.Value; + private Config _config; + private Action? _updateFunc; + private int _linuxSudoPid = -1; + + public async Task Init(Config config, Action updateFunc) + { + if (_config != null) + { + return; + } + _config = config; + _updateFunc = updateFunc; + } + + private void UpdateFunc(bool notify, string msg) + { + _updateFunc?.Invoke(notify, msg); + } + + public async Task RunProcessAsLinuxSudo(string fileName, CoreInfo coreInfo, string configPath) + { + var cmdLine = $"{fileName.AppendQuotes()} {string.Format(coreInfo.Arguments, Utils.GetBinConfigPath(configPath).AppendQuotes())}"; + var shFilePath = await CreateLinuxShellFile(cmdLine, "run_as_sudo.sh"); + + Process proc = new() + { + StartInfo = new() + { + FileName = shFilePath, + Arguments = "", + WorkingDirectory = Utils.GetBinConfigPath(), + UseShellExecute = false, + RedirectStandardInput = true, + RedirectStandardOutput = true, + RedirectStandardError = true, + CreateNoWindow = true, + StandardInputEncoding = Encoding.UTF8, + StandardOutputEncoding = Encoding.UTF8, + StandardErrorEncoding = Encoding.UTF8, + } + }; + + proc.OutputDataReceived += (sender, e) => + { + if (e.Data.IsNotEmpty()) + { + UpdateFunc(false, e.Data + Environment.NewLine); + } + }; + proc.ErrorDataReceived += (sender, e) => + { + if (e.Data.IsNotEmpty()) + { + UpdateFunc(false, e.Data + Environment.NewLine); + } + }; + + proc.Start(); + proc.BeginOutputReadLine(); + proc.BeginErrorReadLine(); + + await Task.Delay(10); + await proc.StandardInput.WriteLineAsync(); + await Task.Delay(10); + await proc.StandardInput.WriteLineAsync(AppHandler.Instance.LinuxSudoPwd); + + await Task.Delay(100); + if (proc is null or { HasExited: true }) + { + throw new Exception(ResUI.FailedToRunCore); + } + + _linuxSudoPid = proc.Id; + + return proc; + } + + public async Task KillProcessAsLinuxSudo() + { + if (_linuxSudoPid < 0) + { + return; + } + + var cmdLine = $"pkill -P {_linuxSudoPid} ; kill {_linuxSudoPid}"; + var shFilePath = await CreateLinuxShellFile(cmdLine, "kill_as_sudo.sh"); + + await Cli.Wrap(shFilePath) + .WithStandardInputPipe(PipeSource.FromString(AppHandler.Instance.LinuxSudoPwd)) + .ExecuteAsync(); + + _linuxSudoPid = -1; + } + + private async Task CreateLinuxShellFile(string cmdLine, string fileName) + { + var shFilePath = Utils.GetBinConfigPath(fileName); + File.Delete(shFilePath); + + var sb = new StringBuilder(); + sb.AppendLine("#!/bin/sh"); + if (Utils.IsAdministrator()) + { + sb.AppendLine($"{cmdLine}"); + } + else + { + sb.AppendLine($"sudo -S {cmdLine}"); + } + + await File.WriteAllTextAsync(shFilePath, sb.ToString()); + await Utils.SetLinuxChmod(shFilePath); + + return shFilePath; + } +} diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index 41ea866d..92c30171 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -13,7 +13,7 @@ public class CoreHandler private Config _config; private Process? _process; private Process? _processPre; - private int _linuxSudoPid = -1; + private bool _linuxSudo = false; private Action? _updateFunc; private const string _tag = "CoreHandler"; @@ -155,23 +155,23 @@ public class CoreHandler { try { + if (_linuxSudo) + { + await CoreAdminHandler.Instance.KillProcessAsLinuxSudo(); + _linuxSudo = false; + } + if (_process != null) { - await ProcUtils.ProcessKill(_process, true); + await ProcUtils.ProcessKill(_process, Utils.IsWindows()); _process = null; } if (_processPre != null) { - await ProcUtils.ProcessKill(_processPre, true); + await ProcUtils.ProcessKill(_processPre, Utils.IsWindows()); _processPre = null; } - - if (_linuxSudoPid > 0) - { - await KillProcessAsLinuxSudo(); - } - _linuxSudoPid = -1; } catch (Exception ex) { @@ -225,15 +225,6 @@ public class CoreHandler _updateFunc?.Invoke(notify, msg); } - private bool IsNeedSudo(ECoreType eCoreType) - { - return _config.TunModeItem.EnableTun - && eCoreType == ECoreType.sing_box - && (Utils.IsNonWindows()) - //&& _config.TunModeItem.LinuxSudoPwd.IsNotEmpty() - ; - } - #endregion Private #region Process @@ -249,69 +240,17 @@ public class CoreHandler try { - Process proc = new() + if (mayNeedSudo + && _config.TunModeItem.EnableTun + && coreInfo.CoreType == ECoreType.sing_box + && Utils.IsNonWindows()) { - StartInfo = new() - { - FileName = fileName, - Arguments = string.Format(coreInfo.Arguments, coreInfo.AbsolutePath ? Utils.GetBinConfigPath(configPath).AppendQuotes() : configPath), - WorkingDirectory = Utils.GetBinConfigPath(), - UseShellExecute = false, - RedirectStandardOutput = displayLog, - RedirectStandardError = displayLog, - CreateNoWindow = true, - StandardOutputEncoding = displayLog ? Encoding.UTF8 : null, - StandardErrorEncoding = displayLog ? Encoding.UTF8 : null, - } - }; - - var isNeedSudo = mayNeedSudo && IsNeedSudo(coreInfo.CoreType); - if (isNeedSudo) - { - await RunProcessAsLinuxSudo(proc, fileName, coreInfo, configPath); + _linuxSudo = true; + await CoreAdminHandler.Instance.Init(_config, _updateFunc); + return await CoreAdminHandler.Instance.RunProcessAsLinuxSudo(fileName, coreInfo, configPath); } - if (displayLog) - { - proc.OutputDataReceived += (sender, e) => - { - if (e.Data.IsNullOrEmpty()) - return; - UpdateFunc(false, e.Data + Environment.NewLine); - }; - proc.ErrorDataReceived += (sender, e) => - { - if (e.Data.IsNullOrEmpty()) - return; - UpdateFunc(false, e.Data + Environment.NewLine); - }; - } - proc.Start(); - - if (isNeedSudo && _config.TunModeItem.LinuxSudoPwd.IsNotEmpty()) - { - var pwd = DesUtils.Decrypt(_config.TunModeItem.LinuxSudoPwd); - await Task.Delay(10); - await proc.StandardInput.WriteLineAsync(pwd); - await Task.Delay(10); - await proc.StandardInput.WriteLineAsync(pwd); - } - if (isNeedSudo) - _linuxSudoPid = proc.Id; - - if (displayLog) - { - proc.BeginOutputReadLine(); - proc.BeginErrorReadLine(); - } - - await Task.Delay(500); - AppHandler.Instance.AddProcess(proc.Handle); - if (proc is null or { HasExited: true }) - { - throw new Exception(ResUI.FailedToRunCore); - } - return proc; + return await RunProcessNormal(fileName, coreInfo, configPath, displayLog); } catch (Exception ex) { @@ -321,89 +260,57 @@ public class CoreHandler } } - #endregion Process - - #region Linux - - private async Task RunProcessAsLinuxSudo(Process proc, string fileName, CoreInfo coreInfo, string configPath) + private async Task RunProcessNormal(string fileName, CoreInfo? coreInfo, string configPath, bool displayLog) { - var cmdLine = $"{fileName.AppendQuotes()} {string.Format(coreInfo.Arguments, Utils.GetBinConfigPath(configPath).AppendQuotes())}"; - - var shFilePath = await CreateLinuxShellFile(cmdLine, "run_as_sudo.sh"); - proc.StartInfo.FileName = shFilePath; - proc.StartInfo.Arguments = ""; - proc.StartInfo.WorkingDirectory = ""; - if (_config.TunModeItem.LinuxSudoPwd.IsNotEmpty()) - { - proc.StartInfo.StandardInputEncoding = Encoding.UTF8; - proc.StartInfo.RedirectStandardInput = true; - } - } - - private async Task KillProcessAsLinuxSudo() - { - var cmdLine = $"kill {_linuxSudoPid}"; - var shFilePath = await CreateLinuxShellFile(cmdLine, "kill_as_sudo.sh"); Process proc = new() { StartInfo = new() { - FileName = shFilePath, + FileName = fileName, + Arguments = string.Format(coreInfo.Arguments, coreInfo.AbsolutePath ? Utils.GetBinConfigPath(configPath).AppendQuotes() : configPath), + WorkingDirectory = Utils.GetBinConfigPath(), UseShellExecute = false, + RedirectStandardOutput = displayLog, + RedirectStandardError = displayLog, CreateNoWindow = true, - StandardInputEncoding = Encoding.UTF8, - RedirectStandardInput = true + StandardOutputEncoding = displayLog ? Encoding.UTF8 : null, + StandardErrorEncoding = displayLog ? Encoding.UTF8 : null, } }; + + if (displayLog) + { + proc.OutputDataReceived += (sender, e) => + { + if (e.Data.IsNotEmpty()) + { + UpdateFunc(false, e.Data + Environment.NewLine); + } + }; + proc.ErrorDataReceived += (sender, e) => + { + if (e.Data.IsNotEmpty()) + { + UpdateFunc(false, e.Data + Environment.NewLine); + } + }; + } proc.Start(); - if (_config.TunModeItem.LinuxSudoPwd.IsNotEmpty()) + if (displayLog) { - try - { - var pwd = DesUtils.Decrypt(_config.TunModeItem.LinuxSudoPwd); - await Task.Delay(10); - await proc.StandardInput.WriteLineAsync(pwd); - await Task.Delay(10); - await proc.StandardInput.WriteLineAsync(pwd); - } - catch (Exception) - { - // ignored - } + proc.BeginOutputReadLine(); + proc.BeginErrorReadLine(); } - var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await proc.WaitForExitAsync(timeout.Token); - await Task.Delay(3000); + await Task.Delay(100); + AppHandler.Instance.AddProcess(proc.Handle); + if (proc is null or { HasExited: true }) + { + throw new Exception(ResUI.FailedToRunCore); + } + return proc; } - private async Task CreateLinuxShellFile(string cmdLine, string fileName) - { - //Shell scripts - var shFilePath = Utils.GetBinConfigPath(AppHandler.Instance.IsAdministrator ? "root_" + fileName : fileName); - File.Delete(shFilePath); - var sb = new StringBuilder(); - sb.AppendLine("#!/bin/sh"); - if (AppHandler.Instance.IsAdministrator) - { - sb.AppendLine($"{cmdLine}"); - } - else if (_config.TunModeItem.LinuxSudoPwd.IsNullOrEmpty()) - { - sb.AppendLine($"pkexec {cmdLine}"); - } - else - { - sb.AppendLine($"sudo -S {cmdLine}"); - } - - await File.WriteAllTextAsync(shFilePath, sb.ToString()); - await Utils.SetLinuxChmod(shFilePath); - Logging.SaveLog(shFilePath); - - return shFilePath; - } - - #endregion Linux + #endregion Process } diff --git a/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs index 71b4c0c2..5892236f 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs @@ -6,9 +6,9 @@ public class VmessFmt : BaseFmt { msg = ResUI.ConfigurationFormatIncorrect; ProfileItem? item; - if (str.IndexOf('?') > 0 && str.IndexOf('&') > 0) + if (str.IndexOf('@') > 0) { - item = ResolveStdVmess(str); + item = ResolveStdVmess(str) ?? ResolveVmess(str, out msg); } else { diff --git a/v2rayN/ServiceLib/Models/ConfigItems.cs b/v2rayN/ServiceLib/Models/ConfigItems.cs index b3fa1b98..afd7e7cc 100644 --- a/v2rayN/ServiceLib/Models/ConfigItems.cs +++ b/v2rayN/ServiceLib/Models/ConfigItems.cs @@ -147,7 +147,6 @@ public class TunModeItem public int Mtu { get; set; } public bool EnableExInbound { get; set; } public bool EnableIPv6Address { get; set; } - public string? LinuxSudoPwd { get; set; } } [Serializable] @@ -157,6 +156,7 @@ public class SpeedTestItem public string SpeedTestUrl { get; set; } public string SpeedPingTestUrl { get; set; } public int MixedConcurrencyCount { get; set; } + public string IPAPIUrl { get; set; } } [Serializable] diff --git a/v2rayN/ServiceLib/Models/IPAPIInfo.cs b/v2rayN/ServiceLib/Models/IPAPIInfo.cs index 21063946..7ba16727 100644 --- a/v2rayN/ServiceLib/Models/IPAPIInfo.cs +++ b/v2rayN/ServiceLib/Models/IPAPIInfo.cs @@ -3,10 +3,17 @@ 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? clientIp { get; set; } + public string? ip_addr { get; set; } + public string? query { get; set; } public string? country { get; set; } public string? country_name { get; set; } public string? country_code { get; set; } + public string? countryCode { get; set; } + public LocationInfo? location { get; set; } +} + +public class LocationInfo +{ + public string? country_code { get; set; } } diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index 0b9cc936..9ba7a90d 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -3201,6 +3201,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 Current connection info test URL 的本地化字符串。 + /// + public static string TbSettingsIPAPIUrl { + get { + return ResourceManager.GetString("TbSettingsIPAPIUrl", resourceCulture); + } + } + /// /// 查找类似 Keep older entries when de-duplicating 的本地化字符串。 /// @@ -3247,7 +3256,7 @@ namespace ServiceLib.Resx { } /// - /// 查找类似 The password is encrypted and stored only in local files 的本地化字符串。 + /// 查找类似 The password you entered cannot be verified, so make sure you enter it correctly. If the application does not work properly due to an incorrect input, please restart the application. The password will not be stored and you will need to enter it again after each restart. 的本地化字符串。 /// public static string TbSettingsLinuxSudoPasswordTip { get { diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx index a937a262..0e18c4be 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx @@ -1339,7 +1339,7 @@ رمز عبور sudo سیستم - رمز عبور رمزگذاری شده و فقط در فایل های محلی ذخیره می شود. + رمز عبوری که وارد کرده اید تایید نمی شود، بنابراین مطمئن شوید که آن را به درستی وارد کرده اید. اگر برنامه به دلیل ورودی نادرست به درستی کار نمی کند، لطفاً برنامه را مجدداً راه اندازی کنید. رمز عبور ذخیره نمی شود و پس از هر بار راه اندازی مجدد باید آن را دوباره وارد کنید. لطفاً ابتدا رمز عبور sudo را در تنظیمات حالت Tun تنظیم کنید @@ -1416,4 +1416,7 @@ صادر کردن سرور + + URL آزمایش اطلاعات اتصال فعلی + diff --git a/v2rayN/ServiceLib/Resx/ResUI.hu.resx b/v2rayN/ServiceLib/Resx/ResUI.hu.resx index 05a12c10..4f8824b7 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.hu.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.hu.resx @@ -1339,7 +1339,7 @@ Rendszer sudo jelszó - A jelszó titkosítva és csak a helyi fájlokban tárolva. + The password you entered cannot be verified, so make sure you enter it correctly. If the application does not work properly due to an incorrect input, please restart the application. The password will not be stored and you will need to enter it again after each restart. Kérlek, először állítsd be a sudo jelszót a Tun módban @@ -1416,4 +1416,7 @@ Export server + + Current connection info test URL + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx index 1fb3d23b..240aa55b 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.resx @@ -1339,7 +1339,7 @@ System sudo password - The password is encrypted and stored only in local files + The password you entered cannot be verified, so make sure you enter it correctly. If the application does not work properly due to an incorrect input, please restart the application. The password will not be stored and you will need to enter it again after each restart. Please set the sudo password in Tun mode settings first @@ -1416,4 +1416,7 @@ Export Configuration + + Current connection info test URL + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx index 824ea29a..ddef42d4 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx @@ -1,17 +1,17 @@ - @@ -118,16 +118,16 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Экспортирование URL в буфер обмена успешно завершено + Ссылка успешно скопирована в буфер обмена - Пожалуйста, сначала проверьте настройки сервера + Сначала проверьте настройки сервера Недопустимый формат конфигурации - Обратите внимание, что пользовательская конфигурация полностью зависит от вашей собственной конфигурации и работает не со всеми настройками. Если вы хотите использовать системный прокси, пожалуйста, измените порт прослушивания вручную. + Обратите внимание, что пользовательская конфигурация полностью зависит от вашей собственной конфигурации и работает не со всеми настройками. Если вы хотите использовать системный прокси, то измените порт прослушивания вручную Загрузка... @@ -136,13 +136,13 @@ Скорость загрузки - Хотите загрузить? {0} + Хотите загрузить {0}? Не удалось преобразовать файл конфигурации - Не удалось создать файл конфигурации по умолчаниюe + Не удалось создать файл конфигурации по умолчанию Не удалось получить конфигурацию по умолчанию @@ -154,37 +154,37 @@ Не удалось прочитать файл конфигурации - Пожалуйста, укажите порт сервера в правильном формате + Укажите порт сервера в правильном формате - Пожалуйста, укажите локальный порт прослушивания + Введите локальный порт для прослушивания - Пожалуйста, введите пароль + Введите пароль - Пожалуйста, заполните адрес сервера + Введите адрес сервера - Пожалуйста, заполните идентификатор пользователя + Введите идентификатор пользователя - Некорректная конфигурация, пожалуйста, проверьте + Некорректная конфигурация. Проверьте Исходная конфигурация - {0} {1} является последней версией. + {0} {1} является последней версией - {0} {1} является последней версией. + {0} {1} является последней версией Адрес - Безопасность + Метод шифрования Порт @@ -199,7 +199,7 @@ Загружено трафика сегодня - Отдано трафика сегодня + Отправлено сегодня Всего загружено @@ -214,13 +214,13 @@ Ядро успешно загружено - Не удалось импортировать содержимое подписки + Не удалось импортировать подписку Содержимое подписки успешно импортировано - Нет установлены подписки + Нет установленных подписок Парсинг {0} прошел успешно @@ -235,7 +235,7 @@ Некорректное содержимое подписки - распаковывается... + Распаковка… Обновление подписки закончено @@ -244,37 +244,37 @@ Обновление подписки начинается - Успешное обновление ядра + Ядро успешно обновлено Успешное обновление ядра! Перезапуск службы... - Не является протоколом Vmess или SS + Не является протоколом VMess или Shadowsocks - Файл Core (имя файла: {1}) не найден в папке ({0}), загрузите и поместите его в папку, адрес загрузки: {2} + Файл ядра ({1}) не найден в папке {0}. Скачайте по адресу {2} и поместите его туда Сканирование завершено, не найден корректный QR код - операция безуспешна, проверьте и попробуйте ещё раз + Операция безуспешна, проверьте и попробуйте ещё раз - Пожалуйста, заполните примечания + Введите примечания - Пожалуйста, выберите метод шифрования + Выберите метод шифрования - Пожалуйста, выберите протокол + Выберите протокол Сначала выберите сервер - Удаление дублей завершено. Старая: {0}, Новая: {1}. + Удаление дублей завершено. Старая: {0}, Новая: {1} Вы уверены, что хотите удалить сервер? @@ -286,16 +286,16 @@ Запуск сервиса ({0})... - Конфигурация успешна {0} + Конфигурация выполнена успешно {0} - Пользовательский сервер конфигурации успешно импортирован. + Пользовательская конфигурация сервера успешно импортирована - {0} серверов импортировано из буфера обмена. + {0} серверов импортировано из буфера обмена - Сканирование URL-адреса импорта успешна. + Сканирование URL-адреса импорта прошло успешно Задержка текущего сервера: {0} мс, {1} @@ -310,7 +310,7 @@ Вы уверены, что хотите удалить правила? - {0}, Один из обязательных.. + {0}: одно из обязательных полей Примечания @@ -322,13 +322,13 @@ Количество - Пожалуйста, заполните адрес (Url) + Введите URL-адрес - Вы хотите добавить правила? Выберите «Да», чтобы добавить, выберите иное, чтобы заменить + Хотите добавить правила? Выберите «Да» для добавления или «Нет» для замены - Загрузка GeoFile: {0} успешна + Загрузка GeoFile {0} прошла успешно Информация @@ -337,49 +337,49 @@ Пользовательская иконка - Пожалуйста, заполните правильный пользовательский DNS + Введите корректный пользовательский DNS - *ws путь + *WebSocket-путь - *h2 путь + *HTTP2-путь - *QUIC ключ/Kcp seed + *QUIC-ключ / KCP-seed - *grpc serviceName + Имя сервиса *gRPC - *http хосты разделенные запятыми (,) + *http-хосты, разделённые запятыми (,) - *ws хост + *WebSocket-хост - *h2 хосты разделенные запятыми (,) + *HTTP2-хосты, разделённые запятыми (,) - * безопасность QUIC + Безопасность *QUIC - * тип TCP камуфляжа + Тип *TCP-камуфляжа - * тип KCP камуфляжа + Тип *KCP-камуфляжа - * тип QUIC камуфляжа + Тип *QUIC-камуфляжа - * режим grpc + Режим *gRPC TLS - *Kcp seed + *KCP-seed Не удалось зарегистрировать глобальную горячую клавишу {0}, причина: {1} @@ -391,10 +391,10 @@ Разгруппировано - Все сервера + Все серверы - Пожалуйста, просмотрите, чтобы импортировать конфигурацию сервера + Выберите файл конфигурации сервера для импорта Тестирование... @@ -436,7 +436,7 @@ Настройки маршрутизации - Сервера + Серверы Настройки @@ -445,7 +445,7 @@ Обновить текущую подписку без прокси - Обновить текущую подписку с прокси + Обновить подписку через прокси Группа подписки @@ -571,7 +571,7 @@ Сортировка - User Agent + Заголовок User-Agent Отмена @@ -628,7 +628,7 @@ TLS - * По-умолчанию TCP + *По-умолчанию TCP Ядро @@ -658,10 +658,10 @@ Шифрования - txtPreSocksPort + Порт SOCKS - * После установки этого значения служба socks будет запущена с использованием Xray/sing-box(Tun) для обеспечения таких функций, как отображение скорости + * После установки этого значения служба SOCKS будет запущена с использованием Xray/sing-box(TUN) для обеспечения таких функций, как отображение скорости Просмотр @@ -697,7 +697,7 @@ Разрешить небезопасные - Outbound Freedom domainStrategy + «Freedom»: стратегия обработки доменов исходящего трафика Автоматически регулировать ширину столбца после обновления подписки @@ -712,7 +712,7 @@ Исключение. Не используйте прокси-сервер для адресов, начинающихся с (,), используйте точку с запятой (;) - Display real-time speed + Показывать скорость в реальном времени Сохранить старые при удалении дублей @@ -721,10 +721,10 @@ Записывать логи - Уровень логгирования + Уровень записи логов - Включите мультиплексирование Mux + Включить мультиплексирование Mux Настройки v2rayN @@ -733,16 +733,16 @@ Пароль аутентификации - Пользовательский DNS (если несколько делите с запятыми (,)) + Пользовательский DNS (если несколько, то делите запятыми (,)) - Set Win10 UWP Loopback + Разрешить loopback для приложений UWP (Win10) Включить сниффинг - Mixed Port + Смешанный порт Автозапуск @@ -751,7 +751,7 @@ Включить статистику (требуется перезагрузка) - URL-адрес конверсии подписки + URL конвертации подписок Настройки системного прокси @@ -766,7 +766,7 @@ Включить UDP - Auth user + Имя пользователя (логин) Очистить системный прокси @@ -816,6 +816,9 @@ Вверх (U) + + Переместить вверх/вниз + Фильтр, поддерживает regex @@ -850,13 +853,13 @@ 2.Прямой домен или IP - 1.Прокси-домен или IP + 1.Прокси домен или IP Предустановленный список наборов правил - * Установите правила, разделенные запятыми (,); Запятая в регулярке заменена на <COMMA> + *Разделяйте правила запятыми (,). Литерал «,» — <COMMA>. Префикс # — отключить правило Импорт правил из буфера обмена @@ -883,16 +886,16 @@ Удалить правила (Delete) - RoutingRuleDetailsSetting + Детальные настройки правил маршрутизации Домен и IP автоматически сортируются при сохранении - Ruleobject Doc + Документация RuleObject - Поддержка DnsObject + Поддерживаются DNS-объекты, нажмите для просмотра документации Необязательное поле @@ -913,16 +916,16 @@ Тест задержки и скорости всех серверов (Ctrl+E) - Задержка (ms) + Задержка (мс) - Скорость (M/s) + Скорость (МБ/с) Не удалось запустить ядро, посмотрите логи - Remarks regular filter + Фильтр примечаний (Regex) Показать логи @@ -934,7 +937,7 @@ Новый порт для локальной сети - Настройки TunMode + Настройки режима TUN Перейти в группу @@ -958,22 +961,22 @@ Тест завершен - TLS отпечаток по умлочанию + TLS отпечаток по умолчанию User-Agent - Этот параметр действителен только для TCP/HTTP и WS + Параметр действует только для TCP/HTTP и WebSocket (WS) Шрифт (требуется перезагрузка) - Скопируйте файл шрифта TTF/TTC в каталог guiFonts, перезапустите настройки + Скопируйте файл шрифта TTF/TTC в каталог guiFonts и заново откройте окно настроек - Pac порт = +3; Xray API порт = +4; mihomo API порт = +5; + Pac порт = +3,Xray API порт = +4, mihomo API порт = +5 Установите это с правами администратора @@ -982,13 +985,10 @@ Размер шрифта - Таймаут одиночного спидтеста + Тайм-аут одиночного тестирования скорости - URL спидтеста - - - Move up and down + URL для тестирования скорости PublicKey @@ -1003,19 +1003,19 @@ Включить аппаратное ускорение (требуется перезагрузка) - Ожидание тестирования (нажмите ESC для отмены)... + Ожидание тестирования (нажмите ESC для отмены)… - Please turn off when there is an abnormal disconnection + Отключите при аномальном разрыве соединения - Updates are not enabled, skip this subscription + Обновления не включены — подписка пропущена Перезагрузить как администратор - More URLs, separated by commas; Subscription conversion will be invalid + Дополнительные URL через запятую, конвертация подписки недоступна {0} : {1}/s↑ | {2}/s↓ @@ -1024,13 +1024,13 @@ Интервал автоматического обновления в минутах - Включить логгирование в файл + Включить запись логов в файл Преобразовать тип цели - Если преобразование не требуется, оставьте поле пустым. + Если преобразование не требуется, оставьте поле пустым Настройки DNS @@ -1039,7 +1039,7 @@ Настройки DNS sing-box - Пожалуйста, заполните структуру DNS. Нажмите, чтобы просмотреть документ. + Заполните структуру DNS, нажмите, чтобы открыть документ Нажмите, чтобы импортировать конфигурацию DNS по умолчанию @@ -1048,88 +1048,88 @@ Стратегия домена для sing-box - sing-box Mux Protocol + Протокол Mux для sing-box - Full process name (Tun mode) + Полное имя процесса (режим TUN) - IP or IP CIDR + IP-адрес или сеть CIDR Домен - Добавить [Hysteria2] сервер + Добавить сервер [Hysteria2] - Hysteria Max bandwidth (Up/Dw) + Максимальная пропускная способность Hysteria (загрузка/отдача) Использовать системные узлы - Добавить [TUIC] сервер + Добавить сервер [TUIC] Контроль перегрузок - Previous proxy remarks + Примечания к предыдущему прокси - Next proxy remarks + Примечания к следующему прокси - Пожалуйста, убедитесь, что примечание существует и является уникальным. + Убедитесь, что примечание существует и является уникальным - Enable additional Inbound + Включить дополнительный входящий канал Включить IPv6 адреса - Добавить [WireGuard] сервер + Добавить сервер [WireGuard] - PrivateKey + Приватный ключ - Reserved(2,3,4) + Зарезервировано (2, 3, 4) - Адрес(Ipv4,Ipv6) + Адрес (Ipv4,Ipv6) - obfs password + Пароль obfs - (Domain or IP or ProcName) and Port and Protocol and InboundTag => OutboundTag + (Домен или IP или имя процесса) и порт, и протокол, и InboundTag => OutboundTag Автоматическая прокрутка в конец - URL-адрес для проверки скорости пинга + URL для быстрой проверки реальной задержки - Updating subscription, only determine remarks exists + Обновляя подписку, проверять лишь наличие примечаний Отмена тестирования... - *grpc Authority + *gRPC Authority - Добавить [HTTP] сервер + Добавить сервер [HTTP] - Use Xray and enable non-Tun mode, which conflicts with the group previous proxy + Используйте Xray и отключите режим TUN, так как он конфликтует с предыдущим прокси-сервером группы - Включить фрагмент + Включить фрагментацию (Fragment) Включить файл кэша для sing-box (файлы наборов правил) @@ -1138,7 +1138,7 @@ Пользовательский набор правил для sing-box - Successful operation. Click the settings menu to reboot the app. + Операция успешна. Перезапустите приложение Открыть место хранения @@ -1147,7 +1147,7 @@ Сортировка - Chain + Цепочка По умолчанию @@ -1159,7 +1159,7 @@ Скорость загрузки - Download Traffic + Скачанный трафик Узел @@ -1177,10 +1177,10 @@ Тип - Скорость загрузки + Скорость отдачи - Upload Traffic + Отправленный трафик Соединения @@ -1198,13 +1198,13 @@ Режим правила - Direct + Прямое соединение - Global + Глобальный режим - Do not change + Не менять Правила @@ -1213,13 +1213,13 @@ Тест задержки - Part Node Latency Test + Тест задержки выбранных узлов Обновить прокси - Активировать узел (Enter) + Сделать узел активным (Enter) Стратегия домена по умолчанию для исходящих @@ -1234,7 +1234,7 @@ Автоматическая регулировка ширины столбца - Export Base64-encoded Share Links to Clipboard + Экспорт ссылок в формате Base64 в буфер обмена Экспортировать выбранный сервер для полной конфигурации в буфер обмена @@ -1243,7 +1243,7 @@ Показать или скрыть главное окно - Пользовательская конфигурация порта socks + Пользовательская конфигурация порта SOCKS Резервное копирование и восстановление @@ -1255,28 +1255,28 @@ Восстановить из файла - Backup to remote (WebDAV) + Резервное копирование на удалённый сервер (WebDAV) - Restore from remote (WebDAV) + Восстановить с удалённого сервера (WebDAV) - Local + Локально - Remote (WebDAV) + Удалённо (WebDAV) - WebDav Url + URL WebDAV - WebDav User Name + Имя пользователя WebDAV - WebDav Password + Пароль WebDAV - WebDav Check + Проверить WebDAV Имя удаленной папки (необязательно) @@ -1285,16 +1285,16 @@ Неверный файл резервной копии - Host filter + Фильтр хостов - Active + Активный - Источник geo файлов + Источник файлов Geo (необязательно) - Источник sing-box srs файлов + Источник файлов наборов правил sing-box (необязательно) Программы для обновления не существует @@ -1315,7 +1315,7 @@ Иран - Используйте Настройки -> Региональные пресеты вместо изменения этого поля + Пользователи из Китая могут пропустить этот пункт Сканировать QR-код с изображения @@ -1324,7 +1324,7 @@ Неверный адрес (Url) - Пожалуйста, не используйте небезопасный адрес подписки по протоколу HTTP. + Не используйте небезопасный адрес подписки по протоколу HTTP Установите шрифт в систему и перезапустите настройки @@ -1333,43 +1333,43 @@ Вы уверены, что хотите выйти? - Remarks Memo + Заметка (Memo) - System sudo password + Пароль sudo системы - Пароль зашифрован и хранится только в локальных файлах.. + Введенный вами пароль не может быть подтвержден, поэтому убедитесь, что вы ввели его правильно. Если приложение не работает должным образом из-за неправильного ввода, то перезапустите его. Пароль не будет сохранен, и вам придется вводить его заново после каждого перезапуска - Please set the sudo password in Tun mode settings first + Сначала задайте пароль sudo в настройках TUN-режима - Пожалуйста, не запускайте программу как суперпользователь. + Не запускайте программу как суперпользователь - *xhttp mode + *XHTTP-режим - XHTTP Extra raw JSON, format: { XHTTPObject } + Дополнительный XHTTP сырой JSON, формат: { XHTTPObject } Скрыть в трее при закрытии окна - The number of concurrent during multi-test + Количество одновременно выполняемых тестов при многоэтапном тестировании Исключение. Не используйте прокси-сервер для адресов с запятой (,) - Sniffing type + Тип сниффинга - Enable second mixed port + Включить второй смешанный порт - socks: local port, socks2: second local port, socks3: LAN port + socks: локальный порт, socks2: второй локальный порт, socks3: LAN порт Темы @@ -1378,7 +1378,7 @@ Копировать команду прокси в буфер обмена - Starting retesting failed parts, {0} remaining. Press ESC to terminate... + Повторное тестирование неудачных элементов, осталось {0}. Нажмите ESC для остановки… По результату теста @@ -1387,33 +1387,36 @@ Удалить недействительные по результатам теста - Удалено {0} недействительных. + Удалено {0} недействительных Диапазон портов сервера - Will cover the port, separate with commas (,) + Заменит указанный порт, перечисляйте через запятую (,) - Multi-server to custom configuration + От мультиконфигурации к пользовательской конфигурации - Multi-server Random by Xray + Случайный (Xray) - Multi-server RoundRobin by Xray + Круговой (Xray) - Multi-server LeastPing by Xray + Минимальное RTT (минимальное время туда-обратно) (Xray) - Multi-server LeastLoad by Xray + Минимальная нагрузка (Xray) - Multi-server LeastPing by sing-box + Минимальное RTT (минимальное время туда-обратно) (sing-box) - Export server + Экспортировать конфигурацию - \ No newline at end of file + + URL для тестирования текущего соединения + + diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx index a5f07957..97305242 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx @@ -1071,13 +1071,13 @@ 拥塞控制算法 - + 前置代理配置文件别名 - + 落地代理配置文件別名 - + 请确保配置文件别名存在并唯一 @@ -1336,7 +1336,7 @@ 系统的 sudo 密码 - 密码已加密且只存储在本地文件中,无密码则每次都要输入 + 输入的密码无法校验,所以请确保输入正确。如果因为输入错误导致无法正常运行时,请重启本应用。 密码不会存储,每次重启后都需要再次输入。 请先在 Tun 模式设置中设置 sudo 密码 @@ -1413,4 +1413,7 @@ 导出配置文件 - + + 当前连接信息测试地址 + + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx index b8a5011a..35148566 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx @@ -1071,13 +1071,13 @@ 擁塞控制算法 - + 前置代理設定檔別名 - + 落地代理設定檔別名 - + 請確保設定檔別名存在並且唯一 @@ -1336,7 +1336,7 @@ 系統的 sudo 密碼 - 密碼已加密且只儲存在本機檔案中,無密碼則每次都要輸入 + 輸入的密碼無法校驗,所以請確保輸入正確。如果因為輸入錯誤導致無法正常運作時,請重新啟動本應用。 密碼不會存儲,每次重啟後都需要再次輸入。 請先在 Tun 模式設定中設定 sudo 密碼 @@ -1413,4 +1413,7 @@ 匯出設定檔 - + + 目前連接資訊測試地址 + + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Sample/dns_v2ray_normal b/v2rayN/ServiceLib/Sample/dns_v2ray_normal index 3f9c8b22..fdb30dae 100644 --- a/v2rayN/ServiceLib/Sample/dns_v2ray_normal +++ b/v2rayN/ServiceLib/Sample/dns_v2ray_normal @@ -6,11 +6,10 @@ "servers": [ { "address": "1.1.1.1", + "skipFallback": true, "domains": [ - "geosite:geolocation-!cn" - ], - "expectIPs": [ - "geoip:!cn" + "domain:googleapis.cn", + "domain:gstatic.com" ] }, { @@ -23,6 +22,7 @@ "geoip:cn" ] }, + "1.1.1.1", "8.8.8.8", "https://dns.google/dns-query" ] diff --git a/v2rayN/ServiceLib/Sample/proxy_set_linux_sh b/v2rayN/ServiceLib/Sample/proxy_set_linux_sh index 6267fd35..335cce0e 100644 --- a/v2rayN/ServiceLib/Sample/proxy_set_linux_sh +++ b/v2rayN/ServiceLib/Sample/proxy_set_linux_sh @@ -95,6 +95,21 @@ detect_desktop_environment() { return fi + if [[ "$XDG_CURRENT_DESKTOP" == *"UKUI"* ]] || [[ "$XDG_SESSION_DESKTOP" == *"ukui"* ]]; then + echo "gnome" + return + fi + + if [[ "$XDG_CURRENT_DESKTOP" == *"DDE"* ]] || [[ "$XDG_SESSION_DESKTOP" == *"dde"* ]]; then + echo "gnome" + return + fi + + if [[ "$XDG_CURRENT_DESKTOP" == *"MATE"* ]] || [[ "$XDG_SESSION_DESKTOP" == *"mate"* ]]; then + echo "gnome" + return + fi + local KDE_ENVIRONMENTS=("KDE" "plasma") for ENV in "${KDE_ENVIRONMENTS[@]}"; do if [ "$XDG_CURRENT_DESKTOP" == "$ENV" ] || [ "$XDG_SESSION_DESKTOP" == "$ENV" ]; then diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 34ae6f79..ba436903 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -979,26 +979,6 @@ public class CoreConfigSingboxService try { var dnsOutbound = "dns_out"; - if (!_config.Inbound.First().SniffingEnabled) - { - singboxConfig.route.rules.Add(new() - { - port = [53], - network = ["udp"], - outbound = dnsOutbound - }); - } - - singboxConfig.route.rules.Insert(0, new() - { - outbound = Global.DirectTag, - clash_mode = ERuleMode.Direct.ToString() - }); - singboxConfig.route.rules.Insert(0, new() - { - outbound = Global.ProxyTag, - clash_mode = ERuleMode.Global.ToString() - }); if (_config.TunModeItem.EnableTun) { @@ -1025,6 +1005,27 @@ public class CoreConfigSingboxService }); } + if (!_config.Inbound.First().SniffingEnabled) + { + singboxConfig.route.rules.Add(new() + { + port = [53], + network = ["udp"], + outbound = dnsOutbound + }); + } + + singboxConfig.route.rules.Add(new() + { + outbound = Global.DirectTag, + clash_mode = ERuleMode.Direct.ToString() + }); + singboxConfig.route.rules.Add(new() + { + outbound = Global.ProxyTag, + clash_mode = ERuleMode.Global.ToString() + }); + var routing = await ConfigHandler.GetDefaultRouting(_config); if (routing != null) { @@ -1047,28 +1048,30 @@ public class CoreConfigSingboxService private void GenRoutingDirectExe(out List lstDnsExe, out List lstDirectExe) { - lstDnsExe = new(); - lstDirectExe = new(); - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(); - foreach (var it in coreInfo) + var dnsExeSet = new HashSet(StringComparer.OrdinalIgnoreCase); + var directExeSet = new HashSet(StringComparer.OrdinalIgnoreCase); + + var coreInfoResult = CoreInfoHandler.Instance.GetCoreInfo(); + + foreach (var coreConfig in coreInfoResult) { - if (it.CoreType == ECoreType.v2rayN) + if (coreConfig.CoreType == ECoreType.v2rayN) { continue; } - foreach (var it2 in it.CoreExes) - { - if (!lstDnsExe.Contains(it2) && it.CoreType != ECoreType.sing_box) - { - lstDnsExe.Add($"{it2}.exe"); - } - if (!lstDirectExe.Contains(it2)) + foreach (var baseExeName in coreConfig.CoreExes) + { + if (coreConfig.CoreType != ECoreType.sing_box) { - lstDirectExe.Add($"{it2}.exe"); + dnsExeSet.Add(Utils.GetExeName(baseExeName)); } + directExeSet.Add(Utils.GetExeName(baseExeName)); } } + + lstDnsExe = new List(dnsExeSet); + lstDirectExe = new List(directExeSet); } private async Task GenRoutingUserRule(RulesItem item, List rules) @@ -1087,14 +1090,11 @@ public class CoreConfigSingboxService if (item.Port.IsNotEmpty()) { - if (item.Port.Contains("-")) - { - rule.port_range = new List { item.Port.Replace("-", ":") }; - } - else - { - rule.port = new List { item.Port.ToInt() }; - } + var portRanges = item.Port.Split(',').Where(it => it.Contains('-')).Select(it => it.Replace("-", ":")).ToList(); + var ports = item.Port.Split(',').Where(it => !it.Contains('-')).Select(it => it.ToInt()).ToList(); + + rule.port_range = portRanges.Count > 0 ? portRanges : null; + rule.port = ports.Count > 0 ? ports : null; } if (item.Network.IsNotEmpty()) { diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 7b940d07..ccbfb057 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -328,7 +328,7 @@ public class CoreConfigV2rayService { listen = Global.Loopback, port = port, - protocol = EInboundProtocol.socks.ToString(), + protocol = EInboundProtocol.mixed.ToString(), }; inbound.tag = inbound.protocol + inbound.port.ToString(); v2rayConfig.inbounds.Add(inbound); @@ -403,7 +403,7 @@ public class CoreConfigV2rayService tag = $"{EInboundProtocol.socks}{port}", listen = Global.Loopback, port = port, - protocol = EInboundProtocol.socks.ToString(), + protocol = EInboundProtocol.mixed.ToString(), }); ret.Msg = string.Format(ResUI.SuccessfulConfiguration, ""); @@ -507,7 +507,7 @@ public class CoreConfigV2rayService } inbound.tag = protocol.ToString(); inbound.port = inItem.LocalPort + (int)protocol; - inbound.protocol = EInboundProtocol.socks.ToString(); + inbound.protocol = EInboundProtocol.mixed.ToString(); inbound.settings.udp = inItem.UdpEnabled; inbound.sniffing.enabled = inItem.SniffingEnabled; inbound.sniffing.destOverride = inItem.DestOverride; @@ -1183,7 +1183,6 @@ public class CoreConfigV2rayService if (servers != null) { var domainList = new List(); - string? wireguardEndpointDomain = null; if (Utils.IsDomain(node.Address)) { domainList.Add(node.Address); @@ -1210,14 +1209,7 @@ public class CoreConfigV2rayService && nextNode.ConfigType != EConfigType.TUIC && Utils.IsDomain(nextNode.Address)) { - if (nextNode.ConfigType == EConfigType.WireGuard) - { - wireguardEndpointDomain = nextNode.Address; - } - else - { - domainList.Add(nextNode.Address); - } + domainList.Add(nextNode.Address); } } if (domainList.Count > 0) @@ -1230,16 +1222,6 @@ public class CoreConfigV2rayService }; servers.AsArray().Add(JsonUtils.SerializeToNode(dnsServer)); } - if (wireguardEndpointDomain is not null) - { - var dnsServer = new DnsServer4Ray() - { - address = string.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.DomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress, - skipFallback = true, - domains = new() { wireguardEndpointDomain } - }; - servers.AsArray().Insert(0, JsonUtils.SerializeToNode(dnsServer)); - } } return await Task.FromResult(0); } diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index f896e4ad..636f3616 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -194,11 +194,11 @@ public class UpdateService { if (Utils.IsBase64String(result2)) { - result += Utils.Base64Decode(result2); + result += Environment.NewLine + Utils.Base64Decode(result2); } else { - result += result2; + result += Environment.NewLine + result2; } } } @@ -243,21 +243,6 @@ public class UpdateService _updateFunc?.Invoke(true, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, "geo")); } - public async Task RunAvailabilityCheck() - { - 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, Global.IPAPIUrl); - var ipInfo = JsonUtils.Deserialize(result); - ip = $"({ipInfo?.country_code}) {ipInfo?.ip}"; - } - - return string.Format(ResUI.TestMeOutput, time, ip); - } - #region CheckUpdate private private async Task CheckUpdateAsync(DownloadService downloadHandle, ECoreType type, bool preRelease) diff --git a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs index b99339d6..57d8cac7 100644 --- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs @@ -70,6 +70,7 @@ public class OptionSettingViewModel : MyReactiveObject [Reactive] public string GeoFileSourceUrl { get; set; } [Reactive] public string SrsFileSourceUrl { get; set; } [Reactive] public string RoutingRulesSourceUrl { get; set; } + [Reactive] public string IPAPIUrl { get; set; } #endregion UI @@ -88,7 +89,6 @@ public class OptionSettingViewModel : MyReactiveObject [Reactive] public int TunMtu { get; set; } [Reactive] public bool TunEnableExInbound { get; set; } [Reactive] public bool TunEnableIPv6Address { get; set; } - [Reactive] public string TunLinuxSudoPassword { get; set; } #endregion Tun mode @@ -187,6 +187,7 @@ public class OptionSettingViewModel : MyReactiveObject GeoFileSourceUrl = _config.ConstItem.GeoSourceUrl; SrsFileSourceUrl = _config.ConstItem.SrsSourceUrl; RoutingRulesSourceUrl = _config.ConstItem.RouteRulesTemplateSourceUrl; + IPAPIUrl = _config.SpeedTestItem.IPAPIUrl; #endregion UI @@ -205,7 +206,6 @@ public class OptionSettingViewModel : MyReactiveObject TunMtu = _config.TunModeItem.Mtu; TunEnableExInbound = _config.TunModeItem.EnableExInbound; TunEnableIPv6Address = _config.TunModeItem.EnableIPv6Address; - TunLinuxSudoPassword = _config.TunModeItem.LinuxSudoPwd; #endregion Tun mode @@ -346,6 +346,7 @@ public class OptionSettingViewModel : MyReactiveObject _config.ConstItem.GeoSourceUrl = GeoFileSourceUrl; _config.ConstItem.SrsSourceUrl = SrsFileSourceUrl; _config.ConstItem.RouteRulesTemplateSourceUrl = RoutingRulesSourceUrl; + _config.SpeedTestItem.IPAPIUrl = IPAPIUrl; //systemProxy _config.SystemProxyItem.SystemProxyExceptions = systemProxyExceptions; @@ -358,10 +359,6 @@ public class OptionSettingViewModel : MyReactiveObject _config.TunModeItem.Mtu = TunMtu; _config.TunModeItem.EnableExInbound = TunEnableExInbound; _config.TunModeItem.EnableIPv6Address = TunEnableIPv6Address; - if (TunLinuxSudoPassword != _config.TunModeItem.LinuxSudoPwd) - { - _config.TunModeItem.LinuxSudoPwd = DesUtils.Encrypt(TunLinuxSudoPassword); - } //coreType await SaveCoreType(); diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs index 00cc391a..82b48aff 100644 --- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs @@ -320,7 +320,7 @@ public class StatusBarViewModel : MyReactiveObject var msg = await Task.Run(async () => { - return await (new UpdateService()).RunAvailabilityCheck(); + return await ConnectionHandler.Instance.RunAvailabilityCheck(); }); NoticeHandler.Instance.SendMessageEx(msg); @@ -436,11 +436,13 @@ public class StatusBarViewModel : MyReactiveObject Locator.Current.GetService()?.RebootAsAdmin(); return; } - else if (Utils.IsOSX()) + else { - _config.TunModeItem.EnableTun = false; - NoticeHandler.Instance.SendMessageAndEnqueue(ResUI.TbSettingsLinuxSudoPasswordIsEmpty); - return; + if (await _updateView?.Invoke(EViewAction.PasswordInput, null) == false) + { + _config.TunModeItem.EnableTun = false; + return; + } } } await ConfigHandler.SaveConfig(_config); @@ -452,15 +454,15 @@ public class StatusBarViewModel : MyReactiveObject { if (Utils.IsWindows()) { - return AppHandler.Instance.IsAdministrator; + return Utils.IsAdministrator(); } else if (Utils.IsLinux()) { - return _config.TunModeItem.LinuxSudoPwd.IsNotEmpty(); + return AppHandler.Instance.LinuxSudoPwd.IsNotEmpty(); } else if (Utils.IsOSX()) { - return _config.TunModeItem.LinuxSudoPwd.IsNotEmpty(); + return AppHandler.Instance.LinuxSudoPwd.IsNotEmpty(); } return false; } diff --git a/v2rayN/v2rayN.Desktop/App.axaml.cs b/v2rayN/v2rayN.Desktop/App.axaml.cs index b797c90b..7626edfd 100644 --- a/v2rayN/v2rayN.Desktop/App.axaml.cs +++ b/v2rayN/v2rayN.Desktop/App.axaml.cs @@ -43,7 +43,7 @@ public partial class App : Application { if (e.ExceptionObject != null) { - Logging.SaveLog("CurrentDomain_UnhandledException", (Exception)e.ExceptionObject!); + Logging.SaveLog("CurrentDomain_UnhandledException", (Exception)e.ExceptionObject); } } diff --git a/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs index b4426c29..c39724eb 100644 --- a/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs @@ -52,9 +52,16 @@ public partial class ClashConnectionsView : ReactiveUserControl } else { - if (AppHandler.Instance.IsAdministrator) + if (Utils.IsAdministrator()) { this.Title = $"{Utils.GetVersion()} - {ResUI.TbSettingsLinuxSudoPasswordNotSudoRunApp}"; NoticeHandler.Instance.SendMessageAndEnqueue(ResUI.TbSettingsLinuxSudoPasswordNotSudoRunApp); @@ -388,7 +388,7 @@ public partial class MainWindow : ReactiveWindow private async void MenuClose_Click(object? sender, RoutedEventArgs e) { - if (await UI.ShowYesNo(this, ResUI.menuExitTips) == ButtonResult.No) + if (await UI.ShowYesNo(this, ResUI.menuExitTips) != ButtonResult.Yes) { return; } diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml index 8c9351d7..004f68a4 100644 --- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml @@ -343,7 +343,7 @@ + RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto"> + + + + @@ -784,28 +798,6 @@ Margin="{StaticResource Margin4}" HorizontalAlignment="Left" /> - - - diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs index 58aceaf1..fd319d92 100644 --- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs @@ -92,6 +92,10 @@ public partial class OptionSettingWindow : ReactiveWindow + { + cmbIPAPIUrl.Items.Add(it); + }); foreach (EGirdOrientation it in Enum.GetValues(typeof(EGirdOrientation))) { cmbMainGirdOrientation.Items.Add(it.ToString()); @@ -143,6 +147,7 @@ public partial class OptionSettingWindow : ReactiveWindow vm.GeoFileSourceUrl, v => v.cmbGetFilesSourceUrl.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SrsFileSourceUrl, v => v.cmbSrsFilesSourceUrl.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.RoutingRulesSourceUrl, v => v.cmbRoutingRulesSourceUrl.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.IPAPIUrl, v => v.cmbIPAPIUrl.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.notProxyLocalAddress, v => v.tognotProxyLocalAddress.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.systemProxyAdvancedProtocol, v => v.cmbsystemProxyAdvancedProtocol.SelectedValue).DisposeWith(disposables); @@ -153,7 +158,6 @@ public partial class OptionSettingWindow : ReactiveWindow vm.TunMtu, v => v.cmbMtu.SelectedValue).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.TunLinuxSudoPassword, v => v.txtLinuxSudoPassword.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.CoreType1, v => v.cmbCoreType1.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.CoreType2, v => v.cmbCoreType2.SelectedValue).DisposeWith(disposables); @@ -170,10 +174,6 @@ public partial class OptionSettingWindow : ReactiveWindow break; case EViewAction.ShowYesNo: - if (await UI.ShowYesNo(_window, ResUI.RemoveServer) == ButtonResult.No) + if (await UI.ShowYesNo(_window, ResUI.RemoveServer) != ButtonResult.Yes) { return false; } @@ -345,9 +345,16 @@ public partial class ProfilesView : ReactiveUserControl private void AutofitColumnWidth() { - foreach (var it in lstProfiles.Columns) + try { - it.Width = new DataGridLength(1, DataGridLengthUnitType.Auto); + foreach (var it in lstProfiles.Columns) + { + it.Width = new DataGridLength(1, DataGridLengthUnitType.Auto); + } + } + catch (Exception ex) + { + Logging.SaveLog("ProfilesView", ex); } } diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml.cs index 1fbe5c2b..1cae4c0b 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml.cs @@ -80,14 +80,14 @@ public partial class RoutingRuleSettingWindow : ReactiveWindow return false; await AvaUtils.SetClipboardData(this, (string)obj); break; + + case EViewAction.PasswordInput: + return await PasswordInputAsync(); + break; } return await Task.FromResult(true); } @@ -96,6 +101,20 @@ public partial class StatusBarView : ReactiveUserControl } } + private async Task PasswordInputAsync() + { + var dialog = new SudoPasswordInputView(); + var obj = await DialogHost.Show(dialog); + if (obj == null) + { + togEnableTun.IsChecked = false; + return false; + } + + AppHandler.Instance.LinuxSudoPwd = obj.ToString() ?? string.Empty; + return true; + } + private void TxtRunningServerDisplay_Tapped(object? sender, Avalonia.Input.TappedEventArgs e) { ViewModel?.TestServerAvailability(); diff --git a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs index bd1dd4df..7882449e 100644 --- a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs @@ -45,7 +45,7 @@ public partial class SubSettingWindow : ReactiveWindow break; case EViewAction.ShowYesNo: - if (await UI.ShowYesNo(this, ResUI.RemoveServer) == ButtonResult.No) + if (await UI.ShowYesNo(this, ResUI.RemoveServer) != ButtonResult.Yes) { return false; } diff --git a/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml b/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml new file mode 100644 index 00000000..507cbb49 --- /dev/null +++ b/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml @@ -0,0 +1,70 @@ + + + + + + + @@ -61,9 +62,9 @@ Width="30" Height="30" Margin="{StaticResource MarginLeftRight8}" + AutomationProperties.Name="{x:Static resx:ResUI.menuProfileAutofitColumnWidth}" Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}" - ToolTip="{x:Static resx:ResUI.menuProfileAutofitColumnWidth}" - AutomationProperties.Name="{x:Static resx:ResUI.menuProfileAutofitColumnWidth}"> + ToolTip="{x:Static resx:ResUI.menuProfileAutofitColumnWidth}"> + AutomationProperties.Name="{x:Static resx:ResUI.MsgServerTitle}" + Style="{StaticResource DefTextBox}" /> + VerticalAlignment="Center" + AutomationProperties.Name="{x:Static resx:ResUI.TbEnableTunAs}" /> + Style="{StaticResource MaterialDesignFloatingHintComboBox}"> @@ -88,10 +89,11 @@ Width="160" Margin="{StaticResource MarginLeftRight8}" materialDesign:HintAssist.Hint="{x:Static resx:ResUI.menuRouting}" + AutomationProperties.Name="{x:Static resx:ResUI.menuRouting}" DisplayMemberPath="Remarks" FontSize="{DynamicResource StdFontSize}" - Style="{StaticResource MaterialDesignFloatingHintComboBox}" - AutomationProperties.Name="{x:Static resx:ResUI.menuRouting}"/> + Style="{StaticResource MaterialDesignFloatingHintComboBox}"> + @@ -109,8 +111,10 @@ ToolTipText="v2rayN"> - + - + - + - + - + + Style="{StaticResource MaterialDesignFilledComboBox}"> + @@ -184,10 +197,11 @@ x:Name="cmbServers" MaxWidth="300" materialDesign:HintAssist.Hint="{x:Static resx:ResUI.menuServers}" + AutomationProperties.Name="{x:Static resx:ResUI.menuServers}" DisplayMemberPath="Text" FontSize="{DynamicResource StdFontSize}" - Style="{StaticResource MaterialDesignFilledComboBox}" - AutomationProperties.Name="{x:Static resx:ResUI.menuServers}"/> + Style="{StaticResource MaterialDesignFilledComboBox}"> + diff --git a/v2rayN/v2rayN/Views/SubEditWindow.xaml b/v2rayN/v2rayN/Views/SubEditWindow.xaml index c7cd0ea1..4d33cb11 100644 --- a/v2rayN/v2rayN/Views/SubEditWindow.xaml +++ b/v2rayN/v2rayN/Views/SubEditWindow.xaml @@ -1,11 +1,11 @@