Merge remote-tracking branch 'origin/bug-fixing' into clint

# Conflicts:
#	ZitiTunneler/MainWindow.xaml.cs
This commit is contained in:
Jeremy Tellier - ROG
2020-05-07 20:13:40 +01:00
7 changed files with 76 additions and 12 deletions
+36
View File
@@ -132,6 +132,7 @@ namespace ZitiTunneler {
IdentityMenu.OnForgot += IdentityForgotten;
}
<<<<<<< HEAD
private void ServiceClient_OnMetricsUpdate(object sender, Metrics e) {
this.Dispatcher.Invoke(() => {
DownloadSpeed.Content = (e.Down / 1000).ToString();
@@ -139,6 +140,41 @@ namespace ZitiTunneler {
});
}
private void ServiceClient_OnTunnelStatusUpdated(object sender, TunnelStatus e) {
=======
private void ServiceClient_OnMetricsUpdate(object sender, Metrics e)
{
if (e != null) {
this.Dispatcher.Invoke(() =>
{
DownloadSpeed.Content = (e.Down / 1000).ToString();
UploadSpeed.Content = (e.Up / 1000).ToString();
});
}
}
private void ServiceClient_OnTunnelStatusUpdated(object sender, TunnelStatus e)
{
if (e != null)
{
long totalUp = 0;
long totalDown = 0;
foreach (var id in e.Identities)
{
System.Diagnostics.Debug.WriteLine($"id {id.Name} down: {totalDown} up:{totalUp}");
if (id?.Metrics != null)
{
totalDown += id.Metrics.Down;
totalUp += id.Metrics.Up;
}
}
this.Dispatcher.Invoke(() =>
{
System.Diagnostics.Debug.WriteLine($"Triggering update of total down: {totalDown} up:{totalUp}");
DownloadSpeed.Content = (totalDown / 1000).ToString();
UploadSpeed.Content = (totalUp / 1000).ToString();
});
}
>>>>>>> origin/bug-fixing
}
private void IdentityForgotten(ZitiIdentity forgotten) {
+8 -1
View File
@@ -119,7 +119,14 @@ namespace ZitiTunneler.ServiceClient
{
break;
}
MetricsUpdate(r.Payload.Metrics);
if (r?.Payload?.Status != null)
{
ZitiTunnelStatusUpdate(r.Payload.Status);
}
if (r?.Payload?.Metrics != null)
{
MetricsUpdate(r.Payload.Metrics);
}
}
Console.WriteLine("THREAD DONE");
});
+2 -2
View File
@@ -108,8 +108,8 @@ namespace ZitiTunneler.ServiceClient
public class Metrics
{
public int TotalBytes { get; set; }
public double Up { get; set; }
public double Down { get; set; }
public long Up { get; set; }
public long Down { get; set; }
}
public class Identity
+1 -1
View File
@@ -26,7 +26,7 @@ type Identity struct {
Config idcfg.Config
Status string
Services []*Service
Metrics Metrics
Metrics *Metrics
Connected bool `json:"-"`
NFContext *cziti.CZitiCtx `json:"-"`
+16 -2
View File
@@ -2,11 +2,12 @@ package idutil
import (
idcfg "github.com/netfoundry/ziti-sdk-golang/ziti/config"
"wintun-testing/cziti"
"wintun-testing/ziti-tunnel/dto"
)
//Removes the Config from the provided identity and returns a 'cleaned' id
func Clean(id dto.Identity) *dto.Identity {
func Clean(id dto.Identity) dto.Identity {
nid := id
nid.Config = idcfg.Config{}
nid.Config.ZtAPI = id.Config.ZtAPI
@@ -14,5 +15,18 @@ func Clean(id dto.Identity) *dto.Identity {
for i, svc := range id.Services{
nid.Services[i] = svc
}
return &nid
GetMetrics(nid)
return nid
}
func GetMetrics(id dto.Identity) /*dto.Metrics*/ {
up, down := cziti.GetTransferRates(id.NFContext)
id.Metrics.Up = up
id.Metrics.Down = down
/*
return dto.Metrics{
Up: up,
Down: down,
}
*/
}
+9 -3
View File
@@ -80,7 +80,7 @@ func SubMain(ops <-chan string, changes chan<- svc.Status) error {
case <-every5sDone:
return
case <-every5s.C:
stat := rst
/*
for _, a := range activeIds {
up, down := cziti.GetTransferRates(a.NFContext)
top.Broadcast <- dto.ZitiTunnelStatus{
@@ -90,7 +90,12 @@ func SubMain(ops <-chan string, changes chan<- svc.Status) error {
Down: down,
},
}
}
}*/
s := rts.ToStatus()
top.Broadcast <- dto.ZitiTunnelStatus{
Status: &s,
Metrics: nil,
}
}
}
}()
@@ -405,8 +410,9 @@ func serveEvents(conn net.Conn) {
func reportStatus(out *json.Encoder) {
log.Debugf("request for status")
s := rts.ToStatus()
respond(out, dto.ZitiTunnelStatus{
Status: rts.ToStatus(),
Status: &s,
Metrics: nil,
})
log.Debugf("request for status responded to")
+4 -3
View File
@@ -68,7 +68,7 @@ func SaveState(t *RuntimeState) {
log.Debug("state saved")
}
func (t *RuntimeState) ToStatus() *dto.TunnelStatus {
func (t *RuntimeState) ToStatus() dto.TunnelStatus {
var d int64
if t.state.Active {
now := time.Now()
@@ -86,10 +86,11 @@ func (t *RuntimeState) ToStatus() *dto.TunnelStatus {
}
for i, id := range t.state.Identities {
log.Debugf("returning clean identity: %s", id.Name)
clean.Identities[i] = idutil.Clean(*id)
cid := idutil.Clean(*id)
clean.Identities[i] = &cid
}
return &clean
return clean
}
func (t *RuntimeState) CreateTun() error {