From ab96916247072275388af32baf1571c12cf34749 Mon Sep 17 00:00:00 2001 From: Mary Lincy Dcouto Date: Thu, 29 Jul 2021 15:16:10 +0530 Subject: [PATCH 01/11] send status message after reauth --- ZitiUpdateService/UpdateService.cs | 1 - service/cziti/sdk.go | 5 ++++- service/ziti-tunnel/service/ipc.go | 9 ++++++++- version | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ZitiUpdateService/UpdateService.cs b/ZitiUpdateService/UpdateService.cs index fa37d40e..14b9fceb 100644 --- a/ZitiUpdateService/UpdateService.cs +++ b/ZitiUpdateService/UpdateService.cs @@ -728,7 +728,6 @@ namespace ZitiUpdateService { if (!check.HashIsValid(updateFolder, filename)) { Logger.Warn("The file was downloaded but the hash is not valid. The file will be removed: {0}", fileDestination); File.Delete(fileDestination); - semaphore.Release(); return; } Logger.Debug("downloaded file hash was correct. update can continue."); diff --git a/service/cziti/sdk.go b/service/cziti/sdk.go index 2334cc82..511e336a 100644 --- a/service/cziti/sdk.go +++ b/service/cziti/sdk.go @@ -626,6 +626,7 @@ func eventCB(ztx C.ziti_context, event *C.ziti_event_t) { var minimumTimeoutRem int32 = -1 var maximumTimeoutRem int32 = -1 noTimeoutSvc := false + noTimeoutRemSvc := false if len(servicesToAdd) > 0 { zid.Services.Range(func(key interface{}, value interface{}) bool { //string, ZService @@ -649,7 +650,7 @@ func eventCB(ztx C.ziti_context, event *C.ziti_event_t) { maximumTimeoutRem = val.Service.TimeoutRemaining } } else { - noTimeoutSvc = true + noTimeoutRemSvc = true } return true @@ -657,6 +658,8 @@ func eventCB(ztx C.ziti_context, event *C.ziti_event_t) { }) if noTimeoutSvc { maximumTimeout = -1 + } + if noTimeoutRemSvc { maximumTimeoutRem = -1 } } diff --git a/service/ziti-tunnel/service/ipc.go b/service/ziti-tunnel/service/ipc.go index dab1783d..46d14678 100644 --- a/service/ziti-tunnel/service/ipc.go +++ b/service/ziti-tunnel/service/ipc.go @@ -1326,8 +1326,15 @@ func authMfa(out *json.Encoder, fingerprint string, code string) { id := rts.Find(fingerprint) result := cziti.AuthMFA(id.CId, code) if result == nil { - id.CId.UpdateMFATime() + // respond with auth success message immediately respond(out, dto.Response{Message: "AuthMFA complete", Code: SUCCESS, Error: "", Payload: fingerprint}) + + id.CId.UpdateMFATime() + rts.BroadcastEvent(dto.TunnelStatusEvent{ + StatusEvent: dto.StatusEvent{Op: "status"}, + Status: rts.ToStatus(true), + ApiVersion: API_VERSION, + }) } else { respondWithError(out, fmt.Sprintf("AuthMFA failed. the supplied code [%s] was not valid: %s", code, result), 1, result) } diff --git a/version b/version index 81c871de..4dae2985 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.10.0 +1.10.1 From 9d5085261520f342b23e2efddf0b7debc9cc6cf4 Mon Sep 17 00:00:00 2001 From: Mary Lincy Dcouto Date: Thu, 29 Jul 2021 23:07:23 +0530 Subject: [PATCH 02/11] updating c-sdk to 0.25.6, changes to timeoutRemaining type --- service/build.bat | 2 +- service/cziti/sdk.go | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/service/build.bat b/service/build.bat index 799c976e..c3538624 100644 --- a/service/build.bat +++ b/service/build.bat @@ -14,7 +14,7 @@ REM See the License for the specific language governing permissions and REM limitations under the License. REM SET REPO_URL=https://github.com/openziti/ziti-tunnel-sdk-c.git -SET ZITI_TUNNEL_REPO_BRANCH=v0.15.10 +SET ZITI_TUNNEL_REPO_BRANCH=v0.15.11 REM override the c sdk used in the build - leave blank for the same as specified in the tunneler sdk SET ZITI_SDK_C_BRANCH= REM the number of TCP connections the tunneler sdk can have at any one time diff --git a/service/cziti/sdk.go b/service/cziti/sdk.go index 511e336a..fb5506be 100644 --- a/service/cziti/sdk.go +++ b/service/cziti/sdk.go @@ -428,18 +428,26 @@ func serviceCB(ziti_ctx C.ziti_context, service *C.ziti_service, status C.int, z var pcId string pcId = C.GoString(pq.id) - log.Infof("Posture query %s, timeout %d, timeoutRemaining %d", C.GoString(pq.id), int(pq.timeout), int(pq.timeoutRemaining)) + + var pcTimeoutRemaining int + if unsafe.Pointer(pq.timeoutRemaining) != C.NULL { + pcTimeoutRemaining = int(*(*C.int)(pq.timeoutRemaining)) + } else { + pcTimeoutRemaining = -1 + } + + log.Infof("Posture query %s, timeout %d, timeoutRemaining %d", pcId, int(pq.timeout), pcTimeoutRemaining) _, found := pcIds[pcId] if found { log.Tracef("posture check with id %s already in failing posture check map", pcId) for _, pc := range postureChecks { - if pc.Id == C.GoString(pq.id) { + if pc.Id == pcId { if timeout == -1 || timeout > int(pq.timeout) { timeout = int(pq.timeout) } - if timeoutRemaining == -1 || timeoutRemaining > int(pq.timeoutRemaining) { - timeoutRemaining = int(pq.timeoutRemaining) + if timeoutRemaining == -1 || timeoutRemaining > pcTimeoutRemaining { + timeoutRemaining = pcTimeoutRemaining } break } @@ -451,7 +459,7 @@ func serviceCB(ziti_ctx C.ziti_context, service *C.ziti_service, status C.int, z QueryType: C.GoString(pq.query_type), Id: pcId, Timeout: int(pq.timeout), - TimeoutRemaining: int(pq.timeoutRemaining), + TimeoutRemaining: pcTimeoutRemaining, } timeout = pc.Timeout timeoutRemaining = pc.TimeoutRemaining From 8c078505d085572e0e9b02adfb9d5b2d5f77bb23 Mon Sep 17 00:00:00 2001 From: Mary Lincy Dcouto Date: Fri, 30 Jul 2021 00:59:55 +0530 Subject: [PATCH 03/11] no status after auth --- service/ziti-tunnel/service/ipc.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/service/ziti-tunnel/service/ipc.go b/service/ziti-tunnel/service/ipc.go index 46d14678..da8bc271 100644 --- a/service/ziti-tunnel/service/ipc.go +++ b/service/ziti-tunnel/service/ipc.go @@ -1277,8 +1277,8 @@ func Clean(src *Id) dto.Identity { if src.CId.MfaRefreshNeeded() && val.Service.TimeoutRemaining > 0 { var svcTimeout int32 = -1 for _, pc := range val.Service.PostureChecks { - if svcTimeout == -1 || svcTimeout > int32(pc.TimeoutRemaining) { - svcTimeout = int32(pc.TimeoutRemaining) + if svcTimeout == -1 || svcTimeout > int32(pc.Timeout) { + svcTimeout = int32(pc.Timeout) } break } @@ -1300,7 +1300,7 @@ func Clean(src *Id) dto.Identity { nid.MfaLastUpdatedTime = time.Now() } else { nid.MfaLastUpdatedTime = src.CId.MfaLastUpdatedTime - if (nid.MfaMaxTimeoutRem-int32(time.Since(nid.MfaLastUpdatedTime).Seconds())) < 0 && nid.MfaEnabled { + if (nid.MfaMaxTimeoutRem > -1 && (nid.MfaMaxTimeoutRem-int32(time.Since(nid.MfaLastUpdatedTime).Seconds())) < 0) && nid.MfaEnabled { nid.MfaNeeded = true } } @@ -1330,11 +1330,6 @@ func authMfa(out *json.Encoder, fingerprint string, code string) { respond(out, dto.Response{Message: "AuthMFA complete", Code: SUCCESS, Error: "", Payload: fingerprint}) id.CId.UpdateMFATime() - rts.BroadcastEvent(dto.TunnelStatusEvent{ - StatusEvent: dto.StatusEvent{Op: "status"}, - Status: rts.ToStatus(true), - ApiVersion: API_VERSION, - }) } else { respondWithError(out, fmt.Sprintf("AuthMFA failed. the supplied code [%s] was not valid: %s", code, result), 1, result) } From 12b349a069c62d3e0582a37cf800469e5f2be1ce Mon Sep 17 00:00:00 2001 From: Mary Lincy Dcouto Date: Fri, 30 Jul 2021 12:15:21 +0530 Subject: [PATCH 04/11] update the timeout remaining field in status message --- service/cziti/sdk.go | 29 ++++-- service/ziti-tunnel/dto/dtos.go | 2 + service/ziti-tunnel/service/ipc.go | 137 +++++++++++++++++------------ 3 files changed, 105 insertions(+), 63 deletions(-) diff --git a/service/cziti/sdk.go b/service/cziti/sdk.go index fb5506be..fad9c200 100644 --- a/service/cziti/sdk.go +++ b/service/cziti/sdk.go @@ -86,6 +86,7 @@ type BulkServiceChange struct { MfaMinTimeoutRem int32 MfaMaxTimeoutRem int32 MfaLastUpdatedTime time.Time + ServiceUpdatedTime time.Time } type NotificationMessage struct { @@ -162,6 +163,7 @@ type ZIdentity struct { MfaMinTimeoutRem int32 MfaMaxTimeoutRem int32 MfaLastUpdatedTime time.Time + ServiceUpdatedTime time.Time } func NewZid(statusChange func(int)) *ZIdentity { @@ -174,6 +176,7 @@ func NewZid(statusChange func(int)) *ZIdentity { zid.MfaMaxTimeout = -1 zid.MfaMinTimeout = -1 zid.MfaLastUpdatedTime = time.Now() + zid.ServiceUpdatedTime = time.Now() return zid } @@ -257,14 +260,27 @@ func (zid *ZIdentity) MfaRefreshNeeded() bool { return !(zid.MfaMinTimeoutRem == -1 && zid.MfaMaxTimeoutRem == -1) } -func (zid *ZIdentity) GetRemainingTime(timeout int32) int32 { +func (zid *ZIdentity) GetRemainingTime(timeout int32, timeoutRemaining int32) int32 { var remainingTimeout int32 - if (timeout - int32(time.Since(zid.MfaLastUpdatedTime).Seconds())) <= 0 { - remainingTimeout = 0 + + // calculate effective timeout remaining from last mfa or service update time + if zid.MfaLastUpdatedTime.After(zid.ServiceUpdatedTime) { + //calculate svc remaining timeout + if (timeout - int32(time.Since(zid.MfaLastUpdatedTime).Seconds())) < 0 { + remainingTimeout = 0 + } else { + remainingTimeout = timeout-int32(time.Since(zid.MfaLastUpdatedTime).Seconds()) + } } else { - remainingTimeout = timeout - int32(time.Since(zid.MfaLastUpdatedTime).Seconds()) + //calculate svc remaining timeout + if (timeoutRemaining - int32(time.Since(zid.ServiceUpdatedTime).Seconds())) < 0 { + remainingTimeout = 0 + } else { + remainingTimeout = timeoutRemaining - int32(time.Since(zid.ServiceUpdatedTime).Seconds()) + } } return remainingTimeout + } func (zid *ZIdentity) GetMFAState(interval int32) int { @@ -677,7 +693,7 @@ func eventCB(ztx C.ziti_context, event *C.ziti_event_t) { zid.MfaMaxTimeout = maximumTimeout zid.MfaMinTimeoutRem = minimumTimeoutRem zid.MfaMaxTimeoutRem = maximumTimeoutRem - zid.MfaLastUpdatedTime = now + zid.ServiceUpdatedTime = now svcChange := BulkServiceChange{ Fingerprint: zid.Fingerprint, @@ -689,7 +705,8 @@ func eventCB(ztx C.ziti_context, event *C.ziti_event_t) { MfaMaxTimeout: maximumTimeout, MfaMinTimeoutRem: minimumTimeoutRem, MfaMaxTimeoutRem: maximumTimeoutRem, - MfaLastUpdatedTime: now, + MfaLastUpdatedTime: zid.MfaLastUpdatedTime, + ServiceUpdatedTime: now, } if len(BulkServiceChanges) == cap(BulkServiceChanges) { diff --git a/service/ziti-tunnel/dto/dtos.go b/service/ziti-tunnel/dto/dtos.go index 17544e60..657a5a47 100644 --- a/service/ziti-tunnel/dto/dtos.go +++ b/service/ziti-tunnel/dto/dtos.go @@ -89,6 +89,8 @@ type Identity struct { MfaMinTimeoutRem int32 MfaMaxTimeoutRem int32 MfaLastUpdatedTime time.Time + ServiceUpdatedTime time.Time + } type Metrics struct { Up int64 diff --git a/service/ziti-tunnel/service/ipc.go b/service/ziti-tunnel/service/ipc.go index da8bc271..4032eb5a 100644 --- a/service/ziti-tunnel/service/ipc.go +++ b/service/ziti-tunnel/service/ipc.go @@ -1136,6 +1136,10 @@ func handleBulkServiceChange(sc cziti.BulkServiceChange) { }, } rts.BroadcastEvent(m) + + if (sc.MfaMinTimeoutRem > -1 && sc.MfaMinTimeoutRem < 60) || (sc.MfaMaxTimeoutRem > -1 && sc.MfaMaxTimeoutRem < 60) { + broadcastNotification() + } } func addUnit(count int, unit string) (result string) { @@ -1189,56 +1193,60 @@ func handleEvents(isInitialized chan struct{}) { // notification message case <-notificationFrequency.C: - cleanNotifications := make([]cziti.NotificationMessage, 0) - for _, id := range rts.ids { - if id.CId == nil || !id.CId.MfaRefreshNeeded() { - continue - } - notificationMessage := "" - - var notificationMinTimeout int32 = 0 - var notificationMaxTimeout int32 = -1 - switch mfaState := id.CId.GetMFAState(int32((constants.MaximumFrequency + rts.state.NotificationFrequency) * 60)); mfaState { - case constants.MfaAllSvcTimeout: - notificationMessage = fmt.Sprintf("All of the services of identity %s are timed out", id.Name) - case constants.MfaFewSvcTimeout: - notificationMessage = fmt.Sprintf("Some of the services of identity %s are timed out", id.Name) - case constants.MfaNearingTimeout: - notificationMinTimeout = id.CId.GetRemainingTime(id.CId.MfaMinTimeoutRem) - notificationMessage = fmt.Sprintf("Some of the services of identity %s are timing out in %s", id.Name, secondsToReadableFmt(notificationMinTimeout)) - default: - // do nothing - } - if len(notificationMessage) > 0 { - - if id.CId.MfaMaxTimeoutRem > -1 { - notificationMaxTimeout = id.CId.GetRemainingTime(id.CId.MfaMaxTimeoutRem) - } - notificationMinTimeout = id.CId.GetRemainingTime(id.CId.MfaMinTimeoutRem) - - cleanNotifications = append(cleanNotifications, cziti.NotificationMessage{ - Fingerprint: id.FingerPrint, - IdentityName: id.Name, - Severity: "major", - MfaMinimumTimeout: notificationMinTimeout, - MfaMaximumTimeout: notificationMaxTimeout, - Message: notificationMessage, - MfaTimeDuration: int(time.Since(id.CId.MfaLastUpdatedTime).Seconds()), - }) - } - } - - if len(cleanNotifications) > 0 { - log.Debugf("Sending notification message to UI %v", cleanNotifications) - rts.BroadcastEvent(cziti.TunnelNotificationEvent{ - Op: "notification", - Notification: cleanNotifications, - }) - } + broadcastNotification() } } } +func broadcastNotification() { + cleanNotifications := make([]cziti.NotificationMessage, 0) + for _, id := range rts.ids { + if id.CId == nil || !id.CId.MfaRefreshNeeded() { + continue + } + notificationMessage := "" + + var notificationMinTimeout int32 = 0 + var notificationMaxTimeout int32 = -1 + switch mfaState := id.CId.GetMFAState(int32((constants.MaximumFrequency + rts.state.NotificationFrequency) * 60)); mfaState { + case constants.MfaAllSvcTimeout: + notificationMessage = fmt.Sprintf("All of the services of identity %s are timed out", id.Name) + case constants.MfaFewSvcTimeout: + notificationMessage = fmt.Sprintf("Some of the services of identity %s are timed out", id.Name) + case constants.MfaNearingTimeout: + notificationMinTimeout = id.CId.GetRemainingTime(id.CId.MfaMinTimeout, id.CId.MfaMinTimeoutRem) + notificationMessage = fmt.Sprintf("Some of the services of identity %s are timing out in %s", id.Name, secondsToReadableFmt(notificationMinTimeout)) + default: + // do nothing + } + if len(notificationMessage) > 0 { + + if id.CId.MfaMaxTimeoutRem > -1 { + notificationMaxTimeout = id.CId.GetRemainingTime(id.CId.MfaMaxTimeout, id.CId.MfaMaxTimeoutRem) + } + notificationMinTimeout = id.CId.GetRemainingTime(id.CId.MfaMinTimeout, id.CId.MfaMinTimeoutRem) + + cleanNotifications = append(cleanNotifications, cziti.NotificationMessage{ + Fingerprint: id.FingerPrint, + IdentityName: id.Name, + Severity: "major", + MfaMinimumTimeout: notificationMinTimeout, + MfaMaximumTimeout: notificationMaxTimeout, + Message: notificationMessage, + MfaTimeDuration: int(time.Since(id.CId.MfaLastUpdatedTime).Seconds()), + }) + } + } + + if len(cleanNotifications) > 0 { + log.Debugf("Sending notification message to UI %v", cleanNotifications) + rts.BroadcastEvent(cziti.TunnelNotificationEvent{ + Op: "notification", + Notification: cleanNotifications, + }) + } +} + func ResetFrequency(newFrequency int) { notificationFrequency.Reset(time.Duration(newFrequency) * time.Minute) } @@ -1270,23 +1278,39 @@ func Clean(src *Id) dto.Identity { } if src.CId != nil { + var mfaMinTimeoutRemaining int32 = -1 + var mfaMaxTimeoutRemaining int32 = -1 src.CId.Services.Range(func(key interface{}, value interface{}) bool { //string, ZService val := value.(*cziti.ZService) + var svcMinTimeoutRemaining int32 = -1 if src.CId.MfaRefreshNeeded() && val.Service.TimeoutRemaining > 0 { var svcTimeout int32 = -1 + var svcTimeoutRemaining int32 = -1 + // fetch svc timeout and timeout remaining from pc for _, pc := range val.Service.PostureChecks { if svcTimeout == -1 || svcTimeout > int32(pc.Timeout) { svcTimeout = int32(pc.Timeout) } - break + if svcTimeoutRemaining == -1 || svcTimeoutRemaining > int32(pc.TimeoutRemaining) { + svcTimeoutRemaining = int32(pc.TimeoutRemaining) + } } - if (svcTimeout - int32(time.Since(src.CId.MfaLastUpdatedTime).Seconds())) < 0 { - atomic.StoreInt32(&val.Service.TimeoutRemaining, 0) - } else { - atomic.StoreInt32(&val.Service.TimeoutRemaining, svcTimeout-int32(time.Since(src.CId.MfaLastUpdatedTime).Seconds())) + + // calculate effective timeout remaining from last mfa or service update time + svcMinTimeoutRemaining = src.CId.GetRemainingTime(svcTimeout, svcTimeoutRemaining) + //calculate mfa min remaining timeout + if mfaMinTimeoutRemaining == -1 && src.CId.MfaMinTimeoutRem != -1 { + mfaMinTimeoutRemaining = src.CId.GetRemainingTime(src.CId.MfaMinTimeout, src.CId.MfaMinTimeoutRem) } + //calculate mfa max remaining timeout + if mfaMaxTimeoutRemaining == -1 && src.CId.MfaMaxTimeoutRem != -1 { + mfaMaxTimeoutRemaining = src.CId.GetRemainingTime(src.CId.MfaMaxTimeout, src.CId.MfaMaxTimeoutRem) + } + + atomic.StoreInt32(&val.Service.TimeoutRemaining, svcMinTimeoutRemaining) + } nid.Services = append(nid.Services /*svcToDto(val)*/, val.Service) @@ -1294,12 +1318,11 @@ func Clean(src *Id) dto.Identity { }) nid.MfaMinTimeout = src.CId.MfaMinTimeout nid.MfaMaxTimeout = src.CId.MfaMaxTimeout - nid.MfaMinTimeoutRem = src.CId.MfaMinTimeoutRem - nid.MfaMaxTimeoutRem = src.CId.MfaMaxTimeoutRem - if !src.CId.MfaRefreshNeeded() { - nid.MfaLastUpdatedTime = time.Now() - } else { - nid.MfaLastUpdatedTime = src.CId.MfaLastUpdatedTime + nid.MfaMinTimeoutRem = mfaMinTimeoutRemaining + nid.MfaMaxTimeoutRem = mfaMaxTimeoutRemaining + nid.ServiceUpdatedTime = src.CId.ServiceUpdatedTime + nid.MfaLastUpdatedTime = src.CId.MfaLastUpdatedTime + if src.CId.MfaRefreshNeeded() { if (nid.MfaMaxTimeoutRem > -1 && (nid.MfaMaxTimeoutRem-int32(time.Since(nid.MfaLastUpdatedTime).Seconds())) < 0) && nid.MfaEnabled { nid.MfaNeeded = true } From 00726febcdca760780f4320671ff7bca5612b95e Mon Sep 17 00:00:00 2001 From: Mary Lincy Dcouto Date: Fri, 30 Jul 2021 12:26:13 +0530 Subject: [PATCH 05/11] updating go sum file --- service/go.sum | 1 + 1 file changed, 1 insertion(+) diff --git a/service/go.sum b/service/go.sum index 02ec49d1..b1429893 100644 --- a/service/go.sum +++ b/service/go.sum @@ -278,6 +278,7 @@ github.com/openziti/foundation v0.15.44/go.mod h1:kYCUttsGO/GjoD7BSNhVOeyYDXHYMA github.com/openziti/sdk-golang v0.15.35 h1:SAHJk1y0SDlXnMXDoLGSaHrrTs511sWVDPBePyLk6r0= github.com/openziti/sdk-golang v0.15.35/go.mod h1:jrvkpxP7U1ejSKEj4J9/UTNWlt6nJaofUGKkTx7afvM= github.com/openziti/sdk-golang v0.15.43 h1:Lz65VocDRtdt0aR0JmK767UkRvtEz4Wm4PG4/bvJuDM= +github.com/openziti/sdk-golang v0.15.68 h1:KsHBbybpTfcQFSGFOQyO/C2x9HVBwT2BHdJJHaQckiI= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 h1:fa50YL1pzKW+1SsBnJDOHppJN9stOEwS+CRWyUtyYGU= github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= From 66d8587b6482c1f7cd23f0693e884ab611950ed9 Mon Sep 17 00:00:00 2001 From: Mary Lincy Dcouto Date: Fri, 30 Jul 2021 13:58:42 +0530 Subject: [PATCH 06/11] display identity name instead of fingerprint in log --- service/cziti/mfa.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/cziti/mfa.go b/service/cziti/mfa.go index cce2c9fb..ed515491 100644 --- a/service/cziti/mfa.go +++ b/service/cziti/mfa.go @@ -303,5 +303,5 @@ func ziti_mfa_cb_remove_go(_ C.ziti_context, status C.int, cFingerprint *C.char) func EndpointStateChanged(id *ZIdentity, woken bool, unlocked bool) { C.ziti_endpoint_state_change(id.czctx, C.bool(woken), C.bool(unlocked)) - log.Debugf("Endpoint status changed for id %s - woken %t, unlocked %t", id.Fingerprint, woken, unlocked) + log.Debugf("Endpoint status changed for id %s - woken %t, unlocked %t", id.Name, woken, unlocked) } From a8a20725546551d6df308a1ce801371e5d8cd8d0 Mon Sep 17 00:00:00 2001 From: Mary Lincy Dcouto Date: Wed, 4 Aug 2021 17:31:14 +0530 Subject: [PATCH 07/11] updating release notes --- release-notes.md | 17 +++++++++++++++-- service/cziti/sdk.go | 2 +- service/ziti-tunnel/service/ipc.go | 3 --- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/release-notes.md b/release-notes.md index 375fbaf7..69f21abd 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,14 +1,27 @@ -# Release 1.10.0 +# Release 1.10.1 ## What's New * none ## Other changes: +* [#421](https://github.com/openziti/desktop-edge-win/issues/421) Calculate timeoutRemaining based on the service updates time or mfa auth time + +## Bugs fixed: +* none + +## Dependency Updates +* updated c-sdk to v0.25.6, updated t-sdk to v0.15.11 + +# Release 1.10.0 + +## What's New +* mfa timeout process. ZDE will prompt the user to enter MFA token, when the timeout set for the services is about to expire. Sends notification periodically until MFA token is entered +* [#418](https://github.com/openziti/desktop-edge-win/issues/418) notification has to be sent based on timeout remaining field. When User enters auth Mfa, the timer will reset to original timeout field. timeout remaining field will also be reset to the value in timeout field * [#278](https://github.com/openziti/desktop-edge-win/issues/278) inform the user an update is available before automatically updating. So user can manually install the latest version anytime within 2 hours after the release is published. If a major/minor version has changed, then the auto installation will start immediately. If the user does not initiate manual installation within the given time, a warning will be displayed and after 2 hours the ZDE will auto update. -* mfa timeout process ## Other changes: * [#381](https://github.com/openziti/desktop-edge-win/issues/381) Open Ziti UI on startup. +* [#415](https://github.com/openziti/desktop-edge-win/issues/415) The notification frequency should be between 5 and 20 minutes. ZDE accepts the requests to modify it (UI is not ready yet). 20 minutes before the timeout, it should start sending the notification to UI ## Bugs fixed: * none diff --git a/service/cziti/sdk.go b/service/cziti/sdk.go index fad9c200..3c5d7ab3 100644 --- a/service/cziti/sdk.go +++ b/service/cziti/sdk.go @@ -269,7 +269,7 @@ func (zid *ZIdentity) GetRemainingTime(timeout int32, timeoutRemaining int32) in if (timeout - int32(time.Since(zid.MfaLastUpdatedTime).Seconds())) < 0 { remainingTimeout = 0 } else { - remainingTimeout = timeout-int32(time.Since(zid.MfaLastUpdatedTime).Seconds()) + remainingTimeout = timeout - int32(time.Since(zid.MfaLastUpdatedTime).Seconds()) } } else { //calculate svc remaining timeout diff --git a/service/ziti-tunnel/service/ipc.go b/service/ziti-tunnel/service/ipc.go index 4032eb5a..cc27d7ff 100644 --- a/service/ziti-tunnel/service/ipc.go +++ b/service/ziti-tunnel/service/ipc.go @@ -1137,9 +1137,6 @@ func handleBulkServiceChange(sc cziti.BulkServiceChange) { } rts.BroadcastEvent(m) - if (sc.MfaMinTimeoutRem > -1 && sc.MfaMinTimeoutRem < 60) || (sc.MfaMaxTimeoutRem > -1 && sc.MfaMaxTimeoutRem < 60) { - broadcastNotification() - } } func addUnit(count int, unit string) (result string) { From befadf054eafca7eb3f8b8a1f3bc5a1ae8c09a4c Mon Sep 17 00:00:00 2001 From: Mary Lincy Dcouto Date: Fri, 6 Aug 2021 13:10:36 +0530 Subject: [PATCH 08/11] sending installation notification to UI when user restarts UI or ziti tunnel --- ZitiUpdateService/UpdateService.cs | 34 ++++++++++++++++++++------ ZitiUpdateService/utils/CustomTimer.cs | 3 +++ service/cziti/mfa.go | 2 +- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/ZitiUpdateService/UpdateService.cs b/ZitiUpdateService/UpdateService.cs index 14b9fceb..d0081c16 100644 --- a/ZitiUpdateService/UpdateService.cs +++ b/ZitiUpdateService/UpdateService.cs @@ -85,6 +85,7 @@ namespace ZitiUpdateService { private SvcResponse TriggerUpdate() { SvcResponse r = new SvcResponse(); + r.Message = "Initiating Update Check"; checkUpdateImmediately(); return r; } @@ -493,6 +494,12 @@ namespace ZitiUpdateService { }; await writer.WriteLineAsync(JsonConvert.SerializeObject(status)); await writer.FlushAsync(); + if (_installationReminder != null) { + TimerState state = _installationReminder.State; + InstallationNotificationEvent notificationMsg = logAndNotifyInstallationUpdates(state.zdeInstallerInfo, true); + await writer.WriteLineAsync(JsonConvert.SerializeObject(notificationMsg)); + await writer.FlushAsync(); + } } #pragma warning disable 1998 //This async method lacks 'await' @@ -674,6 +681,7 @@ namespace ZitiUpdateService { if (info.IsCritical) { info.TimeRemaining = 0; + info.InstallTime = DateTime.Now; NotifyInstallationUpdates(info, 0, ""); installZDE(fileDestination, filename); } else if (!info.IsCritical && _installationReminder == null) { @@ -699,12 +707,7 @@ namespace ZitiUpdateService { } if (_installationReminder != null) { - info.TimeRemaining = _installationReminder.DueTime.TotalMilliseconds / 1000; // converting to seconds - info.InstallTime = DateTime.Now.AddMilliseconds(_installationReminder.DueTime.TotalMilliseconds); - Logger.Info("Installation of ZDE version {0} will be initiated in {1} seconds, approximately at {2}", info.Version, info.TimeRemaining, info.InstallTime); - if (info.TimeRemaining > 0 && (info.TimeRemaining / 1000) < 1 ) { - NotifyInstallationUpdates(info, 0, ""); - } + logAndNotifyInstallationUpdates(info, false); } } } catch (Exception ex) { @@ -722,6 +725,16 @@ namespace ZitiUpdateService { semaphore.Release(); } + private InstallationNotificationEvent logAndNotifyInstallationUpdates(Checkers.ZDEInstallerInfo info, bool newClient) { + info.TimeRemaining = _installationReminder.DueTime.TotalMilliseconds / 1000; // converting to seconds + info.InstallTime = DateTime.Now.AddMilliseconds(_installationReminder.DueTime.TotalMilliseconds); + Logger.Info("Installation of ZDE version {0} will be initiated in {1} seconds, approximately at {2}", info.Version, info.TimeRemaining, info.InstallTime); + if (newClient || (info.TimeRemaining > 0 && (info.TimeRemaining / 1000) < 1)) { + return NotifyInstallationUpdates(info, 0, ""); + } + return null; + } + private void installZDE(string fileDestination, string filename) { Logger.Info("package is in {0} - moving to install phase", fileDestination); @@ -886,6 +899,10 @@ namespace ZitiUpdateService { dnsProbeTimer.Start(); Logger.Info("DNS Probe enabled"); } + if (_installationReminder != null) { + TimerState state = _installationReminder.State; + logAndNotifyInstallationUpdates(state.zdeInstallerInfo, true); + } } private void Svc_OnClientDisconnected(object sender, object e) { @@ -931,7 +948,7 @@ namespace ZitiUpdateService { } } - private void NotifyInstallationUpdates(Checkers.ZDEInstallerInfo info, int code, string error) { + private InstallationNotificationEvent NotifyInstallationUpdates(Checkers.ZDEInstallerInfo info, int code, string error) { try { InstallationNotificationEvent installationNotificationEvent = new InstallationNotificationEvent() { Code = code, @@ -946,10 +963,11 @@ namespace ZitiUpdateService { }; EventRegistry.SendEventToConsumers(installationNotificationEvent); Logger.Debug("The installation updates for version {0} is sent to the events pipe...", info.Version); + return installationNotificationEvent; } catch (Exception e) { Logger.Error("The notification for the installation updates for version {0} has failed", info.Version); } - + return null; } } diff --git a/ZitiUpdateService/utils/CustomTimer.cs b/ZitiUpdateService/utils/CustomTimer.cs index 6b7c9344..d1818957 100644 --- a/ZitiUpdateService/utils/CustomTimer.cs +++ b/ZitiUpdateService/utils/CustomTimer.cs @@ -15,6 +15,7 @@ namespace ZitiUpdateService.Utils { private DateTime _next; private DateTime _lastTickTime; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + private TimerState _state; public CustomTimer(TimerCallback callback, object state, TimeSpan dueTime, TimeSpan period) { _timer = new Timer(Callback, state, dueTime, period); @@ -22,6 +23,7 @@ namespace ZitiUpdateService.Utils { _period = period; _next = DateTime.Now.Add(dueTime); _lastTickTime = DateTime.Now; + _state = (TimerState)state; } private void Callback(object state) { @@ -32,6 +34,7 @@ namespace ZitiUpdateService.Utils { public TimeSpan Period => _period; public DateTime Next => _next; public TimeSpan DueTime => _next - DateTime.Now; + public TimerState State => _state; public bool Change(TimeSpan dueTime, TimeSpan period) { _period = period; _next = DateTime.Now.Add(dueTime); diff --git a/service/cziti/mfa.go b/service/cziti/mfa.go index ed515491..54be8fe9 100644 --- a/service/cziti/mfa.go +++ b/service/cziti/mfa.go @@ -303,5 +303,5 @@ func ziti_mfa_cb_remove_go(_ C.ziti_context, status C.int, cFingerprint *C.char) func EndpointStateChanged(id *ZIdentity, woken bool, unlocked bool) { C.ziti_endpoint_state_change(id.czctx, C.bool(woken), C.bool(unlocked)) - log.Debugf("Endpoint status changed for id %s - woken %t, unlocked %t", id.Name, woken, unlocked) + log.Debugf("Endpoint status changed for id %s:%s - woken %t, unlocked %t", id.Name, id.Fingerprint, woken, unlocked) } From d7ce283b3904616a3961156c182f625e63cc658a Mon Sep 17 00:00:00 2001 From: Mary Lincy Dcouto Date: Fri, 6 Aug 2021 19:45:58 +0530 Subject: [PATCH 09/11] updating the t-sdk version to v0.15.12 --- ZitiUpdateService/UpdateService.cs | 4 ---- release-notes.md | 2 +- service/build.bat | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ZitiUpdateService/UpdateService.cs b/ZitiUpdateService/UpdateService.cs index d0081c16..f8fe6291 100644 --- a/ZitiUpdateService/UpdateService.cs +++ b/ZitiUpdateService/UpdateService.cs @@ -899,10 +899,6 @@ namespace ZitiUpdateService { dnsProbeTimer.Start(); Logger.Info("DNS Probe enabled"); } - if (_installationReminder != null) { - TimerState state = _installationReminder.State; - logAndNotifyInstallationUpdates(state.zdeInstallerInfo, true); - } } private void Svc_OnClientDisconnected(object sender, object e) { diff --git a/release-notes.md b/release-notes.md index 69f21abd..ebbc2544 100644 --- a/release-notes.md +++ b/release-notes.md @@ -10,7 +10,7 @@ * none ## Dependency Updates -* updated c-sdk to v0.25.6, updated t-sdk to v0.15.11 +* updated c-sdk to v0.25.6, updated t-sdk to v0.15.12 # Release 1.10.0 diff --git a/service/build.bat b/service/build.bat index c3538624..67678ef0 100644 --- a/service/build.bat +++ b/service/build.bat @@ -14,7 +14,7 @@ REM See the License for the specific language governing permissions and REM limitations under the License. REM SET REPO_URL=https://github.com/openziti/ziti-tunnel-sdk-c.git -SET ZITI_TUNNEL_REPO_BRANCH=v0.15.11 +SET ZITI_TUNNEL_REPO_BRANCH=v0.15.12 REM override the c sdk used in the build - leave blank for the same as specified in the tunneler sdk SET ZITI_SDK_C_BRANCH= REM the number of TCP connections the tunneler sdk can have at any one time From 26a9f082b1bb802e1d9928ac9de6f729b9d86fca Mon Sep 17 00:00:00 2001 From: Mary Lincy Dcouto Date: Fri, 6 Aug 2021 20:50:57 +0530 Subject: [PATCH 10/11] update advanced installer version --- Installer/build.ps1 | 2 +- Installer/reg.bat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Installer/build.ps1 b/Installer/build.ps1 index 2083a5dc..4c299ae3 100644 --- a/Installer/build.ps1 +++ b/Installer/build.ps1 @@ -24,7 +24,7 @@ msbuild ZitiDesktopEdge.sln /property:Configuration=Release Pop-Location -$ADV_INST_HOME = "C:\Program Files (x86)\Caphyon\Advanced Installer 18.4" +$ADV_INST_HOME = "C:\Program Files (x86)\Caphyon\Advanced Installer 18.5" $ADVINST = "${ADV_INST_HOME}\bin\x86\AdvancedInstaller.com" $ADVPROJECT = "${scriptPath}\ZitiDesktopEdge.aip" $installerVersion=(Get-Content -Path ${scriptPath}\..\version) diff --git a/Installer/reg.bat b/Installer/reg.bat index 044ca561..d50078a9 100644 --- a/Installer/reg.bat +++ b/Installer/reg.bat @@ -1 +1 @@ -"C:\Program Files (x86)\Caphyon\Advanced Installer 18.4\bin\x86\AdvancedInstaller.com" /register %1 +"C:\Program Files (x86)\Caphyon\Advanced Installer 18.5\bin\x86\AdvancedInstaller.com" /register %1 From f4a2d2a338b56be7bbd15b602e5e07bf12b32162 Mon Sep 17 00:00:00 2001 From: ziti-ci Date: Fri, 6 Aug 2021 15:33:32 +0000 Subject: [PATCH 11/11] [ci skip] committing updated version related files --- DesktopEdge/Properties/AssemblyInfo.cs | 6 +++--- Installer/ZitiDesktopEdge.aip | 6 +++--- ZitiUpdateService/Properties/AssemblyInfo.cs | 6 +++--- service/ziti-tunnel/version.go | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/DesktopEdge/Properties/AssemblyInfo.cs b/DesktopEdge/Properties/AssemblyInfo.cs index 4b76b04f..c3654d4a 100644 --- a/DesktopEdge/Properties/AssemblyInfo.cs +++ b/DesktopEdge/Properties/AssemblyInfo.cs @@ -50,6 +50,6 @@ using System.Windows; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.10.0.0")] -[assembly: AssemblyVersion("1.10.0.0")] -[assembly: AssemblyFileVersion("1.10.0.0")] +// [assembly: AssemblyVersion("1.10.1.0")] +[assembly: AssemblyVersion("1.10.1.0")] +[assembly: AssemblyFileVersion("1.10.1.0")] diff --git a/Installer/ZitiDesktopEdge.aip b/Installer/ZitiDesktopEdge.aip index 1c3c8f44..a917e4dd 100644 --- a/Installer/ZitiDesktopEdge.aip +++ b/Installer/ZitiDesktopEdge.aip @@ -1,5 +1,5 @@ - + @@ -23,10 +23,10 @@ - + - + diff --git a/ZitiUpdateService/Properties/AssemblyInfo.cs b/ZitiUpdateService/Properties/AssemblyInfo.cs index fbe51c90..f44ce159 100644 --- a/ZitiUpdateService/Properties/AssemblyInfo.cs +++ b/ZitiUpdateService/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.10.0.0")] -[assembly: AssemblyVersion("1.10.0.0")] -[assembly: AssemblyFileVersion("1.10.0.0")] +// [assembly: AssemblyVersion("1.10.1.0")] +[assembly: AssemblyVersion("1.10.1.0")] +[assembly: AssemblyFileVersion("1.10.1.0")] diff --git a/service/ziti-tunnel/version.go b/service/ziti-tunnel/version.go index b7e435cb..b049e135 100644 --- a/service/ziti-tunnel/version.go +++ b/service/ziti-tunnel/version.go @@ -20,9 +20,9 @@ package main const ( - Version = "1.10.0" - Revision = "75ba67f8120d" + Version = "1.10.1" + Revision = "4ac4dd9c46dc" Branch = "release-next" BuildUser = "" - BuildDate = "2021-07-28 05:58:20" + BuildDate = "2021-08-06 15:28:13" )