save capabilities

This commit is contained in:
pascal
2026-06-18 14:53:32 +02:00
parent bb6ee60d1b
commit bdcef5efbc
2 changed files with 7 additions and 6 deletions
+2 -1
View File
@@ -1154,8 +1154,9 @@ func (am *DefaultAccountManager) LoginPeer(ctx context.Context, login types.Peer
return err return err
} }
if peer.SSHKey != login.SSHKey { if peer.SSHKey != login.SSHKey || peer.Meta.CapabilitiesEqual(login.Meta.Capabilities) {
peer.SSHKey = login.SSHKey peer.SSHKey = login.SSHKey
peer.Meta.Capabilities = login.Meta.Capabilities
shouldStorePeer = true shouldStorePeer = true
} }
+5 -5
View File
@@ -209,12 +209,12 @@ func (p *Peer) SupportsSourcePrefixes() bool {
return p.HasCapability(PeerCapabilitySourcePrefixes) return p.HasCapability(PeerCapabilitySourcePrefixes)
} }
func capabilitiesEqual(a, b []int32) bool { func (a PeerSystemMeta) CapabilitiesEqual(b []int32) bool {
if len(a) != len(b) { if len(a.Capabilities) != len(b) {
return false return false
} }
set := make(map[int32]struct{}, len(a)) set := make(map[int32]struct{}, len(a.Capabilities))
for _, c := range a { for _, c := range a.Capabilities {
set[c] = struct{}{} set[c] = struct{}{}
} }
for _, c := range b { for _, c := range b {
@@ -350,7 +350,7 @@ func metaDiff(old, new PeerSystemMeta) []string {
if !old.Flags.isEqual(new.Flags) { if !old.Flags.isEqual(new.Flags) {
add("flags", fmt.Sprintf("%+v", old.Flags), fmt.Sprintf("%+v", new.Flags)) add("flags", fmt.Sprintf("%+v", old.Flags), fmt.Sprintf("%+v", new.Flags))
} }
if !capabilitiesEqual(old.Capabilities, new.Capabilities) { if !old.CapabilitiesEqual(new.Capabilities) {
add("capabilities", old.Capabilities, new.Capabilities) add("capabilities", old.Capabilities, new.Capabilities)
} }