mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-20 09:47:49 +02:00
[management] Fix logging out peers on deletion (#2453)
This commit is contained in:
parent
80b0db80bc
commit
8c2d37d3fc
@ -132,24 +132,30 @@ func (s *GRPCServer) Sync(req *proto.EncryptedMessage, srv proto.ManagementServi
|
|||||||
|
|
||||||
ctx := srv.Context()
|
ctx := srv.Context()
|
||||||
|
|
||||||
realIP := getRealIP(ctx)
|
|
||||||
|
|
||||||
syncReq := &proto.SyncRequest{}
|
syncReq := &proto.SyncRequest{}
|
||||||
peerKey, err := s.parseRequest(ctx, req, syncReq)
|
peerKey, err := s.parseRequest(ctx, req, syncReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint
|
// nolint:staticcheck
|
||||||
ctx = context.WithValue(ctx, nbContext.PeerIDKey, peerKey.String())
|
ctx = context.WithValue(ctx, nbContext.PeerIDKey, peerKey.String())
|
||||||
|
|
||||||
accountID, err := s.accountManager.GetAccountIDForPeerKey(ctx, peerKey.String())
|
accountID, err := s.accountManager.GetAccountIDForPeerKey(ctx, peerKey.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// this case should not happen and already indicates an issue but we don't want the system to fail due to being unable to log in detail
|
// nolint:staticcheck
|
||||||
accountID = "UNKNOWN"
|
ctx = context.WithValue(ctx, nbContext.AccountIDKey, "UNKNOWN")
|
||||||
|
log.WithContext(ctx).Tracef("peer %s is not registered", peerKey.String())
|
||||||
|
if errStatus, ok := internalStatus.FromError(err); ok && errStatus.Type() == internalStatus.NotFound {
|
||||||
|
return status.Errorf(codes.PermissionDenied, "peer is not registered")
|
||||||
}
|
}
|
||||||
//nolint
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// nolint:staticcheck
|
||||||
ctx = context.WithValue(ctx, nbContext.AccountIDKey, accountID)
|
ctx = context.WithValue(ctx, nbContext.AccountIDKey, accountID)
|
||||||
|
|
||||||
|
realIP := getRealIP(ctx)
|
||||||
log.WithContext(ctx).Debugf("Sync request from peer [%s] [%s]", req.WgPubKey, realIP.String())
|
log.WithContext(ctx).Debugf("Sync request from peer [%s] [%s]", req.WgPubKey, realIP.String())
|
||||||
|
|
||||||
if syncReq.GetMeta() == nil {
|
if syncReq.GetMeta() == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user