From c3ae168acadf88ce8f83bb498a3212dcdc52995b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9A=E9=BA=9F=20=E5=90=B4?= Date: Sun, 6 Mar 2022 00:07:30 +0800 Subject: [PATCH] Bug fix. --- v2rayN/v2rayN/Forms/QRCodeControl.cs | 9 +-- v2rayN/v2rayN/Forms/QRCodeControl.resx | 90 ++++++-------------------- v2rayN/v2rayN/Handler/QRCodeHelper.cs | 3 +- v2rayN/v2rayN/Handler/UpdateHandle.cs | 2 +- v2rayN/v2rayN/Tool/Utils.cs | 45 +++++++------ v2rayN/v2rayN/v2rayN.csproj | 1 + 6 files changed, 53 insertions(+), 97 deletions(-) diff --git a/v2rayN/v2rayN/Forms/QRCodeControl.cs b/v2rayN/v2rayN/Forms/QRCodeControl.cs index 855db30d..6e2410e3 100644 --- a/v2rayN/v2rayN/Forms/QRCodeControl.cs +++ b/v2rayN/v2rayN/Forms/QRCodeControl.cs @@ -10,12 +10,13 @@ namespace v2rayN.Forms { InitializeComponent(); } + private void QRCodeControl_Load(object sender, System.EventArgs e) { - txtUrl.MouseUp += txtUrl_MouseUp; + txtUrl.MouseUp += txtUrl_MouseUp; } - void txtUrl_MouseUp(object sender, MouseEventArgs e) + private void txtUrl_MouseUp(object sender, MouseEventArgs e) { txtUrl.SelectAll(); } @@ -32,8 +33,8 @@ namespace v2rayN.Forms return; } txtUrl.Text = url; - picQRCode.Image = QRCodeHelper.GetQRCode(url); + picQRCode.Image = QRCodeHelper.GetQRCode(url); } } } -} +} \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/QRCodeControl.resx b/v2rayN/v2rayN/Forms/QRCodeControl.resx index a6ceff05..89991a4e 100644 --- a/v2rayN/v2rayN/Forms/QRCodeControl.resx +++ b/v2rayN/v2rayN/Forms/QRCodeControl.resx @@ -1,64 +1,4 @@ - - - + @@ -117,20 +57,24 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Bottom - 0, 371 + 0, 527 + + + + 4, 4, 4, 4 True - 356, 70 + 415, 98 0 @@ -139,7 +83,7 @@ txtUrl - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TextBox, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089 $this @@ -153,8 +97,11 @@ 0, 0 + + 4, 4, 4, 4 + - 356, 371 + 415, 527 Zoom @@ -166,7 +113,7 @@ picQRCode - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.PictureBox, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089 $this @@ -178,15 +125,18 @@ True - 6, 12 + 7, 17 + + + 4, 4, 4, 4 - 356, 441 + 415, 625 QRCodeControl - System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.UserControl, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/v2rayN/v2rayN/Handler/QRCodeHelper.cs b/v2rayN/v2rayN/Handler/QRCodeHelper.cs index 2fc56954..05451f24 100644 --- a/v2rayN/v2rayN/Handler/QRCodeHelper.cs +++ b/v2rayN/v2rayN/Handler/QRCodeHelper.cs @@ -1,6 +1,7 @@ using System.Drawing; using ZXing; using ZXing.QrCode; +using ZXing.Windows.Compatibility; namespace v2rayN.Handler { @@ -40,4 +41,4 @@ namespace v2rayN.Handler } } } -} +} \ No newline at end of file diff --git a/v2rayN/v2rayN/Handler/UpdateHandle.cs b/v2rayN/v2rayN/Handler/UpdateHandle.cs index 332368c7..d0bb6b87 100644 --- a/v2rayN/v2rayN/Handler/UpdateHandle.cs +++ b/v2rayN/v2rayN/Handler/UpdateHandle.cs @@ -290,7 +290,7 @@ namespace v2rayN.Handler try { Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13); - WebRequestHandler webRequestHandler = new WebRequestHandler + HttpClientHandler webRequestHandler = new HttpClientHandler { AllowAutoRedirect = false }; diff --git a/v2rayN/v2rayN/Tool/Utils.cs b/v2rayN/v2rayN/Tool/Utils.cs index dc28ce38..5e56dc97 100644 --- a/v2rayN/v2rayN/Tool/Utils.cs +++ b/v2rayN/v2rayN/Tool/Utils.cs @@ -22,12 +22,12 @@ using v2rayN.Base; using Newtonsoft.Json.Linq; using System.Web; using log4net; +using ZXing.Windows.Compatibility; namespace v2rayN { - class Utils + internal class Utils { - #region 资源Json操作 /// @@ -55,7 +55,6 @@ namespace v2rayN return result; } - /// /// 取得存储资源 /// @@ -167,7 +166,8 @@ namespace v2rayN return null; } } - #endregion + + #endregion 资源Json操作 #region 转换函数 @@ -199,6 +199,7 @@ namespace v2rayN return string.Empty; } } + /// /// 逗号分隔的字符串,转List /// @@ -353,18 +354,17 @@ namespace v2rayN return $"{string.Format("{0:f1}", result)} {unit}"; } - - public static string UrlEncode(string url) { return HttpUtility.UrlEncode(url); } + public static string UrlDecode(string url) { return HttpUtility.UrlDecode(url); } - #endregion + #endregion 转换函数 #region 数据检查 @@ -408,7 +408,7 @@ namespace v2rayN /// /// 验证IP地址是否合法 /// - /// + /// public static bool IsIP(string ip) { //如果为空 @@ -433,7 +433,6 @@ namespace v2rayN } } - //模式字符串 string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"; @@ -444,7 +443,7 @@ namespace v2rayN /// /// 验证Domain地址是否合法 /// - /// + /// public static bool IsDomain(string domain) { //如果为空 @@ -467,7 +466,7 @@ namespace v2rayN /// 验证输入字符串是否与模式字符串匹配,匹配返回true /// /// 输入字符串 - /// 模式字符串 + /// 模式字符串 public static bool IsMatch(string input, string pattern) { return Regex.IsMatch(input, pattern, RegexOptions.IgnoreCase); @@ -482,8 +481,10 @@ namespace v2rayN { case AddressFamily.InterNetwork: return false; + case AddressFamily.InterNetworkV6: return true; + default: return false; } @@ -491,11 +492,12 @@ namespace v2rayN return false; } - #endregion + #endregion 数据检查 #region 开机自动启动 private static string autoRunName = "v2rayNAutoRun"; + private static string autoRunRegPath { get @@ -651,7 +653,7 @@ namespace v2rayN } } - #endregion + #endregion 开机自动启动 #region 测速 @@ -754,7 +756,8 @@ namespace v2rayN } return inUse; } - #endregion + + #endregion 测速 #region 杂项 @@ -902,7 +905,8 @@ namespace v2rayN return fileName; } - #endregion + + #endregion 杂项 #region TempPath @@ -934,7 +938,7 @@ namespace v2rayN return Encoding.UTF8.GetString(sb.ToArray()); } - #endregion + #endregion TempPath #region Log @@ -943,6 +947,7 @@ namespace v2rayN var logger = LogManager.GetLogger("Log1"); logger.Info(strContent); } + public static void SaveLog(string strTitle, Exception ex) { var logger = LogManager.GetLogger("Log2"); @@ -950,8 +955,7 @@ namespace v2rayN logger.Debug(ex); } - #endregion - + #endregion Log #region scan screen @@ -1008,7 +1012,6 @@ namespace v2rayN return string.Empty; } - #endregion - + #endregion scan screen } -} +} \ No newline at end of file diff --git a/v2rayN/v2rayN/v2rayN.csproj b/v2rayN/v2rayN/v2rayN.csproj index d4db394c..297089fc 100644 --- a/v2rayN/v2rayN/v2rayN.csproj +++ b/v2rayN/v2rayN/v2rayN.csproj @@ -142,6 +142,7 @@ all + copy /y $(SolutionDir)v2rayUpgrade\$(OutDir)* $(TargetDir)