From: Vsevolod Stakhov Date: Fri, 20 Mar 2015 14:19:20 +0000 (+0000) Subject: Allow multiple values for `secure_ip` option. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81b97d51b93215aac4e5605c0e894b727a364097;p=thirdparty%2Frspamd.git Allow multiple values for `secure_ip` option. Issue: #234 Conflicts: src/controller.c --- diff --git a/src/controller.c b/src/controller.c index 33422f7824..d47cf32dae 100644 --- a/src/controller.c +++ b/src/controller.c @@ -106,7 +106,7 @@ struct rspamd_controller_worker_ctx { /* SSL private key */ gchar *ssl_key; /* A map of secure IP */ - gchar *secure_ip; + GList *secure_ip; radix_compressed_t *secure_map; /* Static files dir */ @@ -1602,7 +1602,7 @@ init_controller_worker (struct rspamd_config *cfg) timeout), RSPAMD_CL_FLAG_TIME_INTEGER); rspamd_rcl_register_worker_option (cfg, type, "secure_ip", - rspamd_rcl_parse_struct_string, ctx, + rspamd_rcl_parse_struct_string_list, ctx, G_STRUCT_OFFSET (struct rspamd_controller_worker_ctx, secure_ip), 0); rspamd_rcl_register_worker_option (cfg, type, "static_dir", @@ -1625,7 +1625,8 @@ start_controller_worker (struct rspamd_worker *worker) struct module_ctx *mctx; GHashTableIter iter; gpointer key, value; - + struct rspamd_keypair_cache *cache; + GList *secure_ip; ctx->ev_base = rspamd_prepare_worker (worker, "controller", @@ -1639,14 +1640,23 @@ start_controller_worker (struct rspamd_worker *worker) ctx->custom_commands = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal); if (ctx->secure_ip != NULL) { - if (!rspamd_map_add (worker->srv->cfg, ctx->secure_ip, - "Allow webui access from the specified IP", - rspamd_radix_read, rspamd_radix_fin, (void **)&ctx->secure_map)) { - if (!radix_add_generic_iplist (ctx->secure_ip, - &ctx->secure_map)) { - msg_warn ("cannot load or parse ip list from '%s'", - ctx->secure_ip); + cur = ctx->secure_ip; + + while (cur) { + secure_ip = cur->data; + + /* Try map syntax */ + if (!rspamd_map_add (worker->srv->cfg, secure_ip, + "Allow webui access from the specified IP", + rspamd_radix_read, rspamd_radix_fin, (void **)&ctx->secure_map)) { + /* Fallback to the plain IP */ + if (!radix_add_generic_iplist (secure_ip, + &ctx->secure_map)) { + msg_warn ("cannot load or parse ip list from '%s'", + secure_ip); + } } + cur = g_list_next (cur); } } /* Accept event */