From c75615d1f7614a889ed17fdf19c86ab5a03c8260 Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Mon, 8 Feb 2021 18:27:17 -0500
Subject: [PATCH 01/20] bump tsdk to latest - 0.8.16
---
service/build.bat | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/service/build.bat b/service/build.bat
index 8a77e20d..dac04bcb 100644
--- a/service/build.bat
+++ b/service/build.bat
@@ -14,7 +14,7 @@ REM See the License for the specific language governing permissions and
REM limitations under the License.
REM
SET REPO_URL=https://github.com/openziti/ziti-tunnel-sdk-c.git
-SET ZITI_TUNNEL_REPO_BRANCH=v0.8.15
+SET ZITI_TUNNEL_REPO_BRANCH=v0.8.16
REM override the c sdk used in the build - leave blank for the same as specified in the tunneler sdk
SET ZITI_SDK_C_BRANCH=
REM the number of TCP connections the tunneler sdk can have at any one time
From fc4ae26888f4f19346a3194c4e956ed7ab729d44 Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Mon, 8 Feb 2021 18:27:33 -0500
Subject: [PATCH 02/20] bump version to 1.7.8
---
version | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/version b/version
index 91c74a58..84298f96 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-1.7.7
+1.7.8
From 9625c318cb9d094c680bea41fc2649925b1aa30a Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Mon, 8 Feb 2021 18:27:51 -0500
Subject: [PATCH 03/20] add a dummy record for dns probe testing.
---
service/cziti/dns.go | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/service/cziti/dns.go b/service/cziti/dns.go
index b7ce7a0a..627867c6 100644
--- a/service/cziti/dns.go
+++ b/service/cziti/dns.go
@@ -274,6 +274,15 @@ func DnsInit(tun api.DesktopEdgeIface, ip string, maskBits int) {
dnsMgrPrivate.serviceMap = make(map[string]*ctxService)
//DNS.ipMap = make(map[uint32]string)
dnsMgrPrivate.hostnameMap = make(map[string]*ctxIp)
+ //register the test dns entry:
+ dnsMgrPrivate.hostnameMap[normalizeDnsName("dew-dns-probe.openziti.org")] = &ctxIp{
+ //ctx: nil,
+ ip: net.ParseIP("127.0.0.1"),
+ //network: "",
+ dnsEnabled: true,
+ refCount: 0,
+ }
+
dnsip = net.ParseIP(ip).To4()
mask := net.CIDRMask(maskBits, 32)
dnsMgrPrivate.cidr = binary.BigEndian.Uint32(dnsip) & binary.BigEndian.Uint32(mask)
From 32df96f5174e7c6d5b46157b77afbf8617c8a2dc Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Mon, 8 Feb 2021 18:29:09 -0500
Subject: [PATCH 04/20] update versions of assemblies and add the nuget ref to
DnsClient
---
DesktopEdge/Properties/AssemblyInfo.cs | 6 +++---
Installer/ZitiDesktopEdge.aip | 4 ++--
ZitiUpdateService/Properties/AssemblyInfo.cs | 6 +++---
ZitiUpdateService/packages.config | 2 ++
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/DesktopEdge/Properties/AssemblyInfo.cs b/DesktopEdge/Properties/AssemblyInfo.cs
index 7841b0c5..206acfd2 100644
--- a/DesktopEdge/Properties/AssemblyInfo.cs
+++ b/DesktopEdge/Properties/AssemblyInfo.cs
@@ -50,6 +50,6 @@ 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.7.6.0")]
-[assembly: AssemblyVersion("1.7.6.0")]
-[assembly: AssemblyFileVersion("1.7.6.0")]
+// [assembly: AssemblyVersion("1.7.8.0")]
+[assembly: AssemblyVersion("1.7.8.0")]
+[assembly: AssemblyFileVersion("1.7.8.0")]
diff --git a/Installer/ZitiDesktopEdge.aip b/Installer/ZitiDesktopEdge.aip
index 73373d6d..862c6a01 100644
--- a/Installer/ZitiDesktopEdge.aip
+++ b/Installer/ZitiDesktopEdge.aip
@@ -22,10 +22,10 @@
-
+
-
+
diff --git a/ZitiUpdateService/Properties/AssemblyInfo.cs b/ZitiUpdateService/Properties/AssemblyInfo.cs
index 49d06c1f..6c862ebf 100644
--- a/ZitiUpdateService/Properties/AssemblyInfo.cs
+++ b/ZitiUpdateService/Properties/AssemblyInfo.cs
@@ -30,6 +30,6 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.7.6.0")]
-[assembly: AssemblyVersion("1.7.6.0")]
-[assembly: AssemblyFileVersion("1.7.6.0")]
+// [assembly: AssemblyVersion("1.7.8.0")]
+[assembly: AssemblyVersion("1.7.8.0")]
+[assembly: AssemblyFileVersion("1.7.8.0")]
diff --git a/ZitiUpdateService/packages.config b/ZitiUpdateService/packages.config
index 04f986fe..18c2b3df 100644
--- a/ZitiUpdateService/packages.config
+++ b/ZitiUpdateService/packages.config
@@ -1,6 +1,8 @@
+
+
\ No newline at end of file
From e834ed4c6bb65b914b21e5da161ae89c1795f132 Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Mon, 8 Feb 2021 18:30:32 -0500
Subject: [PATCH 05/20] remove small compiler warning
---
ZitiUpdateService/checkers/GithubCheck.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/ZitiUpdateService/checkers/GithubCheck.cs b/ZitiUpdateService/checkers/GithubCheck.cs
index 352aa6db..eeca9452 100644
--- a/ZitiUpdateService/checkers/GithubCheck.cs
+++ b/ZitiUpdateService/checkers/GithubCheck.cs
@@ -15,7 +15,6 @@ namespace ZitiUpdateService.checkers {
string url;
string downloadUrl = null;
string downloadFileName = null;
- string currentResponse = null;
Version nextVersion = null;
public GithubCheck(string url) {
From f1db5283d25b970d6b82466f102df015ecfb7430 Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Mon, 8 Feb 2021 18:47:33 -0500
Subject: [PATCH 06/20] implement dns probe from monitor with backoff on
logging
---
ZitiUpdateService/UpdateService.cs | 70 +++++++++++++++++++++-
ZitiUpdateService/ZitiUpdateService.csproj | 6 ++
2 files changed, 73 insertions(+), 3 deletions(-)
diff --git a/ZitiUpdateService/UpdateService.cs b/ZitiUpdateService/UpdateService.cs
index ee8a7442..67d5cd64 100644
--- a/ZitiUpdateService/UpdateService.cs
+++ b/ZitiUpdateService/UpdateService.cs
@@ -17,6 +17,8 @@ using ZitiDesktopEdge.Utility;
using NLog;
using Newtonsoft.Json;
+using DnsClient;
+using System.Net;
namespace ZitiUpdateService {
public partial class UpdateService : ServiceBase {
@@ -55,6 +57,9 @@ namespace ZitiUpdateService {
Task eventServer = null;
checkers.UpdateCheck check = null;
+ private Timer dnsProbeTimer = new Timer();
+ private IPAddress dnsIpAddress = null;
+
public UpdateService() {
InitializeComponent();
@@ -368,10 +373,61 @@ namespace ZitiUpdateService {
});
}
Logger.Info("ziti-monitor service is initialized and running");
+ dnsProbeTimer.Elapsed += DnsProbe_Elapsed;
+ dnsProbeTimer.Interval = dnsProbeIntervalInSeconds * 1000;
base.OnStart(args);
}
- async private Task onEventsClientAsync(StreamWriter writer) {
+ IPAddress lh = IPAddress.Parse("127.0.0.1"); //expected result
+ int dnsProbeFailCount = 0;
+ int dnsProbeIntervalInSeconds = 15;
+ bool dnsProbeStarted = false;
+
+ private void DnsProbe_Elapsed(object sender, ElapsedEventArgs e) {
+ if (dnsProbeStarted) return; //skip out if it's already going...
+ dnsProbeStarted = true;
+ try {
+ if (dnsIpAddress != null) {
+ DnsQuestion q = new DnsQuestion("dew-dns-probe.openziti.org", QueryType.A);
+ var dnsEp = new IPEndPoint(dnsIpAddress, 53);
+ var dnsProbe = new LookupClient(dnsEp);
+
+ foreach (DnsClient.Protocol.ARecord arec in dnsProbe.Query(q).AllRecords) {
+ if (arec.Address.Equals(lh)) {
+ dnsProbeFailCount = 0;
+ } else {
+ dnsProbeFailCount++;
+ logDnsProbeFailure(null);
+ }
+ }
+ }
+ } catch(Exception dnse) {
+ //don't really care but it probably means a timeout happened. but might as well log a trace error anyway...
+ //it's expected that this is due to the service shutting down...
+ dnsProbeFailCount++;
+ logDnsProbeFailure(dnse);
+ }
+ dnsProbeStarted = false;
+ }
+
+ private void logDnsProbeFailure(Exception e) {
+ bool logit = false;
+ if (dnsProbeFailCount <= 4) {
+ logit = true;
+ } else {
+ //else log it every 5 minutes...
+ logit = (5 * 60 / dnsProbeIntervalInSeconds) % dnsProbeFailCount == 0;
+ }
+ if (logit) {
+ if (e != null) {
+ Logger.Warn(e, "dns probe failed due to error. This has happened {0} times", dnsProbeFailCount);
+ } else {
+ Logger.Warn("dns probe failed. This has happened {0} times", dnsProbeFailCount);
+ }
+ }
+ }
+
+ async private Task onEventsClientAsync(StreamWriter writer) {
Logger.Info("a new events client was connected");
//reset to release stream
//initial status when connecting the event stream
@@ -711,18 +767,26 @@ namespace ZitiUpdateService {
EventRegistry.SendEventToConsumers(status);
}
- private static void Svc_OnTunnelStatusEvent(object sender, TunnelStatusEvent e) {
+ private void Svc_OnTunnelStatusEvent(object sender, TunnelStatusEvent e) {
string dns = e?.Status?.IpInfo?.DNS;
string version = e?.Status?.ServiceVersion.Version;
string op = e?.Op;
Logger.Info($"Operation {op}. running dns: {dns} at version {version}");
+
+ try {
+ dnsIpAddress = IPAddress.Parse(dns);
+ } catch {
+ //ignore it
+ }
}
- private static void Svc_OnClientConnected(object sender, object e) {
+ private void Svc_OnClientConnected(object sender, object e) {
Logger.Info("successfully connected to service");
+ dnsProbeTimer.Start();
}
private void Svc_OnClientDisconnected(object sender, object e) {
+ //dnsProbeTimer.Stop();
DataClient svc = (DataClient)sender;
if (svc.CleanShutdown) {
//then this is fine and expected - the service is shutting down
diff --git a/ZitiUpdateService/ZitiUpdateService.csproj b/ZitiUpdateService/ZitiUpdateService.csproj
index d2e99b4e..a2e7c843 100644
--- a/ZitiUpdateService/ZitiUpdateService.csproj
+++ b/ZitiUpdateService/ZitiUpdateService.csproj
@@ -76,6 +76,9 @@
bin\Releases\
+
+ ..\packages\DnsClient.1.3.2\lib\net471\DnsClient.dll
+
..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
@@ -83,6 +86,9 @@
..\packages\NLog.4.7.6\lib\net45\NLog.dll
+
+ ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll
+
From 8a5511eb2abad7b30c3e17ddd7d64337a3a39e71 Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Mon, 8 Feb 2021 18:49:14 -0500
Subject: [PATCH 07/20] fix mod math and some formatting
---
ZitiUpdateService/UpdateService.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ZitiUpdateService/UpdateService.cs b/ZitiUpdateService/UpdateService.cs
index 67d5cd64..142d68d5 100644
--- a/ZitiUpdateService/UpdateService.cs
+++ b/ZitiUpdateService/UpdateService.cs
@@ -416,7 +416,7 @@ namespace ZitiUpdateService {
logit = true;
} else {
//else log it every 5 minutes...
- logit = (5 * 60 / dnsProbeIntervalInSeconds) % dnsProbeFailCount == 0;
+ logit = dnsProbeFailCount % (5 * 60 / dnsProbeIntervalInSeconds) == 0;
}
if (logit) {
if (e != null) {
@@ -777,7 +777,7 @@ namespace ZitiUpdateService {
dnsIpAddress = IPAddress.Parse(dns);
} catch {
//ignore it
- }
+ }
}
private void Svc_OnClientConnected(object sender, object e) {
From 4d220b681cb4b508b809d2e574546268b04e7b98 Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Mon, 8 Feb 2021 18:49:43 -0500
Subject: [PATCH 08/20] format commit
---
ZitiUpdateService/UpdateService.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ZitiUpdateService/UpdateService.cs b/ZitiUpdateService/UpdateService.cs
index 142d68d5..b1d2c910 100644
--- a/ZitiUpdateService/UpdateService.cs
+++ b/ZitiUpdateService/UpdateService.cs
@@ -418,8 +418,8 @@ namespace ZitiUpdateService {
//else log it every 5 minutes...
logit = dnsProbeFailCount % (5 * 60 / dnsProbeIntervalInSeconds) == 0;
}
- if (logit) {
- if (e != null) {
+ if (logit) {
+ if (e != null) {
Logger.Warn(e, "dns probe failed due to error. This has happened {0} times", dnsProbeFailCount);
} else {
Logger.Warn("dns probe failed. This has happened {0} times", dnsProbeFailCount);
From 764b012b0c847cc2eb5c9bddded4f58b9bfd00ac Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Tue, 9 Feb 2021 15:24:21 -0500
Subject: [PATCH 09/20] update the log to be an error - not debug, when an
error happens
---
ZitiDesktopEdge.Client/ServiceClient/AbstractClient.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ZitiDesktopEdge.Client/ServiceClient/AbstractClient.cs b/ZitiDesktopEdge.Client/ServiceClient/AbstractClient.cs
index 81053e52..70a4ebe2 100644
--- a/ZitiDesktopEdge.Client/ServiceClient/AbstractClient.cs
+++ b/ZitiDesktopEdge.Client/ServiceClient/AbstractClient.cs
@@ -227,12 +227,12 @@ namespace ZitiDesktopEdge.ServiceClient {
return respAsString;
} catch (IOException ioe) {
//almost certainly a problem with the pipe
- Logger.Debug("io error in read: " + ioe.Message);
+ Logger.Error(ioe, "io error in read: " + ioe.Message);
ClientDisconnected(null);
throw ioe;
} catch (Exception ee) {
//almost certainly a problem with the pipe
- Logger.Debug("unexpected error in read: " + ee.Message);
+ Logger.Error(ee, "unexpected error in read: " + ee.Message);
ClientDisconnected(null);
throw ee;
}
From c274ae139f8af4724acc00ee649889abbed7be3d Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Tue, 9 Feb 2021 16:44:44 -0500
Subject: [PATCH 10/20] tweak some logging around the dns probe
---
ZitiUpdateService/UpdateService.cs | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/ZitiUpdateService/UpdateService.cs b/ZitiUpdateService/UpdateService.cs
index b1d2c910..5a7d2b08 100644
--- a/ZitiUpdateService/UpdateService.cs
+++ b/ZitiUpdateService/UpdateService.cs
@@ -360,6 +360,9 @@ namespace ZitiUpdateService {
AccessUtils.GrantAccessToFile(Path.Combine(exeLocation, "ZitiDesktopEdge.exe.config")); //allow anyone to change the config file
AccessUtils.GrantAccessToFile(Path.Combine(exeLocation, "ZitiDesktopEdge-log.config")); //allow anyone to change the log file config
+ dnsProbeTimer.Elapsed += DnsProbe_Elapsed;
+ dnsProbeTimer.Interval = dnsProbeIntervalInSeconds * 1000;
+
Logger.Info("starting ipc server");
ipcServer = svr.startIpcServerAsync(onIpcClientAsync);
Logger.Info("starting events server");
@@ -373,8 +376,6 @@ namespace ZitiUpdateService {
});
}
Logger.Info("ziti-monitor service is initialized and running");
- dnsProbeTimer.Elapsed += DnsProbe_Elapsed;
- dnsProbeTimer.Interval = dnsProbeIntervalInSeconds * 1000;
base.OnStart(args);
}
@@ -386,6 +387,7 @@ namespace ZitiUpdateService {
private void DnsProbe_Elapsed(object sender, ElapsedEventArgs e) {
if (dnsProbeStarted) return; //skip out if it's already going...
dnsProbeStarted = true;
+ Logger.Trace("dns probe started");
try {
if (dnsIpAddress != null) {
DnsQuestion q = new DnsQuestion("dew-dns-probe.openziti.org", QueryType.A);
@@ -395,6 +397,7 @@ namespace ZitiUpdateService {
foreach (DnsClient.Protocol.ARecord arec in dnsProbe.Query(q).AllRecords) {
if (arec.Address.Equals(lh)) {
dnsProbeFailCount = 0;
+ Logger.Debug("dns probe success");
} else {
dnsProbeFailCount++;
logDnsProbeFailure(null);
@@ -782,7 +785,11 @@ namespace ZitiUpdateService {
private void Svc_OnClientConnected(object sender, object e) {
Logger.Info("successfully connected to service");
- dnsProbeTimer.Start();
+ if (!dnsProbeTimer.Enabled) {
+ dnsProbeTimer.Enabled = true;
+ dnsProbeTimer.Start();
+ Logger.Info("DNS Probe enabled");
+ }
}
private void Svc_OnClientDisconnected(object sender, object e) {
From dfde600d489a225fa646ae41cee945a5b643f18f Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Tue, 9 Feb 2021 17:07:58 -0500
Subject: [PATCH 11/20] forgot to include dll in installer. update release
notes and build script
---
Installer/ZitiDesktopEdge.aip | 3 +++
release-notes.md | 18 ++++++++++++++++++
service/build.bat | 2 +-
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/Installer/ZitiDesktopEdge.aip b/Installer/ZitiDesktopEdge.aip
index 862c6a01..f165da32 100644
--- a/Installer/ZitiDesktopEdge.aip
+++ b/Installer/ZitiDesktopEdge.aip
@@ -50,6 +50,7 @@
+
@@ -87,6 +88,7 @@
+
@@ -248,6 +250,7 @@
+
diff --git a/release-notes.md b/release-notes.md
index 0e5ff903..758b4ead 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -1,3 +1,20 @@
+# Release 1.7.8
+
+## What's New
+* a new DNS probe record was added to the DNS server to allow DNS-related testing
+* ziti-monitor service now probes the DNS server for diagnostic reasons
+* added code to check upgrade status - only useful when the ziti-monitor service is not running
+
+## Other changes:
+* minor logging updates
+
+## Bugs fixed:
+* fixed an issue with hosting connections after channel failure [CSDK #233](https://github.com/openziti/ziti-sdk-c/pull/233)
+* fixed a UI issue when no identites existed
+
+## Dependency Updates
+* Tunneler SDK to v0.8.17/CSDK 0.20.12
+
# Release 1.7.7
## What's New
@@ -11,6 +28,7 @@
## Dependency Updates
* Tunneler SDK to v0.8.15
+
# Release 1.7.6
## What's New
diff --git a/service/build.bat b/service/build.bat
index dac04bcb..77291a63 100644
--- a/service/build.bat
+++ b/service/build.bat
@@ -14,7 +14,7 @@ REM See the License for the specific language governing permissions and
REM limitations under the License.
REM
SET REPO_URL=https://github.com/openziti/ziti-tunnel-sdk-c.git
-SET ZITI_TUNNEL_REPO_BRANCH=v0.8.16
+SET ZITI_TUNNEL_REPO_BRANCH=v0.8.17
REM override the c sdk used in the build - leave blank for the same as specified in the tunneler sdk
SET ZITI_SDK_C_BRANCH=
REM the number of TCP connections the tunneler sdk can have at any one time
From 7a3976e7882fb6ae2a807f0df8a17844026a6be8 Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Tue, 9 Feb 2021 17:37:56 -0500
Subject: [PATCH 12/20] System.Buffers also needed in installer
---
Installer/ZitiDesktopEdge.aip | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Installer/ZitiDesktopEdge.aip b/Installer/ZitiDesktopEdge.aip
index f165da32..c1fcd02f 100644
--- a/Installer/ZitiDesktopEdge.aip
+++ b/Installer/ZitiDesktopEdge.aip
@@ -55,6 +55,7 @@
+
@@ -89,6 +90,7 @@
+
@@ -251,6 +253,7 @@
+
From 288fb4a06d638118617f89c9a52cf754a113858a Mon Sep 17 00:00:00 2001
From: Mary Lincy Dcouto
Date: Thu, 18 Feb 2021 23:10:03 +0530
Subject: [PATCH 13/20] scan and copy from backup folder
---
service/ziti-tunnel/config/config.go | 76 ++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/service/ziti-tunnel/config/config.go b/service/ziti-tunnel/config/config.go
index d5f54fc4..2391aad5 100644
--- a/service/ziti-tunnel/config/config.go
+++ b/service/ziti-tunnel/config/config.go
@@ -18,9 +18,12 @@
package config
import (
+ "fmt"
+ "io"
"log"
"os"
"path/filepath"
+ "strings"
)
func ExecutablePath() string {
@@ -62,3 +65,76 @@ func ensureFolder(path string) error {
}
return nil
}
+func ScanAndCopyFromBackup() error {
+ srcBackUpPaths := [2]string{"\\Windows.~BT", "\\Windows.old"}
+ sysRoot := os.Getenv("SYSTEMROOT")
+ if sysRoot == "" {
+ return nil
+ }
+ for _, srcPath := range srcBackUpPaths {
+ sourcePath := sysRoot + srcPath
+ _, err := os.Stat(sourcePath)
+ if err != nil {
+ log.Debugf("Folder %s does not exist", sourcePath)
+ continue
+ }
+ err = searchAndCopyFilesFromBackup(sourcePath)
+ if err != nil {
+ fmt.Printf("Copy files from %s failed, %v", sourcePath, err)
+ }
+ }
+ return nil
+}
+
+func searchAndCopyFilesFromBackup(srcPath string) error {
+ err := filepath.Walk(srcPath, visit)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func visit(path string, f os.FileInfo, err error) error {
+ if strings.Contains(path, "config\\systemprofile\\AppData\\Roaming\\NetFoundry") && !f.IsDir() {
+ log.Infof("\nFound: %s\n", path)
+ destinationFile := filepath.Join(Path(), string(os.PathSeparator), f.Name())
+ nBytes, err := copy(path, destinationFile)
+ if err != nil {
+ log.Errorf("Error occured while Copying the file %s, %v", f.Name(), err)
+ return err
+ } else {
+ log.Infof("Copied the file %s, %d bytes transfered", f.Name(), nBytes)
+ log.Infof("Removing file %s", path)
+ err := os.Remove(path)
+ if err != nil {
+ log.Warnf("Could not remove file %v", err)
+ }
+ }
+ }
+ return nil
+}
+
+func copy(src, dst string) (int64, error) {
+ sourceFileStat, err := os.Stat(src)
+ if err != nil {
+ return 0, err
+ }
+
+ if !sourceFileStat.Mode().IsRegular() {
+ return 0, fmt.Errorf("%s is not a regular file", src)
+ }
+
+ source, err := os.Open(src)
+ if err != nil {
+ return 0, err
+ }
+ defer source.Close()
+
+ destination, err := os.Create(dst)
+ if err != nil {
+ return 0, err
+ }
+ defer destination.Close()
+ nBytes, err := io.Copy(destination, source)
+ return nBytes, err
+}
From 36043c59d03b7887cecf35a4c73f31f6b5998e55 Mon Sep 17 00:00:00 2001
From: Mary Lincy Dcouto
Date: Fri, 19 Feb 2021 00:22:12 +0530
Subject: [PATCH 14/20] remove files from the backup folder
---
service/ziti-tunnel/config/config.go | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/service/ziti-tunnel/config/config.go b/service/ziti-tunnel/config/config.go
index 2391aad5..dbb004e4 100644
--- a/service/ziti-tunnel/config/config.go
+++ b/service/ziti-tunnel/config/config.go
@@ -98,21 +98,31 @@ func visit(path string, f os.FileInfo, err error) error {
if strings.Contains(path, "config\\systemprofile\\AppData\\Roaming\\NetFoundry") && !f.IsDir() {
log.Infof("\nFound: %s\n", path)
destinationFile := filepath.Join(Path(), string(os.PathSeparator), f.Name())
+ //check if the file is present in the destination folder
+ _, err := os.Stat(destinationFile)
+ if err == nil && !strings.Contains(f.Name(), "config.json") {
+ fmt.Printf("File %s is already present in the config path and it is not config.json, So not transfering", f.Name())
+ deleteFile(path)
+ return nil
+ }
nBytes, err := copy(path, destinationFile)
if err != nil {
log.Errorf("Error occured while Copying the file %s, %v", f.Name(), err)
return err
} else {
log.Infof("Copied the file %s, %d bytes transfered", f.Name(), nBytes)
- log.Infof("Removing file %s", path)
- err := os.Remove(path)
- if err != nil {
- log.Warnf("Could not remove file %v", err)
- }
+ deleteFile(path)
}
}
return nil
}
+func deleteFile(path string) {
+ fmt.Printf("\nRemoving file %s", path)
+ err := os.Remove(path)
+ if err != nil {
+ fmt.Println(err)
+ }
+}
func copy(src, dst string) (int64, error) {
sourceFileStat, err := os.Stat(src)
From ad97457dbd9f38ba812294a4505f507b6207bf3d Mon Sep 17 00:00:00 2001
From: Mary Lincy Dcouto
Date: Fri, 19 Feb 2021 00:32:52 +0530
Subject: [PATCH 15/20] changing the root path to systemdrive
---
service/ziti-tunnel/config/config.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/service/ziti-tunnel/config/config.go b/service/ziti-tunnel/config/config.go
index dbb004e4..8568c316 100644
--- a/service/ziti-tunnel/config/config.go
+++ b/service/ziti-tunnel/config/config.go
@@ -67,7 +67,7 @@ func ensureFolder(path string) error {
}
func ScanAndCopyFromBackup() error {
srcBackUpPaths := [2]string{"\\Windows.~BT", "\\Windows.old"}
- sysRoot := os.Getenv("SYSTEMROOT")
+ sysRoot := os.Getenv("SystemDrive")
if sysRoot == "" {
return nil
}
From a1546e12c681014b0d95a614cd5576799b3939c0 Mon Sep 17 00:00:00 2001
From: Mary Lincy Dcouto
Date: Fri, 19 Feb 2021 01:10:05 +0530
Subject: [PATCH 16/20] moving backup config functions to service package
---
service/ziti-tunnel/config/config.go | 86 -----------------
.../service/orphaned-identities.go | 95 +++++++++++++++++++
service/ziti-tunnel/service/state.go | 46 ++++-----
3 files changed, 119 insertions(+), 108 deletions(-)
create mode 100644 service/ziti-tunnel/service/orphaned-identities.go
diff --git a/service/ziti-tunnel/config/config.go b/service/ziti-tunnel/config/config.go
index 8568c316..d5f54fc4 100644
--- a/service/ziti-tunnel/config/config.go
+++ b/service/ziti-tunnel/config/config.go
@@ -18,12 +18,9 @@
package config
import (
- "fmt"
- "io"
"log"
"os"
"path/filepath"
- "strings"
)
func ExecutablePath() string {
@@ -65,86 +62,3 @@ func ensureFolder(path string) error {
}
return nil
}
-func ScanAndCopyFromBackup() error {
- srcBackUpPaths := [2]string{"\\Windows.~BT", "\\Windows.old"}
- sysRoot := os.Getenv("SystemDrive")
- if sysRoot == "" {
- return nil
- }
- for _, srcPath := range srcBackUpPaths {
- sourcePath := sysRoot + srcPath
- _, err := os.Stat(sourcePath)
- if err != nil {
- log.Debugf("Folder %s does not exist", sourcePath)
- continue
- }
- err = searchAndCopyFilesFromBackup(sourcePath)
- if err != nil {
- fmt.Printf("Copy files from %s failed, %v", sourcePath, err)
- }
- }
- return nil
-}
-
-func searchAndCopyFilesFromBackup(srcPath string) error {
- err := filepath.Walk(srcPath, visit)
- if err != nil {
- return err
- }
- return nil
-}
-
-func visit(path string, f os.FileInfo, err error) error {
- if strings.Contains(path, "config\\systemprofile\\AppData\\Roaming\\NetFoundry") && !f.IsDir() {
- log.Infof("\nFound: %s\n", path)
- destinationFile := filepath.Join(Path(), string(os.PathSeparator), f.Name())
- //check if the file is present in the destination folder
- _, err := os.Stat(destinationFile)
- if err == nil && !strings.Contains(f.Name(), "config.json") {
- fmt.Printf("File %s is already present in the config path and it is not config.json, So not transfering", f.Name())
- deleteFile(path)
- return nil
- }
- nBytes, err := copy(path, destinationFile)
- if err != nil {
- log.Errorf("Error occured while Copying the file %s, %v", f.Name(), err)
- return err
- } else {
- log.Infof("Copied the file %s, %d bytes transfered", f.Name(), nBytes)
- deleteFile(path)
- }
- }
- return nil
-}
-func deleteFile(path string) {
- fmt.Printf("\nRemoving file %s", path)
- err := os.Remove(path)
- if err != nil {
- fmt.Println(err)
- }
-}
-
-func copy(src, dst string) (int64, error) {
- sourceFileStat, err := os.Stat(src)
- if err != nil {
- return 0, err
- }
-
- if !sourceFileStat.Mode().IsRegular() {
- return 0, fmt.Errorf("%s is not a regular file", src)
- }
-
- source, err := os.Open(src)
- if err != nil {
- return 0, err
- }
- defer source.Close()
-
- destination, err := os.Create(dst)
- if err != nil {
- return 0, err
- }
- defer destination.Close()
- nBytes, err := io.Copy(destination, source)
- return nBytes, err
-}
diff --git a/service/ziti-tunnel/service/orphaned-identities.go b/service/ziti-tunnel/service/orphaned-identities.go
new file mode 100644
index 00000000..8c4fb3db
--- /dev/null
+++ b/service/ziti-tunnel/service/orphaned-identities.go
@@ -0,0 +1,95 @@
+package service
+
+import (
+ "fmt"
+ "io"
+ "os"
+ "path/filepath"
+ "strings"
+
+ "github.com/openziti/desktop-edge-win/service/ziti-tunnel/config"
+)
+
+func ScanAndCopyFromBackup() error {
+ srcBackUpPaths := [2]string{"\\Windows.~BT", "\\Windows.old"}
+ sysRoot := os.Getenv("SystemDrive")
+ if sysRoot == "" {
+ return nil
+ }
+ for _, srcPath := range srcBackUpPaths {
+ sourcePath := sysRoot + srcPath
+ _, err := os.Stat(sourcePath)
+ if err != nil {
+ log.Debugf("Folder %s does not exist", sourcePath)
+ continue
+ }
+ err = searchAndCopyFilesFromBackup(sourcePath)
+ if err != nil {
+ fmt.Printf("Copy files from %s failed, %v", sourcePath, err)
+ }
+ }
+ return nil
+}
+
+func searchAndCopyFilesFromBackup(srcPath string) error {
+ err := filepath.Walk(srcPath, visit)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func visit(path string, f os.FileInfo, err error) error {
+ if strings.Contains(path, "config\\systemprofile\\AppData\\Roaming\\NetFoundry") && !f.IsDir() {
+ log.Infof("\nFound: %s\n", path)
+ destinationFile := filepath.Join(config.Path(), string(os.PathSeparator), f.Name())
+ //check if the file is present in the destination folder
+ _, err := os.Stat(destinationFile)
+ if err == nil && !strings.Contains(f.Name(), "config.json") {
+ fmt.Printf("File %s is already present in the config path and it is not config.json, So not transfering", f.Name())
+ deleteFile(path)
+ return nil
+ }
+ nBytes, err := copy(path, destinationFile)
+ if err != nil {
+ log.Errorf("Error occured while Copying the file %s, %v", f.Name(), err)
+ return err
+ } else {
+ log.Infof("Copied the file %s, %d bytes transfered", f.Name(), nBytes)
+ deleteFile(path)
+ }
+ }
+ return nil
+}
+func deleteFile(path string) {
+ fmt.Printf("\nRemoving file %s", path)
+ err := os.Remove(path)
+ if err != nil {
+ fmt.Println(err)
+ }
+}
+
+func copy(src, dst string) (int64, error) {
+ sourceFileStat, err := os.Stat(src)
+ if err != nil {
+ return 0, err
+ }
+
+ if !sourceFileStat.Mode().IsRegular() {
+ return 0, fmt.Errorf("%s is not a regular file", src)
+ }
+
+ source, err := os.Open(src)
+ if err != nil {
+ return 0, err
+ }
+ defer source.Close()
+
+ destination, err := os.Create(dst)
+ if err != nil {
+ return 0, err
+ }
+ defer destination.Close()
+ nBytes, err := io.Copy(destination, source)
+ return nBytes, err
+}
diff --git a/service/ziti-tunnel/service/state.go b/service/ziti-tunnel/service/state.go
index 4453dad5..1b644b0a 100644
--- a/service/ziti-tunnel/service/state.go
+++ b/service/ziti-tunnel/service/state.go
@@ -21,6 +21,14 @@ import (
"bufio"
"encoding/json"
"fmt"
+ "io"
+ "io/ioutil"
+ "net"
+ "os"
+ "path"
+ "strings"
+ "time"
+
"github.com/openziti/desktop-edge-win/service/cziti"
"github.com/openziti/desktop-edge-win/service/ziti-tunnel/config"
"github.com/openziti/desktop-edge-win/service/ziti-tunnel/constants"
@@ -29,13 +37,6 @@ import (
"golang.org/x/sys/windows/registry"
"golang.zx2c4.com/wireguard/tun"
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"
- "io"
- "io/ioutil"
- "net"
- "os"
- "path"
- "strings"
- "time"
)
type RuntimeState struct {
@@ -58,7 +59,7 @@ func (t *RuntimeState) SaveState() {
_ = os.MkdirAll(config.Path(), 0644)
log.Debugf("backing up config")
- backup,err := backupConfig()
+ backup, err := backupConfig()
if err != nil {
log.Warnf("could not backup config file! %v", err)
} else {
@@ -141,16 +142,16 @@ func (t *RuntimeState) ToStatus(onlyInitialized bool) dto.TunnelStatus {
func (t *RuntimeState) ToMetrics() dto.TunnelStatus {
clean := dto.TunnelStatus{
- Identities: make([]*dto.Identity, len(t.ids)),
+ Identities: make([]*dto.Identity, len(t.ids)),
}
i := 0
for _, id := range t.ids {
AddMetrics(id)
clean.Identities[i] = &dto.Identity{
- Name: id.Name,
- FingerPrint: id.FingerPrint,
- Metrics: id.Metrics,
+ Name: id.Name,
+ FingerPrint: id.FingerPrint,
+ Metrics: id.Metrics,
}
i++
}
@@ -160,7 +161,7 @@ func (t *RuntimeState) ToMetrics() dto.TunnelStatus {
func (t *RuntimeState) CreateTun(ipv4 string, ipv4mask int) (net.IP, *tun.Device, error) {
log.Infof("creating TUN device: %s", TunName)
- tunDevice, err := tun.CreateTUN(TunName, 64*1024 - 1)
+ tunDevice, err := tun.CreateTUN(TunName, 64*1024-1)
if err == nil {
t.tun = &tunDevice
tunName, err2 := tunDevice.Name()
@@ -201,7 +202,7 @@ func (t *RuntimeState) CreateTun(ipv4 string, ipv4mask int) (net.IP, *tun.Device
return nil, nil, fmt.Errorf("failed to set IP address to %v: (%v)", ip, err)
}
- dnsServers := []net.IP{ ip }
+ dnsServers := []net.IP{ip}
log.Infof("adding DNS servers to TUN: %s", dnsServers)
err = luid.AddDNS(dnsServers)
@@ -217,7 +218,7 @@ func (t *RuntimeState) CreateTun(ipv4 string, ipv4mask int) (net.IP, *tun.Device
log.Infof("TUN dns servers set to: %s", dns)
log.Infof("setting routes for cidr: %s. Next Hop: %s", ipnet.String(), ipnet.IP.String())
- err = luid.SetRoutes([]*winipcfg.RouteData{{ Destination: *ipnet, NextHop: ipnet.IP, Metric: 0}})
+ err = luid.SetRoutes([]*winipcfg.RouteData{{Destination: *ipnet, NextHop: ipnet.IP, Metric: 0}})
if err != nil {
return nil, nil, fmt.Errorf("failed to SetRoutes: (%v)", err)
}
@@ -233,7 +234,7 @@ func (t *RuntimeState) LoadIdentity(id *Id, refreshInterval int) {
}
_, err := os.Stat(id.Path())
- if err != nil{
+ if err != nil {
if os.IsNotExist(err) {
//file does not exist. TODO remove this from the list
} else {
@@ -244,7 +245,7 @@ func (t *RuntimeState) LoadIdentity(id *Id, refreshInterval int) {
log.Infof("loading identity %s[%s]", id.Name, id.FingerPrint)
- sc := func(status int){
+ sc := func(status int) {
log.Infof("status change! %d", status)
id.ControllerVersion = id.CId.Version
@@ -267,7 +268,7 @@ func (t *RuntimeState) LoadIdentity(id *Id, refreshInterval int) {
events.broadcast <- dto.IdentityEvent{
ActionEvent: IDENTITY_ADDED,
- Id: id.Identity,
+ Id: id.Identity,
}
log.Infof("connecting identity completed: %s[%s]", id.Name, id.FingerPrint)
}
@@ -278,6 +279,7 @@ func (t *RuntimeState) LoadIdentity(id *Id, refreshInterval int) {
}
func (t *RuntimeState) LoadConfig() {
+ ScanAndCopyFromBackup()
err := readConfig(t, config.File())
if err != nil {
err = readConfig(t, config.BackupFile())
@@ -319,7 +321,7 @@ func (t *RuntimeState) scanForOrphanedIdentities(folder string) {
fingerprint := strings.Split(f.Name(), ".")[0]
var found *dto.Identity
for _, sid := range t.state.Identities {
- if sid.FingerPrint == fingerprint{
+ if sid.FingerPrint == fingerprint {
found = sid
break
}
@@ -387,11 +389,11 @@ func readConfig(t *RuntimeState, filename string) error {
return nil
}
-func (t *RuntimeState) UpdateIpv4Mask(ipv4mask int){
+func (t *RuntimeState) UpdateIpv4Mask(ipv4mask int) {
rts.state.TunIpv4Mask = ipv4mask
rts.SaveState()
}
-func (t *RuntimeState) UpdateIpv4(ipv4 string){
+func (t *RuntimeState) UpdateIpv4(ipv4 string) {
rts.state.TunIpv4 = ipv4
rts.SaveState()
}
@@ -447,7 +449,7 @@ func (t *RuntimeState) Close() {
t.RemoveZitiTun()
}
-func(t *RuntimeState) RemoveZitiTun() {
+func (t *RuntimeState) RemoveZitiTun() {
log.Infof("Removing existing interface: %s", TunName)
wt, err := tun.WintunPool.OpenAdapter(TunName)
if err == nil {
From 7a5b5866a5b196f855b102cee01ae0a450c03fb1 Mon Sep 17 00:00:00 2001
From: Mary Lincy Dcouto
Date: Fri, 19 Feb 2021 20:58:45 +0530
Subject: [PATCH 17/20] changes as per the code review comments
---
.../service/orphaned-identities.go | 34 +++++++++++--------
service/ziti-tunnel/service/pkg-vars.go | 24 +++++++------
service/ziti-tunnel/service/state.go | 2 +-
3 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/service/ziti-tunnel/service/orphaned-identities.go b/service/ziti-tunnel/service/orphaned-identities.go
index 8c4fb3db..f2841538 100644
--- a/service/ziti-tunnel/service/orphaned-identities.go
+++ b/service/ziti-tunnel/service/orphaned-identities.go
@@ -1,6 +1,7 @@
package service
import (
+ "errors"
"fmt"
"io"
"os"
@@ -10,14 +11,17 @@ import (
"github.com/openziti/desktop-edge-win/service/ziti-tunnel/config"
)
-func ScanAndCopyFromBackup() error {
- srcBackUpPaths := [2]string{"\\Windows.~BT", "\\Windows.old"}
- sysRoot := os.Getenv("SystemDrive")
- if sysRoot == "" {
+// After System update, the identity files are not getting copied to the config path
+// So we are adding a function to scan for identities in the backtup location
+func scanForIdentitiesPostWindowsUpdate() error {
+ srcBackUpPaths := [2]string{"Windows.~BT\\Windows\\System32\\config\\systemprofile\\AppData\\Roaming\\NetFoundry",
+ "Windows.old\\Windows\\System32\\config\\systemprofile\\AppData\\Roaming\\NetFoundry"}
+ systemDrivePath := os.Getenv("SystemDrive")
+ if systemDrivePath == "" {
return nil
}
for _, srcPath := range srcBackUpPaths {
- sourcePath := sysRoot + srcPath
+ sourcePath := filepath.Join(systemDrivePath, string(os.PathSeparator), srcPath)
_, err := os.Stat(sourcePath)
if err != nil {
log.Debugf("Folder %s does not exist", sourcePath)
@@ -25,27 +29,27 @@ func ScanAndCopyFromBackup() error {
}
err = searchAndCopyFilesFromBackup(sourcePath)
if err != nil {
- fmt.Printf("Copy files from %s failed, %v", sourcePath, err)
+ log.Debugf("Copy files from %s failed, %v", sourcePath, err)
}
}
return nil
}
func searchAndCopyFilesFromBackup(srcPath string) error {
- err := filepath.Walk(srcPath, visit)
+ err := filepath.Walk(srcPath, copyFilesFromBackUp)
if err != nil {
return err
}
return nil
}
-func visit(path string, f os.FileInfo, err error) error {
- if strings.Contains(path, "config\\systemprofile\\AppData\\Roaming\\NetFoundry") && !f.IsDir() {
- log.Infof("\nFound: %s\n", path)
+func copyFilesFromBackUp(path string, f os.FileInfo, err error) error {
+ if !f.IsDir() {
+ log.Infof("Found: %s", path)
destinationFile := filepath.Join(config.Path(), string(os.PathSeparator), f.Name())
//check if the file is present in the destination folder
_, err := os.Stat(destinationFile)
- if err == nil && !strings.Contains(f.Name(), "config.json") {
+ if err == nil && !strings.Contains(f.Name(), ConfigFile) {
fmt.Printf("File %s is already present in the config path and it is not config.json, So not transfering", f.Name())
deleteFile(path)
return nil
@@ -62,10 +66,12 @@ func visit(path string, f os.FileInfo, err error) error {
return nil
}
func deleteFile(path string) {
- fmt.Printf("\nRemoving file %s", path)
+ log.Infof("Removing file %s", path)
err := os.Remove(path)
if err != nil {
- fmt.Println(err)
+ log.Infof("Error occured while removing the file %s, %v", path, err)
+ } else {
+ log.Infof("Removed file %s", path)
}
}
@@ -76,7 +82,7 @@ func copy(src, dst string) (int64, error) {
}
if !sourceFileStat.Mode().IsRegular() {
- return 0, fmt.Errorf("%s is not a regular file", src)
+ return 0, errors.New(fmt.Sprintf("%s is not a regular file", src))
}
source, err := os.Open(src)
diff --git a/service/ziti-tunnel/service/pkg-vars.go b/service/ziti-tunnel/service/pkg-vars.go
index 339b69a3..fba29d25 100644
--- a/service/ziti-tunnel/service/pkg-vars.go
+++ b/service/ziti-tunnel/service/pkg-vars.go
@@ -18,12 +18,14 @@
package service
import (
+ "sync"
+ "time"
+
"github.com/openziti/desktop-edge-win/service/ziti-tunnel/dto"
"github.com/openziti/desktop-edge-win/service/ziti-tunnel/util/logging"
"golang.org/x/sys/windows/svc"
- "sync"
- "time"
)
+
var Version dto.ServiceVersion
var pipeBase = `\\.\pipe\OpenZiti\ziti\`
@@ -42,7 +44,7 @@ var Debug bool
var TunStarted time.Time
var log = logging.Logger()
-var events = newTopic(32)
+var events = newTopic(32)
const (
API_VERSION = 1
@@ -60,13 +62,13 @@ const (
cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown | svc.AcceptPauseAndContinue
InformationEvent = 0 //1
- ContinueEvent = 0 //2
- PauseEvent = 0 //3
- InstallEvent = 0 //4
+ ContinueEvent = 0 //2
+ PauseEvent = 0 //3
+ InstallEvent = 0 //4
InterrogateEvent = 0 //5
- StopEvent = 0 //6
- ShutdownEvent = 0 //7
- ErrorEvent = 0 //1000
+ StopEvent = 0 //6
+ ShutdownEvent = 0 //7
+ ErrorEvent = 0 //1000
// This is the name you will use for the NET START command
SvcStartName = "ziti"
@@ -88,7 +90,9 @@ const (
LocalService = "(A;;FA;;;LS)"
NF_GROUP_NAME = "NetFoundry Tunneler Users"
- TunName = "ZitiTUN"
+ TunName = "ZitiTUN"
STATUS_ENROLLED = "enrolled"
+
+ ConfigFile = "config.json"
)
diff --git a/service/ziti-tunnel/service/state.go b/service/ziti-tunnel/service/state.go
index 1b644b0a..9e83ec1c 100644
--- a/service/ziti-tunnel/service/state.go
+++ b/service/ziti-tunnel/service/state.go
@@ -279,7 +279,7 @@ func (t *RuntimeState) LoadIdentity(id *Id, refreshInterval int) {
}
func (t *RuntimeState) LoadConfig() {
- ScanAndCopyFromBackup()
+ scanForIdentitiesPostWindowsUpdate()
err := readConfig(t, config.File())
if err != nil {
err = readConfig(t, config.BackupFile())
From 272a0da6e179f90b910b4d3d76cd9450fd90135a Mon Sep 17 00:00:00 2001
From: Mary Lincy Dcouto
Date: Fri, 19 Feb 2021 22:44:03 +0530
Subject: [PATCH 18/20] changing the log levels
---
service/ziti-tunnel/service/orphaned-identities.go | 10 +++++-----
service/ziti-tunnel/service/pkg-vars.go | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/service/ziti-tunnel/service/orphaned-identities.go b/service/ziti-tunnel/service/orphaned-identities.go
index f2841538..8efe8638 100644
--- a/service/ziti-tunnel/service/orphaned-identities.go
+++ b/service/ziti-tunnel/service/orphaned-identities.go
@@ -49,17 +49,17 @@ func copyFilesFromBackUp(path string, f os.FileInfo, err error) error {
destinationFile := filepath.Join(config.Path(), string(os.PathSeparator), f.Name())
//check if the file is present in the destination folder
_, err := os.Stat(destinationFile)
- if err == nil && !strings.Contains(f.Name(), ConfigFile) {
- fmt.Printf("File %s is already present in the config path and it is not config.json, So not transfering", f.Name())
+ if err == nil && !strings.Contains(f.Name(), ConfigFileName) {
+ log.Debugf("File %s is already present in the config path and it is not %s, So not transfering", f.Name(), ConfigFileName)
deleteFile(path)
return nil
}
nBytes, err := copy(path, destinationFile)
if err != nil {
- log.Errorf("Error occured while Copying the file %s, %v", f.Name(), err)
+ log.Errorf("Error occurred while copying the Windows backup folder %s --> %s %v", f.Name(), destinationFile, err)
return err
} else {
- log.Infof("Copied the file %s, %d bytes transfered", f.Name(), nBytes)
+ log.Infof("Found backup file at %s. Restored this file to %s", path, destinationFile)
deleteFile(path)
}
}
@@ -69,7 +69,7 @@ func deleteFile(path string) {
log.Infof("Removing file %s", path)
err := os.Remove(path)
if err != nil {
- log.Infof("Error occured while removing the file %s, %v", path, err)
+ log.Errorf("Error occured while removing the file %s, %v", path, err)
} else {
log.Infof("Removed file %s", path)
}
diff --git a/service/ziti-tunnel/service/pkg-vars.go b/service/ziti-tunnel/service/pkg-vars.go
index fba29d25..8636deb6 100644
--- a/service/ziti-tunnel/service/pkg-vars.go
+++ b/service/ziti-tunnel/service/pkg-vars.go
@@ -94,5 +94,5 @@ const (
STATUS_ENROLLED = "enrolled"
- ConfigFile = "config.json"
+ ConfigFileName = "config.json"
)
From 8093a96a635dc966b0bf4519b2c0a5cf9fb4fe6d Mon Sep 17 00:00:00 2001
From: Mary Lincy Dcouto
Date: Fri, 19 Feb 2021 23:38:02 +0530
Subject: [PATCH 19/20] fixing compilation error
---
service/ziti-tunnel/service/orphaned-identities.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/service/ziti-tunnel/service/orphaned-identities.go b/service/ziti-tunnel/service/orphaned-identities.go
index 8efe8638..af6f5c10 100644
--- a/service/ziti-tunnel/service/orphaned-identities.go
+++ b/service/ziti-tunnel/service/orphaned-identities.go
@@ -54,10 +54,10 @@ func copyFilesFromBackUp(path string, f os.FileInfo, err error) error {
deleteFile(path)
return nil
}
- nBytes, err := copy(path, destinationFile)
+ _, err = copy(path, destinationFile)
if err != nil {
log.Errorf("Error occurred while copying the Windows backup folder %s --> %s %v", f.Name(), destinationFile, err)
- return err
+ return nil
} else {
log.Infof("Found backup file at %s. Restored this file to %s", path, destinationFile)
deleteFile(path)
From cd1464f4bdb12bfb1cd6c2a85b6089d5a81b1f6b Mon Sep 17 00:00:00 2001
From: Mary Lincy Dcouto
Date: Sat, 20 Feb 2021 00:15:34 +0530
Subject: [PATCH 20/20] updating version
---
release-notes.md | 5 +++++
version | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/release-notes.md b/release-notes.md
index 758b4ead..67686c9e 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -1,3 +1,8 @@
+# Release 1.7.9
+
+## Bugs fixed:
+* [#310](https://github.com/openziti/desktop-edge-win/pull/310) Restore identities moved by Windows after Windows system update
+
# Release 1.7.8
## What's New
diff --git a/version b/version
index 84298f96..f65dc1e2 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-1.7.8
+1.7.9