Merge pull request #2530 from InterestingDarkness/master

Add Check for Pre-Release Updates
pull/2556/head
2dust 2 years ago committed by GitHub
commit 7a48617fea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1364,7 +1364,7 @@ namespace v2rayN.Forms
menuExit_Click(null, null);
}
};
(new UpdateHandle()).CheckUpdateGuiN(config, _updateUI);
(new UpdateHandle()).CheckUpdateGuiN(config, _updateUI, config.checkPreReleaseUpdate);
}
private void tsbCheckUpdateCore_Click(object sender, EventArgs e)
@ -1412,7 +1412,7 @@ namespace v2rayN.Forms
AppendText(false, ResUI.MsgUpdateV2rayCoreSuccessfully);
}
};
(new UpdateHandle()).CheckUpdateCore(type, config, _updateUI);
(new UpdateHandle()).CheckUpdateCore(type, config, _updateUI, config.checkPreReleaseUpdate);
}
private void tsbCheckUpdateGeo_Click(object sender, EventArgs e)

@ -75,6 +75,7 @@
this.label17 = new System.Windows.Forms.Label();
this.txtautoUpdateSubInterval = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.chkEnableCheckPreReleaseUpdate = new System.Windows.Forms.CheckBox();
this.chkEnableSecurityProtocolTls13 = new System.Windows.Forms.CheckBox();
this.chkEnableAutoAdjustMainLvColWidth = new System.Windows.Forms.CheckBox();
this.btnSetLoopback = new System.Windows.Forms.Button();
@ -407,6 +408,7 @@
this.tabPage7.Controls.Add(this.label17);
this.tabPage7.Controls.Add(this.txtautoUpdateSubInterval);
this.tabPage7.Controls.Add(this.label3);
this.tabPage7.Controls.Add(this.chkEnableCheckPreReleaseUpdate);
this.tabPage7.Controls.Add(this.chkEnableSecurityProtocolTls13);
this.tabPage7.Controls.Add(this.chkEnableAutoAdjustMainLvColWidth);
this.tabPage7.Controls.Add(this.btnSetLoopback);
@ -445,6 +447,12 @@
resources.ApplyResources(this.label3, "label3");
this.label3.Name = "label3";
//
// chkEnableCheckPreReleaseUpdate
//
resources.ApplyResources(this.chkEnableCheckPreReleaseUpdate, "chkEnableCheckPreReleaseUpdate");
this.chkEnableCheckPreReleaseUpdate.Name = "chkEnableCheckPreReleaseUpdate";
this.chkEnableCheckPreReleaseUpdate.UseVisualStyleBackColor = true;
//
// chkEnableSecurityProtocolTls13
//
resources.ApplyResources(this.chkEnableSecurityProtocolTls13, "chkEnableSecurityProtocolTls13");
@ -769,5 +777,6 @@
private System.Windows.Forms.NumericUpDown numStatisticsFreshRate;
private System.Windows.Forms.ComboBox cmbdomainStrategy4Freedom;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.CheckBox chkEnableCheckPreReleaseUpdate;
}
}

@ -98,6 +98,7 @@ namespace v2rayN.Forms
txtautoUpdateInterval.Text = config.autoUpdateInterval.ToString();
txtautoUpdateSubInterval.Text = config.autoUpdateSubInterval.ToString();
chkEnableCheckPreReleaseUpdate.Checked = config.checkPreReleaseUpdate;
txttrayMenuServersLimit.Text = config.trayMenuServersLimit.ToString();
}
@ -298,6 +299,7 @@ namespace v2rayN.Forms
config.autoUpdateInterval = Utils.ToInt(txtautoUpdateInterval.Text);
config.autoUpdateSubInterval = Utils.ToInt(txtautoUpdateSubInterval.Text);
config.checkPreReleaseUpdate = chkEnableCheckPreReleaseUpdate.Checked;
config.trayMenuServersLimit = Utils.ToInt(txttrayMenuServersLimit.Text);
return 0;
}

File diff suppressed because it is too large Load Diff

@ -388,4 +388,7 @@
<data name="$this.Text" xml:space="preserve">
<value>参数设置</value>
</data>
<data name="chkEnableCheckPreReleaseUpdate.Text" xml:space="preserve">
<value>检查Pre-Release更新</value>
</data>
</root>

