From e2d50db7a7c8674a33a95b3aea9bbf974552875d Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Fri, 27 Nov 2020 14:42:47 -0500 Subject: [PATCH 1/5] change the location of the logs to a subfolder of the installation path - same as the other logs --- service/ziti-tunnel/config/config.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/service/ziti-tunnel/config/config.go b/service/ziti-tunnel/config/config.go index 58de2012..617fc518 100644 --- a/service/ziti-tunnel/config/config.go +++ b/service/ziti-tunnel/config/config.go @@ -18,9 +18,19 @@ package config import ( + "log" "os" + "path/filepath" ) +func ExecutablePath() string { + fi, err := os.Executable() + if err != nil { + log.Panic("COULD NOT STAT os.executable! %v", err) + } + dir := filepath.Dir(fi) + return dir +} func File() string { return Path() + "config.json" } @@ -29,9 +39,11 @@ func Path() string { return path + string(os.PathSeparator) + "NetFoundry" + string(os.PathSeparator) } func LogFile() string { - return Path() + "ziti-tunneler.log" + return filepath.Join(LogsPath(), "ziti-tunneler.log") +} +func LogsPath() string { + return filepath.Join(ExecutablePath(), "logs", "service") } - func BackupFile() string { return File() + ".backup" } From 861c3445ec45379e8239d2091f95141766373f95 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Fri, 27 Nov 2020 14:44:09 -0500 Subject: [PATCH 2/5] remove collect-logs.ps1 hopefully forever --- Installer/collect-logs.ps1 | 64 -------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 Installer/collect-logs.ps1 diff --git a/Installer/collect-logs.ps1 b/Installer/collect-logs.ps1 deleted file mode 100644 index 5fe92af7..00000000 --- a/Installer/collect-logs.ps1 +++ /dev/null @@ -1,64 +0,0 @@ -function EndLogs { -echo "===================================== collecting logs ends =====================================" -echo "" -} -function ExitWithCode($exitcode) { - #$host.SetShouldExit($exitcode) - exit $exitcode -} - -$now=(Get-Date).ToString('yyyy-MM-dd_HHmmss') -$logroot="${env:ProgramFiles(x86)}\NetFoundry, Inc\Ziti Desktop Edge\logs" -$ipinfo="${logroot}\ipconfig.info.txt" - -$logdest="$logroot\ziti-service\" -$logdest -$logsrc="${env:WINDIR}\System32\config\systemprofile\AppData\Roaming\NetFoundry\*.log" -$destArchive="${logroot}\logs-${now}.zip" - -echo "" -echo "===================================== collecting logs begins =====================================" -echo " checking for admin privs" -$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) -$isAdmin=$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -if (!$isAdmin) { - echo "" - echo " ERROR: administrator rights not found" - echo " this script requires access to files on the administrator can access" - echo "" - EndLogs - exit 11 -} -echo " ensure folder exists: $logdest" -mkdir $logdest -ErrorAction SilentlyContinue > $null - -echo " issuing ipconfig /all" -echo " " -ipconfig /all > "$ipinfo" - -echo " copying log files...." -echo " source: $logsrc" -echo " to: $logdest" -cp $logsrc $logdest - -echo " " -echo " creating archive: ${destArchive}" -mkdir "${logroot}\UI" -ErrorAction SilentlyContinue > $null -compress-archive -Path "${ipinfo}","${logroot}\ziti-service","${logroot}\UI","${logroot}\ZitiMonitorService" -DestinationPath "${destArchive}" - -echo " " -echo " removing log folder: $logdest" -rm -r "$logdest" -echo " removing ipinfo : $ipinfo" -rm "$ipinfo" - -$Acl = Get-ACL $logroot -$AccessRule= New-Object System.Security.AccessControl.FileSystemAccessRule("everyone","FullControl","ContainerInherit,Objectinherit","none","Allow") -$Acl.AddAccessRule($AccessRule) -Set-Acl $logroot $Acl - -echo " " -echo " Logs collected successfully" -echo " Log location: ${destArchive}" - -EndLogs From d0bc162f69f127d15852bb4a50552eba013a83ce Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Fri, 27 Nov 2020 14:45:08 -0500 Subject: [PATCH 3/5] add a couple of extra lines to make it easy to find when the service/ui starts --- DesktopEdge/MainWindow.xaml.cs | 5 ++++- ZitiUpdateService/Program.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/DesktopEdge/MainWindow.xaml.cs b/DesktopEdge/MainWindow.xaml.cs index a1631b1e..cfa389bb 100644 --- a/DesktopEdge/MainWindow.xaml.cs +++ b/DesktopEdge/MainWindow.xaml.cs @@ -66,8 +66,10 @@ namespace ZitiDesktopEdge { var curdir = Path.GetDirectoryName(asm.Location); string nlogFile = Path.Combine(curdir, logname + "-log.config"); + bool byFile = false; if (File.Exists(nlogFile)) { LogManager.Configuration = new XmlLoggingConfiguration(nlogFile); + byFile = true; } else { var config = new LoggingConfiguration(); // Targets where to log to: File and Console @@ -87,7 +89,8 @@ namespace ZitiDesktopEdge { // Apply config LogManager.Configuration = config; } - logger.Info("service started - logger initialized"); + logger.Info("============================== UI started =============================="); + logger.Info("logger initialized using file? {0}", byFile); App.Current.MainWindow.WindowState = WindowState.Normal; App.Current.MainWindow.Closing += MainWindow_Closing; diff --git a/ZitiUpdateService/Program.cs b/ZitiUpdateService/Program.cs index e88a6a8c..512794e8 100644 --- a/ZitiUpdateService/Program.cs +++ b/ZitiUpdateService/Program.cs @@ -21,8 +21,10 @@ namespace ZitiUpdateService { var curdir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string nlogFile = Path.Combine(curdir, $"{logname}-log.config"); + bool byFile = false; if (File.Exists(nlogFile)) { LogManager.Configuration = new XmlLoggingConfiguration(nlogFile); + byFile = true; } else { var config = new LoggingConfiguration(); // Targets where to log to: File and Console @@ -42,7 +44,8 @@ namespace ZitiUpdateService { // Apply config LogManager.Configuration = config; } - Logger.Info("service started - logger initialized"); + Logger.Info("============================== ziti-monitor started =============================="); + Logger.Info("logger initialized using file? {0}", byFile); UpdateService updateSvc = new UpdateService(); updateSvc.AutoLog = true; From 89b6590f2583d68d500d7f095fdc13b818326ba4 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Fri, 27 Nov 2020 14:45:53 -0500 Subject: [PATCH 4/5] make the log grabbing experience a little bit better, still can't find a way to NOT set the stupid 'from' field... --- DesktopEdge/MainMenu.xaml.cs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/DesktopEdge/MainMenu.xaml.cs b/DesktopEdge/MainMenu.xaml.cs index 81ed57d8..448fca57 100644 --- a/DesktopEdge/MainMenu.xaml.cs +++ b/DesktopEdge/MainMenu.xaml.cs @@ -41,8 +41,11 @@ namespace ZitiDesktopEdge private string _updateUrl = "https://api.github.com/repos/openziti/desktop-edge-win/releases/latest"; private string _downloadUrl = ""; + private string appVersion = null; public MainMenu() { InitializeComponent(); + + appVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); LicensesItems.Text = licenseData; CheckUpdates(); } @@ -107,10 +110,9 @@ namespace ZitiDesktopEdge 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 installed = new Version(appVersion); Version published = new Version(serverVersion); int compare = installed.CompareTo(published); if (compare < 0) @@ -164,7 +166,7 @@ namespace ZitiDesktopEdge } // Interface Version - VersionInfo.Content = "App: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()+" Service: "+ version; + VersionInfo.Content = $"App: {appVersion} Service: {version}"; } else if (menuState=="Advanced") { MenuTitle.Content = "Advanced Settings"; @@ -226,11 +228,15 @@ namespace ZitiDesktopEdge async private void ShowFeedback(object sender, MouseButtonEventArgs e) { DataClient client = (DataClient)Application.Current.Properties["ServiceClient"]; - var mailMessage = new MailMessage(); - mailMessage.From = new MailAddress("ziti-support@netfoundry.io"); + var mailMessage = new MailMessage("ziti-support@netfoundry.io", "clint@netfoundry.io"); + //var mailMessage = new MailMessage("ziti-support@netfoundry.io", "ziti-support@netfoundry.io"); mailMessage.Subject = "Ziti Support"; - mailMessage.IsBodyHtml = true; - mailMessage.Body = ""; + 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 monitorClient = (MonitorClient)Application.Current.Properties["MonitorClient"]; @@ -255,15 +261,14 @@ namespace ZitiDesktopEdge } var p = Process.Start(emlFile); - Task.Run(async () => { - logger.Info("Waiting to send email..."); - p.WaitForExit(); - logger.Info("Email sent or cancelled... removing file: {0}", emlFile); + p.Exited += (object lambdaSender, EventArgs lambdaEventArgs) => { + logger.Info("Removing temp file: {0}", emlFile); File.Delete(emlFile); - logger.Info("file removed: {0}", emlFile); - }); + }; + p.EnableRaisingEvents = true; } - private void ShowSupport(object sender, MouseButtonEventArgs e) { + + private void ShowSupport(object sender, MouseButtonEventArgs e) { Process.Start(new ProcessStartInfo("https://openziti.discourse.group/") { UseShellExecute = true }); } From c808aed3a49aa60389eca63729e9305b5e949697 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Fri, 27 Nov 2020 14:47:15 -0500 Subject: [PATCH 5/5] ugh - wrong emailaddy pushed --- DesktopEdge/MainMenu.xaml.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/DesktopEdge/MainMenu.xaml.cs b/DesktopEdge/MainMenu.xaml.cs index 448fca57..29c266f8 100644 --- a/DesktopEdge/MainMenu.xaml.cs +++ b/DesktopEdge/MainMenu.xaml.cs @@ -228,8 +228,7 @@ namespace ZitiDesktopEdge async private void ShowFeedback(object sender, MouseButtonEventArgs e) { DataClient client = (DataClient)Application.Current.Properties["ServiceClient"]; - var mailMessage = new MailMessage("ziti-support@netfoundry.io", "clint@netfoundry.io"); - //var mailMessage = new MailMessage("ziti-support@netfoundry.io", "ziti-support@netfoundry.io"); + var mailMessage = new MailMessage("ziti-support@netfoundry.io", "ziti-support@netfoundry.io"); mailMessage.Subject = "Ziti Support"; mailMessage.IsBodyHtml = false; System.Text.StringBuilder sb = new System.Text.StringBuilder();