added limiter on login

This commit is contained in:
crn4
2025-10-30 20:23:11 +01:00
parent 00da7b0482
commit e88f8a9948

View File

@@ -503,6 +503,12 @@ func (s *GRPCServer) parseRequest(ctx context.Context, req *proto.EncryptedMessa
// In case it isn't, the endpoint checks whether setup key is provided within the request and tries to register a peer.
// In case of the successful registration login is also successful
func (s *GRPCServer) Login(ctx context.Context, req *proto.EncryptedMessage) (*proto.EncryptedMessage, error) {
if s.syncSem.Load() >= s.syncLim {
return nil, status.Errorf(codes.ResourceExhausted, "too many concurrent login requests, please try again later")
}
s.syncSem.Add(1)
defer s.syncSem.Add(-1)
reqStart := time.Now()
realIP := getRealIP(ctx)
sRealIP := realIP.String()