diff --git a/.gitignore b/.gitignore index 3c4efe20..ec134fcb 100644 --- a/.gitignore +++ b/.gitignore @@ -258,4 +258,6 @@ paket-files/ # Python Tools for Visual Studio (PTVS) __pycache__/ -*.pyc \ No newline at end of file +*.pyc + +*/*.dll diff --git a/README.md b/README.md index 47f8edf6..0adbcf7a 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,18 @@ -# ziti-client-windows +# Ziti Tunnel for Windows -This is a Windows 10 vpn plugin that "almost" works with windows 10. The VPN API is very fragile -and replacing the wrong element in the wrong place will likely result in errors. +(the uwp project which used to be here has moved to uwp-vpnplugin-archive and is likely abandoned) -Some notes: +The Ziti Tunnel for Windows is an application that is necessary to integrate applications which cannot embed a Ziti SDK +directly into the application. This is colloquially known as a "brown field" Ziti-enabled application because the app +itself has no understanding that it has been Ziti-enabled. -* to connect to a TCP server the traffic seems to be required to leave the actual machine. you - cannot use a locally listening socket for the tcpTransport +In order for an application that has no knowledge of being Ziti-enabled to work the connections established by the app +must be intercepted before leaving the computer and routed through the Ziti network. This is accomplished by three main +components: -* using an empty list as opposed to null in StartWithMainTransport might result in unexpected out of - memory erorrs. - -* git@github.com:YtFlow/YtFlowTunnel.git at least compiles and deploys. never got it working but - might be useful +* [wintun](https://www.wintun.net) - provides a Layer 3 TUN for Windows +* A Windows service which runs as the local system account which creates the TUN as well as manages the Ziti connections +* A Windows UWP UI application that allows the interactively logged on user to interact with the Windows service -Testing: -once deployed (ideally using a remote machine so as to not risk your running windows) you should be able to -get the 'conenct' and 'disconnect' buttons to function. You'll need to update ZitiVPNPlugin.DESIRED_HOST -as that was using a linux vm. - -You can run netcat on that linux vm using: nc -k -l 0.0.0.0 8900 -Then you can see what routes are configured using: netstat -nr -If you run dnsmasq on that same linux VM you can set the vpnContext.DnsServer in MainPage.xaml.cs to the -same machine and influence what DNS results you get back and map those to whatever routes are added via the plugin diff --git a/wintun-testing/.gitignore b/service/.gitignore similarity index 100% rename from wintun-testing/.gitignore rename to service/.gitignore diff --git a/wintun-testing/.run/ziti-tunnel-debug.run.xml b/service/.run/ziti-tunnel-debug.run.xml similarity index 100% rename from wintun-testing/.run/ziti-tunnel-debug.run.xml rename to service/.run/ziti-tunnel-debug.run.xml diff --git a/wintun-testing/README.md b/service/README.md similarity index 100% rename from wintun-testing/README.md rename to service/README.md diff --git a/wintun-testing/build.bat b/service/build.bat similarity index 100% rename from wintun-testing/build.bat rename to service/build.bat diff --git a/wintun-testing/build.sh b/service/build.sh similarity index 100% rename from wintun-testing/build.sh rename to service/build.sh diff --git a/wintun-testing/cziti/ctun.go b/service/cziti/ctun.go similarity index 100% rename from wintun-testing/cziti/ctun.go rename to service/cziti/ctun.go diff --git a/wintun-testing/cziti/cziti-cli/main.go b/service/cziti/cziti-cli/main.go similarity index 100% rename from wintun-testing/cziti/cziti-cli/main.go rename to service/cziti/cziti-cli/main.go diff --git a/wintun-testing/cziti/dns-proxy.go b/service/cziti/dns-proxy.go similarity index 100% rename from wintun-testing/cziti/dns-proxy.go rename to service/cziti/dns-proxy.go diff --git a/wintun-testing/cziti/dns.go b/service/cziti/dns.go similarity index 100% rename from wintun-testing/cziti/dns.go rename to service/cziti/dns.go diff --git a/wintun-testing/cziti/sdk.c b/service/cziti/sdk.c similarity index 100% rename from wintun-testing/cziti/sdk.c rename to service/cziti/sdk.c diff --git a/wintun-testing/cziti/sdk.go b/service/cziti/sdk.go similarity index 100% rename from wintun-testing/cziti/sdk.go rename to service/cziti/sdk.go diff --git a/wintun-testing/cziti/sdk.h b/service/cziti/sdk.h similarity index 100% rename from wintun-testing/cziti/sdk.h rename to service/cziti/sdk.h diff --git a/wintun-testing/cziti/windns/windns.go b/service/cziti/windns/windns.go similarity index 100% rename from wintun-testing/cziti/windns/windns.go rename to service/cziti/windns/windns.go diff --git a/wintun-testing/go.mod b/service/go.mod similarity index 100% rename from wintun-testing/go.mod rename to service/go.mod diff --git a/wintun-testing/go.sum b/service/go.sum similarity index 100% rename from wintun-testing/go.sum rename to service/go.sum diff --git a/service/libuv.dll b/service/libuv.dll deleted file mode 100644 index cdd43f9d..00000000 Binary files a/service/libuv.dll and /dev/null differ diff --git a/wintun-testing/reset-nw.bat b/service/reset-nw.bat similarity index 100% rename from wintun-testing/reset-nw.bat rename to service/reset-nw.bat diff --git a/wintun-testing/ziti-tunnel/config/config.go b/service/ziti-tunnel/config/config.go similarity index 100% rename from wintun-testing/ziti-tunnel/config/config.go rename to service/ziti-tunnel/config/config.go diff --git a/wintun-testing/ziti-tunnel/dto/dtos.go b/service/ziti-tunnel/dto/dtos.go similarity index 100% rename from wintun-testing/ziti-tunnel/dto/dtos.go rename to service/ziti-tunnel/dto/dtos.go diff --git a/wintun-testing/ziti-tunnel/globals/loghelper.go b/service/ziti-tunnel/globals/loghelper.go similarity index 100% rename from wintun-testing/ziti-tunnel/globals/loghelper.go rename to service/ziti-tunnel/globals/loghelper.go diff --git a/wintun-testing/ziti-tunnel/idutil/identity.go b/service/ziti-tunnel/idutil/identity.go similarity index 100% rename from wintun-testing/ziti-tunnel/idutil/identity.go rename to service/ziti-tunnel/idutil/identity.go diff --git a/wintun-testing/ziti-tunnel/main.go b/service/ziti-tunnel/main.go similarity index 100% rename from wintun-testing/ziti-tunnel/main.go rename to service/ziti-tunnel/main.go diff --git a/service/ziti-tunnel/runtime/package-variables.go b/service/ziti-tunnel/runtime/package-variables.go new file mode 100644 index 00000000..88031833 --- /dev/null +++ b/service/ziti-tunnel/runtime/package-variables.go @@ -0,0 +1,26 @@ +package runtime + +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/permissions.go b/service/ziti-tunnel/runtime/permissions.go similarity index 98% rename from wintun-testing/ziti-tunnel/service/permissions.go rename to service/ziti-tunnel/runtime/permissions.go index 6f01eaca..ddb4c612 100644 --- a/wintun-testing/ziti-tunnel/service/permissions.go +++ b/service/ziti-tunnel/runtime/permissions.go @@ -1,4 +1,4 @@ -package service +package runtime import ( "github.com/netfoundry/ziti-foundation/util/stringz" diff --git a/wintun-testing/ziti-tunnel/service/state.go b/service/ziti-tunnel/runtime/state.go similarity index 62% rename from wintun-testing/ziti-tunnel/service/state.go rename to service/ziti-tunnel/runtime/state.go index 558ab9a9..0b7a38c8 100644 --- a/wintun-testing/ziti-tunnel/service/state.go +++ b/service/ziti-tunnel/runtime/state.go @@ -1,4 +1,4 @@ -package service +package runtime import ( "bufio" @@ -11,42 +11,54 @@ import ( "strconv" "time" "wintun-testing/cziti" + "wintun-testing/ziti-tunnel/config" "wintun-testing/ziti-tunnel/dto" "wintun-testing/ziti-tunnel/idutil" ) -type RuntimeState struct { - state *dto.TunnelStatus +type TunnelerState struct { + Active bool + Duration int64 + Identities []*dto.Identity + IpInfo *TunIpInfo `json:"IpInfo,omitempty"` + tun *tun.Device tunName string } -func (t *RuntimeState) RemoveByFingerprint(fingerprint string) { +type TunIpInfo struct { + Ip string + Subnet string + MTU uint16 + DNS string +} + +func (t *TunnelerState) RemoveByFingerprint(fingerprint string) { log.Debugf("removing fingerprint: %s", fingerprint) - if index, _ := t.Find(fingerprint); index < len(t.state.Identities) { - t.state.Identities = append(t.state.Identities[:index], t.state.Identities[index+1:]...) + if index, _ := t.Find(fingerprint); index < len(t.Identities) { + t.Identities = append(t.Identities[:index], t.Identities[index+1:]...) } } -func (t *RuntimeState) Find(fingerprint string) (int, *dto.Identity) { - for i, n := range t.state.Identities { +func (t *TunnelerState) Find(fingerprint string) (int, *dto.Identity) { + for i, n := range t.Identities { if n.FingerPrint == fingerprint { return i, n } } - return len(t.state.Identities), nil + return len(t.Identities), nil } -func (t *RuntimeState) RemoveByIdentity(id dto.Identity) { +func (t *TunnelerState) RemoveByIdentity(id dto.Identity) { t.RemoveByFingerprint(id.FingerPrint) } -func (t *RuntimeState) FindByIdentity(id dto.Identity) (int, *dto.Identity) { +func (t *TunnelerState) FindByIdentity(id dto.Identity) (int, *dto.Identity) { return t.Find(id.FingerPrint) } -func SaveState(t *RuntimeState) { +func SaveState(s *TunnelerState) { // overwrite file if it exists _ = os.MkdirAll(config.Path(), 0644) @@ -57,11 +69,8 @@ func SaveState(t *RuntimeState) { w := bufio.NewWriter(bufio.NewWriter(cfg)) enc := json.NewEncoder(w) enc.SetIndent("", " ") - t.state.IpInfo = nil - for _, id := range t.state.Identities { - id.Services = nil - } - _ = enc.Encode(t.state) + s.IpInfo = nil + _ = enc.Encode(s) _ = w.Flush() err = cfg.Close() @@ -71,34 +80,31 @@ func SaveState(t *RuntimeState) { log.Debug("state saved") } -func (t *RuntimeState) ToStatus() dto.TunnelStatus { - var uptime int64 - - now := time.Now() - tunStart := now.Sub(TunStarted) - uptime = tunStart.Milliseconds() - - var idCount int - if t.state != nil && t.state.Identities != nil { - idCount = len(t.state.Identities) +func (t *TunnelerState) Clean() TunnelerState { + var d int64 + if t.Active { + now := time.Now() + dd := now.Sub(TunStarted) + d = dd.Milliseconds() + } else { + d = 0 } - clean := dto.TunnelStatus{ - Active: t.state.Active, - Duration: uptime, - Identities: make([]*dto.Identity, idCount), - IpInfo: t.state.IpInfo, + rtn := TunnelerState{ + Active: t.Active, + Duration: d, + Identities: make([]*dto.Identity, len(t.Identities)), + IpInfo: t.IpInfo, + } + for i, id := range t.Identities { + log.Debug("returning clean identity: %s", id.Name) + rtn.Identities[i] = idutil.Clean(*id) } - for i, id := range t.state.Identities { - cid := idutil.Clean(*id) - clean.Identities[i] = &cid - } - - return clean + return rtn } -func (t *RuntimeState) CreateTun() error { +func (t *TunnelerState) CreateTun() error { if noZiti() { log.Warnf("NOZITI set to true. this should be only used for debugging") return nil @@ -162,38 +168,7 @@ func (t *RuntimeState) CreateTun() error { return nil } -func (t *RuntimeState) LoadIdentity(id *dto.Identity) { - if !noZiti() { - if id.Connected { - log.Warnf("id [%s] already connected", id.FingerPrint) - return - } - 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) - return - } - log.Infof("successfully loaded %s@%s", ctx.Name(), ctx.Controller()) - - log.Debugf("name changed from %s to %s", id.Name, ctx.Name()) - id.Name = ctx.Name() - id.Services = make([]*dto.Service, 0) - - } else { - log.Warnf("NOZITI set to true. this should be only used for debugging") - } -} - -func noZiti() bool { - v, _ := strconv.ParseBool(os.Getenv("NOZITI")) - return v -} - -func (t *RuntimeState) Close() { +func (t *TunnelerState) Close() { if t.tun != nil { log.Warn("TODO: actually close the tun - or disable all the identities etc.") /* @@ -207,26 +182,42 @@ func (t *RuntimeState) Close() { } } -func (t *RuntimeState) LoadConfig() { - log.Infof("reading config file located at: %s", config.File()) - file, err := os.OpenFile(config.File(), os.O_RDONLY, 0644) - if err != nil { - t.state = &dto.TunnelStatus{} - return - } +func (t *TunnelerState) LoadIdentity(id *dto.Identity) { + if !noZiti() { + if id.Connected { + log.Warnf("id [%s] already connected", id.FingerPrint) + return + } + log.Infof("loading identity %s with fingerprint %s", id.Name, id.FingerPrint) + ctx := cziti.LoadZiti(id.Path()) + id.Connected = true + if ctx == nil { + log.Warnf("connecting to identity with fingerprint [%s] did not error but no context was returned", id.FingerPrint) + return + } + log.Infof("successfully loaded %s@%s", ctx.Name(), ctx.Controller()) - r := bufio.NewReader(file) - dec := json.NewDecoder(r) + log.Debug("name changed from %s to %s", id.Name, ctx.Name()) + id.Name = ctx.Name() - err = dec.Decode(&rts.state) - if err != nil { - log.Warnf("unexpected error reading config file. %v", err) - t.state = &dto.TunnelStatus{} - return + if ctx.Services != nil { + log.Debug("ranging over services...") + id.Services = make([]*dto.Service, 0) + for _, svc := range *ctx.Services { + id.Services = append(id.Services, &dto.Service{ + Name: svc.Name, + HostName: svc.InterceptHost, + Port: uint16(svc.InterceptPort)}) + } + } else { + log.Warnf("no services to load for service name: %s", ctx.Name()) + } + } else { + log.Warnf("NOZITI set to true. this should be only used for debugging") } +} - err = file.Close() - if err != nil { - log.Errorf("could not close configuration file. this is not normal! %v", err) - } -} \ No newline at end of file +func noZiti() bool { + v, _ := strconv.ParseBool(os.Getenv("NOZITI")) + return v +} diff --git a/wintun-testing/ziti-tunnel/service/install.go b/service/ziti-tunnel/service/install.go similarity index 100% rename from wintun-testing/ziti-tunnel/service/install.go rename to service/ziti-tunnel/service/install.go diff --git a/wintun-testing/ziti-tunnel/service/ipc.go b/service/ziti-tunnel/service/ipc.go similarity index 100% rename from wintun-testing/ziti-tunnel/service/ipc.go rename to service/ziti-tunnel/service/ipc.go diff --git a/wintun-testing/ziti-tunnel/service/manage.go b/service/ziti-tunnel/service/manage.go similarity index 100% rename from wintun-testing/ziti-tunnel/service/manage.go rename to service/ziti-tunnel/service/manage.go diff --git a/wintun-testing/ziti-tunnel/service/pkg-vars.go b/service/ziti-tunnel/service/pkg-vars.go similarity index 100% rename from wintun-testing/ziti-tunnel/service/pkg-vars.go rename to service/ziti-tunnel/service/pkg-vars.go diff --git a/wintun-testing/ziti-tunnel/service/service.go b/service/ziti-tunnel/service/service.go similarity index 100% rename from wintun-testing/ziti-tunnel/service/service.go rename to service/ziti-tunnel/service/service.go diff --git a/wintun-testing/ziti-wintun/main.go b/service/ziti-wintun/main.go similarity index 100% rename from wintun-testing/ziti-wintun/main.go rename to service/ziti-wintun/main.go diff --git a/service/ziti.dll b/service/ziti.dll deleted file mode 100644 index c4398b01..00000000 Binary files a/service/ziti.dll and /dev/null differ diff --git a/uwp-vpnplugin-archive/README.md b/uwp-vpnplugin-archive/README.md new file mode 100644 index 00000000..47f8edf6 --- /dev/null +++ b/uwp-vpnplugin-archive/README.md @@ -0,0 +1,27 @@ +# ziti-client-windows + +This is a Windows 10 vpn plugin that "almost" works with windows 10. The VPN API is very fragile +and replacing the wrong element in the wrong place will likely result in errors. + +Some notes: + +* to connect to a TCP server the traffic seems to be required to leave the actual machine. you + cannot use a locally listening socket for the tcpTransport + +* using an empty list as opposed to null in StartWithMainTransport might result in unexpected out of + memory erorrs. + +* git@github.com:YtFlow/YtFlowTunnel.git at least compiles and deploys. never got it working but + might be useful + +Testing: + +once deployed (ideally using a remote machine so as to not risk your running windows) you should be able to +get the 'conenct' and 'disconnect' buttons to function. You'll need to update ZitiVPNPlugin.DESIRED_HOST +as that was using a linux vm. + +You can run netcat on that linux vm using: nc -k -l 0.0.0.0 8900 +Then you can see what routes are configured using: netstat -nr +If you run dnsmasq on that same linux VM you can set the vpnContext.DnsServer in MainPage.xaml.cs to the +same machine and influence what DNS results you get back and map those to whatever routes are added via the plugin + diff --git a/ZitiUWPClient/ZitiUWPClient.csproj b/uwp-vpnplugin-archive/ZitiUWPClient/ZitiUWPClient.csproj similarity index 100% rename from ZitiUWPClient/ZitiUWPClient.csproj rename to uwp-vpnplugin-archive/ZitiUWPClient/ZitiUWPClient.csproj diff --git a/wintun-testing/ziti-tunnel/cmd/root.go b/wintun-testing/ziti-tunnel/cmd/root.go deleted file mode 100644 index c95fef8b..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root.go +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index 28460aec..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root_addidentity.go +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index ec9ff0db..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root_debug.go +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 94c8b46a..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root_disable_id.go +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index ebdbeee2..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root_enable_id.go +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 92444aa7..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root_removeidentity.go +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index decfbd6f..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root_svc.go +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index ed838e84..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root_svc_install.go +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 4a0a64a2..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root_svc_remove.go +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 4de6e9c1..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root_svc_start.go +++ /dev/null @@ -1,19 +0,0 @@ -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 deleted file mode 100644 index 6bcac35a..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root_svc_status.go +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index ac400f52..00000000 --- a/wintun-testing/ziti-tunnel/cmd/root_svc_stop.go +++ /dev/null @@ -1,19 +0,0 @@ -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 deleted file mode 100644 index 3e0ef436..00000000 --- a/wintun-testing/ziti-tunnel/cmd/version.go +++ /dev/null @@ -1,20 +0,0 @@ -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/service/debug.go b/wintun-testing/ziti-tunnel/service/debug.go deleted file mode 100644 index 911faccc..00000000 --- a/wintun-testing/ziti-tunnel/service/debug.go +++ /dev/null @@ -1,76 +0,0 @@ -package service - -import ( - idcfg "github.com/netfoundry/ziti-sdk-golang/ziti/config" - "wintun-testing/ziti-tunnel/dto" -) - -func dbg() { - - r := rts.ToStatus() - events.broadcast <- dto.TunnelStatusEvent{ - StatusEvent: dto.StatusEvent{Op: "status"}, - Status: r, - } - - - svcs := make([]*dto.Service, 2) - svcs[0] = &dto.Service{ - Name: "FakeService1", - HostName: "fake-service.com", - Port: 1234, - } - svcs[1] = &dto.Service{ - Name: "Second Fake Service", - HostName: "some-other-host.ziti", - Port: 5555, - } - - events.broadcast <- dto.IdentityEvent{ - ActionEvent: IDENTITY_ADDED, - Id: dto.Identity{ - Name: "NewIdentity", - FingerPrint: "new_id_fingerprint", - Active: true, - Config: idcfg.Config{ - ZtAPI: "http://new_id.com:2123", - }, - Status: STATUS_ENROLLED, - Services: svcs, - Metrics: nil, - }, - } - - events.broadcast <- dto.ServiceEvent{ - ActionEvent: SERVICE_ADDED, - Service: dto.Service{ - Name: "New Service", - HostName: "some new hostname", - Port: 5000, - }, - Fingerprint: "new_id_fingerprint", - } - - events.broadcast <- dto.ServiceEvent{ - ActionEvent: SERVICE_REMOVED, - Service: dto.Service{ - Name: "New Service", - }, - Fingerprint: "new_id_fingerprint", - } - - events.broadcast <- dto.IdentityEvent{ - ActionEvent: IDENTITY_REMOVED, - Id: dto.Identity{ - Name: "", - FingerPrint: "new_id_fingerprint", - Active: false, - Config: idcfg.Config{}, - Status: "", - Services: nil, - Metrics: nil, - Connected: false, - NFContext: nil, - }, - } -} diff --git a/wintun-testing/ziti-tunnel/service/events.go b/wintun-testing/ziti-tunnel/service/events.go deleted file mode 100644 index 6422a4c7..00000000 --- a/wintun-testing/ziti-tunnel/service/events.go +++ /dev/null @@ -1,28 +0,0 @@ -package service - -import "wintun-testing/ziti-tunnel/dto" - -const ( - ADDED = "added" - REMOVED = "removed" - SERVICE_OP = "service" - IDENTITY_OP = "identity" -) - -var SERVICE_ADDED = dto.ActionEvent{ - StatusEvent: dto.StatusEvent{Op: SERVICE_OP}, - Action: ADDED, -} -var SERVICE_REMOVED = dto.ActionEvent{ - StatusEvent: dto.StatusEvent{Op: SERVICE_OP}, - Action: REMOVED, -} - -var IDENTITY_ADDED = dto.ActionEvent{ - StatusEvent: dto.StatusEvent{Op: IDENTITY_OP}, - Action: ADDED, -} -var IDENTITY_REMOVED = dto.ActionEvent{ - StatusEvent: dto.StatusEvent{Op: IDENTITY_OP}, - Action: REMOVED, -} \ No newline at end of file diff --git a/wintun-testing/ziti-tunnel/service/topic.go b/wintun-testing/ziti-tunnel/service/topic.go deleted file mode 100644 index 6f8c100f..00000000 --- a/wintun-testing/ziti-tunnel/service/topic.go +++ /dev/null @@ -1,43 +0,0 @@ -package service - -type topic struct { - broadcast chan interface{} - channels map[int]chan interface{} - done chan bool -} - -func newTopic() topic { - return topic{ - broadcast: make(chan interface{}, 8), - channels: make(map[int]chan interface{}), - done: make(chan bool), - } -} - -func(t *topic) register(id int, c chan interface{}) { - t.channels[id] = c -} - -func(t *topic) unregister(id int) { - delete(t.channels, id) -} - -func(t *topic) shutdown() { - t.done <- true -} - -func(t *topic) run() { - go func() { - for { - select { - case msg := <-t.broadcast: - for _, c := range t.channels { - c <- msg - } - break - case <-t.done: - return - } - } - }() -}