#
# reject_delay: When sending an Access-Reject, it can be
- # delayed for a few seconds. This may help slow down a DoS
- # attack. It also helps to slow down people trying to brute-force
- # crack a users password.
+ # delayed for a short period of time. This may help slow
+ # down a DoS attack. It also helps to slow down people
+ # trying to brute-force crack a users password.
+ #
+ # The reject will be sent no earlier then "recieve time + delay".
+ # This configuration will not _add_ a fixed delay, it makes sure
+ # that the time between Access-Request and Access-Reject is
+ # _at least_ the given reject_delay value.
+ #
+ # i.e. if "reject_delay = 1", and the server takes 4 seconds to
+ # query an SQL database, then the reject has already been delayed
+ # for 4 seconds.
#
# Setting this number to 0 means "send rejects immediately"
#
# Useful ranges: 0.5 to 5
reject_delay = 1
+ #
+ # Do we apply reject delays to proxied packets, too?
+ #
+# delay_proxy_rejects = no
+
#
# status_server: Whether or not the server will respond
# to Status-Server requests.
bool proxy_requests; //!< Toggle to enable/disable proxying globally.
#endif
struct timeval reject_delay; //!< How long to wait before sending an Access-Reject.
+ bool delay_proxy_rejects; //!< do we delay proxied rejects
bool status_server; //!< Whether to respond to status-server messages.
static const CONF_PARSER security_config[] = {
{ "max_attributes", FR_CONF_POINTER(PW_TYPE_INTEGER, &fr_max_attributes), STRINGIFY(0) },
{ "reject_delay", FR_CONF_POINTER(PW_TYPE_TIMEVAL, &main_config.reject_delay), STRINGIFY(0) },
+ { "delay_proxy_rejects", FR_CONF_POINTER(PW_TYPE_BOOLEAN, &main_config.delay_proxy_rejects), "no" },
{ "status_server", FR_CONF_POINTER(PW_TYPE_BOOLEAN, &main_config.status_server), "no"},
{ "require_message_authenticator", FR_CONF_POINTER(PW_TYPE_STRING, &require_message_authenticator), "auto"},
{ "limit_proxy_state", FR_CONF_POINTER(PW_TYPE_STRING, &limit_proxy_state), "auto"},
* adding their own reject delay, which would
* result in N*reject_delays being applied.
*/
- if (request->proxy && (!request->proxy_reply || request->proxy->dst_port != 0)) {
+ if (request->proxy && !request->root->delay_proxy_rejects &&
+ (!request->proxy_reply || request->proxy->dst_port != 0)) {
request->response_delay.tv_sec = 0;
request->response_delay.tv_usec = 0;
}
#endif
+
+ /*
+ * We want to delay for AT LEAST the delay. We
+ * don't want to ADD in the delay.
+ */
+ if ((request->response_delay.tv_sec != 0) ||
+ (request->response_delay.tv_usec != 0)) {
+ struct timeval when;
+
+ /*
+ * if ((received time + delay) < now) {
+ * send packet
+ * else
+ * delay = (received time + delay) - now
+ */
+ timeradd(&request->packet->timestamp, &request->response_delay, &when);
+
+ if (timercmp(&when, &request->reply->timestamp, <=)) {
+ request->response_delay.tv_sec = 0;
+ request->response_delay.tv_usec = 0;
+ } else {
+ timersub(&when, &request->reply->timestamp, &request->response_delay);
+ }
+ }
}
/*