From fbce349729b85fd5b6ded13d50674bc3cd758871 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 3 Jan 2016 17:13:14 +0000 Subject: [PATCH] Add local_addrs/local_networks option --- conf/options.inc | 3 +++ doc/markdown/configuration/options.md | 1 + src/libserver/cfg_rcl.c | 12 ++++++++++++ src/plugins/spf.c | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/conf/options.inc b/conf/options.inc index 29e737712..44ba68bd6 100644 --- a/conf/options.inc +++ b/conf/options.inc @@ -32,3 +32,6 @@ allow_raw_input = true; # Start ignore words when reaching the following limit, so the total # amount of words processed will not be *LIKELY more than the twice of that limit words_decay = 200; + +# Local networks +local_addrs = "192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/8"; diff --git a/doc/markdown/configuration/options.md b/doc/markdown/configuration/options.md index 44b9abe2b..9d11a2007 100644 --- a/doc/markdown/configuration/options.md +++ b/doc/markdown/configuration/options.md @@ -54,6 +54,7 @@ symbol). * `cores_dir`: directory where rspamd is intended to drop core files * `max_cores_size`: maximum total size of core files that are placed in `cores_dir` * `max_cores_count`: maximum number of files in `cores_dir` +* `local_addrs` or `local_networks`: map or list of ip networks used as local, so certain checks are skipped for them (e.g. SPF checks) ## DNS options diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index ff349e75e..c0daef15e 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -1604,6 +1604,18 @@ rspamd_rcl_config_init (struct rspamd_config *cfg) G_STRUCT_OFFSET (struct rspamd_config, max_cores_count), RSPAMD_CL_FLAG_INT_SIZE, "Limit of files count in `cores_dir`"); + rspamd_rcl_add_default_handler (sub, + "local_addrs", + rspamd_rcl_parse_struct_string, + G_STRUCT_OFFSET (struct rspamd_config, local_addrs), + 0, + "Use the specified addresses as local ones"); + rspamd_rcl_add_default_handler (sub, + "local_networks", + rspamd_rcl_parse_struct_string, + G_STRUCT_OFFSET (struct rspamd_config, local_addrs), + 0, + "Use the specified addresses as local ones (alias for `local_addrs`)"); /* New DNS configuration */ ssub = rspamd_rcl_add_section_doc (&sub->subsections, "dns", NULL, NULL, diff --git a/src/plugins/spf.c b/src/plugins/spf.c index c54c27215..ac2f1ddb4 100644 --- a/src/plugins/spf.c +++ b/src/plugins/spf.c @@ -358,7 +358,7 @@ spf_symbol_callback (struct rspamd_task *task, void *unused) } if (task->user != NULL || rspamd_inet_address_is_local (task->from_addr)) { - msg_info_task ("skip SPF checks for local and authorized users"); + msg_info_task ("skip SPF checks for local networks and authorized users"); return; } -- 2.39.5