diff --git a/Netch/Flags.cs b/Netch/Flags.cs index 1216e0b2..72984b34 100644 --- a/Netch/Flags.cs +++ b/Netch/Flags.cs @@ -7,5 +7,7 @@ namespace Netch public static readonly bool IsWindows10Upper = Environment.OSVersion.Version.Major >= 10; public static bool AlwaysShowNewVersionFound { get; set; } + + public static bool NoSupport { get; set; } } } \ No newline at end of file diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs index 0e34f768..cd782ab4 100644 --- a/Netch/Forms/MainForm.cs +++ b/Netch/Forms/MainForm.cs @@ -43,6 +43,9 @@ namespace Netch.Forms #region i18N Translations + if (Flags.NoSupport) + _mainFormText.Add(Name, new[] { "{0} ({1})", "Netch", "No Support" }); + _mainFormText.Add(UninstallServiceToolStripMenuItem.Name, new[] { "Uninstall {0}", "NF Service" }); #endregion diff --git a/Netch/Forms/SettingForm.Designer.cs b/Netch/Forms/SettingForm.Designer.cs index 5a68ad21..415dfe74 100644 --- a/Netch/Forms/SettingForm.Designer.cs +++ b/Netch/Forms/SettingForm.Designer.cs @@ -99,6 +99,7 @@ namespace Netch.Forms this.StopWhenExitedCheckBox = new System.Windows.Forms.CheckBox(); this.StartWhenOpenedCheckBox = new System.Windows.Forms.CheckBox(); this.MinimizeWhenStartedCheckBox = new System.Windows.Forms.CheckBox(); + this.NoSupportDialogCheckBox = new System.Windows.Forms.CheckBox(); this.RunAtStartupCheckBox = new System.Windows.Forms.CheckBox(); this.CheckUpdateWhenOpenedCheckBox = new System.Windows.Forms.CheckBox(); this.CheckBetaUpdateCheckBox = new System.Windows.Forms.CheckBox(); @@ -771,6 +772,7 @@ namespace Netch.Forms this.OtherTabPage.Controls.Add(this.StopWhenExitedCheckBox); this.OtherTabPage.Controls.Add(this.StartWhenOpenedCheckBox); this.OtherTabPage.Controls.Add(this.MinimizeWhenStartedCheckBox); + this.OtherTabPage.Controls.Add(this.NoSupportDialogCheckBox); this.OtherTabPage.Controls.Add(this.RunAtStartupCheckBox); this.OtherTabPage.Controls.Add(this.CheckUpdateWhenOpenedCheckBox); this.OtherTabPage.Controls.Add(this.CheckBetaUpdateCheckBox); @@ -825,6 +827,16 @@ namespace Netch.Forms this.MinimizeWhenStartedCheckBox.Text = "Minimize when started"; this.MinimizeWhenStartedCheckBox.UseVisualStyleBackColor = true; // + // NoSupportDialogCheckBox + // + this.NoSupportDialogCheckBox.AutoSize = true; + this.NoSupportDialogCheckBox.Location = new System.Drawing.Point(6, 72); + this.NoSupportDialogCheckBox.Name = "NoSupportDialogCheckBox"; + this.NoSupportDialogCheckBox.Size = new System.Drawing.Size(174, 21); + this.NoSupportDialogCheckBox.TabIndex = 4; + this.NoSupportDialogCheckBox.Text = "Disable Support Warning"; + this.NoSupportDialogCheckBox.UseVisualStyleBackColor = true; + // // RunAtStartupCheckBox // this.RunAtStartupCheckBox.AutoSize = true; @@ -1080,5 +1092,6 @@ namespace Netch.Forms private System.Windows.Forms.CheckBox ChildProcessHandleCheckBox; private System.Windows.Forms.TextBox ICMPDelayTextBox; private System.Windows.Forms.Label ICMPDelayLabel; + private System.Windows.Forms.CheckBox NoSupportDialogCheckBox; } } \ No newline at end of file diff --git a/Netch/Forms/SettingForm.cs b/Netch/Forms/SettingForm.cs index a8186838..352f2f8c 100644 --- a/Netch/Forms/SettingForm.cs +++ b/Netch/Forms/SettingForm.cs @@ -205,6 +205,8 @@ namespace Netch.Forms BindCheckBox(UpdateServersWhenOpenedCheckBox, b => Global.Settings.UpdateServersWhenOpened = b, Global.Settings.UpdateServersWhenOpened); + BindCheckBox(NoSupportDialogCheckBox, b => Global.Settings.NoSupportDialog = b, Global.Settings.NoSupportDialog); + #endregion #region AioDNS diff --git a/Netch/Models/Setting.cs b/Netch/Models/Setting.cs index bc14c2f4..e3d054f9 100644 --- a/Netch/Models/Setting.cs +++ b/Netch/Models/Setting.cs @@ -263,6 +263,8 @@ namespace Netch.Models public V2rayConfig V2RayConfig { get; set; } = new(); + public bool NoSupportDialog { get; set; } = false; + public Setting Clone() { return (Setting)MemberwiseClone(); diff --git a/Netch/Netch.cs b/Netch/Netch.cs index 1363411b..426683c7 100644 --- a/Netch/Netch.cs +++ b/Netch/Netch.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using System.Reflection; +using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -10,6 +12,7 @@ using Windows.Win32; using Windows.Win32.Foundation; using Microsoft.VisualStudio.Threading; using Netch.Controllers; +using Netch.Enums; using Netch.Forms; using Netch.Services; using Netch.Utils; @@ -90,6 +93,8 @@ namespace Netch } Task.Run(LogEnvironment).Forget(); + CheckClr(); + CheckOS(); // 绑定错误捕获 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); @@ -105,13 +110,43 @@ namespace Netch private static void LogEnvironment() { Log.Information("Netch Version: {Version}", $"{UpdateChecker.Owner}/{UpdateChecker.Repo}@{UpdateChecker.Version}"); - Log.Information("Environment: {OSVersion}", Environment.OSVersion); + Log.Information("OS: {OSVersion}", Environment.OSVersion); Log.Information("SHA256: {Hash}", $"{Utils.Utils.SHA256CheckSum(Global.NetchExecutable)}"); Log.Information("System Language: {Language}", CultureInfo.CurrentCulture.Name); if (Log.IsEnabled(LogEventLevel.Debug)) Log.Debug("Third-party Drivers:\n{Drivers}", string.Join("\n", SystemInfo.SystemDrivers(false))); } + private static void CheckClr() + { + var framework = Assembly.GetExecutingAssembly().GetCustomAttribute()?.FrameworkName; + if (framework == null) + { + Log.Warning("TargetFrameworkAttribute null"); + return; + } + + var frameworkName = new FrameworkName(framework); + + if (frameworkName.Version.Major != Environment.Version.Major) + { + Log.Information("CLR: {OSVersion}", Environment.Version); + Flags.NoSupport = true; + if(!Global.Settings.NoSupportDialog) + MessageBoxX.Show(i18N.TranslateFormat("{0} won't get developers' support, Please do not report any issues or seek help from developers.", "CLR " + Environment.Version), LogLevel.WARNING); + } + } + + private static void CheckOS() + { + if (Environment.OSVersion.Version.Build < 17763) + { + Flags.NoSupport = true; + if(!Global.Settings.NoSupportDialog) + MessageBoxX.Show(i18N.TranslateFormat("{0} won't get developers' support, Please do not report any issues or seek help from developers.", Environment.OSVersion), LogLevel.WARNING); + } + } + private static void InitConsole() { PInvoke.AllocConsole(); diff --git a/Netch/Resources/zh-CN b/Netch/Resources/zh-CN index 7bdab97c..873b0bc4 100644 --- a/Netch/Resources/zh-CN +++ b/Netch/Resources/zh-CN @@ -163,6 +163,7 @@ "Language": "语言", "Resolve Server Hostname": "解析服务器主机名", "FullCone Support (Required Server Xray-core v1.3.0+)": "FullCone 支持(需服务端 Xray-core v1.3.0+)", + "Disable Support Warning": "停用支持警告", "Profile": "配置名", "Profiles": "配置", @@ -174,5 +175,7 @@ "The {0} port is in use.": "{0} 端口已被占用", "The {0} port is reserved by system.": "{0} 端口是系统保留端口", - "\"Core.bin\" is missing. Please check your Antivirus software": "找不到 \"Core.bin\" 文件!请检查你的杀毒软件。" + "\"Core.bin\" is missing. Please check your Antivirus software": "找不到 \"Core.bin\" 文件!请检查你的杀毒软件。", + "{0} won't get developers' support, Please do not report any issues or seek help from developers.": "{0} 将不会得到开发者的支持,请不要报告任何问题或寻求开发人员的帮助。", + "No Support": "不受支持" }