@ -72,7 +72,7 @@ namespace v2rayN.Handler
{
coreType = ECoreType.v2rayN,
coreUrl = Global.NUrl,
coreLatestUrl = Global.NUrl + "/latest",
coreReleaseApiUrl = Global.NUrl.Replace(@"https://github.com", @"https://api.github.com/repos"),
coreDownloadUrl32 = Global.NUrl + "/download/{0}/v2rayN.zip",
coreDownloadUrl64 = Global.NUrl + "/download/{0}/v2rayN.zip",
});
@ -83,7 +83,7 @@ namespace v2rayN.Handler
coreExes = new List<string> { "wv2ray", "v2ray" },
arguments = "",
coreUrl = Global.v2flyCoreUrl,
coreLatestUrl = Global.v2flyCoreUrl + "/latest",
coreReleaseApiUrl = Global.v2flyCoreUrl.Replace(@"https://github.com", @"https://api.github.com/repos"),
coreDownloadUrl32 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
match = "V2Ray",
@ -96,7 +96,7 @@ namespace v2rayN.Handler
coreExes = new List<string> { "v2ray" },
arguments = "run",
coreUrl = Global.SagerNetCoreUrl,
coreLatestUrl = Global.SagerNetCoreUrl + "/latest",
coreReleaseApiUrl = Global.SagerNetCoreUrl.Replace(@"https://github.com", @"https://api.github.com/repos"),
coreDownloadUrl32 = Global.SagerNetCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
coreDownloadUrl64 = Global.SagerNetCoreUrl + "/download/{0}/v2ray-windows-{1}.zip",
match = "V2Ray",
@ -109,7 +109,7 @@ namespace v2rayN.Handler
coreExes = new List<string> { "xray" },
arguments = "",
coreUrl = Global.xrayCoreUrl,
coreLatestUrl = Global.xrayCoreUrl + "/latest",
coreReleaseApiUrl = Global.xrayCoreUrl.Replace(@"https://github.com", @"https://api.github.com/repos"),
coreDownloadUrl32 = Global.xrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
coreDownloadUrl64 = Global.xrayCoreUrl + "/download/{0}/Xray-windows-{1}.zip",
match = "Xray",
@ -122,7 +122,7 @@ namespace v2rayN.Handler
coreExes = new List<string> { "clash-windows-amd64-v3", "clash-windows-amd64", "clash-windows-386", "clash" },
arguments = "-f config.json",
coreUrl = Global.clashCoreUrl,
coreLatestUrl = Global.clashCoreUrl + "/latest",
coreReleaseApiUrl = Global.clashCoreUrl.Replace(@"https://github.com", @"https://api.github.com/repos"),
coreDownloadUrl32 = Global.clashCoreUrl + "/download/{0}/clash-windows-386-{0}.zip",
coreDownloadUrl64 = Global.clashCoreUrl + "/download/{0}/clash-windows-amd64-{0}.zip",
match = "v",
@ -135,7 +135,7 @@ namespace v2rayN.Handler
coreExes = new List<string> { "Clash.Meta-windows-amd64-compatible", "Clash.Meta-windows-amd64", "Clash.Meta-windows-386", "Clash.Meta", "clash" },
arguments = "-f config.json",
coreUrl = Global.clashMetaCoreUrl,
coreLatestUrl = Global.clashMetaCoreUrl + "/latest",
coreReleaseApiUrl = Global.clashMetaCoreUrl.Replace(@"https://github.com", @"https://api.github.com/repos"),
coreDownloadUrl32 = Global.clashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-386-{0}.zip",
coreDownloadUrl64 = Global.clashMetaCoreUrl + "/download/{0}/Clash.Meta-windows-amd64-compatible-{0}.zip",
match = "v",
@ -148,7 +148,7 @@ namespace v2rayN.Handler
coreExes = new List<string> { "hysteria-tun-windows-6.0-amd64", "hysteria-tun-windows-6.0-386", "hysteria" },
arguments = "",
coreUrl = Global.hysteriaCoreUrl,
coreLatestUrl = Global.hysteriaCoreUrl + "/latest",
coreReleaseApiUrl = Global.hysteriaCoreUrl.Replace(@"https://github.com", @"https://api.github.com/repos"),
coreDownloadUrl32 = Global.hysteriaCoreUrl + "/download/{0}/hysteria-tun-windows-6.0-386.exe",
coreDownloadUrl64 = Global.hysteriaCoreUrl + "/download/{0}/hysteria-tun-windows-6.0-amd64.exe",
});

