Merge pull request #305 from openziti/show-version-info

Show version merging to master to produce a candidate build 
info
This commit is contained in:
dovholuknf
2021-02-08 18:51:08 -05:00
committed by GitHub
20 changed files with 234 additions and 39 deletions
+3
View File
@@ -102,6 +102,9 @@
<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>
<Label Name="VersionOlder" Content=" checking version information " HorizontalAlignment="Center" FontSize="10" Height="50" Padding="0,30,0,0" Foreground="#F4044D" Margin="0,-20,0,0" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans"></Label>
<Label Name="VersionNewer" Content="" HorizontalAlignment="Center" FontSize="10" Height="50" Padding="0,30,0,0" Foreground="#0069FF" Margin="0,-20,0,0" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans"></Label>
</StackPanel>
<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>
+17
View File
@@ -452,5 +452,22 @@ namespace ZitiDesktopEdge {
IdListView.Children.Add(item);
}
}
public void SetAppUpgradeAvailableText(string msg) {
this.Dispatcher.Invoke(() => {
VersionOlder.Content = msg;
VersionNewer.Content = "";
VersionOlder.Visibility = Visibility.Visible;
VersionNewer.Visibility = Visibility.Collapsed;
});
}
public void SetAppIsNewer(string msg) {
this.Dispatcher.Invoke(() => {
VersionNewer.Content = msg;
VersionOlder.Content = "";
VersionNewer.Visibility = Visibility.Visible;
VersionOlder.Visibility = Visibility.Collapsed;
});
}
}
}
+28
View File
@@ -14,6 +14,7 @@ using System.Threading.Tasks;
using ZitiDesktopEdge.Models;
using ZitiDesktopEdge.DataStructures;
using ZitiDesktopEdge.ServiceClient;
using ZitiDesktopEdge.Utility;
using NLog;
using NLog.Config;
@@ -282,6 +283,7 @@ namespace ZitiDesktopEdge {
monitorClient.OnClientConnected += MonitorClient_OnClientConnected;
monitorClient.OnServiceStatusEvent += MonitorClient_OnServiceStatusEvent;
monitorClient.OnShutdownEvent += MonitorClient_OnShutdownEvent;
monitorClient.OnReconnectFailure += MonitorClient_OnReconnectFailure;
Application.Current.Properties.Add("MonitorClient", monitorClient);
Application.Current.Properties.Add("Identities", new List<ZitiIdentity>());
@@ -308,6 +310,31 @@ namespace ZitiDesktopEdge {
Placement();
}
string nextVersionStr = null;
private void MonitorClient_OnReconnectFailure(object sender, object e) {
if(nextVersionStr == null) {
// check for the current version
nextVersionStr = "checking for update";
Version nextVersion = VersionUtil.NormalizeVersion(GithubAPI.GetVersion(GithubAPI.GetJson(GithubAPI.ProdUrl)));
nextVersionStr = nextVersion.ToString();
Version currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; //fetch from ziti?
int compare = currentVersion.CompareTo(nextVersion);
if (compare < 0) {
MainMenu.SetAppUpgradeAvailableText("Upgrade available: " + nextVersionStr);
logger.Info("upgrade is available. Published version: {} is newer than the current version: {}", nextVersion, currentVersion);
//UpgradeAvailable();
} else if (compare > 0) {
logger.Info("the version installed: {0} is newer than the released version: {1}", currentVersion, nextVersion);
MainMenu.SetAppIsNewer("This version is newer than the latest: " + nextVersionStr);
} else {
logger.Info("Current version installed: {0} is the same as the latest released version {1}", currentVersion, nextVersion);
MainMenu.SetAppUpgradeAvailableText("");
}
}
}
private void MonitorClient_OnShutdownEvent(object sender, StatusEvent e) {
Application.Current.Shutdown();
}
@@ -433,6 +460,7 @@ namespace ZitiDesktopEdge {
private void MonitorClient_OnClientConnected(object sender, object e) {
logger.Debug("MonitorClient_OnClientConnected");
MainMenu.SetAppUpgradeAvailableText("");
}
async private void LogLevelChanged(string level) {
+3 -3
View File
@@ -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")]
+2 -2
View File
@@ -22,10 +22,10 @@
<ROW Property="CTRLS" Value="2"/>
<ROW Property="Manufacturer" Value="NetFoundry, Inc."/>
<ROW Property="MsiLogging" MultiBuildValue="AnyCPU_Release:vp"/>
<ROW Property="ProductCode" Value="1033:{B2CCD650-A02F-469E-A7A4-B816679F3128} " Type="16"/>
<ROW Property="ProductCode" Value="1033:{CBC8B589-1E39-42E2-8AAC-8EECC679D7CA} " Type="16"/>
<ROW Property="ProductLanguage" Value="1033"/>
<ROW Property="ProductName" Value="Ziti Desktop Edge"/>
<ROW Property="ProductVersion" Value="1.7.6" Type="32"/>
<ROW Property="ProductVersion" Value="1.7.8" Type="32"/>
<ROW Property="REBOOT" MultiBuildValue="AnyCPU_Release:Suppress"/>
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND;AI_SETUPEXEPATH;SETUPEXEDIR"/>
<ROW Property="UpgradeCode" Value="{CB7E173A-663D-4A23-BB22-D1E8D885C2F3}"/>
@@ -15,6 +15,10 @@ using ZitiDesktopEdge.DataStructures;
namespace ZitiDesktopEdge.ServiceClient {
public abstract class AbstractClient {
public event EventHandler<object> OnClientConnected = null;
public event EventHandler<object> OnClientDisconnected;
public event EventHandler<StatusEvent> OnShutdownEvent;
public event EventHandler<object> OnReconnectFailure;
protected NamedPipeClientStream pipeClient = null;
protected NamedPipeClientStream eventClient = null;
@@ -81,6 +85,10 @@ namespace ZitiDesktopEdge.ServiceClient {
OnShutdownEvent?.Invoke(this, e);
}
protected virtual void ReconnectFailureEvent(object e) {
OnReconnectFailure?.Invoke(this, e);
}
async protected Task sendAsync(object objToSend) {
bool retried = false;
while (true) {
@@ -118,10 +126,6 @@ namespace ZitiDesktopEdge.ServiceClient {
}
}
public event EventHandler<object> OnClientConnected = null;
public event EventHandler<object> OnClientDisconnected;
public event EventHandler<StatusEvent> OnShutdownEvent;
public bool Reconnecting { get; set; }
public bool Connected { get; set; }
public bool CleanShutdown { get; set; }
@@ -162,6 +166,11 @@ namespace ZitiDesktopEdge.ServiceClient {
//ClientDisconnected(null);
}
} catch {
try {
ReconnectFailureEvent("reconnect failure");
} catch {
}
var now = DateTime.Now;
if (now > logAgainAfter) {
Logger.Debug("Reconnect failed. Trying again...");
@@ -0,0 +1,33 @@
using System;
using System.Net;
using System.IO;
using NLog;
using Newtonsoft.Json.Linq;
namespace ZitiDesktopEdge.Utility {
public static class GithubAPI {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public const string ProdUrl = "https://api.github.com/repos/openziti/desktop-edge-win/releases/latest";
public const string BetaUrl = "https://api.github.com/repos/openziti/desktop-edge-win-beta/releases/latest";
public static JObject GetJson(string url) {
HttpWebRequest httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.Method = "GET";
httpWebRequest.ContentType = "application/json";
httpWebRequest.UserAgent = "OpenZiti UpdateService";
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream());
string currentResponse = streamReader.ReadToEnd();
Logger.Trace("response received: {0}", currentResponse);
return JObject.Parse(currentResponse);
}
public static Version GetVersion(JObject json) {
string releaseVersion = json.Property("tag_name").Value.ToString();
string releaseName = json.Property("name").Value.ToString();
return VersionUtil.NormalizeVersion(new Version(releaseVersion));
}
}
}
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ZitiDesktopEdge.Utility {
public static class VersionUtil {
public static Version NormalizeVersion(Version v) {
if (v.Minor < 1) return new Version(v.Major, 0, 0, 0);
if (v.Build < 1) return new Version(v.Major, v.Minor, 0, 0);
if (v.Revision < 1) return new Version(v.Major, v.Minor, v.Build, 0);
return v;
}
}
}
@@ -62,6 +62,8 @@
<Compile Include="ServiceClient\DataClient.cs" />
<Compile Include="DataStructures\DataStructures.cs" />
<Compile Include="ServiceClient\MonitorClient.cs" />
<Compile Include="Utility\GithubAPI.cs" />
<Compile Include="Utility\VersionUtil.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
+3 -3
View File
@@ -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")]
+72 -6
View File
@@ -8,13 +8,17 @@ using System.Configuration;
using System.Threading.Tasks;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using System.IO.Compression;
using NLog;
using ZitiDesktopEdge.DataStructures;
using ZitiDesktopEdge.ServiceClient;
using ZitiDesktopEdge.Server;
using System.IO.Compression;
using ZitiDesktopEdge.Utility;
using NLog;
using Newtonsoft.Json;
using DnsClient;
using System.Net;
namespace ZitiUpdateService {
public partial class UpdateService : ServiceBase {
@@ -53,6 +57,9 @@ namespace ZitiUpdateService {
Task eventServer = null;
checkers.UpdateCheck check = null;
private Timer dnsProbeTimer = new Timer();
private IPAddress dnsIpAddress = null;
public UpdateService() {
InitializeComponent();
@@ -366,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 = dnsProbeFailCount % (5 * 60 / dnsProbeIntervalInSeconds) == 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
@@ -613,7 +671,7 @@ namespace ZitiUpdateService {
if (fi.Name.StartsWith(filePrefix)) {
Logger.Debug("scanning for staleness: " + f);
string ver = Path.GetFileNameWithoutExtension(f).Substring(filePrefix.Length);
Version fileVersion = checkers.UpdateCheck.NormalizeVersion(new Version(ver));
Version fileVersion = VersionUtil.NormalizeVersion(new Version(ver));
if (isOlder(fileVersion)) {
Logger.Info("Removing old download: " + fi.Name);
fi.Delete();
@@ -709,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
@@ -76,6 +76,9 @@
<OutputPath>bin\Releases\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="DnsClient, Version=1.3.2.0, Culture=neutral, PublicKeyToken=4574bb5573c51424, processorArchitecture=MSIL">
<HintPath>..\packages\DnsClient.1.3.2\lib\net471\DnsClient.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
@@ -83,6 +86,9 @@
<HintPath>..\packages\NLog.4.7.6\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
+5 -12
View File
@@ -1,12 +1,13 @@
using System;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using NLog;
using Newtonsoft.Json.Linq;
using ZitiDesktopEdge.Utility;
namespace ZitiUpdateService.checkers {
internal class GithubCheck : UpdateCheck {
@@ -14,7 +15,6 @@ namespace ZitiUpdateService.checkers {
string url;
string downloadUrl = null;
string downloadFileName = null;
string currentResponse = null;
Version nextVersion = null;
public GithubCheck(string url) {
@@ -40,15 +40,7 @@ namespace ZitiUpdateService.checkers {
override public int IsUpdateAvailable(Version currentVersion) {
Logger.Debug("checking for update begins. current version detected as {0}", currentVersion);
Logger.Debug("issuing http get to url: {0}", url);
HttpWebRequest httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.Method = "GET";
httpWebRequest.ContentType = "application/json";
httpWebRequest.UserAgent = "OpenZiti UpdateService";
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream());
currentResponse = streamReader.ReadToEnd();
Logger.Trace("response received: {0}", currentResponse);
JObject json = JObject.Parse(currentResponse);
JObject json = GithubAPI.GetJson(url);
JArray assets = JArray.Parse(json.Property("assets").Value.ToString());
foreach (JObject asset in assets.Children<JObject>()) {
@@ -72,7 +64,8 @@ namespace ZitiUpdateService.checkers {
string releaseVersion = json.Property("tag_name").Value.ToString();
string releaseName = json.Property("name").Value.ToString();
nextVersion = NormalizeVersion(new Version(releaseVersion));
nextVersion = VersionUtil.NormalizeVersion(new Version(releaseVersion));
int compare = currentVersion.CompareTo(nextVersion);
if (compare < 0) {
Logger.Info("upgrade {} is available. Published version: {} is newer than the current version: {}", releaseName, nextVersion, currentVersion);
@@ -12,12 +12,5 @@ namespace ZitiUpdateService.checkers {
public abstract bool AlreadyDownloaded(string destinationFolder, string destinationName);
public abstract bool HashIsValid(string destinationFolder, string destinationName);
public abstract Version GetNextVersion();
public static Version NormalizeVersion(Version v) {
if (v.Minor < 1) return new Version(v.Major, 0, 0, 0);
if (v.Build < 1) return new Version(v.Major, v.Minor, 0, 0);
if (v.Revision < 1) return new Version(v.Major, v.Minor, v.Build, 0);
return v;
}
}
}
+2
View File
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DnsClient" version="1.3.2" targetFramework="net48" />
<package id="Microsoft.PowerShell.5.ReferenceAssemblies" version="1.1.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net48" />
<package id="NLog" version="4.7.6" targetFramework="net48" />
<package id="System.Buffers" version="4.4.0" targetFramework="net48" />
</packages>
+1 -1
View File
@@ -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
+9
View File
@@ -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)
+17
View File
@@ -26,6 +26,7 @@ package cziti
#include "ziti/ziti_log.h"
#include "sdk.h"
extern void doZitiShutdown(uv_async_t *handle);
extern void zitiContextEvent(ziti_context nf, int status, void *ctx);
extern void eventCB(ziti_context ztx, ziti_event_t *event);
@@ -212,6 +213,22 @@ func (c *ZIdentity) Controller() string {
return C.GoString(c.Options.controller)
}
func (zid *ZIdentity) Shutdown() {
async := (*C.uv_async_t)(C.malloc(C.sizeof_uv_async_t))
async.data = unsafe.Pointer(zid.czctx)
log.Debugf("setting up call to ziti_shutdown for context %p using uv_async_t", async.data)
C.uv_async_init(_impl.libuvCtx.l, async, C.uv_async_cb(C.doZitiShutdown))
C.uv_async_send((*C.uv_async_t)(unsafe.Pointer(async)))
}
//export doZitiShutdown
func doZitiShutdown(async *C.uv_async_t) {
ctx := C.ziti_context(async.data)
log.Infof("invoking ziti_shutdown for context %p", &ctx)
C.ziti_shutdown(ctx)
}
var cTunClientCfgName = C.CString("ziti-tunneler-client.v1")
var cTunServerCfgName = C.CString("ziti-tunneler-server.v1")
+1
View File
@@ -846,6 +846,7 @@ func removeIdentity(out *json.Encoder, fingerprint string) {
resp := dto.Response{Message: "success", Code: SUCCESS, Error: anyErrs, Payload: nil}
respond(out, resp)
// call shutdown some day id.CId.Shutdown()
log.Infof("request to remove identity by fingerprint: %s responded to", fingerprint)
}
+1 -1
View File
@@ -1 +1 @@
1.7.7
1.7.8