mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-25 22:09:08 +01:00
add semaphore on grpc
This commit is contained in:
@@ -444,6 +444,16 @@ func (s *GRPCServer) Login(ctx context.Context, req *proto.EncryptedMessage) (*p
|
||||
//nolint
|
||||
ctx = context.WithValue(ctx, nbContext.AccountIDKey, accountID)
|
||||
|
||||
err = TryAcquire(loginReq.GetPeerKeys().String())
|
||||
if err != nil {
|
||||
log.WithContext(ctx).Debugf("error while acquiring grpc semaphore for %s: %v", loginReq.GetPeerKeys().String(), err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
Release(loginReq.GetPeerKeys().String())
|
||||
}()
|
||||
|
||||
if loginReq.GetMeta() == nil {
|
||||
msg := status.Errorf(codes.FailedPrecondition,
|
||||
"peer system meta has to be provided to log in. Peer %s, remote addr %s", peerKey.String(), realIP)
|
||||
|
||||
Reference in New Issue
Block a user