@ -1,11 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
using v2rayN.Base;
using v2rayN.Mode;
using v2rayN.Resx;
@ -31,7 +34,7 @@ namespace v2rayN.Handler
}
}
public void CheckUpdateGuiN(Config config, Action<bool, string> update)
public void CheckUpdateGuiN(Config config, Action<bool, string> update, bool preRelease)
{
_config = config;
_updateFunc = update;
@ -97,11 +100,11 @@ namespace v2rayN.Handler
}
};
_updateFunc(false, string.Format(ResUI.MsgStartUpdating, "v2rayN"));
CheckUpdateAsync(ECoreType.v2rayN);
CheckUpdateAsync(ECoreType.v2rayN, preRelease);
}
public void CheckUpdateCore(ECoreType type, Config config, Action<bool, string> update)
public void CheckUpdateCore(ECoreType type, Config config, Action<bool, string> update, bool preRelease)
{
_config = config;
_updateFunc = update;
@ -152,7 +155,7 @@ namespace v2rayN.Handler
}
};
_updateFunc(false, string.Format(ResUI.MsgStartUpdating, "Core"));
CheckUpdateAsync(type);
CheckUpdateAsync(type, preRelease);
}
@ -305,17 +308,17 @@ namespace v2rayN.Handler
#region private
private async void CheckUpdateAsync(ECoreType type)
private async void CheckUpdateAsync(ECoreType type, bool preRelease)
{
try
{
var coreInfo = LazyConfig.Instance.GetCoreInfo(type);
string url = coreInfo.coreLatestUrl;
string url = coreInfo.coreReleaseApiUrl;
var result = await (new DownloadHandle()).UrlRedirectAsync(url, true);
var result = await (new DownloadHandle()).DownloadStringAsync(url, true, "");
if (!Utils.IsNullOrEmpty(result))
{
responseHandler(type, result);
responseHandler(type, result, preRelease);
}
else
{
@ -391,11 +394,20 @@ namespace v2rayN.Handler
return "";
}
}
private void responseHandler(ECoreType type, string redirectUrl)
private void responseHandler(ECoreType type, string gitHubReleaseApi, bool preRelease)
{
try
{
string version = redirectUrl.Substring(redirectUrl.LastIndexOf("/", StringComparison.Ordinal) + 1);
var gitHubReleases = JsonConvert.DeserializeObject<List<GitHubRelease>>(gitHubReleaseApi);
string version;
if (preRelease)
{
version = gitHubReleases!.First().TagName;
}
else
{
version = gitHubReleases!.First(r => r.Prerelease == false).TagName;
}
var coreInfo = LazyConfig.Instance.GetCoreInfo(type);
string curVersion;

@ -137,6 +137,8 @@ namespace v2rayN.Mode
public int autoUpdateInterval { get; set; } = 0;
public int autoUpdateSubInterval { get; set; } = 0;
public bool checkPreReleaseUpdate { get; set; } = false;
public bool enableSecurityProtocolTls13
{

@ -14,7 +14,7 @@ namespace v2rayN.Mode
public string coreUrl { get; set; }
public string coreLatestUrl { get; set; }
public string coreReleaseApiUrl { get; set; }
public string coreDownloadUrl32 { get; set; }

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace v2rayN.Mode;
public class Asset
{
[JsonProperty("url")] public string Url { get; set; }
[JsonProperty("id")] public int Id { get; set; }
[JsonProperty("node_id")] public string NodeId { get; set; }
[JsonProperty("name")] public string Name { get; set; }
[JsonProperty("label")] public object Label { get; set; }
[JsonProperty("content_type")] public string ContentType { get; set; }
[JsonProperty("state")] public string State { get; set; }
[JsonProperty("size")] public int Size { get; set; }
[JsonProperty("download_count")] public int DownloadCount { get; set; }
[JsonProperty("created_at")] public DateTime CreatedAt { get; set; }
[JsonProperty("updated_at")] public DateTime UpdatedAt { get; set; }
[JsonProperty("browser_download_url")] public string BrowserDownloadUrl { get; set; }
}
public class GitHubRelease
{
[JsonProperty("url")] public string Url { get; set; }
[JsonProperty("assets_url")] public string AssetsUrl { get; set; }
[JsonProperty("upload_url")] public string UploadUrl { get; set; }
[JsonProperty("html_url")] public string HtmlUrl { get; set; }
[JsonProperty("id")] public int Id { get; set; }
[JsonProperty("node_id")] public string NodeId { get; set; }
[JsonProperty("tag_name")] public string TagName { get; set; }
[JsonProperty("target_commitish")] public string TargetCommitish { get; set; }
[JsonProperty("name")] public string Name { get; set; }
[JsonProperty("draft")] public bool Draft { get; set; }
[JsonProperty("prerelease")] public bool Prerelease { get; set; }
[JsonProperty("created_at")] public DateTime CreatedAt { get; set; }
[JsonProperty("published_at")] public DateTime PublishedAt { get; set; }
[JsonProperty("assets")] public List<Asset> Assets { get; set; }
[JsonProperty("tarball_url")] public string TarballUrl { get; set; }
[JsonProperty("zipball_url")] public string ZipballUrl { get; set; }
[JsonProperty("body")] public string Body { get; set; }
}

@ -2,6 +2,7 @@
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<LangVersion>preview</LangVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0A9785E6-D256-4B73-9757-4EF59955FD1E}</ProjectGuid>
@ -209,6 +210,7 @@
<Compile Include="Mode\ESysProxyType.cs" />
<Compile Include="Mode\EMove.cs" />
<Compile Include="Mode\EServerColName.cs" />
<Compile Include="Mode\GitHubRelease.cs" />
<Compile Include="Mode\RoutingItem.cs" />
<Compile Include="Mode\RulesItem.cs" />
<Compile Include="Mode\ServerStatistics.cs" />

Loading…
Cancel
Save