Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair deferred updates and other cleanup #554

Merged
merged 7 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/installer.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ jobs:
with:
add: 'DesktopEdge/Properties/AssemblyInfo.cs ZitiDesktopEdge.Client/Properties/AssemblyInfo.cs ZitiUpdateService/Properties/AssemblyInfo.cs Installer/ZitiDesktopEdge.aip'
default_author: github_actions
committer_name: ziti-ci
committer_name: ziti-ci
24 changes: 16 additions & 8 deletions .github/workflows/mattermost-ziti-webhook.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
name: mattermost-ziti-webhook
on:
create:
delete:
on:
issues:
issue_comment:
pull_request_review:
types: [submitted]
pull_request_review_comment:
pull_request:
types: [opened, reopened]
push:
fork:
release:
types: [released]
workflow_dispatch:

jobs:
mattermost-ziti-webhook:
runs-on: macos-latest
runs-on: ubuntu-latest
name: POST Webhook
steps:
- uses: openziti/ziti-webhook-action@main
- uses: openziti/ziti-mattermost-action-py@main
if: |
github.repository_owner == 'openziti'
&& ((github.event_name != 'pull_request_review')
|| (github.event_name == 'pull_request_review' && github.event.review.state == 'approved'))
with:
ziti-id: ${{ secrets.ZITI_MATTERMOST_IDENTITY }}
webhook-url: ${{ secrets.ZITI_MATTERMOST_WEBHOOK_URL }}
webhook-secret: ${{ secrets.ZITI_MATTERMOSTI_WEBHOOK_SECRET }}
zitiId: ${{ secrets.ZITI_MATTERMOST_IDENTITY }}
webhookUrl: ${{ secrets.ZHOOK_URL }}
eventJson: ${{ toJson(github.event) }}
senderUsername: "GitHubZ"
destChannel: "dev-notifications"
25 changes: 17 additions & 8 deletions DesktopEdge/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ private void ModalHideComplete(object sender, EventArgs e) {
/// <summary>
/// Close the MFA Screen with animation
/// </summary>
async private void DoClose(bool isComplete) {
private void DoClose(bool isComplete) {
DoubleAnimation animation = new DoubleAnimation(0, TimeSpan.FromSeconds(.3));
ThicknessAnimation animateThick = new ThicknessAnimation(new Thickness(0, 0, 0, 0), TimeSpan.FromSeconds(.3));
animation.Completed += CloseComplete;
Expand Down Expand Up @@ -433,8 +433,8 @@ public MainWindow() {
IdentityMenu.OnMessage += IdentityMenu_OnMessage;
}

private void MFASetup_OnError(string message) {
ShowBlurbAsync(message, "", "error");
async private void MFASetup_OnError(string message) {
await ShowBlurbAsync(message, "", "error");
}

private void ToastNotificationManagerCompat_OnActivated(ToastNotificationActivatedEventArgsCompat e) {
Expand Down Expand Up @@ -599,7 +599,7 @@ async private void MainWindow_Loaded(object sender, RoutedEventArgs e) {
app.ReceiveString += App_ReceiveString;

// add a new service client
serviceClient = new DataClient();
serviceClient = new DataClient("ui");
serviceClient.OnClientConnected += ServiceClient_OnClientConnected;
serviceClient.OnClientDisconnected += ServiceClient_OnClientDisconnected;
serviceClient.OnIdentityEvent += ServiceClient_OnIdentityEvent;
Expand All @@ -613,7 +613,7 @@ async private void MainWindow_Loaded(object sender, RoutedEventArgs e) {
serviceClient.OnControllerEvent += ServiceClient_OnControllerEvent;
Application.Current.Properties.Add("ServiceClient", serviceClient);

monitorClient = new MonitorClient();
monitorClient = new MonitorClient("ui");
monitorClient.OnClientConnected += MonitorClient_OnClientConnected;
monitorClient.OnNotificationEvent += MonitorClient_OnInstallationNotificationEvent;
monitorClient.OnServiceStatusEvent += MonitorClient_OnServiceStatusEvent;
Expand Down Expand Up @@ -835,9 +835,18 @@ private void MonitorClient_OnInstallationNotificationEvent(object sender, Instal
if ("installationupdate".Equals(evt.Message?.ToLower())) {
logger.Debug("Installation Update is available - {0}", evt.ZDEVersion);
IsUpdateAvailable = true;
MainMenu.ShowUpdateAvailable(evt.TimeRemaining, evt.InstallTime);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was TimeRemaining bogus? or does it mean something else? should it be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was utterly superfluous and i removed it from the json object the montior service sends, yes. It was replaced by a simple "now - installtime" calculation (which is already there):

var remaining = evt.InstallTime - DateTime.Now;
...
MainMenu.ShowUpdateAvailable(remaining.TotalSeconds, evt.InstallTime);

var remaining = evt.InstallTime - DateTime.Now;
MainMenu.ShowUpdateAvailable(remaining.TotalSeconds, evt.InstallTime);
AlertCanvas.Visibility = Visibility.Visible;
ShowToast("An Update is Available for Ziti Desktop Edge, will initiate auto installation by " + evt.InstallTime);

if (remaining.TotalSeconds < 60) {
//this is an immediate update - show a different message
ShowToast("Ziti Desktop Edge will initiate auto installation in the next minute!");
}
else
{
ShowToast("An Update is Available for Ziti Desktop Edge, will initiate auto installation by " + evt.InstallTime);
}
SetNotifyIcon("");
// display a tag in UI and a button for the update software
}
Expand Down Expand Up @@ -1559,7 +1568,7 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
}
}

public void ShowError(String title, String message) {
public void ShowError(string title, string message) {
this.Dispatcher.Invoke(() => {
ErrorTitle.Content = title;
ErrorDetails.Text = message;
Expand Down
7 changes: 6 additions & 1 deletion DesktopEdge/Utils/UIUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ public class UIUtils {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

public static void SetLogLevel(string level) {
try {
try
{
Logger.Info("request to change log level received: {0}", level);
if ((""+level).ToLower() == "verbose") {
level = "trace";
Logger.Info("request to change log level to verbose - but using trace instead");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not respect "verbose" ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NLog doesn't have the level

}
var l = LogLevel.FromString(level);
foreach (var rule in LogManager.Configuration.LoggingRules) {
rule.EnableLoggingForLevel(l);
Expand Down
36 changes: 5 additions & 31 deletions DesktopEdge/Views/Screens/MainMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,11 @@ private void ShowTerms(object sender, MouseButtonEventArgs e) {
async private void ShowFeedback(object sender, MouseButtonEventArgs e) {
try {
MainWindow.ShowLoad("Collecting Information", "Please wait while we run some commands\nand collect some diagnostic information");
var mailMessage = new MailMessage("help@openziti.org", "help@openziti.org");
mailMessage.Subject = "Ziti Support";
mailMessage.IsBodyHtml = false;

System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("Logs collected at : " + DateTime.Now.ToString());
sb.Append(". client version : " + appVersion);

mailMessage.Body = sb.ToString();

string timestamp = DateTime.Now.ToFileTime().ToString();

var dataClient = (DataClient)Application.Current.Properties["ServiceClient"];
Expand All @@ -330,32 +326,10 @@ async private void ShowFeedback(object sender, MouseButtonEventArgs e) {
}
string pathToLogs = resp.Message;
logger.Info("Log files found at : {0}", resp.Message);
mailMessage.Attachments.Add(new Attachment(pathToLogs));

string emlFile = Path.Combine(Path.GetTempPath(), timestamp + "-ziti.eml");

using (var filestream = File.Open(emlFile, FileMode.Create)) {
var binaryWriter = new BinaryWriter(filestream);
binaryWriter.Write(System.Text.Encoding.UTF8.GetBytes("X-Unsent: 1" + Environment.NewLine));
var assembly = typeof(SmtpClient).Assembly;
var mailWriterType = assembly.GetType("System.Net.Mail.MailWriter");
var mailWriterContructor = mailWriterType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(Stream) }, null);
var mailWriter = mailWriterContructor.Invoke(new object[] { filestream });
var sendMethod = typeof(MailMessage).GetMethod("Send", BindingFlags.Instance | BindingFlags.NonPublic);
sendMethod.Invoke(mailMessage, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { mailWriter, true, true }, null);
var closeMethod = mailWriter.GetType().GetMethod("Close", BindingFlags.Instance | BindingFlags.NonPublic);
closeMethod.Invoke(mailWriter, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { }, null);
}
var p = Process.Start(emlFile);
if (p != null) {
p.Exited += (object lambdaSender, EventArgs lambdaEventArgs) => {
logger.Info("Removing temp file: {0}", emlFile);
File.Delete(emlFile);
};
p.EnableRaisingEvents = true;
} else {
logger.Debug("process was null. most likely the email file format was not known when the process tried to start");
}
string args = string.Format("/Select, \"{0}\"", pathToLogs);

ProcessStartInfo pfi = new ProcessStartInfo("Explorer.exe", args);
Process.Start(pfi);
} catch (Exception ex) {
logger.Warn(ex, "An unexpected error has occurred when submitting feedback? {0}", ex.Message);
}
Expand Down
58 changes: 17 additions & 41 deletions DesktopEdge/ZitiDesktopEdge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
Expand Down Expand Up @@ -75,7 +76,7 @@
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
Expand All @@ -86,41 +87,34 @@
<PropertyGroup>
<ApplicationIcon>ziti.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugUpdates|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\DebugUpdates\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationFramework.Aero2" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Management" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Management.Automation.dll.10.0.10586.0\lib\net40\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.Management.Instrumentation" />
<Reference Include="System.Net" />
<Reference Include="System.Net.NetworkInformation, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.NetworkInformation.4.3.0\lib\net46\System.Net.NetworkInformation.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Presentation" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
Expand Down Expand Up @@ -310,8 +304,6 @@
<ItemGroup>
<Resource Include="Assets\Images\icon.ico" />
<Resource Include="Assets\Images\icon.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\identity.png" />
<Resource Include="Assets\Images\jwt.png" />
<Resource Include="Assets\Images\loading.png" />
Expand All @@ -328,8 +320,6 @@
<Resource Include="Assets\Images\support.png" />
<Resource Include="Assets\Images\up.png" />
<Resource Include="Assets\Images\z.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\about.png" />
<Resource Include="Assets\Images\advanced.png" />
<Resource Include="Assets\Images\appicon.png" />
Expand All @@ -347,26 +337,12 @@
<Resource Include="Assets\Images\globe.png" />
<Resource Include="Assets\Images\hamburger.png" />
<Resource Include="Assets\Images\header.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\x.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\nextArrow.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\lastArrow.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\logs.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\wrench.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\detach.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\ziti-green.ico" />
<Resource Include="Assets\Images\Ziti-Green.png" />
<Resource Include="Assets\Images\ziti-red.ico" />
Expand Down Expand Up @@ -459,19 +435,19 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
<Version>7.0.2</Version>
<Version>7.1.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.Contracts">
<Version>10.0.19041.1</Version>
<Version>10.0.22621.1</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
<Version>13.0.1</Version>
</PackageReference>
<PackageReference Include="NLog">
<Version>4.7.8</Version>
<Version>5.0.1</Version>
</PackageReference>
<PackageReference Include="QRCoder">
<Version>1.4.1</Version>
<Version>1.4.3</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 1 addition & 5 deletions ZitiDesktopEdge.Client/DataStructures/DataStructures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ public class ActionEvent : StatusEvent
public class TunnelStatusEvent : StatusEvent
{
public TunnelStatus Status { get; set; }
public int ApiVersion { get; set; }
}

public class MetricsEvent : StatusEvent
Expand Down Expand Up @@ -495,10 +494,7 @@ public class StatusCheck : MonitorServiceStatusEvent {

public class InstallationNotificationEvent : MonitorServiceStatusEvent
{
public String ZDEVersion { get; set; }
public DateTime CreationDate { get; set; }
public bool IsCritical { get; set; }
public double TimeRemaining { get; set; }
public string ZDEVersion { get; set; }
public DateTime InstallTime { get; set; }
}

Expand Down
8 changes: 5 additions & 3 deletions ZitiDesktopEdge.Client/ServiceClient/AbstractClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public abstract class AbstractClient {
protected abstract Task ConnectPipesAsync();
protected abstract void ProcessLine(string line);
protected abstract Logger Logger { get; }
protected string Id { get; set; }

protected const string localPipeServer = ".";
protected const int ServiceConnectTimeout = 500;
Expand Down Expand Up @@ -136,7 +137,8 @@ async protected Task sendAsync(object objToSend) {
public bool Connected { get; set; }
public bool CleanShutdown { get; set; }

public AbstractClient() {
public AbstractClient(string id) {
this.Id = id;
}

async public Task ConnectAsync() {
Expand Down Expand Up @@ -197,7 +199,7 @@ public void Reconnect() {
}

protected void debugServiceCommunication(string msg) {
#if DEBUG
#if DEBUGSVCCOM
Logger.Debug(msg);
#else
Logger.Trace(msg);
Expand Down Expand Up @@ -250,7 +252,7 @@ async public Task WaitForConnectionAsync() {
}

public class ShouldSerializeContractResolver : DefaultContractResolver {
public new static readonly ShouldSerializeContractResolver Instance = new ShouldSerializeContractResolver();
public static readonly ShouldSerializeContractResolver Instance = new ShouldSerializeContractResolver();
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) {
JsonProperty property = base.CreateProperty(member, memberSerialization);

Expand Down
4 changes: 2 additions & 2 deletions ZitiDesktopEdge.Client/ServiceClient/DataClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected override void ClientDisconnected(object e) {
const string ipcPipe = @"ziti-edge-tunnel.sock";
const string eventPipe = @"ziti-edge-tunnel-event.sock";

public DataClient() : base() {
public DataClient(string id) : base(id) {
}

PipeSecurity CreateSystemIOPipeSecurity() {
Expand Down Expand Up @@ -337,7 +337,7 @@ protected override void ProcessLine(string line) {
case "status": //break here to see status on startup
//dbg comment Logger.Warn("STATUS EVENT: \n" + respAsString);
TunnelStatusEvent tse = serializer.Deserialize<TunnelStatusEvent>(jsonReader);

if (tse != null) {
TunnelStatusEvent(tse);
}
Expand Down
Loading