mirror of
https://github.com/tailscale/tailscale.git
synced 2025-09-21 05:31:36 +02:00
ipn/ipnlocal, types: plumb tailnet display name cap through to network profile (#17045)
Updates tailscale/corp#30456 Signed-off-by: Nick O'Neill <nick@tailscale.com>
This commit is contained in:
parent
f1ded84454
commit
77250a301a
@ -1650,12 +1650,18 @@ func (b *LocalBackend) SetControlClientStatus(c controlclient.Client, st control
|
||||
prefsChanged = true
|
||||
}
|
||||
|
||||
// If the tailnet's display name has changed, update prefs.
|
||||
if st.NetMap != nil && st.NetMap.TailnetDisplayName() != b.pm.CurrentProfile().NetworkProfile().DisplayName {
|
||||
prefsChanged = true
|
||||
}
|
||||
|
||||
// Perform all mutations of prefs based on the netmap here.
|
||||
if prefsChanged {
|
||||
// Prefs will be written out if stale; this is not safe unless locked or cloned.
|
||||
if err := b.pm.SetPrefs(prefs.View(), ipn.NetworkProfile{
|
||||
MagicDNSName: curNetMap.MagicDNSSuffix(),
|
||||
DomainName: curNetMap.DomainName(),
|
||||
DisplayName: curNetMap.TailnetDisplayName(),
|
||||
}); err != nil {
|
||||
b.logf("Failed to save new controlclient state: %v", err)
|
||||
}
|
||||
@ -1716,6 +1722,7 @@ func (b *LocalBackend) SetControlClientStatus(c controlclient.Client, st control
|
||||
if err := b.pm.SetPrefs(p, ipn.NetworkProfile{
|
||||
MagicDNSName: st.NetMap.MagicDNSSuffix(),
|
||||
DomainName: st.NetMap.DomainName(),
|
||||
DisplayName: st.NetMap.TailnetDisplayName(),
|
||||
}); err != nil {
|
||||
b.logf("Failed to save new controlclient state: %v", err)
|
||||
}
|
||||
@ -6185,6 +6192,7 @@ func (b *LocalBackend) resolveExitNode() (changed bool) {
|
||||
if err := b.pm.SetPrefs(prefs.View(), ipn.NetworkProfile{
|
||||
MagicDNSName: nm.MagicDNSSuffix(),
|
||||
DomainName: nm.DomainName(),
|
||||
DisplayName: nm.TailnetDisplayName(),
|
||||
}); err != nil {
|
||||
b.logf("failed to save exit node changes: %v", err)
|
||||
}
|
||||
|
@ -168,6 +168,7 @@ func (nb *nodeBackend) NetworkProfile() ipn.NetworkProfile {
|
||||
// These are ok to call with nil netMap.
|
||||
MagicDNSName: nb.netMap.MagicDNSSuffix(),
|
||||
DomainName: nb.netMap.DomainName(),
|
||||
DisplayName: nb.netMap.TailnetDisplayName(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -988,6 +988,7 @@ type WindowsUserID string
|
||||
type NetworkProfile struct {
|
||||
MagicDNSName string
|
||||
DomainName string
|
||||
DisplayName string
|
||||
}
|
||||
|
||||
// RequiresBackfill returns whether this object does not have all the data
|
||||
|
@ -252,6 +252,22 @@ func (nm *NetworkMap) DomainName() string {
|
||||
return nm.Domain
|
||||
}
|
||||
|
||||
// TailnetDisplayName returns the admin-editable name contained in
|
||||
// NodeAttrTailnetDisplayName. If the capability is not present it
|
||||
// returns an empty string.
|
||||
func (nm *NetworkMap) TailnetDisplayName() string {
|
||||
if nm == nil || !nm.SelfNode.Valid() {
|
||||
return ""
|
||||
}
|
||||
|
||||
tailnetDisplayNames, err := tailcfg.UnmarshalNodeCapViewJSON[string](nm.SelfNode.CapMap(), tailcfg.NodeAttrTailnetDisplayName)
|
||||
if err != nil || len(tailnetDisplayNames) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
return tailnetDisplayNames[0]
|
||||
}
|
||||
|
||||
// HasSelfCapability reports whether nm.SelfNode contains capability c.
|
||||
//
|
||||
// It exists to satisify an unused (as of 2025-01-04) interface in the logknob package.
|
||||
|
Loading…
x
Reference in New Issue
Block a user