From: Gauthier C Date: Wed, 10 Apr 2019 12:52:18 +0000 (+0200) Subject: add support ES>=6.7 for elasctic module X-Git-Tag: 1.9.2~42^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F2845%2Fhead;p=thirdparty%2Frspamd.git add support ES>=6.7 for elasctic module Since version 6.7.0 of ElasticSearch, the ingest-geoip plugin is a module integrated into the solution. Instead of detecting the version of ElasticSearch I added the configuration parameter ingest_module which is false by default for ElasticSearch versions < 6.7.0 and true for versions >= 6.7.0 --- diff --git a/src/plugins/lua/elastic.lua b/src/plugins/lua/elastic.lua index 03462f9ebf..18cc0ea095 100644 --- a/src/plugins/lua/elastic.lua +++ b/src/plugins/lua/elastic.lua @@ -53,6 +53,7 @@ local settings = { password = nil, no_ssl_verify = false, max_fail = 3, + ingest_module = false, } local function read_file(path) @@ -234,8 +235,7 @@ local opts = rspamd_config:get_all_opt('elastic') local function check_elastic_server(cfg, ev_base, _) local upstream = settings.upstream:get_upstream_round_robin() local ip_addr = upstream:get_addr():to_string(true) - - local plugins_url = connect_prefix .. ip_addr .. '/_nodes/plugins' + local plugins_url = connect_prefix .. ip_addr .. '/_nodes/' .. ingest_geoip_type local function http_callback(err, code, body, _) if code == 200 then local parser = ucl.parser() @@ -446,6 +446,12 @@ if redis_params and opts then connect_prefix = 'https://' end + if settings.ingest_module then + ingest_geoip_type = 'modules' + else + ingest_geoip_type = 'plugins' + end + settings.upstream = upstream_list.create(rspamd_config, settings['server'] or settings['servers'], 9200)