Lines Matching refs:penalty

53  * Entries become active when more than penalty_min seconds of penalty are
56 struct penalty {
61 RB_ENTRY(penalty) by_addr;
62 RB_ENTRY(penalty) by_expiry;
64 static int penalty_addr_cmp(struct penalty *a, struct penalty *b);
65 static int penalty_expiry_cmp(struct penalty *a, struct penalty *b);
66 RB_HEAD(penalties_by_addr, penalty) penalties_by_addr4, penalties_by_addr6;
67 RB_HEAD(penalties_by_expiry, penalty) penalties_by_expiry4, penalties_by_expiry6;
68 RB_GENERATE_STATIC(penalties_by_addr, penalty, by_addr, penalty_addr_cmp)
69 RB_GENERATE_STATIC(penalties_by_expiry, penalty, by_expiry, penalty_expiry_cmp)
201 penalty_addr_cmp(struct penalty *a, struct penalty *b)
208 penalty_expiry_cmp(struct penalty *a, struct penalty *b)
221 struct penalty *penalty, *tmp;
224 RB_FOREACH_SAFE(penalty, penalties_by_expiry, by_expiry, tmp) {
225 if (penalty->expiry >= now)
228 penalty) != penalty ||
230 penalty) != penalty)
231 fatal_f("internal error: %s penalty table corrupt", t);
232 free(penalty);
264 struct penalty find, *penalty;
300 if ((penalty = RB_FIND(penalties_by_addr, by_addr, &find)) == NULL)
301 return 1; /* no penalty */
302 if (penalty->expiry < now) {
304 return 1; /* expired penalty */
306 if (!penalty->active)
308 *reason = penalty->reason;
317 struct penalty *p = NULL;
351 struct penalty *penalty = NULL, *existing = NULL;
376 reason = "penalty: caused crash";
380 reason = "penalty: failed authentication";
384 reason = "penalty: connections without attempting authentication";
388 reason = "penalty: exceeded LoginGraceTime";
391 fatal_f("internal error: unknown penalty %d", penalty_type);
412 verbose_f("%s penalty table full, cannot penalise %s for %s", t,
417 penalty = xcalloc(1, sizeof(*penalty));
418 penalty->addr = masked;
419 penalty->expiry = now + penalty_secs;
420 penalty->reason = reason;
422 penalty)) == NULL) {
423 /* penalty didn't previously exist */
425 penalty->active = 1;
426 if (RB_INSERT(penalties_by_expiry, by_expiry, penalty) != NULL)
427 fatal_f("internal error: %s penalty tables corrupt", t);
428 verbose_f("%s: new %s %s penalty of %d seconds for %s", t,
429 addrnetmask, penalty->active ? "active" : "deferred",
435 debug_f("%s penalty for %s %s already exists, %lld seconds remaining",
440 fatal_f("internal error: %s penalty table corrupt (remove)", t);
441 /* An entry already existed. Accumulate penalty up to maximum */
447 verbose_f("%s: activating %s penalty of %lld seconds for %s",
452 existing->reason = penalty->reason;
453 free(penalty);
454 penalty = NULL;
457 fatal_f("internal error: %s penalty table corrupt (insert)", t);
464 struct penalty *p = NULL;