diff --git a/DesktopEdge/MainWindow.xaml.cs b/DesktopEdge/MainWindow.xaml.cs index 2409679b..456f1584 100644 --- a/DesktopEdge/MainWindow.xaml.cs +++ b/DesktopEdge/MainWindow.xaml.cs @@ -517,6 +517,7 @@ namespace ZitiDesktopEdge { found.Name = zid.Name; found.ControllerUrl = zid.ControllerUrl; found.IsEnabled = zid.IsEnabled; + LoadIdentities(true); return; } } else { diff --git a/service/ziti-tunnel/cli/constants.go b/service/ziti-tunnel/cli/constants.go index 41e9712a..f2643929 100644 --- a/service/ziti-tunnel/cli/constants.go +++ b/service/ziti-tunnel/cli/constants.go @@ -34,8 +34,12 @@ var SET_LOGLEVEL = dto.CommandMsg{ Function: "SetLogLevel", } -var NOTIFY_UI = dto.CommandMsg{ - Function: "NotifyUIAndUpdateService", +var NOTIFY_LOGLEVEL_UI_MONITOR = dto.CommandMsg{ + Function: "NotifyLogLevelUIAndUpdateService", +} + +var NOTIFY_IDENTITY_UI = dto.CommandMsg{ + Function: "NotifyIdentityUI", } var templateIdentity = `{{printf "%40s" "Name"}} | {{printf "%41s" "FingerPrint"}} | {{printf "%6s" "Active"}} | {{printf "%30s" "Config"}} | {{"Status"}} diff --git a/service/ziti-tunnel/cli/service.go b/service/ziti-tunnel/cli/service.go index 5c53c45d..a52dc818 100644 --- a/service/ziti-tunnel/cli/service.go +++ b/service/ziti-tunnel/cli/service.go @@ -19,7 +19,12 @@ func OnOffIdentity(args []string, flags map[string]bool) { identityPayload["Fingerprint"] = args[0] ONOFF_IDENTITY.Payload = identityPayload log.Debugf("OnOffIdentity Payload %v", ONOFF_IDENTITY) - GetDataFromIpcPipe(&ONOFF_IDENTITY, nil, GetIdentityResponseObjectFromRTS, args, flags) + status := GetDataFromIpcPipe(&ONOFF_IDENTITY, nil, GetIdentityResponseObjectFromRTS, args, flags) + if status { + NOTIFY_IDENTITY_UI.Payload = identityPayload + log.Infof("Notifying the Identity Status to UI %v", identityPayload) + GetDataFromIpcPipe(&NOTIFY_IDENTITY_UI, nil, GetResponseObjectFromRTS, args, flags) + } } //SetLogLevel is to change the loglevel through cmdline @@ -33,9 +38,9 @@ func SetLogLevel(args []string, flags map[string]bool) { log.Debugf("LogLevel Payload %v", SET_LOGLEVEL) status := GetDataFromIpcPipe(&SET_LOGLEVEL, nil, GetResponseObjectFromRTS, args, flags) if status { - NOTIFY_UI.Payload = loglevelPayload - log.Infof("Notifying the LogLevel to UI and Ziti monitor service %v", NOTIFY_UI) - GetDataFromIpcPipe(&NOTIFY_UI, nil, GetResponseObjectFromRTS, args, flags) + NOTIFY_LOGLEVEL_UI_MONITOR.Payload = loglevelPayload + log.Infof("Notifying the LogLevel to UI and Ziti monitor service %v", loglevelPayload) + GetDataFromIpcPipe(&NOTIFY_LOGLEVEL_UI_MONITOR, nil, GetResponseObjectFromRTS, args, flags) } } } diff --git a/service/ziti-tunnel/service/ipc.go b/service/ziti-tunnel/service/ipc.go index 85e54c4a..29627276 100644 --- a/service/ziti-tunnel/service/ipc.go +++ b/service/ziti-tunnel/service/ipc.go @@ -433,8 +433,10 @@ func serveIpc(conn net.Conn) { toggleIdentity(enc, fingerprint, onOff) case "SetLogLevel": setLogLevel(enc, cmd.Payload["Level"].(string)) - case "NotifyUIAndUpdateService": + case "NotifyLogLevelUIAndUpdateService": sendLogLevelAndNotify(enc, cmd.Payload["Level"].(string)) + case "NotifyIdentityUI": + sendIdentityAndNotifyUI(enc, cmd.Payload["Fingerprint"].(string)) case "ZitiDump": log.Debug("request to ZitiDump received") for _, id := range rts.ids { @@ -1007,6 +1009,25 @@ func sendLogLevelAndNotify(enc *json.Encoder, loglevel string) { LogLevel: loglevel, } message := fmt.Sprintf("Loglevel %s is sent to the events channel", loglevel) + log.Info(message) resp := dto.Response{Message: "success", Code: SUCCESS, Error: "", Payload: message} respond(enc, resp) } + +func sendIdentityAndNotifyUI(enc *json.Encoder, fingerprint string) { + for _, id := range rts.ids { + if id.FingerPrint == fingerprint { + events.broadcast <- dto.IdentityEvent{ + ActionEvent: IDENTITY_ADDED, + Id: id.Identity, + } + message := fmt.Sprintf("Identity %s - %s updated message is sent to the events channel", id.Identity.Name, id.Identity.FingerPrint) + log.Info(message) + resp := dto.Response{Message: "success", Code: SUCCESS, Error: "", Payload: message} + respond(enc, resp) + return + } + } + resp := dto.Response{Message: "", Code: ERROR, Error: "Could not find id matching fingerprint " + fingerprint, Payload: ""} + respond(enc, resp) +}