From 5cadf59e10cf0df617078fd68b43abadddaa8719 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Thu, 12 Dec 2019 10:16:09 +0800 Subject: [PATCH] add up --- v2rayN/v2rayN.sln | 10 +++ v2rayN/v2rayN/Forms/MainForm.cs | 73 +++++++++++++++++++-- v2rayN/v2rayN/Handler/DownloadHandle.cs | 81 +++++++++++++++++++----- v2rayN/v2rayN/LIB/libs.zip | Bin 3680400 -> 3685337 bytes v2rayN/v2rayN/Resx/ResUI.Designer.cs | 6 +- v2rayN/v2rayN/Resx/ResUI.resx | 6 +- v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx | 6 +- v2rayN/v2rayN/Tool/FileManager.cs | 26 ++++++++ v2rayN/v2rayN/Tool/Utils.cs | 26 ++++---- v2rayN/v2rayN/v2rayN.csproj | 1 + 10 files changed, 190 insertions(+), 45 deletions(-) diff --git a/v2rayN/v2rayN.sln b/v2rayN/v2rayN.sln index 02f175e5..0b906d27 100644 --- a/v2rayN/v2rayN.sln +++ b/v2rayN/v2rayN.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28010.2050 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "v2rayN", "v2rayN\v2rayN.csproj", "{0A9785E6-D256-4B73-9757-4EF59955FD1E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "v2rayUpgrade", "v2rayUpgrade\v2rayUpgrade.csproj", "{F82BE52A-155C-492C-9E0A-1E917EC62C78}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -20,6 +22,14 @@ Global {0A9785E6-D256-4B73-9757-4EF59955FD1E}.Release|Any CPU.ActiveCfg = Release|Any CPU {0A9785E6-D256-4B73-9757-4EF59955FD1E}.Release|Any CPU.Build.0 = Release|Any CPU {0A9785E6-D256-4B73-9757-4EF59955FD1E}.Release|x86.ActiveCfg = Release|Any CPU + {F82BE52A-155C-492C-9E0A-1E917EC62C78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F82BE52A-155C-492C-9E0A-1E917EC62C78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F82BE52A-155C-492C-9E0A-1E917EC62C78}.Debug|x86.ActiveCfg = Debug|Any CPU + {F82BE52A-155C-492C-9E0A-1E917EC62C78}.Debug|x86.Build.0 = Debug|Any CPU + {F82BE52A-155C-492C-9E0A-1E917EC62C78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F82BE52A-155C-492C-9E0A-1E917EC62C78}.Release|Any CPU.Build.0 = Release|Any CPU + {F82BE52A-155C-492C-9E0A-1E917EC62C78}.Release|x86.ActiveCfg = Release|Any CPU + {F82BE52A-155C-492C-9E0A-1E917EC62C78}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 5add9efd..718dd74b 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -10,6 +10,7 @@ using v2rayN.HttpProxyHandler; using v2rayN.Mode; using v2rayN.Base; using v2rayN.Tool; +using System.Diagnostics; namespace v2rayN.Forms { @@ -17,7 +18,6 @@ namespace v2rayN.Forms { private V2rayHandler v2rayHandler; private PACListHandle pacListHandle; - private DownloadHandle downloadHandle; private List lvSelecteds = new List(); private StatisticsHandler statistics = null; @@ -34,8 +34,6 @@ namespace v2rayN.Forms Application.ApplicationExit += (sender, args) => { - Utils.ClearTempPath(); - v2rayHandler.V2rayStop(); HttpProxyHandle.CloseHttpAgent(config); @@ -1134,11 +1132,74 @@ namespace v2rayN.Forms private void tsbCheckUpdateN_Click(object sender, EventArgs e) { - System.Diagnostics.Process.Start(Global.UpdateUrl); + //System.Diagnostics.Process.Start(Global.UpdateUrl); + DownloadHandle downloadHandle = null; + if (downloadHandle == null) + { + downloadHandle = new DownloadHandle(); + downloadHandle.AbsoluteCompleted += (sender2, args) => + { + if (args.Success) + { + AppendText(false, UIRes.I18N("MsgParsingV2rayCoreSuccessfully")); + + string url = args.Msg; + this.Invoke((MethodInvoker)(delegate + { + + if (UI.ShowYesNo(string.Format(UIRes.I18N("DownloadYesNo"), url)) == DialogResult.No) + { + return; + } + else + { + downloadHandle.DownloadFileAsync(config, url, null, -1); + } + })); + } + else + { + AppendText(false, args.Msg); + } + }; + downloadHandle.UpdateCompleted += (sender2, args) => + { + if (args.Success) + { + AppendText(false, UIRes.I18N("MsgDownloadV2rayCoreSuccessfully")); + + try + { + var fileName = Utils.GetPath(downloadHandle.DownloadFileName); + var process = Process.Start("v2rayUpgrade.exe", fileName); + if (process.Id > 0) + { + menuExit_Click(null, null); + } + } + catch (Exception ex) + { + AppendText(false, ex.Message); + } + } + else + { + AppendText(false, args.Msg); + } + }; + downloadHandle.Error += (sender2, args) => + { + AppendText(true, args.GetException().Message); + }; + } + + AppendText(false, UIRes.I18N("MsgStartUpdatingV2rayCore")); + downloadHandle.AbsoluteV2rayN(config); } private void tsbCheckUpdateCore_Click(object sender, EventArgs e) { + DownloadHandle downloadHandle = null; if (downloadHandle == null) { downloadHandle = new DownloadHandle(); @@ -1180,8 +1241,8 @@ namespace v2rayN.Forms string fileName = downloadHandle.DownloadFileName; fileName = Utils.GetPath(fileName); - FileManager.ZipExtractToFile(fileName); - + FileManager.ZipExtractToFile(fileName); + AppendText(false, UIRes.I18N("MsgUpdateV2rayCoreSuccessfullyMore")); Global.reloadV2ray = true; diff --git a/v2rayN/v2rayN/Handler/DownloadHandle.cs b/v2rayN/v2rayN/Handler/DownloadHandle.cs index 68f5d9db..7044e48e 100644 --- a/v2rayN/v2rayN/Handler/DownloadHandle.cs +++ b/v2rayN/v2rayN/Handler/DownloadHandle.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using System.Net; using v2rayN.Base; @@ -37,17 +38,69 @@ namespace v2rayN.Handler } } - private string latestUrl = "https://github.com/v2ray/v2ray-core/releases/latest"; - private const string coreURL = "https://github.com/v2ray/v2ray-core/releases/download/{0}/v2ray-windows-{1}.zip"; private int progressPercentage = -1; private long totalBytesToReceive = 0; private DateTime totalDatetime = new DateTime(); private int DownloadTimeout = -1; + + + #region v2rayN + + private string nLatestUrl = "https://github.com/2dust/v2rayN/releases/latest"; + private const string nUrl = "https://github.com/2dust/v2rayN/releases/download/{0}/v2rayN.zip"; + + public void AbsoluteV2rayN(Config config) + { + Utils.SetSecurityProtocol(); + WebRequest request = WebRequest.Create(nLatestUrl); + request.BeginGetResponse(new AsyncCallback(OnResponseV2rayN), request); + } + + private void OnResponseV2rayN(IAsyncResult ar) + { + try + { + HttpWebRequest request = (HttpWebRequest)ar.AsyncState; + HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(ar); + string redirectUrl = response.ResponseUri.AbsoluteUri; + string version = redirectUrl.Substring(redirectUrl.LastIndexOf("/", StringComparison.Ordinal) + 1); + + var curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString(); + if (curVersion == version) + { + if (AbsoluteCompleted != null) + { + AbsoluteCompleted(this, new ResultEventArgs(false, "Already the latest version")); + } + } + + string url = string.Format(nUrl, version); + if (AbsoluteCompleted != null) + { + AbsoluteCompleted(this, new ResultEventArgs(true, url)); + } + } + catch (Exception ex) + { + Utils.SaveLog(ex.Message, ex); + + if (Error != null) + Error(this, new ErrorEventArgs(ex)); + } + } + + #endregion + + #region Core + + private string coreLatestUrl = "https://github.com/v2ray/v2ray-core/releases/latest"; + private const string coreUrl = "https://github.com/v2ray/v2ray-core/releases/download/{0}/v2ray-windows-{1}.zip"; + public void AbsoluteV2rayCore(Config config) { - SetSecurityProtocol(); - WebRequest request = WebRequest.Create(latestUrl); + Utils.SetSecurityProtocol(); + WebRequest request = WebRequest.Create(coreLatestUrl); request.BeginGetResponse(new AsyncCallback(OnResponseV2rayCore), request); } @@ -69,7 +122,7 @@ namespace v2rayN.Handler { osBit = "32"; } - string url = string.Format(coreURL, version, osBit); + string url = string.Format(coreUrl, version, osBit); if (AbsoluteCompleted != null) { AbsoluteCompleted(this, new ResultEventArgs(true, url)); @@ -84,12 +137,15 @@ namespace v2rayN.Handler } } + #endregion + + #region Download public void DownloadFileAsync(Config config, string url, WebProxy webProxy, int downloadTimeout) { try { - SetSecurityProtocol(); + Utils.SetSecurityProtocol(); if (UpdateCompleted != null) { UpdateCompleted(this, new ResultEventArgs(false, "Downloading...")); @@ -107,7 +163,7 @@ namespace v2rayN.Handler ws.DownloadFileCompleted += ws_DownloadFileCompleted; ws.DownloadProgressChanged += ws_DownloadProgressChanged; - ws.DownloadFileAsync(new Uri(url), Utils.GetPath(DownloadFileName)); + ws.DownloadFileAsync(new Uri(url), Utils.GetPath(DownloadFileName)); } catch (Exception ex) { @@ -193,7 +249,7 @@ namespace v2rayN.Handler string source = string.Empty; try { - SetSecurityProtocol(); + Utils.SetSecurityProtocol(); WebClientEx ws = new WebClientEx(); ws.DownloadStringCompleted += Ws_DownloadStringCompleted; @@ -232,13 +288,6 @@ namespace v2rayN.Handler } } - private void SetSecurityProtocol() - { - ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 - | SecurityProtocolType.Tls - | SecurityProtocolType.Tls11 - | SecurityProtocolType.Tls12; - ServicePointManager.DefaultConnectionLimit = 256; - } + #endregion } } diff --git a/v2rayN/v2rayN/LIB/libs.zip b/v2rayN/v2rayN/LIB/libs.zip index aa07c53095f36d8f3771a2220d7d02b72203353c..df1a7e39ddca115d93b2b32e60fbca9bde372ba1 100644 GIT binary patch delta 5145 zcmZXYXEfUZ+lS3kdl$8-t!l4YMX6a-NQi3fnO4;%!r$H$6>9H2VkBto4mD!$+G3|_ zmg>{@{q&sk+~-{9_u+S+`~H5VU{?s|&Q}P-078HWAO=VPQs5Rq29N`{0SbT;paQ4? z8h{p{1Ly$;fDvE)v`zJ2#XjsQb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OJDKKvehIfae0!aG1z(Rd{yU&b z>(MgoaKGBnKi-Bj^S82&%(&C7yNE3er!IyC1}eu>ZX_TF=9YMlFrs_T#1`l%YR5bQ_0G8sWJDiDol23ZLVojV>M^`VP$eF z8f3F*^y{`de(33&R|WM}ui;AXp8dMSB-&6WSu}8lZXXN%0k2Ibq{-L)5T6urKv>O( zl3r9g-jWC*>L`>NzDWlu_|}e~`0Fm(KX=UonHEjC@-vmb$x;Ytghe^i$+WCIS%uxR z;d!LXJ79QDU`EMA30%a{rM3 zheBH%nW7Sp&Hq|4fq!1?|Ayxu|MvgKkx~4ALqI@Cz)J9xm?tZ~VTy3ND)lzNT-;kF080ULrp+UAVf+)kSnkF@7;d@T&e4Z delta 172 zcmWN=HwwZ~0D$2ajm8ptkG=P9%!7=c!m|X#;RnUZLC8fEPv8L@-Mod9pdWm%&s#Y^ z-^v~Z4_;J!_|XUuBt#gU2vK6hNsuH(nhaTT - /// 查找类似 Download V2rayCore successfully 的本地化字符串。 + /// 查找类似 Download V2ray successfully 的本地化字符串。 /// internal static string MsgDownloadV2rayCoreSuccessfully { get { @@ -448,7 +448,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Resolve V2rayCore successfully 的本地化字符串。 + /// 查找类似 Resolve V2ray successfully 的本地化字符串。 /// internal static string MsgParsingV2rayCoreSuccessfully { get { @@ -484,7 +484,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Start updating V2rayCore... 的本地化字符串。 + /// 查找类似 Start updating V2ray... 的本地化字符串。 /// internal static string MsgStartUpdatingV2rayCore { get { diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx index 9db82297..74280a36 100644 --- a/v2rayN/v2rayN/Resx/ResUI.resx +++ b/v2rayN/v2rayN/Resx/ResUI.resx @@ -269,7 +269,7 @@ Clear original subscription content - Download V2rayCore successfully + Download V2ray successfully Failed to import subscription content @@ -287,7 +287,7 @@ PAC update succeeded - Resolve V2rayCore successfully + Resolve V2ray successfully Simplify PAC Success @@ -299,7 +299,7 @@ Start updating PAC... - Start updating V2rayCore... + Start updating V2ray... Subscription content decoding failed (non-BASE64 code) diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx index b775c152..cf7cab26 100644 --- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx @@ -269,7 +269,7 @@ 清除原订阅内容 - 下载V2rayCore成功 + 下载V2ray成功 导入订阅内容失败 @@ -287,7 +287,7 @@ PAC更新成功 - 解析V2rayCore成功 + 解析V2ray成功 简化PAC成功 @@ -299,7 +299,7 @@ 开始更新PAC... - 开始更新V2rayCore... + 开始更新V2ray... 订阅内容解码失败(非BASE64码) diff --git a/v2rayN/v2rayN/Tool/FileManager.cs b/v2rayN/v2rayN/Tool/FileManager.cs index 96841c96..fffeda94 100644 --- a/v2rayN/v2rayN/Tool/FileManager.cs +++ b/v2rayN/v2rayN/Tool/FileManager.cs @@ -89,5 +89,31 @@ namespace v2rayN.Tool } return true; } + + public static bool ZipExtractToFullFile(string fileName) + { + try + { + using (ZipArchive archive = ZipFile.OpenRead(fileName)) + { + foreach (ZipArchiveEntry entry in archive.Entries) + { + if (entry.Length == 0) + continue; + + string entryOuputPath = Utils.GetPath(entry.FullName); + FileInfo fileInfo = new FileInfo(entryOuputPath); + fileInfo.Directory.Create(); + entry.ExtractToFile(entryOuputPath, true); + } + } + } + catch (Exception ex) + { + Utils.SaveLog(ex.Message, ex); + return false; + } + return true; + } } } diff --git a/v2rayN/v2rayN/Tool/Utils.cs b/v2rayN/v2rayN/Tool/Utils.cs index cff43678..2e840ecd 100644 --- a/v2rayN/v2rayN/Tool/Utils.cs +++ b/v2rayN/v2rayN/Tool/Utils.cs @@ -657,7 +657,14 @@ namespace v2rayN return lstIPAddress; } - + public static void SetSecurityProtocol() + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 + | SecurityProtocolType.Tls + | SecurityProtocolType.Tls11 + | SecurityProtocolType.Tls12; + ServicePointManager.DefaultConnectionLimit = 256; + } #endregion #region 杂项 @@ -779,16 +786,13 @@ namespace v2rayN #region TempPath - private static string _tempPath = null; - // return path to store temporary files public static string GetTempPath() { - if (_tempPath == null) + string _tempPath = Path.Combine(StartupPath(), "v2ray_win_temp"); + if (!Directory.Exists(_tempPath)) { - Directory.CreateDirectory(Path.Combine(StartupPath(), "v2ray_win_temp")); - // don't use "/", it will fail when we call explorer /select xxx/ss_win_temp\xxx.log - _tempPath = Path.Combine(StartupPath(), "v2ray_win_temp"); + Directory.CreateDirectory(_tempPath); } return _tempPath; } @@ -796,13 +800,7 @@ namespace v2rayN public static string GetTempPath(string filename) { return Path.Combine(GetTempPath(), filename); - } - - public static void ClearTempPath() - { - //Directory.Delete(GetTempPath(), true); - //_tempPath = null; - } + } public static string UnGzip(byte[] buf) { diff --git a/v2rayN/v2rayN/v2rayN.csproj b/v2rayN/v2rayN/v2rayN.csproj index c07fc9c8..d3561b38 100644 --- a/v2rayN/v2rayN/v2rayN.csproj +++ b/v2rayN/v2rayN/v2rayN.csproj @@ -287,6 +287,7 @@ SubSettingControl.cs + Designer SubSettingControl.cs