mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-14 08:39:55 +00:00
Merge remote-tracking branch 'origin/bug-fixing' into clint
# Conflicts: # ZitiTunneler/MainWindow.xaml.cs
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:"-"`
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user