|
|
|
|
@ -1,12 +1,9 @@
|
|
|
|
|
using System; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.ComponentModel; |
|
|
|
|
using System.Data; |
|
|
|
|
using System.Diagnostics; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.ServiceProcess; |
|
|
|
|
using System.Text; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
|
namespace ZeroTierOneService |
|
|
|
|
{ |
|
|
|
|
@ -15,14 +12,45 @@ namespace ZeroTierOneService
|
|
|
|
|
public Service() |
|
|
|
|
{ |
|
|
|
|
InitializeComponent(); |
|
|
|
|
|
|
|
|
|
this.ztHome = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Path.DirectorySeparatorChar + "ZeroTier" + Path.DirectorySeparatorChar + "One"; |
|
|
|
|
this.ztUpdatesFolder = this.ztHome + Path.DirectorySeparatorChar + "updates.d"; |
|
|
|
|
this.ztBinary = this.ztHome + Path.DirectorySeparatorChar + (Environment.Is64BitOperatingSystem ? "zerotier-one_x64.exe" : "zerotier-one_x86.exe"); |
|
|
|
|
|
|
|
|
|
this.ztService = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected override void OnStart(string[] args) |
|
|
|
|
{ |
|
|
|
|
startZeroTierService(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected override void OnStop() |
|
|
|
|
{ |
|
|
|
|
stopZeroTierService(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void startZeroTierService() |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void stopZeroTierService() |
|
|
|
|
{ |
|
|
|
|
if (ztService != null) |
|
|
|
|
{ |
|
|
|
|
ztService.Kill(); |
|
|
|
|
ztService = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void ztService_Exited(object sender, System.EventArgs e) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private string ztHome; |
|
|
|
|
private string ztUpdatesFolder; |
|
|
|
|
private string ztBinary; |
|
|
|
|
|
|
|
|
|
private Process ztService; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|