From 266c38fd98fd0853addf0950090990b3752937cd Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Tue, 5 May 2020 17:34:11 -0400
Subject: [PATCH 1/3] stage subcommands
---
wintun-testing/go.mod | 1 +
wintun-testing/go.sum | 3 +++
wintun-testing/ziti-tunnel/cmd/root.go | 27 +++++++++++++++++++
.../ziti-tunnel/cmd/root_addidentity.go | 20 ++++++++++++++
wintun-testing/ziti-tunnel/cmd/root_debug.go | 20 ++++++++++++++
.../ziti-tunnel/cmd/root_disable_id.go | 20 ++++++++++++++
.../ziti-tunnel/cmd/root_enable_id.go | 20 ++++++++++++++
.../ziti-tunnel/cmd/root_removeidentity.go | 20 ++++++++++++++
wintun-testing/ziti-tunnel/cmd/root_svc.go | 20 ++++++++++++++
.../ziti-tunnel/cmd/root_svc_install.go | 20 ++++++++++++++
.../ziti-tunnel/cmd/root_svc_remove.go | 20 ++++++++++++++
.../ziti-tunnel/cmd/root_svc_start.go | 19 +++++++++++++
.../ziti-tunnel/cmd/root_svc_status.go | 20 ++++++++++++++
.../ziti-tunnel/cmd/root_svc_stop.go | 19 +++++++++++++
wintun-testing/ziti-tunnel/cmd/version.go | 20 ++++++++++++++
wintun-testing/ziti-tunnel/main.go | 12 ++++++++-
16 files changed, 280 insertions(+), 1 deletion(-)
create mode 100644 wintun-testing/ziti-tunnel/cmd/root.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/root_addidentity.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/root_debug.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/root_disable_id.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/root_enable_id.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/root_removeidentity.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/root_svc.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/root_svc_install.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/root_svc_remove.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/root_svc_start.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/root_svc_status.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/root_svc_stop.go
create mode 100644 wintun-testing/ziti-tunnel/cmd/version.go
diff --git a/wintun-testing/go.mod b/wintun-testing/go.mod
index 70695225..73c27e15 100644
--- a/wintun-testing/go.mod
+++ b/wintun-testing/go.mod
@@ -14,6 +14,7 @@ require (
github.com/netfoundry/ziti-foundation v0.9.8
github.com/netfoundry/ziti-sdk-golang v0.11.16
github.com/sirupsen/logrus v1.5.0
+ github.com/spf13/cobra v0.0.5
github.com/tebeka/strftime v0.1.4 // indirect
github.com/tv42/topic v0.0.0-20130729201830-aa72cbe81b48
golang.org/x/sys v0.0.0-20200406113430-c6e801f48ba2
diff --git a/wintun-testing/go.sum b/wintun-testing/go.sum
index 26f50c29..33b578ae 100644
--- a/wintun-testing/go.sum
+++ b/wintun-testing/go.sum
@@ -32,6 +32,7 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
+github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4=
@@ -93,9 +94,11 @@ github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s
github.com/speps/go-hashids v2.0.0+incompatible/go.mod h1:P7hqPzMdnZOfyIk+xrlG1QaSMw+gCBdHKsBDnhpaZvc=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
diff --git a/wintun-testing/ziti-tunnel/cmd/root.go b/wintun-testing/ziti-tunnel/cmd/root.go
new file mode 100644
index 00000000..c95fef8b
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root.go
@@ -0,0 +1,27 @@
+package cmd
+
+import (
+ "fmt"
+ "github.com/spf13/cobra"
+ "os"
+ "path/filepath"
+)
+var exeName, _ = os.Executable()
+var rootCmd = &cobra.Command{
+ Use: filepath.Base(exeName) ,
+ Short: "Runs the ziti-tunnel as a service",
+ Long: `This program provides access to a ziti-based network.
+ When executed without parameters it is expected that this application is running as a service`,
+ Run: func(cmd *cobra.Command, args []string) {
+ // Do Stuff Here
+ fmt.Println("i am in command")
+ },
+}
+
+func Execute() {
+ if err := rootCmd.Execute(); err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/root_addidentity.go b/wintun-testing/ziti-tunnel/cmd/root_addidentity.go
new file mode 100644
index 00000000..28460aec
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root_addidentity.go
@@ -0,0 +1,20 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(addIdCmd)
+}
+
+var addIdCmd = &cobra.Command{
+ Use: "addId",
+ Short: "Adds the provided jwt file to the running service",
+ Hidden: true,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("Adds the provided jwt file to the running service")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/root_debug.go b/wintun-testing/ziti-tunnel/cmd/root_debug.go
new file mode 100644
index 00000000..ec9ff0db
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root_debug.go
@@ -0,0 +1,20 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(debugCmd)
+}
+
+var debugCmd = &cobra.Command{
+ Use: "debug",
+ Short: "Runs the program interactively instead of expecting to be run as a service. Used in debugging",
+ Hidden: true,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("Runs the program interactively instead of expecting to be run as a service. Used in debugging")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/root_disable_id.go b/wintun-testing/ziti-tunnel/cmd/root_disable_id.go
new file mode 100644
index 00000000..94c8b46a
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root_disable_id.go
@@ -0,0 +1,20 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(disableIdCmd)
+}
+
+var disableIdCmd = &cobra.Command{
+ Use: "disable",
+ Short: "Disables any identity in the running service using the provided fingerprint",
+ Hidden: true,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("Disables any identity in the running service using the provided fingerprint")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/root_enable_id.go b/wintun-testing/ziti-tunnel/cmd/root_enable_id.go
new file mode 100644
index 00000000..ebdbeee2
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root_enable_id.go
@@ -0,0 +1,20 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(enableIdCmd)
+}
+
+var enableIdCmd = &cobra.Command{
+ Use: "enable",
+ Short: "Enables any identity in the running service using the provided fingerprint",
+ Hidden: true,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("Enables any identity in the running service using the provided fingerprint")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/root_removeidentity.go b/wintun-testing/ziti-tunnel/cmd/root_removeidentity.go
new file mode 100644
index 00000000..92444aa7
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root_removeidentity.go
@@ -0,0 +1,20 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(removeIdCmd)
+}
+
+var removeIdCmd = &cobra.Command{
+ Use: "removeId",
+ Short: "Removes any identity from the running service using the provided fingerprint",
+ Hidden: true,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("Removes any identity from the running service using the provided fingerprint")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/root_svc.go b/wintun-testing/ziti-tunnel/cmd/root_svc.go
new file mode 100644
index 00000000..decfbd6f
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root_svc.go
@@ -0,0 +1,20 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(serviceCmd)
+}
+
+var serviceCmd = &cobra.Command{
+ Use: "service",
+ Short: "Expects to run the program as a service",
+ Hidden: true,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("print or return the version here")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/root_svc_install.go b/wintun-testing/ziti-tunnel/cmd/root_svc_install.go
new file mode 100644
index 00000000..ed838e84
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root_svc_install.go
@@ -0,0 +1,20 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ serviceCmd.AddCommand(installCmd)
+}
+
+var installCmd = &cobra.Command{
+ Use: "install",
+ Short: "Installs the executable as a service.",
+ Long: `When installing as a service using this function make sure not to move the executable. The path to the executing program will be used in the service`,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("install this thing as a service")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/root_svc_remove.go b/wintun-testing/ziti-tunnel/cmd/root_svc_remove.go
new file mode 100644
index 00000000..4a0a64a2
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root_svc_remove.go
@@ -0,0 +1,20 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ serviceCmd.AddCommand(removeCmd)
+}
+
+var removeCmd = &cobra.Command{
+ Use: "remove",
+ Short: "Removes the executable as a service.",
+ Long: `When removing the service make sure the path and service name have not changed`,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("remove this thing as a service")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/root_svc_start.go b/wintun-testing/ziti-tunnel/cmd/root_svc_start.go
new file mode 100644
index 00000000..4de6e9c1
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root_svc_start.go
@@ -0,0 +1,19 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ serviceCmd.AddCommand(startCmd)
+}
+
+var startCmd = &cobra.Command{
+ Use: "start",
+ Short: "Tries to start the service",
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("Tries to start the service")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/root_svc_status.go b/wintun-testing/ziti-tunnel/cmd/root_svc_status.go
new file mode 100644
index 00000000..6bcac35a
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root_svc_status.go
@@ -0,0 +1,20 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ serviceCmd.AddCommand(statusCmd)
+}
+
+var statusCmd = &cobra.Command{
+ Use: "status",
+ Short: "Prints the status of the service",
+ Hidden: true,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("Prints the status of the service")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/root_svc_stop.go b/wintun-testing/ziti-tunnel/cmd/root_svc_stop.go
new file mode 100644
index 00000000..ac400f52
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/root_svc_stop.go
@@ -0,0 +1,19 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ serviceCmd.AddCommand(stopCmd)
+}
+
+var stopCmd = &cobra.Command{
+ Use: "stop",
+ Short: "Tries to stop the service",
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("try to stop the service")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/cmd/version.go b/wintun-testing/ziti-tunnel/cmd/version.go
new file mode 100644
index 00000000..3e0ef436
--- /dev/null
+++ b/wintun-testing/ziti-tunnel/cmd/version.go
@@ -0,0 +1,20 @@
+package cmd
+
+import (
+"fmt"
+
+"github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(versionCmd)
+}
+
+var versionCmd = &cobra.Command{
+ Use: "version",
+ Short: "Print the version of the current executable",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("print or return the version here")
+ },
+}
diff --git a/wintun-testing/ziti-tunnel/main.go b/wintun-testing/ziti-tunnel/main.go
index 2dd05b87..983ead8f 100644
--- a/wintun-testing/ziti-tunnel/main.go
+++ b/wintun-testing/ziti-tunnel/main.go
@@ -7,6 +7,7 @@ import (
"golang.org/x/sys/windows/svc/eventlog"
"os"
"strings"
+ "wintun-testing/ziti-tunnel/cmd"
"wintun-testing/ziti-tunnel/globals"
"golang.org/x/sys/windows/svc"
@@ -18,7 +19,16 @@ var log = globals.Logger()
func main() {
globals.InitLogger("debug")
- // passing no arguments is an indicator that this is excpecting to be run 'as a service'.
+ if len(os.Args) < 2 {
+ // if no args supplied - expect to run as service
+ os.Args = append(os.Args, "service")
+ }
+ cmd.Execute()
+ if true {
+ os.Exit(0)
+ }
+
+ // passing no arguments is an indicator that this is expecting to be run 'as a service'.
// using arg count instead of svc.IsAnInteractiveSession() as svc.IsAnInteractiveSession()
// seems to return false even when run in an interactive shell as via `psexec -i -s cmd.exe`
hasArgs := len(os.Args) > 1
From c4b9cb41b60d8d83b99505530742fbbf021f57de Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Thu, 7 May 2020 08:31:55 -0400
Subject: [PATCH 2/3] update the cziti and UI with the metrics and update cziti
to be up to date
---
ZitiTunneler/MainWindow.xaml | 4 +-
ZitiTunneler/MainWindow.xaml.cs | 13 +++-
ZitiTunneler/ServiceClient/ClientImpl.cs | 34 ++++-----
ZitiTunneler/ServiceClient/DataStructures.cs | 4 +-
ZitiUWPSolution.sln | 78 ++++++++------------
wintun-testing/cziti/ctun.go | 23 +-----
wintun-testing/cziti/cziti-cli/main.go | 9 +--
wintun-testing/cziti/sdk.go | 13 +++-
8 files changed, 79 insertions(+), 99 deletions(-)
diff --git a/ZitiTunneler/MainWindow.xaml b/ZitiTunneler/MainWindow.xaml
index 2d3c3770..cb55fef3 100644
--- a/ZitiTunneler/MainWindow.xaml
+++ b/ZitiTunneler/MainWindow.xaml
@@ -120,7 +120,7 @@
-
+
@@ -132,7 +132,7 @@
-
+
diff --git a/ZitiTunneler/MainWindow.xaml.cs b/ZitiTunneler/MainWindow.xaml.cs
index 1b7ffffd..5c53dd6e 100644
--- a/ZitiTunneler/MainWindow.xaml.cs
+++ b/ZitiTunneler/MainWindow.xaml.cs
@@ -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());
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);
diff --git a/ZitiTunneler/ServiceClient/ClientImpl.cs b/ZitiTunneler/ServiceClient/ClientImpl.cs
index 5065a197..d816a362 100644
--- a/ZitiTunneler/ServiceClient/ClientImpl.cs
+++ b/ZitiTunneler/ServiceClient/ClientImpl.cs
@@ -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("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("event: ", eventReader);
+ if (eventReader.EndOfStream)
+ {
+ break;
+ }
+ MetricsUpdate(r.Payload.Metrics);
+ }
+ Console.WriteLine("THREAD DONE");
+ });
}
}
diff --git a/ZitiTunneler/ServiceClient/DataStructures.cs b/ZitiTunneler/ServiceClient/DataStructures.cs
index 10efb41d..7fbd0917 100644
--- a/ZitiTunneler/ServiceClient/DataStructures.cs
+++ b/ZitiTunneler/ServiceClient/DataStructures.cs
@@ -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
diff --git a/ZitiUWPSolution.sln b/ZitiUWPSolution.sln
index c12bd37e..117a3246 100644
--- a/ZitiUWPSolution.sln
+++ b/ZitiUWPSolution.sln
@@ -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
diff --git a/wintun-testing/cziti/ctun.go b/wintun-testing/cziti/ctun.go
index 96e9cbf1..9f979d51 100644
--- a/wintun-testing/cziti/ctun.go
+++ b/wintun-testing/cziti/ctun.go
@@ -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)
- }
-
- */
-}
diff --git a/wintun-testing/cziti/cziti-cli/main.go b/wintun-testing/cziti/cziti-cli/main.go
index d829da63..760bf930 100644
--- a/wintun-testing/cziti/cziti-cli/main.go
+++ b/wintun-testing/cziti/cziti-cli/main.go
@@ -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
}
diff --git a/wintun-testing/cziti/sdk.go b/wintun-testing/cziti/sdk.go
index 7445c538..612fe748 100644
--- a/wintun-testing/cziti/sdk.go
+++ b/wintun-testing/cziti/sdk.go
@@ -3,9 +3,12 @@ package cziti
/*
#cgo windows LDFLAGS: -l libziti.imp -luv -lws2_32 -lpsapi
+#include
+
#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)
+}
\ No newline at end of file
From 12b8eece4737391e3d88104bbf0006baeaf86d3c Mon Sep 17 00:00:00 2001
From: dovholuknf <46322585+dovholuknf@users.noreply.github.com>
Date: Thu, 7 May 2020 08:32:35 -0400
Subject: [PATCH 3/3] enable metrics and continue to refactor code
---
wintun-testing/ziti-tunnel/dto/dtos.go | 5 +-
wintun-testing/ziti-tunnel/main.go | 17 ++--
wintun-testing/ziti-tunnel/service/ipc.go | 80 ++++++++++++++-----
.../ziti-tunnel/service/package-variables.go | 23 ------
.../ziti-tunnel/service/pkg-vars.go | 45 ++++++-----
wintun-testing/ziti-tunnel/service/state.go | 4 +-
6 files changed, 99 insertions(+), 75 deletions(-)
diff --git a/wintun-testing/ziti-tunnel/dto/dtos.go b/wintun-testing/ziti-tunnel/dto/dtos.go
index 2a34b3dd..c1e6950a 100644
--- a/wintun-testing/ziti-tunnel/dto/dtos.go
+++ b/wintun-testing/ziti-tunnel/dto/dtos.go
@@ -4,6 +4,7 @@ import (
idcfg "github.com/netfoundry/ziti-sdk-golang/ziti/config"
"github.com/netfoundry/ziti-sdk-golang/ziti/enroll"
"log"
+ "wintun-testing/cziti"
"wintun-testing/ziti-tunnel/config"
)
@@ -28,9 +29,11 @@ type Identity struct {
Metrics Metrics
Connected bool `json:"-"`
+ NFContext *cziti.CZitiCtx `json:"-"`
}
type Metrics struct {
- TotalBytes int64
+ Up int64
+ Down int64
}
type CommandMsg struct {
Function string
diff --git a/wintun-testing/ziti-tunnel/main.go b/wintun-testing/ziti-tunnel/main.go
index 983ead8f..8a4d4851 100644
--- a/wintun-testing/ziti-tunnel/main.go
+++ b/wintun-testing/ziti-tunnel/main.go
@@ -7,7 +7,6 @@ import (
"golang.org/x/sys/windows/svc/eventlog"
"os"
"strings"
- "wintun-testing/ziti-tunnel/cmd"
"wintun-testing/ziti-tunnel/globals"
"golang.org/x/sys/windows/svc"
@@ -19,14 +18,14 @@ var log = globals.Logger()
func main() {
globals.InitLogger("debug")
- if len(os.Args) < 2 {
- // if no args supplied - expect to run as service
- os.Args = append(os.Args, "service")
- }
- cmd.Execute()
- if true {
- os.Exit(0)
- }
+ //if len(os.Args) < 2 {
+ // // if no args supplied - expect to run as service
+ // os.Args = append(os.Args, "service")
+ //}
+ //cmd.Execute()
+ //if true {
+ // os.Exit(0)
+ //}
// passing no arguments is an indicator that this is expecting to be run 'as a service'.
// using arg count instead of svc.IsAnInteractiveSession() as svc.IsAnInteractiveSession()
diff --git a/wintun-testing/ziti-tunnel/service/ipc.go b/wintun-testing/ziti-tunnel/service/ipc.go
index df6861b3..d4b8cad9 100644
--- a/wintun-testing/ziti-tunnel/service/ipc.go
+++ b/wintun-testing/ziti-tunnel/service/ipc.go
@@ -30,17 +30,17 @@ type Pipes struct {
events net.Listener
}
-func(p *Pipes) Close() {
+func (p *Pipes) Close() {
p.ipc.Close()
p.logs.Close()
p.events.Close()
}
-func SubMain(ops <- chan string, changes chan<- svc.Status) error {
+func SubMain(ops <-chan string, changes chan<- svc.Status) error {
defer close(top.Broadcast)
log.Info("============================== service begins ==============================")
- _ = globals.Elog.Info(InformationEvent, SvcName + " starting. log file located at " + config.LogFile())
+ _ = globals.Elog.Info(InformationEvent, SvcName+" starting. log file located at "+config.LogFile())
// create a channel for notifying any connections that they are to be interrupted
interrupt = make(chan struct{})
@@ -52,7 +52,7 @@ func SubMain(ops <- chan string, changes chan<- svc.Status) error {
defer pipes.Close()
// wire in a log file for csdk troubleshooting
- logFile, err := os.OpenFile(config.Path() + "cziti.log", os.O_WRONLY | os.O_TRUNC | os.O_APPEND | os.O_CREATE, 0644)
+ logFile, err := os.OpenFile(config.Path()+"cziti.log", os.O_WRONLY|os.O_TRUNC|os.O_APPEND|os.O_CREATE, 0644)
if err != nil {
log.Warnf("could not open cziti.log for writing. no debug information will be captured.")
} else {
@@ -70,13 +70,41 @@ func SubMain(ops <- chan string, changes chan<- svc.Status) error {
setTunnelState(true)
+ // setup metrics notifier
+ every5s := time.NewTicker(5 * time.Second)
+
+ every5sDone := make(chan bool)
+ go func() {
+ for {
+ select {
+ case <-every5sDone:
+ return
+ case <-every5s.C:
+ stat := rst
+ for _, a := range activeIds {
+ up, down := cziti.GetTransferRates(a.NFContext)
+ top.Broadcast <- dto.ZitiTunnelStatus{
+ Status: nil,
+ Metrics: &dto.Metrics{
+ Up: up,
+ Down: down,
+ },
+ }
+ }
+ }
+ }
+ }()
+
// notify the service is running
changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}
- _ = globals.Elog.Info(InformationEvent, SvcName + " status set to running")
+ _ = globals.Elog.Info(InformationEvent, SvcName+" status set to running")
log.Info(SvcName + " status set to running. starting cancel loop")
waitForStopRequest(ops)
+ // stop the metrics ticker
+ every5sDone <- true
+
pipes.shutdownConnections()
windns.ResetDNS()
@@ -87,7 +115,7 @@ func SubMain(ops <- chan string, changes chan<- svc.Status) error {
return nil
}
-func waitForStopRequest(ops <- chan string) {
+func waitForStopRequest(ops <-chan string) {
loop:
for {
@@ -139,13 +167,13 @@ func openPipes() (*Pipes, error) {
log.Infof("events listener ready pipe: %s", eventsPipeName())
return &Pipes{
- ipc: ipc,
- logs: logs,
+ ipc: ipc,
+ logs: logs,
events: events,
}, nil
}
-func(p *Pipes) shutdownConnections() {
+func (p *Pipes) shutdownConnections() {
log.Info("waiting for all connections to close...")
for i := 0; i < connections; i++ {
@@ -205,7 +233,7 @@ func accept(p net.Listener, serveFunction func(net.Conn)) {
return
}
wg.Add(1)
- connections ++
+ connections++
log.Debugf("accepting a new client")
go serveFunction(c)
@@ -218,7 +246,7 @@ func serveIpc(conn net.Conn) {
done := make(chan struct{})
defer close(done) // ensure that goroutine exits
- defer wg.Done() // count down whenever the function exits
+ defer wg.Done() // count down whenever the function exits
go func() {
select {
@@ -294,11 +322,6 @@ func serveIpc(conn net.Conn) {
onOff := cmd.Payload["OnOff"].(bool)
fingerprint := cmd.Payload["Fingerprint"].(string)
toggleIdentity(enc, fingerprint, onOff)
-
- top.Broadcast <- dto.ZitiTunnelStatus{
- Status: rts.ToStatus(),
- Metrics: nil,
- }
default:
log.Warnf("Unknown operation: %s. Returning error on pipe", cmd.Function)
respondWithError(enc, "Something unexpected has happened", UNKNOWN_ERROR, nil)
@@ -360,7 +383,7 @@ func serveEvents(conn net.Conn) {
status, ok := msg.(dto.ZitiTunnelStatus)
if !ok {
log.Errorf("message received couldn't be converted to status? %v", status)
- break
+ break
}
respond(o, dto.Response{Payload: status})
_, err := w.WriteString("\n")
@@ -375,8 +398,6 @@ func serveEvents(conn net.Conn) {
break
}
_ = w.Flush()
-
- log.Infof("got %v", msg)
}
log.Info("exiting serve events")
}
@@ -567,6 +588,7 @@ func connectIdentity(id *dto.Identity) {
//tell the c sdk to use the file from the id and connect
log.Debugf("loading identity %s with fingerprint %s", id.Name, id.FingerPrint)
rts.LoadIdentity(id)
+ activeIds[id.FingerPrint] = id
} else {
log.Debugf("id [%s] is already connected - not reconnecting", id.Name)
}
@@ -622,3 +644,23 @@ func respond(out *json.Encoder, thing interface{}) {
//leave for debugging j.Encode(thing)
_ = out.Encode(thing)
}
+
+func pipeName(path string) string {
+ if !Debug {
+ return pipeBase + path
+ } else {
+ return pipeBase /*+ `debug\`*/ + path
+ }
+}
+
+func ipcPipeName() string {
+ return pipeName("ipc")
+}
+
+func logsPipeName() string {
+ return pipeName("logs")
+}
+
+func eventsPipeName() string {
+ return pipeName("events")
+}
\ No newline at end of file
diff --git a/wintun-testing/ziti-tunnel/service/package-variables.go b/wintun-testing/ziti-tunnel/service/package-variables.go
index d2e9f349..85f5ec4c 100644
--- a/wintun-testing/ziti-tunnel/service/package-variables.go
+++ b/wintun-testing/ziti-tunnel/service/package-variables.go
@@ -1,26 +1,3 @@
package service
-import (
- "time"
- "wintun-testing/ziti-tunnel/globals"
-)
-
-const (
- NF_GROUP_NAME = "NetFoundry Tunneler Users"
- TunName = "ZitiTUN"
-)
-
-var TunStarted time.Time
-var log = globals.Logger()
-
-const Ipv4ip = "169.254.1.1"
-const Ipv4mask = 24
-const Ipv4dns = "127.0.0.1" // use lo -- don't pass DNS queries through tunneler SDK
-
-// IPv6 CIDR fe80:6e66:7a69:7469::/64
-// : nf : zi : ti ::
-const ipv6pfx = "fe80:6e66:7a69:7469"
-const ipv6ip = "1"
-const ipv6mask = 64
-const Ipv6dns = "::1" // must be in "ipv6ip/ipv6mask" CIDR block
diff --git a/wintun-testing/ziti-tunnel/service/pkg-vars.go b/wintun-testing/ziti-tunnel/service/pkg-vars.go
index 6f1cf1ab..017e8ed5 100644
--- a/wintun-testing/ziti-tunnel/service/pkg-vars.go
+++ b/wintun-testing/ziti-tunnel/service/pkg-vars.go
@@ -4,12 +4,14 @@ import (
"github.com/tv42/topic"
"golang.org/x/sys/windows/svc"
"sync"
+ "time"
+ "wintun-testing/ziti-tunnel/dto"
+ "wintun-testing/ziti-tunnel/globals"
)
var pipeBase = `\\.\pipe\NetFoundry\tunneler\`
-//var tunStatus = RuntimeState{}
-//var state = dto.TunnelStatusa{}
+var activeIds = make(map[string]*dto.Identity)
var rts = RuntimeState{}
var interrupt chan struct{}
@@ -17,6 +19,11 @@ var wg sync.WaitGroup
var connections int
var Debug bool
+var top = topic.New()
+
+var TunStarted time.Time
+var log = globals.Logger()
+
const (
SUCCESS = 0
COULD_NOT_WRITE_FILE = 1
@@ -55,24 +62,18 @@ const (
System = "(A;;FA;;;SY)"
BuiltinAdmins = "(A;;FA;;;BA)"
LocalService = "(A;;FA;;;LS)"
+
+ NF_GROUP_NAME = "NetFoundry Tunneler Users"
+ TunName = "ZitiTUN"
+
+ Ipv4ip = "169.254.1.1"
+ Ipv4mask = 24
+ Ipv4dns = "127.0.0.1" // use lo -- don't pass DNS queries through tunneler SDK
+
+ // IPv6 CIDR fe80:6e66:7a69:7469::/64
+ // : nf : zi : ti ::
+ ipv6pfx = "fe80:6e66:7a69:7469"
+ ipv6ip = "1"
+ ipv6mask = 64
+ Ipv6dns = "::1" // must be in "ipv6ip/ipv6mask" CIDR block
)
-
-func pipeName(path string) string {
- if !Debug {
- return pipeBase + path
- } else {
- return pipeBase + `debug\` + path
- }
-}
-
-var top = topic.New()
-
-func ipcPipeName() string {
- return pipeName("ipc")
-}
-func logsPipeName() string {
- return pipeName("logs")
-}
-func eventsPipeName() string {
- return pipeName("events")
-}
diff --git a/wintun-testing/ziti-tunnel/service/state.go b/wintun-testing/ziti-tunnel/service/state.go
index 6f3ee794..f4cf2a3f 100644
--- a/wintun-testing/ziti-tunnel/service/state.go
+++ b/wintun-testing/ziti-tunnel/service/state.go
@@ -164,6 +164,8 @@ func (t *RuntimeState) LoadIdentity(id *dto.Identity) {
}
log.Infof("loading identity %s with fingerprint %s", id.Name, id.FingerPrint)
ctx := cziti.LoadZiti(id.Path())
+ id.NFContext = ctx
+
id.Connected = true
if ctx == nil {
log.Warnf("connecting to identity with fingerprint [%s] did not error but no context was returned", id.FingerPrint)
@@ -171,7 +173,7 @@ func (t *RuntimeState) LoadIdentity(id *dto.Identity) {
}
log.Infof("successfully loaded %s@%s", ctx.Name(), ctx.Controller())
- log.Debug("name changed from %s to %s", id.Name, ctx.Name())
+ log.Debugf("name changed from %s to %s", id.Name, ctx.Name())
id.Name = ctx.Name()
if ctx.Services != nil {