mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-21 18:42:36 +00:00
controlclient,health,ipnlocal,tailcfg: add DisplayMessage support
Updates tailscale/corp#27759 Signed-off-by: James Sanderson <jsanderson@tailscale.com>
This commit is contained in:

committed by
James 'zofrex' Sanderson

parent
5b670eb3a5
commit
11e83f9da5
@@ -90,6 +90,7 @@ type mapSession struct {
|
||||
lastDomain string
|
||||
lastDomainAuditLogID string
|
||||
lastHealth []string
|
||||
lastDisplayMessages map[tailcfg.DisplayMessageID]tailcfg.DisplayMessage
|
||||
lastPopBrowserURL string
|
||||
lastTKAInfo *tailcfg.TKAInfo
|
||||
lastNetmapSummary string // from NetworkMap.VeryConcise
|
||||
@@ -412,6 +413,21 @@ func (ms *mapSession) updateStateFromResponse(resp *tailcfg.MapResponse) {
|
||||
if resp.Health != nil {
|
||||
ms.lastHealth = resp.Health
|
||||
}
|
||||
if resp.DisplayMessages != nil {
|
||||
if v, ok := resp.DisplayMessages["*"]; ok && v == nil {
|
||||
ms.lastDisplayMessages = nil
|
||||
}
|
||||
for k, v := range resp.DisplayMessages {
|
||||
if k == "*" {
|
||||
continue
|
||||
}
|
||||
if v != nil {
|
||||
mak.Set(&ms.lastDisplayMessages, k, *v)
|
||||
} else {
|
||||
delete(ms.lastDisplayMessages, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
if resp.TKAInfo != nil {
|
||||
ms.lastTKAInfo = resp.TKAInfo
|
||||
}
|
||||
@@ -831,14 +847,19 @@ func (ms *mapSession) sortedPeers() []tailcfg.NodeView {
|
||||
func (ms *mapSession) netmap() *netmap.NetworkMap {
|
||||
peerViews := ms.sortedPeers()
|
||||
|
||||
// Convert all ms.lastHealth to the new [netmap.NetworkMap.DisplayMessages].
|
||||
var msgs map[tailcfg.DisplayMessageID]tailcfg.DisplayMessage
|
||||
for _, h := range ms.lastHealth {
|
||||
mak.Set(&msgs, tailcfg.DisplayMessageID("control-health-"+strhash(h)), tailcfg.DisplayMessage{
|
||||
Title: "Coordination server reports an issue",
|
||||
Severity: tailcfg.SeverityMedium,
|
||||
Text: "The coordination server is reporting a health issue: " + h,
|
||||
})
|
||||
if len(ms.lastDisplayMessages) != 0 {
|
||||
msgs = ms.lastDisplayMessages
|
||||
} else if len(ms.lastHealth) > 0 {
|
||||
// Convert all ms.lastHealth to the new [netmap.NetworkMap.DisplayMessages]
|
||||
for _, h := range ms.lastHealth {
|
||||
id := "control-health-" + strhash(h) // Unique ID in case there is more than one health message
|
||||
mak.Set(&msgs, tailcfg.DisplayMessageID(id), tailcfg.DisplayMessage{
|
||||
Title: "Coordination server reports an issue",
|
||||
Severity: tailcfg.SeverityMedium,
|
||||
Text: "The coordination server is reporting a health issue: " + h,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
nm := &netmap.NetworkMap{
|
||||
|
Reference in New Issue
Block a user