MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / loginFail

Method loginFail

src/remote/server/server.cpp:394–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

392 {}
393
394 bool loginFail(const string& login)
395 {
396 if (!login.hasData())
397 {
398 return false;
399 }
400
401 MutexLockGuard guard(fullAccess, FB_FUNCTION);
402 const time_t t = time(0);
403
404 FB_SIZE_T pos;
405 if (find(login, pos))
406 {
407 FailedLogin& l = (*this)[pos];
408 if (t - l.lastAttempt >= FAILURE_DELAY)
409 {
410 l.failCount = 0;
411 }
412 l.lastAttempt = t;
413 if (++l.failCount >= MAX_FAILED_ATTEMPTS)
414 {
415 l.failCount = 0;
416 return true;
417 }
418 return false;
419 }
420
421 if (getCount() >= MAX_CONCURRENT_FAILURES)
422 {
423 // try to perform old entries collection
424 for (iterator i = begin(); i != end(); )
425 {
426 if (t - i->lastAttempt >= FAILURE_DELAY)
427 {
428 remove(i);
429 }
430 else
431 {
432 ++i;
433 }
434 }
435 }
436 if (getCount() >= MAX_CONCURRENT_FAILURES)
437 {
438 // it seems we are under attack - too many wrong logins !!
439 return true;
440 }
441
442 add(FailedLogin(login));
443 return false;
444 }
445
446 void loginSuccess(const string& login)
447 {

Callers 1

loginFailFunction · 0.80

Calls 7

removeFunction · 0.85
FailedLoginClass · 0.85
findFunction · 0.50
beginFunction · 0.50
endFunction · 0.50
addFunction · 0.50
hasDataMethod · 0.45

Tested by

no test coverage detected