diff options
author | ventulis <72085617+ventulis@users.noreply.github.com> | 2020-11-24 16:35:25 +0100 |
---|---|---|
committer | ventulis <72085617+ventulis@users.noreply.github.com> | 2020-11-24 16:35:25 +0100 |
commit | 642909e84aab0a6b9cb110152c1e908ba501fe6e (patch) | |
tree | 35b8dec994b7f3f5f9d4ebe9006b56f542d10e4f /lualib | |
parent | 9497c7103bb63d181498b1634aa3776d3c3145b0 (diff) | |
download | rspamd-642909e84aab0a6b9cb110152c1e908ba501fe6e.tar.gz rspamd-642909e84aab0a6b9cb110152c1e908ba501fe6e.zip |
[Minor] Add disabled and extended ICAP User Agent
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_scanners/icap.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lualib/lua_scanners/icap.lua b/lualib/lua_scanners/icap.lua index c42f4ed99..5fb332dc0 100644 --- a/lualib/lua_scanners/icap.lua +++ b/lualib/lua_scanners/icap.lua @@ -32,8 +32,10 @@ local tcp = require "rspamd_tcp" local upstream_list = require "rspamd_upstream_list" local rspamd_logger = require "rspamd_logger" local common = require "lua_scanners/common" +local rspamd_util = require "rspamd_util" local rspamd_version = rspamd_version + local N = 'icap' local function icap_config(opts) @@ -55,6 +57,7 @@ local function icap_config(opts) default_score = 1, action = false, dynamic_scan = false, + user_agent = "Rspamd", } icap_conf = lua_util.override_defaults(icap_conf, opts) @@ -85,6 +88,10 @@ local function icap_config(opts) icap_conf.servers, icap_conf.default_port) + if icap_conf.user_agent == "extended" then + icap_conf.user_agent = string.format("Rspamd/%s-%s (%s)", rspamd_version('main'), rspamd_version('id'), rspamd_util.get_hostname()) + end + if icap_conf.upstreams then lua_util.add_debug_alias('external_services', icap_conf.name) return icap_conf @@ -106,9 +113,13 @@ local function icap_check(task, content, digest, rule) local options_request = { string.format("OPTIONS icap://%s:%s/%s ICAP/1.0\r\n", addr:to_string(), addr:get_port(), rule.scheme), string.format('Host: %s\r\n', addr:to_string()), - string.format("User-Agent: Rspamd/%s-%s\r\n", rspamd_version('main'), rspamd_version('id')), + string.format("User-Agent: %s\r\n", rule.user_agent), "Encapsulated: null-body=0\r\n\r\n", } + if rule.user_agent == "none" then + table.remove(options_request, 3) + end + local size = string.format("%x", tonumber(#content)) local function icap_callback(err, conn) |