diff options
author | Andrew Lewis <nerf@judo.za.org> | 2016-11-24 11:58:36 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2016-11-24 11:59:38 +0200 |
commit | aed5dec62bbc44e173cd2de62297a44dad8fb126 (patch) | |
tree | 10b1ceee8c4c1b738860ec8ad46859c770fbfbcd /src | |
parent | e7fe6003a2cfb05cdb9eb3b89237595184461271 (diff) | |
download | rspamd-aed5dec62bbc44e173cd2de62297a44dad8fb126.tar.gz rspamd-aed5dec62bbc44e173cd2de62297a44dad8fb126.zip |
[Feature] Clickhouse: support different masks for IPv4/IPv6
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/lua/clickhouse.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index aa39b47da..045e4a175 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -40,6 +40,7 @@ local settings = { attachments_table = 'rspamd_attachments', urls_table = 'rspamd_urls', ipmask = 19, + ipmask6 = 48, full_urls = false, from_tables = nil } @@ -288,7 +289,12 @@ local function clickhouse_collect(task) local ip_str = 'undefined' local ip = task:get_from_ip() if ip and ip:is_valid() then - local ipnet = ip:apply_mask(settings['ipmask']) + local ipnet + if ip:get_version() == 4 then + ipnet = ip:apply_mask(settings['ipmask']) + else + ipnet = ip:apply_mask(settings['ipmask6']) + end ip_str = ipnet:to_string() end |