]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow to parse integer database names for Redis
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Mar 2018 14:13:02 +0000 (14:13 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Mar 2018 14:13:02 +0000 (14:13 +0000)
Issue: #2083
Closes: #2083
lualib/lua_redis.lua
src/libstat/backends/redis_backend.c
src/libstat/learn_cache/redis_cache.c

index ee015fef23c5f3ed1ddd1c61ac6a5b24e8126cd8..067353abcb05b0c25b385f4024175c217ba5d22c 100644 (file)
@@ -98,6 +98,8 @@ local function try_load_redis_servers(options, rspamd_config, result)
       result['db'] = tostring(options['db'])
     elseif options['dbname'] then
       result['db'] = tostring(options['dbname'])
+    elseif options['database'] then
+      result['db'] = tostring(options['database'])
     end
   end
   if options['password'] and not result['password'] then
index f191dc974700f5714a72d495a6649291b99a48b6..121162fc8e18b4ab023195b6f0fc0cf8a1e354cf 100644 (file)
@@ -1256,7 +1256,12 @@ rspamd_redis_try_ucl (struct redis_stat_ctx *backend,
 
        elt = ucl_object_lookup_any (obj, "db", "database", "dbname", NULL);
        if (elt) {
-               backend->dbname = ucl_object_tostring (elt);
+               if (ucl_object_type (elt) == UCL_STRING) {
+                       backend->dbname = ucl_object_tostring (elt);
+               }
+               else if (ucl_object_type (elt) == UCL_INT) {
+                       backend->dbname = ucl_object_tostring_forced (elt);
+               }
        }
        else {
                backend->dbname = NULL;
index b7ba71f4b1c54efb160a28f1e03af62c2bccdf38..c3f4c65988ec9d74be3deb597fc4871f37bb8fa5 100644 (file)
@@ -274,7 +274,12 @@ rspamd_redis_cache_try_ucl (struct rspamd_redis_cache_ctx *cache_ctx,
 
        elt = ucl_object_lookup_any (obj, "db", "database", "dbname", NULL);
        if (elt) {
-               cache_ctx->dbname = ucl_object_tostring (elt);
+               if (ucl_object_type (elt) == UCL_STRING) {
+                       cache_ctx->dbname = ucl_object_tostring (elt);
+               }
+               else if (ucl_object_type (elt) == UCL_INT) {
+                       cache_ctx->dbname = ucl_object_tostring_forced (elt);
+               }
        }
        else {
                cache_ctx->dbname = NULL;