]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Allow multiple values for `secure_ip` option.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 20 Mar 2015 14:19:20 +0000 (14:19 +0000)
committerAndrew Lewis <nerf@judo.za.org>
Fri, 20 Mar 2015 15:50:05 +0000 (17:50 +0200)
Issue: #234

Conflicts:
src/controller.c

src/controller.c

index 33422f78243ae8b11985d17f3f1f6b5d7cd45d48..d47cf32dae030b6e356516266566ef7033d1af69 100644 (file)
@@ -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 */