platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
30
selective-vpn-api/app/transport_policy_owner_lock_state.go
Normal file
30
selective-vpn-api/app/transport_policy_owner_lock_state.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package app
|
||||
|
||||
import "strings"
|
||||
|
||||
func attachTransportOwnershipLockState(items []TransportOwnershipRecord, clients []TransportClient) (out []TransportOwnershipRecord, lockCount int) {
|
||||
if len(items) == 0 {
|
||||
return nil, 0
|
||||
}
|
||||
statusByClientID := map[string]TransportClientStatus{}
|
||||
for _, client := range clients {
|
||||
id := strings.TrimSpace(client.ID)
|
||||
if id == "" {
|
||||
continue
|
||||
}
|
||||
statusByClientID[id] = client.Status
|
||||
}
|
||||
|
||||
out = make([]TransportOwnershipRecord, len(items))
|
||||
for i := range items {
|
||||
rec := items[i]
|
||||
st := statusByClientID[strings.TrimSpace(rec.ClientID)]
|
||||
rec.OwnerStatus = string(st)
|
||||
rec.LockActive = isTransportClientOwnerLockActive(st)
|
||||
if rec.LockActive {
|
||||
lockCount++
|
||||
}
|
||||
out[i] = rec
|
||||
}
|
||||
return out, lockCount
|
||||
}
|
||||
Reference in New Issue
Block a user