diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-19 14:13:02 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-19 14:13:02 +0000 |
commit | e9c35582e7b22661975f5898891d02bbe9651ebf (patch) | |
tree | ce71962cc4822b5f2f5c849478924f9e517ded06 | |
parent | 8fd4189a09d89cbd49527282eeb9360858a24148 (diff) | |
download | rspamd-e9c35582e7b22661975f5898891d02bbe9651ebf.tar.gz rspamd-e9c35582e7b22661975f5898891d02bbe9651ebf.zip |
[Minor] Allow to parse integer database names for Redis
Issue: #2083
Closes: #2083
-rw-r--r-- | lualib/lua_redis.lua | 2 | ||||
-rw-r--r-- | src/libstat/backends/redis_backend.c | 7 | ||||
-rw-r--r-- | src/libstat/learn_cache/redis_cache.c | 7 |
3 files changed, 14 insertions, 2 deletions
diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua index ee015fef2..067353abc 100644 --- a/lualib/lua_redis.lua +++ b/lualib/lua_redis.lua @@ -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 diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c index f191dc974..121162fc8 100644 --- a/src/libstat/backends/redis_backend.c +++ b/src/libstat/backends/redis_backend.c @@ -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; diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c index b7ba71f4b..c3f4c6598 100644 --- a/src/libstat/learn_cache/redis_cache.c +++ b/src/libstat/learn_cache/redis_cache.c @@ -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; |