Merge branch 'release-0.0.30' of github.com:openziti/desktop-edge-win into release-0.0.30

This commit is contained in:
dovholuknf
2020-10-12 15:15:05 -04:00
10 changed files with 249 additions and 24 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

+12 -1
View File
@@ -58,6 +58,16 @@
<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="Service Logs" MouseUp="ShowLogs"></local:MenuItem>
<local:MenuItem HorizontalAlignment="Stretch" Icon="/Assets/Images/logs.png" Width="Auto" Label="Application Logs" MouseUp="ShowUILogs"></local:MenuItem>
<local:MenuItem HorizontalAlignment="Stretch" Icon="/Assets/Images/advanced.png" Width="Auto" Label="Set Logging Level" MouseUp="SetLogLevel"></local:MenuItem>
</StackPanel>
<StackPanel Name="LogLevelItems" Visibility="Collapsed" Orientation="Vertical" HorizontalAlignment="Stretch">
<local:SubOptionItem x:Name="LogFatal" HorizontalAlignment="Stretch" Width="Auto" Label="Fatal" MouseUp="SetLevel"></local:SubOptionItem>
<local:SubOptionItem x:Name="LogError" HorizontalAlignment="Stretch" Width="Auto" Label="Error" MouseUp="SetLevel"></local:SubOptionItem>
<local:SubOptionItem x:Name="LogWarn" HorizontalAlignment="Stretch" Width="Auto" Label="Warn" MouseUp="SetLevel"></local:SubOptionItem>
<local:SubOptionItem x:Name="LogInfo" HorizontalAlignment="Stretch" Width="Auto" Label="Info" MouseUp="SetLevel"></local:SubOptionItem>
<local:SubOptionItem x:Name="LogDebug" HorizontalAlignment="Stretch" Width="Auto" Label="Debug" MouseUp="SetLevel"></local:SubOptionItem>
<local:SubOptionItem x:Name="LogTrace" HorizontalAlignment="Stretch" Width="Auto" Label="Trace" MouseUp="SetLevel"></local:SubOptionItem>
<local:SubOptionItem x:Name="LogVerbose" HorizontalAlignment="Stretch" Width="Auto" Label="Verbose" MouseUp="SetLevel"></local:SubOptionItem>
</StackPanel>
<StackPanel Name="ConfigItems" Visibility="Collapsed" Orientation="Vertical" HorizontalAlignment="Stretch">
<local:MenuEditItem x:Name="ConfigIp" HorizontalAlignment="Stretch" Width="Auto" Label="IPv4 Address:"></local:MenuEditItem>
@@ -71,7 +81,8 @@
<StackPanel Name="AboutItemsArea" Orientation="Vertical" HorizontalAlignment="Stretch" Visibility="Collapsed">
<Label Name="VersionInfo" HorizontalAlignment="Center" FontSize="10" Height="50" Padding="0,30,0,0" 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 Desktop Edge" Cursor="Hand" MouseUp="CloseApp" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" HorizontalAlignment="Center"></Label>
<Label Name="UpdateAvailable" Visibility="Collapsed" Margin="0,0,0,0" Foreground="#F4044D" FontWeight="Normal" Content="An Upgrade is available, click to download" Cursor="Hand" MouseUp="DoUpdate" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" HorizontalAlignment="Center"></Label>
<Label Name="MainItemsButton" Margin="0,10,0,0" Foreground="#F4044D" FontWeight="SemiBold" Content="Quit Ziti Desktop Edge" Cursor="Hand" MouseUp="CloseApp" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" HorizontalAlignment="Center"></Label>
</StackPanel>
</Grid>
</Grid>
+89 -2
View File
@@ -10,6 +10,9 @@ using System.Reflection;
using System.Web;
using System.Net.Mail;
using System.IO;
using System.Net;
using Newtonsoft.Json.Linq;
using System.Threading.Tasks;
namespace ZitiDesktopEdge
{
@@ -21,12 +24,18 @@ namespace ZitiDesktopEdge
public delegate void AttachementChanged(bool attached);
public event AttachementChanged OnAttachmentChange;
public delegate void LogLevelChanged(string level);
public event LogLevelChanged OnLogLevelChanged;
public string menuState = "Main";
public string licenseData = "it's open source.";
public string LogLevel = "";
private string _updateUrl = "https://api.github.com/repos/openziti/desktop-edge-win/releases/latest";
private string _downloadUrl = "";
public MainMenu() {
InitializeComponent();
LicensesItems.Text = licenseData;
CheckUpdates();
}
private void HideMenu(object sender, MouseButtonEventArgs e) {
@@ -39,6 +48,10 @@ namespace ZitiDesktopEdge
Application.Current.Shutdown();
}
private void DoUpdate(object sender, MouseButtonEventArgs e) {
System.Diagnostics.Process.Start(_downloadUrl);
}
private void ShowAbout(object sender, MouseButtonEventArgs e) {
menuState = "About";
UpdateState();
@@ -64,6 +77,39 @@ namespace ZitiDesktopEdge
menuState = "UILogs";
UpdateState();
}
private void SetLogLevel(object sender, MouseButtonEventArgs e) {
menuState = "LogLevel";
UpdateState();
}
private void CheckUpdates() {
HttpWebRequest httpWebRequest = WebRequest.CreateHttp(_updateUrl);
httpWebRequest.Method = "GET";
httpWebRequest.ContentType = "application/json";
httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36";
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream());
string result = streamReader.ReadToEnd();
JObject json = JObject.Parse(result);
string currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
string serverVersion = json.Property("tag_name").Value.ToString() + ".0";
Version installed = new Version(currentVersion);
Version published = new Version(serverVersion);
int compare = installed.CompareTo(published);
if (compare<0) {
UpdateAvailable.Content = "An Upgrade is available, click to download";
UpdateAvailable.Visibility = Visibility.Visible;
} else if (compare>0) {
UpdateAvailable.Content = "Your version is newer than the released version";
UpdateAvailable.Visibility = Visibility.Visible;
}
JArray assets = JArray.Parse(json.Property("assets").Value.ToString());
foreach (JObject asset in assets.Children<JObject>()) {
_downloadUrl = asset.Property("browser_download_url").Value.ToString();
break;
}
}
private void UpdateState() {
MainItems.Visibility = Visibility.Collapsed;
@@ -75,6 +121,7 @@ namespace ZitiDesktopEdge
LicensesItems.Visibility = Visibility.Collapsed;
LogsItems.Visibility = Visibility.Collapsed;
ConfigItems.Visibility = Visibility.Collapsed;
LogLevelItems.Visibility = Visibility.Collapsed;
if (menuState == "About") {
MenuTitle.Content = "About";
@@ -82,8 +129,15 @@ namespace ZitiDesktopEdge
AboutItems.Visibility = Visibility.Visible;
BackArrow.Visibility = Visibility.Visible;
ZitiDesktopEdge.ServiceClient.TunnelStatus s = (ZitiDesktopEdge.ServiceClient.TunnelStatus)Application.Current.Properties["CurrentTunnelStatus"];
string version = $"{s.ServiceVersion.Version}@{s.ServiceVersion.Revision}";
string version = "";
try {
ServiceClient.TunnelStatus s = (ServiceClient.TunnelStatus)Application.Current.Properties["CurrentTunnelStatus"];
version = $"{s.ServiceVersion.Version}@{s.ServiceVersion.Revision}";
} catch (Exception e) {
#if DEBUG
Debug.WriteLine(e.ToString());
#endif
}
// Interface Version
VersionInfo.Content = "App: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()+" Service: "+ version;
@@ -107,6 +161,12 @@ namespace ZitiDesktopEdge
LogsItems.Text = UILog.GetLogs();
LogsItems.Visibility = Visibility.Visible;
BackArrow.Visibility = Visibility.Visible;
} else if (menuState == "LogLevel") {
ResetLevels();
MenuTitle.Content = "Set Log Level";
LogLevelItems.Visibility = Visibility.Visible;
BackArrow.Visibility = Visibility.Visible;
} else if (menuState=="Config") {
MenuTitle.Content = "Tunnel Configuration";
ConfigItems.Visibility = Visibility.Visible;
@@ -213,5 +273,32 @@ namespace ZitiDesktopEdge
OnAttachmentChange(true);
}
}
private void ResetLevels() {
if (this.LogLevel == "") this.LogLevel = "error";
LogVerbose.IsSelected = false;
LogDebug.IsSelected = false;
LogInfo.IsSelected = false;
LogError.IsSelected = false;
LogFatal.IsSelected = false;
LogWarn.IsSelected = false;
LogTrace.IsSelected = false;
if (this.LogLevel == "verbose") LogVerbose.IsSelected = true;
else if (this.LogLevel == "debug") LogDebug.IsSelected = true;
else if (this.LogLevel == "info") LogInfo.IsSelected = true;
else if (this.LogLevel == "error") LogError.IsSelected = true;
else if (this.LogLevel == "fatal") LogFatal.IsSelected = true;
else if (this.LogLevel == "warn") LogWarn.IsSelected = true;
else if (this.LogLevel == "trace") LogTrace.IsSelected = true;
}
private void SetLevel(object sender, MouseButtonEventArgs e) {
SubOptionItem item = (SubOptionItem)sender;
this.LogLevel = item.Label.ToLower();
if (OnLogLevelChanged != null) {
OnLogLevelChanged(this.LogLevel);
}
ResetLevels();
}
}
}
+7 -2
View File
@@ -65,7 +65,6 @@ namespace ZitiDesktopEdge {
LaunchOrInstall();
SetNotifyIcon("white");
InitializeComponent();
}
private void MainWindow_Activated(object sender, EventArgs e) {
@@ -127,6 +126,7 @@ namespace ZitiDesktopEdge {
Application.Current.Properties.Add("ServiceClient", serviceClient);
Application.Current.Properties.Add("Identities", new List<ZitiIdentity>());
MainMenu.OnAttachmentChange += AttachmentChanged;
MainMenu.OnLogLevelChanged += LogLevelChanged;
IdentityMenu.OnError += IdentityMenu_OnError;
try {
@@ -141,6 +141,10 @@ namespace ZitiDesktopEdge {
IdentityMenu.OnForgot += IdentityForgotten;
}
private void LogLevelChanged(string level) {
serviceClient.SetLogLevel(level);
}
private void IdentityMenu_OnError(string message) {
ShowError("Identity Error", message);
}
@@ -247,7 +251,7 @@ namespace ZitiDesktopEdge {
SetCantDisplay("Version mismatch!", "The version of the Service is not compatible");
return;
}
this.MainMenu.LogLevel = e.Status.LogLevel;
InitializeTimer((int)e.Status.Duration);
LoadStatusFromService(e.Status);
LoadIdentities(false);
@@ -395,6 +399,7 @@ namespace ZitiDesktopEdge {
try {
Identity createdId = serviceClient.AddIdentity(System.IO.Path.GetFileName(jwtDialog.FileName), false, fileContent);
ServiceClient.Client client = (ServiceClient.Client)Application.Current.Properties["ServiceClient"];
client.IdentityOnOff(createdId.FingerPrint, true);
if (createdId != null) {
identities.Add(ZitiIdentity.FromClient(createdId));
+2 -2
View File
@@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.2.7.0")]
[assembly: AssemblyFileVersion("1.2.7.0")]
+12
View File
@@ -390,6 +390,18 @@ namespace ZitiDesktopEdge.ServiceClient
}
}
public void SetLogLevel(string level) {
try {
send(new SetLogLevelFunction(level));
SvcResponse resp = read<SvcResponse>(ipcReader);
return;
} catch (IOException ioe) {
//almost certainly a problem with the pipe - recreate the pipe...
//setupPipe();
throw ioe;
}
}
public void SetLogLevel(LogLevelEnum level)
{
try
+18 -16
View File
@@ -198,23 +198,25 @@ namespace ZitiDesktopEdge.ServiceClient
public void Dump(System.IO.TextWriter writer)
{
writer.WriteLine($"Tunnel Active: {Active}");
writer.WriteLine($" ServiceVersion : {ServiceVersion}");
writer.WriteLine($" LogLevel : {LogLevel}");
writer.WriteLine($" EvaluatedLogLevel: {EvaluateLogLevel()}");
foreach (Identity id in Identities)
{
writer.WriteLine($" FingerPrint: {id.FingerPrint}");
writer.WriteLine($" Name : {id.Name}");
writer.WriteLine($" Active : {id.Active}");
writer.WriteLine($" Status : {id.Status}");
writer.WriteLine($" Services:");
foreach (Service s in id?.Services)
{
writer.WriteLine($" Name: {s.Name} HostName: {s.InterceptHost} Port: {s.InterceptPort}");
try {
writer.WriteLine($"Tunnel Active: {Active}");
writer.WriteLine($" LogLevel : {LogLevel}");
writer.WriteLine($" EvaluatedLogLevel: {EvaluateLogLevel()}");
foreach (Identity id in Identities) {
writer.WriteLine($" FingerPrint: {id.FingerPrint}");
writer.WriteLine($" Name : {id.Name}");
writer.WriteLine($" Active : {id.Active}");
writer.WriteLine($" Status : {id.Status}");
writer.WriteLine($" Services:");
foreach (Service s in id.Services) {
writer.WriteLine($" Name: {s.Name} HostName: {s.InterceptHost} Port: {s.InterceptPort}");
}
writer.WriteLine("=============================================");
}
writer.WriteLine("=============================================");
}
} catch (Exception e) {
if (writer!=null) writer.WriteLine(e.ToString());
}
}
public LogLevelEnum EvaluateLogLevel()
@@ -0,0 +1,48 @@
<UserControl x:Class="ZitiDesktopEdge.SubOptionItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ZitiDesktopEdge"
mc:Ignorable="d"
d:DesignHeight="50" HorizontalAlignment="Stretch" d:DesignWidth="375" Cursor="Hand">
<UserControl.Triggers>
<EventTrigger RoutedEvent="UserControl.MouseEnter" >
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BgFill" From="0" To="0.2" Duration="0:0:0.5"></DoubleAnimation>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BgFill" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0:0:0.5" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BgFill" From="0" To="0.2" Duration="0:0:0.5"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="UserControl.MouseLeave" >
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BgFill" From=".2" To="0" Duration="0:0:0.5"></DoubleAnimation>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BgFill" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0:0:0.5" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BgFill" From=".2" To="0" Duration="0:0:0.5"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</UserControl.Triggers>
<Grid>
<Rectangle Name="BgFill" Fill="#7d8faf" Opacity="0"></Rectangle>
<StackPanel Orientation="Vertical">
<Grid Height="49">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Label Name="MainLabel" Grid.Column="0" Content="Main Menu" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="14" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" Foreground="Black"></Label>
<Image x:Name="SelectedCheck" Grid.Column="1" Cursor="Hand" Source="/Assets/Images/Success.png" Width="20" Height="20" Margin="0,0,0,0" />
</Grid>
<Rectangle HorizontalAlignment="Stretch" Height="1" Fill="#7d8faf" Opacity="0.2"></Rectangle>
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ZitiDesktopEdge {
/// <summary>
/// Interaction logic for MenuItem.xaml
/// </summary>
public partial class SubOptionItem : UserControl {
private string _label = "";
private bool _isSelected = false;
public string Label {
get {
return _label;
}
set {
this._label = value;
MainLabel.Content = this._label;
}
}
public bool IsSelected {
get {
return _isSelected;
}
set {
this._isSelected = value;
if (this._isSelected) SelectedCheck.Visibility = Visibility.Visible;
else SelectedCheck.Visibility = Visibility.Collapsed;
}
}
public SubOptionItem() {
InitializeComponent();
}
}
}
+11 -1
View File
@@ -34,7 +34,7 @@
<SuiteName>Ziti</SuiteName>
<AutorunEnabled>true</AutorunEnabled>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.2.1.%2a</ApplicationVersion>
<ApplicationVersion>1.2.7.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
@@ -147,6 +147,9 @@
<Compile Include="RegistrationScreen.xaml.cs">
<DependentUpon>RegistrationScreen.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ItemRenderers\SubOptionItem.xaml.cs">
<DependentUpon>SubOptionItem.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ItemRenderers\SubMenuItem.xaml.cs">
<DependentUpon>SubMenuItem.xaml</DependentUpon>
</Compile>
@@ -201,6 +204,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ItemRenderers\SubOptionItem.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\ItemRenderers\SubMenuItem.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -353,5 +360,8 @@
<ItemGroup>
<Resource Include="Assets\Images\No_Services.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\Success.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>