Add ZeroTier check to installer
This commit is contained in:
parent
84d578366a
commit
9e66762061
@ -15,7 +15,7 @@ using System.Windows.Shapes;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using RageCoop.Client;
|
||||
using RageCoop.Core;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using System.Windows.Forms;
|
||||
@ -54,6 +54,7 @@ namespace RageCoop.Client.Installer
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Installation failed: " + ex.ToString());
|
||||
Environment.Exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -107,6 +108,7 @@ namespace RageCoop.Client.Installer
|
||||
|
||||
foreach (var f in Directory.GetFiles(scriptsPath, "RageCoop.*", SearchOption.AllDirectories))
|
||||
{
|
||||
if (f.EndsWith("RageCoop.Client.Settings.xml")) { continue; }
|
||||
File.Delete(f);
|
||||
}
|
||||
foreach (var f in Directory.GetFiles(installPath, "*.dll", SearchOption.AllDirectories))
|
||||
@ -162,7 +164,7 @@ namespace RageCoop.Client.Installer
|
||||
}
|
||||
if (File.Exists(menyooConfig))
|
||||
{
|
||||
var lines = File.ReadAllLines(menyooConfig).Where(x => x.EndsWith(" = " +(int)settings.MenuKey));
|
||||
var lines = File.ReadAllLines(menyooConfig).Where(x => !x.StartsWith(";") && x.EndsWith(" = " +(int)settings.MenuKey));
|
||||
if (lines.Any())
|
||||
{
|
||||
if(MessageBox.Show("Following menyoo config value will conflict with RAGECOOP menu key\n" +
|
||||
@ -189,6 +191,46 @@ namespace RageCoop.Client.Installer
|
||||
}
|
||||
}
|
||||
|
||||
checkZT:
|
||||
UpdateStatus("Checking ZeroTier");
|
||||
try
|
||||
{
|
||||
ZeroTierHelper.Check();
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (MessageBox.Show("You can't join ZeroTier server unless ZeroTier is installed, do you want to download and install it?","Install ZeroTier",MessageBoxButton.YesNo)==MessageBoxResult.Yes)
|
||||
{
|
||||
var url = "https://download.zerotier.com/dist/ZeroTier%20One.msi";
|
||||
UpdateStatus("Downloading ZeroTier from "+url);
|
||||
try
|
||||
{
|
||||
HttpHelper.DownloadFile(url, "ZeroTier.msi", (p) => UpdateStatus("Downloading ZeroTier " + p + "%"));
|
||||
UpdateStatus("Installing ZeroTier");
|
||||
Process.Start("ZeroTier.msi").WaitForExit();
|
||||
/*
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
UpdateStatus("Waiting ZeroTier to start... " + i);
|
||||
try
|
||||
{
|
||||
ZeroTierHelper.Check();
|
||||
break;
|
||||
}
|
||||
catch(Exception ex) { UpdateStatus(ex.ToString()); }
|
||||
}
|
||||
goto checkZT;
|
||||
*/
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Failed to download ZeroTier, please download it from officail website");
|
||||
Process.Start(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdateStatus("Completed!");
|
||||
MessageBox.Show("Installation sucessful!");
|
||||
Environment.Exit(0);
|
||||
|
@ -16,7 +16,7 @@ using System.Resources;
|
||||
|
||||
|
||||
// Version informationr(
|
||||
[assembly: AssemblyVersion("1.5.1.37")]
|
||||
[assembly: AssemblyFileVersion("1.5.1.37")]
|
||||
[assembly: AssemblyVersion("1.5.1.48")]
|
||||
[assembly: AssemblyFileVersion("1.5.1.48")]
|
||||
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
|
||||
|
||||
|
@ -128,11 +128,6 @@ namespace RageCoop.Client
|
||||
{
|
||||
settings = (Settings)ser.Deserialize(stream);
|
||||
}
|
||||
|
||||
using (FileStream stream = new FileStream(path, FileMode.Truncate, FileAccess.ReadWrite))
|
||||
{
|
||||
ser.Serialize(stream, settings);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
30
RageCoop.Core/Networking/HttpHelper.cs
Normal file
30
RageCoop.Core/Networking/HttpHelper.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
|
||||
namespace RageCoop.Core
|
||||
{
|
||||
internal static class HttpHelper
|
||||
{
|
||||
public static void DownloadFile(string url,string destination,Action<int> progressCallback)
|
||||
{
|
||||
AutoResetEvent ae=new AutoResetEvent(false);
|
||||
WebClient client = new WebClient();
|
||||
|
||||
// TLS only
|
||||
ServicePointManager.Expect100Continue = true;
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
|
||||
client.DownloadProgressChanged += (s, e1) => progressCallback(e1.ProgressPercentage);
|
||||
client.DownloadFileCompleted += (s, e2) =>
|
||||
{
|
||||
ae.Set();
|
||||
};
|
||||
client.DownloadFileAsync(new Uri(url), destination);
|
||||
ae.WaitOne();
|
||||
}
|
||||
}
|
||||
}
|
@ -131,5 +131,9 @@ namespace RageCoop.Core
|
||||
var p = Run(command);
|
||||
return p.StandardOutput.ReadToEnd()+p.StandardError.ReadToEnd();
|
||||
}
|
||||
public static void Check()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ using System.Resources;
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version informationr(
|
||||
[assembly: AssemblyVersion("1.5.1.31")]
|
||||
[assembly: AssemblyFileVersion("1.5.1.31")]
|
||||
[assembly: AssemblyVersion("1.5.1.34")]
|
||||
[assembly: AssemblyFileVersion("1.5.1.34")]
|
||||
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user