Lines Matching refs:penalty

49  * Entries become active when more than penalty_min seconds of penalty are
52 struct penalty {
57 RB_ENTRY(penalty) by_addr;
58 RB_ENTRY(penalty) by_expiry;
60 static int penalty_addr_cmp(struct penalty *a, struct penalty *b);
61 static int penalty_expiry_cmp(struct penalty *a, struct penalty *b);
62 RB_HEAD(penalties_by_addr, penalty) penalties_by_addr4, penalties_by_addr6;
63 RB_HEAD(penalties_by_expiry, penalty) penalties_by_expiry4, penalties_by_expiry6;
64 RB_GENERATE_STATIC(penalties_by_addr, penalty, by_addr, penalty_addr_cmp)
65 RB_GENERATE_STATIC(penalties_by_expiry, penalty, by_expiry, penalty_expiry_cmp)
197 penalty_addr_cmp(struct penalty *a, struct penalty *b)
204 penalty_expiry_cmp(struct penalty *a, struct penalty *b)
217 struct penalty *penalty, *tmp;
220 RB_FOREACH_SAFE(penalty, penalties_by_expiry, by_expiry, tmp) {
221 if (penalty->expiry >= now)
224 penalty) != penalty ||
226 penalty) != penalty)
227 fatal_f("internal error: %s penalty table corrupt", t);
228 free(penalty);
260 struct penalty find, *penalty;
296 if ((penalty = RB_FIND(penalties_by_addr, by_addr, &find)) == NULL)
297 return 1; /* no penalty */
298 if (penalty->expiry < now) {
300 return 1; /* expired penalty */
302 if (!penalty->active)
304 *reason = penalty->reason;
313 struct penalty *p = NULL;
347 struct penalty *penalty = NULL, *existing = NULL;
372 reason = "penalty: caused crash";
376 reason = "penalty: failed authentication";
380 reason = "penalty: connections without attempting authentication";
384 reason = "penalty: exceeded LoginGraceTime";
387 fatal_f("internal error: unknown penalty %d", penalty_type);
408 verbose_f("%s penalty table full, cannot penalise %s for %s", t,
413 penalty = xcalloc(1, sizeof(*penalty));
414 penalty->addr = masked;
415 penalty->expiry = now + penalty_secs;
416 penalty->reason = reason;
418 penalty)) == NULL) {
419 /* penalty didn't previously exist */
421 penalty->active = 1;
422 if (RB_INSERT(penalties_by_expiry, by_expiry, penalty) != NULL)
423 fatal_f("internal error: %s penalty tables corrupt", t);
424 verbose_f("%s: new %s %s penalty of %d seconds for %s", t,
425 addrnetmask, penalty->active ? "active" : "deferred",
431 debug_f("%s penalty for %s %s already exists, %lld seconds remaining",
436 fatal_f("internal error: %s penalty table corrupt (remove)", t);
437 /* An entry already existed. Accumulate penalty up to maximum */
443 verbose_f("%s: activating %s penalty of %lld seconds for %s",
448 existing->reason = penalty->reason;
449 free(penalty);
450 penalty = NULL;
453 fatal_f("internal error: %s penalty table corrupt (insert)", t);
460 struct penalty *p = NULL;