- t = time( NULL ) + Seconds;
- if( t > My_Connections[Idx].delaytime ) My_Connections[Idx].delaytime = t;
+ assert(Idx > NONE);
+ assert(Seconds >= 0);
+
+ /* Limit new penalty to maximum configured, when less than 10 seconds. *
+ The latter is used to limit brute force attacks, therefore we don't *
+ want to limit that! */
+ if (Conf_MaxPenaltyTime >= 0
+ && Seconds > Conf_MaxPenaltyTime
+ && Seconds < 10)
+ Seconds = Conf_MaxPenaltyTime;
+
+ t = time(NULL);
+ if (My_Connections[Idx].delaytime < t)
+ My_Connections[Idx].delaytime = t;
+
+ My_Connections[Idx].delaytime += Seconds;
+
+#ifdef DEBUG
+ Log(LOG_DEBUG,
+ "Add penalty time on connection %d: %ld second%s, total %ld second%s.",
+ Idx, (long)Seconds, Seconds != 1 ? "s" : "",
+ My_Connections[Idx].delaytime - t,
+ My_Connections[Idx].delaytime - t != 1 ? "s" : "");
+#endif