Skip to content

Commit

Permalink
v1.0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lvtx committed Jun 30, 2023
1 parent 618e552 commit 0a868a2
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ C# WinRAR 简体中文-商业版 提取器

#### 更新日志

2023-06-30 发布v1.0.0.4
1. 增加版本日期递减枚举检测功能,以应付6.22版本生成日期与下载日期不同步问题。
(直接检测文件是否能正常下载,缺点是启动会稍微慢一点)

2022-08-21 发布v1.0.0.3
1. 修复新版x32位程序信息无法获取问题。
2. 修复中文授权信息出现问号问题。
Expand Down
80 changes: 80 additions & 0 deletions WinRAR-Extractor/HttpWebHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,86 @@ public static string GetHttpWebData(string url, int? timeout, string userAgent,
}
}

/// <summary>
/// 创建GET方式的HTTP请求
/// </summary>
/// <param name="url">请求的URL</param>
/// <param name="timeout">请求的超时时间</param>
/// <param name="userAgent">请求的客户端浏览器信息,可以为空</param>
/// <param name="cookies">随同HTTP请求发送的Cookie信息,如果不需要身份验证可以为空</param>
/// <returns></returns>
public static bool GetHttpCheck(string url, int? timeout, string userAgent, bool lastModified = false)
{
lock (_lotGetLocker)
{
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;

try
{
if (string.IsNullOrEmpty(url))
{
throw new ArgumentNullException("url");
}

//如果是发送HTTPS请求
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
// 请求前设置一下使用的安全协议类型
ServicePointManager.DefaultConnectionLimit = 512;
ServicePointManager.Expect100Continue = true;
ServicePointManager.CheckCertificateRevocationList = false;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
}

request.Method = "GET";
request.UserAgent = DefaultUserAgent;
request.Accept = "text/html";
request.Headers.Add("Accept-Language", "zh-CN,zh;q=0.9");
request.AllowAutoRedirect = true;
request.KeepAlive = false;
if (!string.IsNullOrEmpty(userAgent))
{
request.UserAgent = userAgent;
}
if (timeout.HasValue)
{
request.Timeout = timeout.Value;
}
request.CookieContainer = new CookieContainer();

//获取网页响应结果
//while (response == null || response.StatusCode != HttpStatusCode.OK)
//{
// if (Config.IsAppExit) return string.Empty;

// response = request.GetResponse() as HttpWebResponse;
//}
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// 获取HttpWebResponse数据
if (response != null && response.StatusCode == HttpStatusCode.OK)
{
response.Close();
response.Dispose();
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
//Config.logProc.WriteLine(ex.Message);
if (request != null) request.Abort();
return false;
}
finally
{
if (request != null) request.Abort();
}
return true;
}
}

//该方法用于验证服务器证书是否合法,当然可以直接返回true来表示验证永远通过。服务器证书具体内容在参数certificate中。可根据个人需求验证
//该方法在request.GetResponse()时触发
private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
Expand Down
4 changes: 2 additions & 2 deletions WinRAR-Extractor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.3")]
[assembly: AssemblyFileVersion("1.0.0.3")]
[assembly: AssemblyVersion("1.0.0.4")]
[assembly: AssemblyFileVersion("1.0.0.4")]
24 changes: 24 additions & 0 deletions WinRAR-Extractor/frmExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,30 @@ private void btnRefresh_Click(object sender, EventArgs e)
string lastModified_x64 = HttpWebHelper.GetHttpWebData(freeUrl_x64, 3000, null, true);
//Console.WriteLine(lastModified_x64);

int lmCheck = Convert.ToInt32(lastModified_x86);
while (lmCheck > 0)
{
if (!HttpWebHelper.GetHttpCheck($"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/rrlb/{lastSCname_x86.Value}sc.exe", 3000, null, true))
{
lmCheck--;
lastModified_x86 = lmCheck.ToString();
continue;
}
break;
}

lmCheck = Convert.ToInt32(lastModified_x64);
while (lmCheck > 0)
{
if (!HttpWebHelper.GetHttpCheck($"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x64}/rrlb/{lastSCname_x64.Value}sc.exe", 3000, null, true))
{
lmCheck--;
lastModified_x64 = lmCheck.ToString();
continue;
}
break;
}

this.labVersion.Text = $"最新版本:[{version}],更新时间:[{lastModified_x86}]-[x86] / [{lastModified_x64}]-[x64] - [简体中文]";

string rrlb_x86 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/rrlb/{lastSCname_x86.Value}sc.exe";
Expand Down
Binary file modified WinRAR-Generate/WinRAR-Generate.rc
Binary file not shown.
2 changes: 1 addition & 1 deletion WinRAR-Generate/WinRAR-Generate.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<ProjectGuid>{E510275F-C4D1-4E4A-922C-9856CF1C8908}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>WinRARGenerate</RootNamespace>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down

0 comments on commit 0a868a2

Please sign in to comment.