diff --git a/v2rayN/v2rayN/Handler/DownloadHandle.cs b/v2rayN/v2rayN/Handler/DownloadHandle.cs
index cfbc9ab8..29db08ca 100644
--- a/v2rayN/v2rayN/Handler/DownloadHandle.cs
+++ b/v2rayN/v2rayN/Handler/DownloadHandle.cs
@@ -5,6 +5,7 @@ using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;
+using System.Text.RegularExpressions;
using v2rayN.Base;
using v2rayN.Mode;
using v2rayN.Properties;
@@ -75,7 +76,8 @@ namespace v2rayN.Handler
{
if (AbsoluteCompleted != null)
{
- AbsoluteCompleted(this, new ResultEventArgs(false, "Already the latest version"));
+ string message = string.Format(UIRes.I18N("IsLatestN"), curVersion);
+ AbsoluteCompleted(this, new ResultEventArgs(false, message));
}
return;
}
@@ -108,7 +110,42 @@ namespace v2rayN.Handler
WebRequest request = WebRequest.Create(coreLatestUrl);
request.BeginGetResponse(new AsyncCallback(OnResponseV2rayCore), request);
}
+ ///
+ /// 获取V2RayCore版本
+ ///
+ public string getV2rayVersion()
+ {
+ try
+ {
+ string filePath = Utils.GetPath("V2ray.exe");
+ if (!File.Exists(filePath))
+ {
+ string msg = string.Format(UIRes.I18N("NotFoundCore"), @"https://github.com/v2ray/v2ray-core/releases");
+ //ShowMsg(true, msg);
+ return "";
+ }
+ Process p = new Process();
+ p.StartInfo.FileName = filePath;
+ p.StartInfo.Arguments = "-version";
+ p.StartInfo.WorkingDirectory = Utils.StartupPath();
+ p.StartInfo.UseShellExecute = false;
+ p.StartInfo.RedirectStandardOutput = true;
+ p.StartInfo.CreateNoWindow = true;
+ p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
+ p.Start();
+ p.WaitForExit(5000);
+ string echo = p.StandardOutput.ReadToEnd();
+ string version = Regex.Match(echo, "V2Ray ([0-9.]+) \\(").Groups[1].Value;
+ return version;
+ }
+
+ catch (Exception ex)
+ {
+ Utils.SaveLog(ex.Message, ex);
+ return "";
+ }
+ }
private void OnResponseV2rayCore(IAsyncResult ar)
{
try
@@ -118,15 +155,18 @@ namespace v2rayN.Handler
string redirectUrl = response.ResponseUri.AbsoluteUri;
string version = redirectUrl.Substring(redirectUrl.LastIndexOf("/", StringComparison.Ordinal) + 1);
- string osBit = string.Empty;
- if (Environment.Is64BitProcess)
- {
- osBit = "64";
- }
- else
+ string curVersion = "v" + getV2rayVersion();
+ if (curVersion == version)
{
- osBit = "32";
+ if (AbsoluteCompleted != null)
+ {
+ string message = string.Format(UIRes.I18N("IsLatestCore"), curVersion);
+ AbsoluteCompleted(this, new ResultEventArgs(false, message));
+ }
+ return;
}
+
+ string osBit = Environment.Is64BitProcess ? "64" : "32";
string url = string.Format(coreUrl, version, osBit);
if (AbsoluteCompleted != null)
{
diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs
index 8bb07589..ae78335f 100644
--- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs
+++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs
@@ -267,6 +267,24 @@ namespace v2rayN.Resx {
}
}
+ ///
+ /// 查找类似 {0} already up to date. 的本地化字符串。
+ ///
+ internal static string IsLatestCore {
+ get {
+ return ResourceManager.GetString("IsLatestCore", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 {0} already up to date. 的本地化字符串。
+ ///
+ internal static string IsLatestN {
+ get {
+ return ResourceManager.GetString("IsLatestN", resourceCulture);
+ }
+ }
+
///
/// 查找类似 Address 的本地化字符串。
///
@@ -574,7 +592,7 @@ namespace v2rayN.Resx {
}
///
- /// 查找类似 V2ray-core not found, download address: {0} 的本地化字符串。
+ /// 查找类似 V2ray-core not found, please download: {0} 的本地化字符串。
///
internal static string NotFoundCore {
get {
@@ -709,7 +727,7 @@ namespace v2rayN.Resx {
}
///
- /// 查找类似 Start service ({0})...... 的本地化字符串。
+ /// 查找类似 Start service ({0})... 的本地化字符串。
///
internal static string StartService {
get {
diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx
index 058dbeeb..0767dc8c 100644
--- a/v2rayN/v2rayN/Resx/ResUI.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.resx
@@ -236,10 +236,16 @@
{0}
- V2ray-core not found, download address: {0}
+ V2ray-core not found, please download: {0}
+
+
+ {0} already up to date.
+
+
+ {0} already up to date.
- Start service ({0})......
+ Start service ({0})...
Address
diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
index 62fdfccf..5a3a465a 100644
--- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
@@ -236,10 +236,16 @@
{0}
- 未找到v2ray-core,下载地址:{0}
+ 找不到 v2ray-core,下载地址: {0}
+
+
+ {0} 已是最新版本。
+
+
+ {0} 已是最新版本。
- 启动服务({0})......
+ 启动服务({0})...
地址