guint32 dns_throttling_time; /**< time in seconds for DNS throttling */
guint32 dns_io_per_server; /**< number of sockets per DNS server */
GList *nameservers; /**< list of nameservers or NULL to parse resolv.conf */
+ guint32 dns_max_requests; /**< limit of DNS requests per task */
guint upstream_max_errors; /**< upstream max errors before shutting off */
gdouble upstream_error_time; /**< rate of upstream errors */
rspamd_rcl_parse_struct_integer,
G_STRUCT_OFFSET (struct rspamd_config, dns_io_per_server),
RSPAMD_CL_FLAG_INT_32);
+ rspamd_rcl_add_default_handler (sub,
+ "dns_max_requests",
+ rspamd_rcl_parse_struct_integer,
+ G_STRUCT_OFFSET (struct rspamd_config, dns_max_requests),
+ RSPAMD_CL_FLAG_INT_32);
/* New DNS configuration */
ssub = rspamd_rcl_add_section (&sub->subsections, "dns", NULL,
cfg->log_extended = TRUE;
cfg->min_word_len = DEFAULT_MIN_WORD;
+ cfg->dns_max_requests = 64;
}
void
return TRUE;
}
+gboolean make_dns_request_task (struct rspamd_task *task,
+ dns_callback_type cb,
+ gpointer ud,
+ enum rdns_request_type type,
+ const char *name)
+{
+ gboolean ret;
+
+ if (task->dns_requests >= task->cfg->dns_max_requests) {
+ return FALSE;
+ }
+
+ ret = make_dns_request (task->resolver, task->s, task->task_pool, cb, ud,
+ type, name);
+
+ if (ret) {
+ task->dns_requests ++;
+
+ if (task->dns_requests >= task->cfg->dns_max_requests) {
+ msg_info ("<%s> stop resolving on reaching %ud requests",
+ task->message_id, task->dns_requests);
+ }
+ }
+
+ return ret;
+}
struct rspamd_dns_resolver *
dns_resolver_init (rspamd_logger_t *logger,
enum rdns_request_type type,
const char *name);
+gboolean make_dns_request_task (struct rspamd_task *task,
+ dns_callback_type cb,
+ gpointer ud,
+ enum rdns_request_type type,
+ const char *name);
+
#endif