This repository has been archived by the owner on Dec 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Informs user of new Updater versions. Code Optimisations.
- Loading branch information
1 parent
0efd47b
commit 41d9f1f
Showing
3 changed files
with
79 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace PrimeHack_Updater | ||
{ | ||
class VersionCheck | ||
{ | ||
public static string getVersion(string html) | ||
{ | ||
if (html == null || html.Length == 0) | ||
{ | ||
Console.WriteLine("Couldn't access JSON info. Press any key to launch."); | ||
Console.ReadKey(); | ||
|
||
return "-1"; | ||
} | ||
|
||
dynamic j = JObject.Parse(html); | ||
string version = (string)j.tag_name; | ||
|
||
return version; | ||
} | ||
|
||
public static string getJSONInfo(string url) | ||
{ | ||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | ||
| SecurityProtocolType.Tls11 | ||
| SecurityProtocolType.Tls12 | ||
| SecurityProtocolType.Ssl3; | ||
|
||
string html = string.Empty; | ||
|
||
try | ||
{ | ||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); | ||
request.AutomaticDecompression = DecompressionMethods.GZip; | ||
request.UserAgent = "PrimeHackUpdater"; | ||
|
||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) | ||
using (Stream stream = response.GetResponseStream()) | ||
using (StreamReader reader = new StreamReader(stream)) | ||
{ | ||
html = reader.ReadToEnd(); | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine("Failed to retrieve version info: " + e.Message); | ||
} | ||
|
||
return html; | ||
} | ||
} | ||
} |