diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-25 09:30:11 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-25 09:30:36 +0100 |
commit | 95a24ff47020b0b7f08ec2872057408db7a0b691 (patch) | |
tree | 7156e43c87f8a1422cfbeb701da16d9f3bc2ab54 | |
parent | 9e61dce1b503b21f85ee24378aa4a3383680e792 (diff) | |
download | rspamd-95a24ff47020b0b7f08ec2872057408db7a0b691.tar.gz rspamd-95a24ff47020b0b7f08ec2872057408db7a0b691.zip |
[Feature] Spf: Add limits configuration support
-rw-r--r-- | src/plugins/spf.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/plugins/spf.c b/src/plugins/spf.c index 841d74e2c..119d79b69 100644 --- a/src/plugins/spf.c +++ b/src/plugins/spf.c @@ -62,6 +62,10 @@ struct spf_ctx { gboolean check_local; gboolean check_authed; + + guint max_dns_nesting; + guint max_dns_requests; + guint min_cache_ttl; }; static void spf_symbol_callback (struct rspamd_task *task, @@ -99,6 +103,9 @@ spf_module_init (struct rspamd_config *cfg, struct module_ctx **ctx) spf_module_ctx = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (*spf_module_ctx)); *ctx = (struct module_ctx *)spf_module_ctx; + spf_module_ctx->min_cache_ttl = SPF_MIN_CACHE_TTL; + spf_module_ctx->max_dns_nesting = SPF_MAX_NESTING; + spf_module_ctx->max_dns_requests = SPF_MAX_DNS_REQUESTS; rspamd_rcl_add_doc_by_path (cfg, NULL, @@ -192,6 +199,34 @@ spf_module_init (struct rspamd_config *cfg, struct module_ctx **ctx) NULL, 0); + rspamd_rcl_add_doc_by_path (cfg, + "spf", + "Minimum cached records TTL, 0 to disable (default: 5min)", + "min_cache_ttl", + UCL_INT, + NULL, + RSPAMD_CL_FLAG_UINT, + NULL, + 0); + rspamd_rcl_add_doc_by_path (cfg, + "spf", + "Maximum number of nested requests (default: " G_STRINGIFY(SPF_MAX_NESTING) ")", + "max_dns_nesting", + UCL_INT, + NULL, + RSPAMD_CL_FLAG_UINT, + NULL, + 0); + rspamd_rcl_add_doc_by_path (cfg, + "spf", + "Maximum number of dns requests to resolve SPF (default: " G_STRINGIFY(SPF_MAX_DNS_REQUESTS) ")", + "max_dns_requests", + UCL_INT, + NULL, + RSPAMD_CL_FLAG_UINT, + NULL, + 0); + return 0; } @@ -293,6 +328,23 @@ spf_module_config (struct rspamd_config *cfg) } if ((value = + rspamd_config_get_module_opt (cfg, "spf", "min_cache_ttl")) != NULL) { + spf_module_ctx->min_cache_ttl = ucl_obj_toint (value); + } + if ((value = + rspamd_config_get_module_opt (cfg, "spf", "max_dns_nesting")) != NULL) { + spf_module_ctx->max_dns_nesting = ucl_obj_toint (value); + } + if ((value = + rspamd_config_get_module_opt (cfg, "spf", "max_dns_requests")) != NULL) { + spf_module_ctx->max_dns_requests = ucl_obj_toint (value); + } + + spf_library_config (spf_module_ctx->max_dns_nesting, + spf_module_ctx->max_dns_requests, + spf_module_ctx->min_cache_ttl); + + if ((value = rspamd_config_get_module_opt (cfg, "spf", "whitelist")) != NULL) { rspamd_config_radix_from_ucl (cfg, value, "SPF whitelist", |