Merge remote-tracking branch 'origin/clint' into jun12

This commit is contained in:
dovholuknf
2020-06-16 15:14:28 -04:00
11 changed files with 234 additions and 98 deletions
-33
View File
@@ -1,33 +0,0 @@
using System;
using System.IO;
using System.Net;
using System.Xml;
using System.Text;
namespace ZitiConsoleApp {
class Program {
private static string _versionUrl = "https://netfoundry.jfrog.io/netfoundry/ziti-maven-snapshot/ziti-tunnel-win/amd64/windows/ziti-tunnel-win/maven-metadata.xml";
private static string _serviceUrl = "https://netfoundry.jfrog.io/netfoundry/ziti-maven-snapshot/ziti-tunnel-win/amd64/windows/ziti-tunnel-win/${version}/ziti-tunnel-win-${version}.zip";
static void Main(string[] args) {
var request = WebRequest.Create(_versionUrl) as HttpWebRequest;
var response = request.GetResponse();
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
var result = readStream.ReadToEnd();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(result);
XmlNode node = xmlDoc.SelectSingleNode("metadata/versioning/release");
string version = node.InnerText;
Console.WriteLine(version);
string remoteService = _serviceUrl.Replace("${version}", version);
Console.WriteLine(remoteService);
}
}
}
-9
View File
@@ -1,9 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release;Releases</Configurations>
</PropertyGroup>
</Project>
+3 -7
View File
@@ -22,7 +22,7 @@ namespace ZitiTunneler {
public delegate void Click(ZitiIdentity identity);
public event Click OnClick;
private ZitiIdentity _identity;
public ZitiIdentity _identity;
public ZitiIdentity Identity {
get {
return _identity;
@@ -64,14 +64,10 @@ namespace ZitiTunneler {
ToggleStatus.Content = "DISABLED";
// MessageBox.Show("jeremy - update the identity and services here. When disabled there will be no services, service count: " + id?.Services?.Count());
}
}
catch(ServiceClient.ServiceException se)
{
} catch(ServiceClient.ServiceException se) {
MessageBox.Show("Unexpected error 5 the toggle needs to be rolled back!!! jeremy!", se.Message);
MessageBox.Show(se.AdditionalInfo, se.Message);
}
catch (Exception ex)
{
} catch (Exception ex) {
MessageBox.Show("Unexpected error 5 the toggle needs to be rolled back!!! jeremy!", ex.Message);
}
}
+4 -5
View File
@@ -53,11 +53,11 @@
<StackPanel Name="AboutItems" Visibility="Collapsed" Orientation="Vertical" HorizontalAlignment="Stretch">
<local:SubMenuItem HorizontalAlignment="Stretch" Width="Auto" Label="Privacy Policy" MouseUp="ShowPrivacy"></local:SubMenuItem>
<local:SubMenuItem HorizontalAlignment="Stretch" Width="Auto" Label="Terms of Service" MouseUp="ShowTerms"></local:SubMenuItem>
<local:SubMenuItem HorizontalAlignment="Stretch" Width="Auto" Label="Third Party Licenses" MouseUp="ShowLicenses"></local:SubMenuItem>
</StackPanel>
<StackPanel Name="AdvancedItems" Visibility="Collapsed" Orientation="Vertical" HorizontalAlignment="Stretch">
<local:MenuItem HorizontalAlignment="Stretch" Icon="/Assets/Images/wrench.png" Width="Auto" Label="Tunnel Configuration" MouseUp="ShowConfig"></local:MenuItem>
<local:MenuItem HorizontalAlignment="Stretch" Icon="/Assets/Images/logs.png" Width="Auto" Label="Logs" MouseUp="ShowLogs"></local:MenuItem>
<local:MenuItem HorizontalAlignment="Stretch" Icon="/Assets/Images/logs.png" Width="Auto" Label="Service Logs" MouseUp="ShowLogs"></local:MenuItem>
<local:MenuItem HorizontalAlignment="Stretch" Icon="/Assets/Images/logs.png" Width="Auto" Label="Application Logs" MouseUp="ShowUILogs"></local:MenuItem>
</StackPanel>
<StackPanel Name="ConfigItems" Visibility="Collapsed" Orientation="Vertical" HorizontalAlignment="Stretch">
<local:MenuEditItem x:Name="ConfigIp" HorizontalAlignment="Stretch" Width="Auto" Label="IPv4 Address:"></local:MenuEditItem>
@@ -66,11 +66,10 @@
<local:MenuEditItem x:Name="ConfigDns" HorizontalAlignment="Stretch" Width="Auto" Label="DNS Servers:"></local:MenuEditItem>
</StackPanel>
<TextBox Name="LicensesItems" Height="400" Width="{Binding ActualWidth, ElementName=MainStack}" TextWrapping="Wrap" Visibility="Collapsed"></TextBox>
<TextBox Name="LogsItems" Height="400" Width="{Binding ActualWidth, ElementName=MainStack}" TextWrapping="Wrap" Visibility="Collapsed"></TextBox>
<TextBox Name="LogsItems" Height="400" Width="{Binding ActualWidth, ElementName=MainStack}" TextWrapping="Wrap" Visibility="Collapsed" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto"></TextBox>
<StackPanel Name="AboutItemsButton" Orientation="Vertical" HorizontalAlignment="Stretch" Visibility="Collapsed">
<Image Grid.Column="0" Source="/Assets/Images/logo.png" Height="60" Width="240"></Image>
<Label HorizontalAlignment="Center" Content="Version 1.0 (23)" FontSize="10" Foreground="#638190" Margin="0,-20,0,0" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans"></Label>
<Label Name="ServiceVersion" HorizontalAlignment="Center" FontSize="10" Foreground="#638190" Margin="0,-20,0,0" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans"></Label>
</StackPanel>
<Label Name="MainItemsButton" Margin="0,30,0,0" Foreground="#F4044D" FontWeight="SemiBold" Content="Quit Ziti Tunneler" Cursor="Hand" MouseDown="CloseApp" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" HorizontalAlignment="Center"></Label>
</StackPanel>
+13 -2
View File
@@ -5,6 +5,7 @@ using System.Diagnostics;
using System;
using System.Threading;
using System.Management.Automation;
using ZitiTunneler.Models;
namespace ZitiTunneler
{
@@ -55,6 +56,10 @@ namespace ZitiTunneler
menuState = "Logs";
UpdateState();
}
private void ShowUILogs(object sender, MouseButtonEventArgs e) {
menuState = "UILogs";
UpdateState();
}
private void UpdateState() {
MainItems.Visibility = Visibility.Collapsed;
@@ -82,10 +87,16 @@ namespace ZitiTunneler
BackArrow.Visibility = Visibility.Visible;
} else if (menuState=="Logs") {
ServiceClient.Client client = (ServiceClient.Client)Application.Current.Properties["ServiceClient"];
MenuTitle.Content = "Application Logs";
MenuTitle.Content = "Service Logs";
LogsItems.Text = client.GetLogs();
LogsItems.Visibility = Visibility.Visible;
BackArrow.Visibility = Visibility.Visible;
} else if (menuState == "UILogs") {
ServiceClient.Client client = (ServiceClient.Client)Application.Current.Properties["ServiceClient"];
MenuTitle.Content = "Application Logs";
LogsItems.Text = UILog.GetLogs();
LogsItems.Visibility = Visibility.Visible;
BackArrow.Visibility = Visibility.Visible;
} else if (menuState=="Config") {
MenuTitle.Content = "Tunnel Configuration";
ConfigItems.Visibility = Visibility.Visible;
@@ -103,7 +114,7 @@ namespace ZitiTunneler
}
private void GoBack(object sender, MouseButtonEventArgs e) {
if (menuState=="Config"||menuState=="Logs") {
if (menuState=="Config"||menuState=="Logs"||menuState=="UILogs") {
menuState = "Advanced";
} else if (menuState=="Licenses") {
menuState = "About";
+90 -1
View File
@@ -12,7 +12,72 @@
ClipToBounds="False"
Icon="Assets/Images/icon.png" AllowsTransparency="True"
Closing="Window_Closing"
WindowStyle="None" Loaded="MainWindow1_Loaded" Background="#000F0F23">
WindowStyle="None" Loaded="MainWindow1_Loaded" Deactivated="MainUI_Deactivated" Activated="MainUI_Activated" Background="#000F0F23">
<Window.Resources>
<SolidColorBrush x:Key="ProgressBar.Progress" Color="#FF06B025"/>
<SolidColorBrush x:Key="ProgressBar.Background" Color="#FFE6E6E6"/>
<SolidColorBrush x:Key="ProgressBar.Border" Color="#FFBCBCBC"/>
<Style TargetType="{x:Type ProgressBar}">
<Setter Property="Foreground" Value="{StaticResource ProgressBar.Progress}"/>
<Setter Property="Background" Value="{StaticResource ProgressBar.Background}"/>
<Setter Property="BorderBrush" Value="{StaticResource ProgressBar.Border}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ProgressBar}">
<Grid x:Name="TemplateRoot">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Determinate"/>
<VisualState x:Name="Indeterminate">
<Storyboard RepeatBehavior="Forever">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="Animation">
<EasingDoubleKeyFrame KeyTime="0" Value="0.25"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.25"/>
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="0.25"/>
</DoubleAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="Animation">
<EasingPointKeyFrame KeyTime="0" Value="-0.5,0.5"/>
<EasingPointKeyFrame KeyTime="0:0:1" Value="0.5,0.5"/>
<EasingPointKeyFrame KeyTime="0:0:2" Value="1.5,0.5"/>
</PointAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="5" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
<Rectangle x:Name="PART_Track"/>
<Grid x:Name="PART_Indicator" ClipToBounds="true" HorizontalAlignment="Left">
<Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}"/>
<Rectangle x:Name="Animation" Fill="{TemplateBinding Foreground}" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="LayoutTransform" TargetName="TemplateRoot">
<Setter.Value>
<RotateTransform Angle="-90"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsIndeterminate" Value="true">
<Setter Property="Visibility" TargetName="Indicator" Value="Collapsed"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
@@ -153,6 +218,30 @@
<Label Name="QuitButton" Grid.Row="3" Foreground="#F4044D" FontWeight="SemiBold" Content="Quit Ziti Tunneler" Cursor="Hand" MouseDown="CloseApp" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" HorizontalAlignment="Center"></Label>
</Grid>
</Grid>
<Grid x:Name="LoadingScreen" Visibility="Collapsed" Width="350">
<Rectangle RadiusX="10" RadiusY="10">
<Rectangle.Fill>
<SolidColorBrush Color="Black" Opacity="0.9"/>
</Rectangle.Fill>
</Rectangle>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="10"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Label Name="LoadingTitle" Foreground="White" Content="Loading" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans"/>
<TextBlock x:Name="LoadingDetails" TextWrapping="WrapWithOverflow" Foreground="LightGray" Padding="10" Text="Operation pending, please wait..." Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" FontSize="14" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans"/>
<ProgressBar x:Name="LoadProgress" Width="100" Grid.Row="3" IsEnabled="True" />
</Grid>
</Grid>
<Grid x:Name="ErrorView" Visibility="Collapsed" Width="350">
<Rectangle RadiusX="10" RadiusY="10">
<Rectangle.Fill>
+78 -32
View File
@@ -14,6 +14,8 @@ using System.Diagnostics;
using System.Security.Principal;
using System.Net;
using System.Windows.Controls;
using System.Threading.Tasks;
using System.Threading;
namespace ZitiTunneler {
@@ -30,6 +32,7 @@ namespace ZitiTunneler {
private int _right = 75;
private int _bottom = 0;
private double _maxHeight = 800d;
private string _serviceVersion = "0.0.8";
private string[] suffixes = { "bps", "kbps", "mbps", "gbps", "tbps", "pbps" };
private List<ZitiIdentity> identities {
@@ -46,7 +49,8 @@ namespace ZitiTunneler {
if (ctl.Status!=ServiceControllerStatus.Running) {
try {
ctl.Start();
} catch /*ignored for now (Exception e)*/ {
} catch (Exception e) {
UILog.Log(e.Message);
SetCantDisplay();
}
}
@@ -65,6 +69,8 @@ namespace ZitiTunneler {
notifyIcon.Visible = true;
LaunchOrInstall();
MainMenu.ServiceVersion.Content = _serviceVersion;
SetNotifyIcon("white");
InitializeComponent();
}
@@ -208,15 +214,8 @@ namespace ZitiTunneler {
if (e.Action == "added") {
ZitiService zs = new ZitiService(e.Service.Name, e.Service.HostName, e.Service.Port);
var svc = found.Services.Find(s => s.Name == zs.Name);
if (svc == null)
{
found.Services.Add(zs);
}
else
{
Debug.WriteLine("the service named " + zs.Name + " is already accounted for on this identity.");
}
if (svc == null) found.Services.Add(zs);
else Debug.WriteLine("the service named " + zs.Name + " is already accounted for on this identity.");
} else {
Debug.WriteLine("removing the service named: " + e.Service.Name);
found.Services.RemoveAll(s => s.Name == e.Service.Name);
@@ -229,8 +228,7 @@ namespace ZitiTunneler {
{
if (e == null) return; //just skip it for now...
Debug.WriteLine($"==== TunnelStatusEvent: ");
this.Dispatcher.Invoke(() =>
{
this.Dispatcher.Invoke(() => {
InitializeTimer((int)e.Status.Duration);
LoadStatusFromService(e.Status);
LoadIdentities();
@@ -240,7 +238,7 @@ namespace ZitiTunneler {
private void IdentityForgotten(ZitiIdentity forgotten) {
ZitiIdentity idToRemove = null;
foreach (var id in identities) {
if(id.Fingerprint == forgotten.Fingerprint) {
if (id.Fingerprint == forgotten.Fingerprint) {
idToRemove = id;
break;
}
@@ -302,10 +300,8 @@ namespace ZitiTunneler {
private void updateViewWithIdentity(Identity id) {
var zid = ZitiIdentity.FromClient(id);
foreach (var i in identities)
{
if(i.Fingerprint == zid.Fingerprint)
{
foreach (var i in identities) {
if (i.Fingerprint == zid.Fingerprint) {
identities.Remove(i);
break;
}
@@ -328,6 +324,11 @@ namespace ZitiTunneler {
IdentityMenu.SetHeight(this.Height-160);
for (int i=0; i<ids.Length; i++) {
IdentityItem id = new IdentityItem();
if (ids[i].IsEnabled) {
SetNotifyIcon("green");
ConnectButton.Visibility = Visibility.Collapsed;
DisconnectButton.Visibility = Visibility.Visible;
}
id.Identity = ids[i];
id.OnClick += OpenIdentity;
IdList.Children.Add(id);
@@ -351,6 +352,7 @@ namespace ZitiTunneler {
jwtDialog.DefaultExt = ".jwt";
jwtDialog.Filter = "Ziti Identities (*.jwt)|*.jwt";
if (jwtDialog.ShowDialog() == true) {
ShowLoad();
string fileContent = File.ReadAllText(jwtDialog.FileName);
try {
@@ -360,8 +362,6 @@ namespace ZitiTunneler {
if (createdId != null) {
identities.Add(ZitiIdentity.FromClient(createdId));
LoadIdentities();
//MessageBox.Show("New identity added with fingerprint: " + createdId.FingerPrint);
//updateViewWithIdentity(createdId);
} else {
ShowError("Identity Error", "Identity Id was null, please try again");
}
@@ -371,19 +371,7 @@ namespace ZitiTunneler {
ShowError("Unexpected Error", "Code 2:" + ex.Message);
}
LoadIdentities();
}
}
private void Connect(object sender, RoutedEventArgs e) {
try {
serviceClient.SetTunnelState(true);
SetNotifyIcon("green");
ConnectButton.Visibility = Visibility.Collapsed;
DisconnectButton.Visibility = Visibility.Visible;
} catch (ServiceException se) {
ShowError(se.AdditionalInfo, se.Message);
} catch (Exception ex) {
ShowError("Unexpected Error", "Code 3:" + ex.Message);
HideLoad();
}
}
@@ -406,7 +394,37 @@ namespace ZitiTunneler {
_timer.Enabled = true;
_timer.Start();
}
private async void Connect(object sender, RoutedEventArgs e) {
ShowLoad();
Dispatcher.Invoke(new Action(() => { }), System.Windows.Threading.DispatcherPriority.ContextIdle);
DoConnect();
HideLoad();
}
private void DoConnect() {
try {
serviceClient.SetTunnelState(true);
SetNotifyIcon("green");
ConnectButton.Visibility = Visibility.Collapsed;
DisconnectButton.Visibility = Visibility.Visible;
for (int i = 0; i < identities.Count; i++) {
serviceClient.IdentityOnOff(identities[i].Fingerprint, true);
}
for (int i = 0; i < IdList.Children.Count; i++) {
IdentityItem item = IdList.Children[i] as IdentityItem;
item.isOn = true;
item._identity.IsEnabled = true;
item.RefreshUI();
}
} catch (ServiceException se) {
ShowError(se.AdditionalInfo, se.Message);
} catch (Exception ex) {
ShowError("Unexpected Error", "Code 3:" + ex.Message);
}
}
private void Disconnect(object sender, RoutedEventArgs e) {
ShowLoad();
try {
ConnectedTime.Content = "00:00:00";
_timer.Stop();
@@ -414,11 +432,31 @@ namespace ZitiTunneler {
SetNotifyIcon("white");
ConnectButton.Visibility = Visibility.Visible;
DisconnectButton.Visibility = Visibility.Collapsed;
for (int i = 0; i < identities.Count; i++) {
serviceClient.IdentityOnOff(identities[i].Fingerprint, false);
}
for (int i = 0; i < IdList.Children.Count; i++) {
IdentityItem item = IdList.Children[i] as IdentityItem;
item.isOn = false;
item._identity.IsEnabled = false;
item.RefreshUI();
}
} catch (ServiceException se) {
ShowError(se.AdditionalInfo, se.Message);
} catch (Exception ex) {
ShowError("Unexpected Error", "Code 4:"+ex.Message);
}
HideLoad();
}
private void ShowLoad() {
LoadProgress.IsIndeterminate = true;
LoadingScreen.Visibility = Visibility.Visible;
}
private void HideLoad() {
LoadingScreen.Visibility = Visibility.Collapsed;
LoadProgress.IsIndeterminate = false;
}
private void FormFadeOut_Completed(object sender, EventArgs e) {
@@ -446,5 +484,13 @@ namespace ZitiTunneler {
private void CloseApp(object sender, MouseButtonEventArgs e) {
Application.Current.Shutdown();
}
private void MainUI_Deactivated(object sender, EventArgs e) {
this.WindowState = WindowState.Minimized;
}
private void MainUI_Activated(object sender, EventArgs e) {
this.WindowState = WindowState.Normal;
}
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.IO;
namespace ZitiTunneler.Models {
public class UILog {
private static string _logDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "NetFoundry" ,"Logs", "Log.log");
public static void Log(string message) {
try {
File.WriteAllText(_logDirectory, message);
} catch (Exception e) {
Console.WriteLine(e.Message);
}
}
public static string GetLogs() {
return File.ReadAllText(_logDirectory);
}
}
}
+8 -2
View File
@@ -81,7 +81,7 @@
<OutputPath>bin\Releases\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Assets\Images\icon.ico</ApplicationIcon>
<ApplicationIcon>ziti.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -132,6 +132,7 @@
<Compile Include="MainMenu.xaml.cs">
<DependentUpon>MainMenu.xaml</DependentUpon>
</Compile>
<Compile Include="Models\UILog.cs" />
<Compile Include="ServiceInfo.xaml.cs">
<DependentUpon>ServiceInfo.xaml</DependentUpon>
</Compile>
@@ -333,9 +334,14 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Resource Include="ziti.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\server.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

+12 -7
View File
@@ -23,13 +23,13 @@ namespace ZitiUpdateService {
private bool _isNew = true;
/// private int _majorVersion = 1;
private string _versionUrl = "https://netfoundry.jfrog.io/netfoundry/ziti-maven-snapshot/ziti-tunnel-win/amd64/windows/ziti-tunnel-win/maven-metadata.xml";
private string _serviceUrl = "https://netfoundry.jfrog.io/netfoundry/ziti-maven-snapshot/ziti-tunnel-win/amd64/windows/ziti-tunnel-win/${version}/ziti-tunnel-win-${version}.zip";
private string _serviceUrl = "https://netfoundry.jfrog.io/netfoundry/ziti-maven-snapshot/ziti-tunnel-win/amd64/windows/ziti-tunnel-win/0.0.8-SNAPSHOT/ziti-tunnel-win-0.0.8-SNAPSHOT.zip";
private System.Timers.Timer _checkTimer = new System.Timers.Timer();
private System.Timers.Timer _updateTimer = new System.Timers.Timer();
private string _rootDirectory = "";
private string _logDirectory = "";
private bool _isJustStopped = true;
private string _versionType = "release";
private string _versionType = "latest";
ServiceController controller;
public UpdateService() {
@@ -37,8 +37,12 @@ namespace ZitiUpdateService {
}
protected override void OnStart(string[] args) {
if (ConfigurationManager.AppSettings.Get("UpdateUrl")!=null) _versionUrl = ConfigurationManager.AppSettings.Get("UpdateUrl");
if (ConfigurationManager.AppSettings.Get("Version") !=null) _versionType = ConfigurationManager.AppSettings.Get("Version");
try {
if (ConfigurationManager.AppSettings.Get("UpdateUrl") != null) _versionUrl = ConfigurationManager.AppSettings.Get("UpdateUrl");
if (ConfigurationManager.AppSettings.Get("Version") != null) _versionType = ConfigurationManager.AppSettings.Get("Version");
} catch (Exception e) {
Log(e.ToString());
}
_rootDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "NetFoundry");
if (!Directory.Exists(_rootDirectory)) Directory.CreateDirectory(_rootDirectory);
_logDirectory = Path.Combine(_rootDirectory, "Logs");
@@ -97,7 +101,7 @@ namespace ZitiUpdateService {
xmlDoc.LoadXml(result);
XmlNode node = xmlDoc.SelectSingleNode("metadata/versioning/"+ _versionType);
string version = node.InnerText;
Log("Version Checked: " + version+" on "+_version);
Log("Version Checked: " + version+" on "+_version+" from "+_versionType);
if (version != _version) {
StopZiti();
UpdateServiceFiles();
@@ -135,9 +139,9 @@ namespace ZitiUpdateService {
var result = readStream.ReadToEnd();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(result);
XmlNode node = xmlDoc.SelectSingleNode("metadata/versioning/release");
XmlNode node = xmlDoc.SelectSingleNode("metadata/versioning/"+_versionType);
string version = node.InnerText;
Log("Got Version: " + version);
Log("Got Version: " + version+" from "+_versionType);
string remoteService = _serviceUrl.Replace("${version}", version);
@@ -152,6 +156,7 @@ namespace ZitiUpdateService {
}
}
WebClient webClient = new WebClient();
Log("Get From: "+remoteService);
webClient.DownloadFile(remoteService, Path.Combine(_rootDirectory, "Service") + @"\windows-tunneler.zip");
Log("Zip Downloaded");
ZipFile.ExtractToDirectory(Path.Combine(_rootDirectory, "Service") + @"\windows-tunneler.zip", Path.Combine(_rootDirectory, "Service"));