From 594f2a484df9ea8cb91454c316cf44f583607b3d Mon Sep 17 00:00:00 2001 From: Viktor Liu Date: Tue, 28 Apr 2026 08:38:48 +0200 Subject: [PATCH] Look up peers by IPv6 address in GetPeerByIP --- management/server/store/sql_store.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/management/server/store/sql_store.go b/management/server/store/sql_store.go index 81ced86d0..6ba4da66f 100644 --- a/management/server/store/sql_store.go +++ b/management/server/store/sql_store.go @@ -4532,11 +4532,15 @@ func (s *SqlStore) GetPeerByIP(ctx context.Context, lockStrength LockingStrength tx = tx.Clauses(clause.Locking{Strength: string(lockStrength)}) } + column := "ip" + if ip.To4() == nil { + column = "ipv6" + } jsonValue := fmt.Sprintf(`"%s"`, ip.String()) var peer nbpeer.Peer result := tx. - Take(&peer, "account_id = ? AND ip = ?", accountID, jsonValue) + Take(&peer, fmt.Sprintf("account_id = ? AND %s = ?", column), accountID, jsonValue) if result.Error != nil { // no logging here return nil, status.Errorf(status.Internal, "failed to get peer from store")