mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-14 16:50:03 +00:00
update the cziti and UI with the metrics and update cziti to be up to date
This commit is contained in:
@@ -120,7 +120,7 @@
|
||||
<Image Grid.Column="1" Source="/Assets/Images/down.png" Width="20" HorizontalAlignment="Left" Height="20"></Image>
|
||||
</Grid>
|
||||
<Label Name="DownloadSpeed" Margin="0,-16,0,0" Foreground="#0069FF" Content="0" FontSize="40" HorizontalAlignment="Center" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" />
|
||||
<Label Foreground="White" Margin="0,-20,0,30" Content="Mbps" FontSize="11" HorizontalAlignment="Center" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" />
|
||||
<Label Foreground="White" Margin="0,-20,0,30" Content="KBps" FontSize="11" HorizontalAlignment="Center" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Orientation="Vertical">
|
||||
<Grid HorizontalAlignment="Stretch" Width="Auto">
|
||||
@@ -132,7 +132,7 @@
|
||||
<Image Grid.Column="1" Source="/Assets/Images/up.png" Width="20" HorizontalAlignment="Left" Height="20"></Image>
|
||||
</Grid>
|
||||
<Label Name="UploadSpeed" Margin="0,-16,0,0" Foreground="#FF0047" Content="0" FontSize="40" HorizontalAlignment="Center" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" />
|
||||
<Label Foreground="White" Margin="0,-20,0,30" Content="Mbps" FontSize="11" HorizontalAlignment="Center" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" />
|
||||
<Label Foreground="White" Margin="0,-20,0,30" Content="KBps" FontSize="11" HorizontalAlignment="Center" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" SnapsToDevicePixels="True" CanContentScroll="True">
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace ZitiTunneler {
|
||||
// add a new service client
|
||||
serviceClient = new Client();
|
||||
serviceClient.OnTunnelStatusUpdate += ServiceClient_OnTunnelStatusUpdated;
|
||||
serviceClient.OnMetricsUpdate += ServiceClient_OnMetricsUpdate;
|
||||
Application.Current.Properties.Add("ServiceClient", serviceClient);
|
||||
Application.Current.Properties.Add("Identities", new List<ZitiIdentity>());
|
||||
MainMenu.OnAttachmentChange += AttachmentChanged;
|
||||
@@ -86,6 +87,15 @@ namespace ZitiTunneler {
|
||||
IdentityMenu.OnForgot += IdentityForgotten;
|
||||
}
|
||||
|
||||
private void ServiceClient_OnMetricsUpdate(object sender, Metrics e)
|
||||
{
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
DownloadSpeed.Content = (e.Down / 1000).ToString();
|
||||
UploadSpeed.Content = (e.Up / 1000).ToString();
|
||||
});
|
||||
}
|
||||
|
||||
private void ServiceClient_OnTunnelStatusUpdated(object sender, TunnelStatus e)
|
||||
{
|
||||
}
|
||||
@@ -117,7 +127,8 @@ namespace ZitiTunneler {
|
||||
}
|
||||
|
||||
private void LoadStatusFromService() {
|
||||
TunnelStatus status = serviceClient.GetStatus().Status;
|
||||
var s = serviceClient.GetStatus();
|
||||
TunnelStatus status = s.Status;
|
||||
if (status != null) {
|
||||
if (status.Active) {
|
||||
InitializeTimer((int)status.Duration);
|
||||
|
||||
@@ -61,23 +61,6 @@ namespace ZitiTunneler.ServiceClient
|
||||
{
|
||||
//establish the named pipe to the service
|
||||
setupPipe();
|
||||
|
||||
Task.Run(() => {
|
||||
Console.WriteLine("THREAD BEGINS");
|
||||
NamedPipeClientStream eventClient = new NamedPipeClientStream(localPipeServer, eventPipe, PipeDirection.In);
|
||||
eventClient.Connect();
|
||||
StreamReader eventReader = new StreamReader(eventClient);
|
||||
while (true)
|
||||
{
|
||||
var r = read<StatusUpdateResponse>("event: ", eventReader);
|
||||
if (eventReader.EndOfStream)
|
||||
{
|
||||
break;
|
||||
}
|
||||
Debug.WriteLine(r.Payload);
|
||||
}
|
||||
Console.WriteLine("THREAD DONE");
|
||||
});
|
||||
}
|
||||
PipeSecurity CreateSystemIOPipeSecurity()
|
||||
{
|
||||
@@ -123,6 +106,23 @@ namespace ZitiTunneler.ServiceClient
|
||||
ipcWriter = null;
|
||||
pipeClient = null;
|
||||
}
|
||||
|
||||
Task.Run(() => {
|
||||
Console.WriteLine("THREAD BEGINS");
|
||||
NamedPipeClientStream eventClient = new NamedPipeClientStream(localPipeServer, eventPipe, PipeDirection.In);
|
||||
eventClient.Connect();
|
||||
StreamReader eventReader = new StreamReader(eventClient);
|
||||
while (true)
|
||||
{
|
||||
var r = read<StatusUpdateResponse>("event: ", eventReader);
|
||||
if (eventReader.EndOfStream)
|
||||
{
|
||||
break;
|
||||
}
|
||||
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 Upload { get; set; }
|
||||
public double Download { get; set; }
|
||||
public double Up { get; set; }
|
||||
public double Down { get; set; }
|
||||
}
|
||||
|
||||
public class Identity
|
||||
|
||||
+30
-48
@@ -14,6 +14,36 @@ EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZitiNotifyIcon", "ZitiNotifyIcon\ZitiNotifyIcon.csproj", "{F620947D-5C32-4A6F-BEAA-4DCBB2032668}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|Default = Debug|Default
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|Default = Release|Default
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|Default.ActiveCfg = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|Default.Build.0 = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|Default.ActiveCfg = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|Default.Build.0 = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|Default.ActiveCfg = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|Default.Build.0 = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|Default.ActiveCfg = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|Default.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {196E91E3-8AF1-41B3-9BD5-002BC225B6E3}
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
@@ -26,52 +56,4 @@ Global
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|x64.Build.0 = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|x64.Build.0 = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F620947D-5C32-4A6F-BEAA-4DCBB2032668}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {196E91E3-8AF1-41B3-9BD5-002BC225B6E3}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -26,7 +26,7 @@ extern void readIdle(uv_prepare_t *idler);
|
||||
|
||||
extern void call_on_packet(void *packet, ssize_t len, packet_cb cb, void *ctx);
|
||||
|
||||
extern void dnsHandler(tunneler_io_context tio, void *ctx, addr_t src, uint16_t sport, void *data, ssize_t len);
|
||||
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
@@ -227,7 +227,6 @@ func (t *tunnel) runWriteLoop() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (t *tunnel) AddIntercept(service string, host string, port int, ctx unsafe.Pointer) {
|
||||
@@ -237,23 +236,3 @@ func (t *tunnel) AddIntercept(service string, host string, port int, ctx unsafe.
|
||||
C.CString(service), C.CString(host), C.int(port))
|
||||
log.Debug("intercept added", res)
|
||||
}
|
||||
|
||||
// extern void dnsHandler(tunneler_io_context tio, void *ctx, addr_t src, uint16_t sport, void *data, ssize_t len);
|
||||
//export dnsHandler
|
||||
func dnsHandler(tio C.tunneler_io_context, ctx unsafe.Pointer, src C.addr_t, sport C.uint16_t, b unsafe.Pointer, bl C.ssize_t) {
|
||||
/*
|
||||
reply, err := processDNSquery(C.GoBytes(b, C.int(bl)))
|
||||
|
||||
if err == nil {
|
||||
replyC := C.CBytes(reply)
|
||||
rc := C.NF_udp_send(tio, src, sport, replyC, C.ssize_t(len(reply)))
|
||||
C.free(replyC)
|
||||
if rc != 0 {
|
||||
log.Debug("NF_udp_reply rc=", rc)
|
||||
}
|
||||
} else {
|
||||
log.Debug("dns message error", err)
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -92,12 +92,9 @@ func load(args []string) error {
|
||||
return fmt.Errorf("path to configfile required")
|
||||
}
|
||||
|
||||
if ctx, err := cziti.LoadZiti(args[0]); err != nil {
|
||||
return err
|
||||
} else {
|
||||
fmt.Printf("successfully loaded %s@%s\n", ctx.Name(), ctx.Controller())
|
||||
contexts = append(contexts, ctx)
|
||||
}
|
||||
ctx := cziti.LoadZiti(args[0])
|
||||
fmt.Printf("successfully loaded %s@%s\n", ctx.Name(), ctx.Controller())
|
||||
contexts = append(contexts, ctx)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ package cziti
|
||||
/*
|
||||
#cgo windows LDFLAGS: -l libziti.imp -luv -lws2_32 -lpsapi
|
||||
|
||||
#include <nf/ziti.h>
|
||||
|
||||
#include "sdk.h"
|
||||
extern void initCB(nf_context nf, int status, void *ctx);
|
||||
extern void serviceCB(nf_context nf, ziti_service*, int status, void *ctx);
|
||||
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
@@ -169,7 +172,7 @@ func LoadZiti(cfg string) *CZitiCtx {
|
||||
ctx.options.config = C.CString(cfg)
|
||||
ctx.options.init_cb = C.nf_init_cb(C.initCB)
|
||||
ctx.options.service_cb = C.nf_service_cb(C.serviceCB)
|
||||
ctx.options.refresh_interval = C.int(600)
|
||||
ctx.options.refresh_interval = C.long(600)
|
||||
ctx.options.config_types = C.all_configs
|
||||
//ctx.options.ctx = unsafe.Pointer(&ctx)
|
||||
|
||||
@@ -188,3 +191,11 @@ func LoadZiti(cfg string) *CZitiCtx {
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func GetTransferRates(ctx *CZitiCtx) (int64, int64) { //extern void NF_get_transfer_rates(nf_context nf, double* up, double* down);
|
||||
var up, down C.double
|
||||
C.NF_get_transfer_rates(ctx.nf, &up, &down)
|
||||
log.Tracef("Up: %v Down %v", up, down)
|
||||
|
||||
return int64(up), int64(down)
|
||||
}
|
||||
Reference in New Issue
Block a user