]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Log SMTP HELO/.EHLO to ClickHouse
authorAnton Yuzhaninov <citrin+github@citrin.ru>
Wed, 26 Jun 2019 16:02:45 +0000 (17:02 +0100)
committerAnton Yuzhaninov <citrin+github@citrin.ru>
Wed, 26 Jun 2019 18:21:58 +0000 (19:21 +0100)
src/plugins/lua/clickhouse.lua

index f62bda2c64b66a421fd96aade690c11162b8a9f7..b4c5d55675b40da8fe32bc321a6db0e923770641 100644 (file)
@@ -95,6 +95,7 @@ CREATE TABLE rspamd
     From String COMMENT 'Domain part of the return address (RFC5321.MailFrom)',
     MimeFrom String COMMENT 'Domain part of the address in From: header (RFC5322.From)',
     IP String COMMENT 'SMTP client IP as provided by MTA or from Received: header',
+    Helo String COMMENT 'Full hostname as sent by the SMTP client (RFC5321.HELO/.EHLO)',
     Score Float32 COMMENT 'Message score',
     NRcpt UInt8 COMMENT 'Number of envelope recipients (RFC5321.RcptTo)',
     Size UInt32 COMMENT 'Message size in bytes',
@@ -210,6 +211,14 @@ local migrations = {
     -- New version
     [[INSERT INTO rspamd_version (Version) Values (6)]],
   },
+  [6] = {
+    -- Add new columns
+    [[ALTER TABLE rspamd
+      ADD COLUMN Helo String AFTER IP
+    ]],
+    -- New version
+    [[INSERT INTO rspamd_version (Version) Values (7)]],
+  },
 }
 
 local predefined_actions = {
@@ -228,6 +237,7 @@ local function clickhouse_main_row(res)
     'From',
     'MimeFrom',
     'IP',
+    'Helo',
     'Score',
     'NRcpt',
     'Size',
@@ -429,16 +439,6 @@ local function clickhouse_collect(task)
       from_domain = from['domain']:lower()
       from_user = from['user']
     end
-
-    if from_domain == '' then
-      if task:get_helo() then
-        from_domain = task:get_helo()
-      end
-    end
-  else
-    if task:get_helo() then
-      from_domain = task:get_helo()
-    end
   end
 
   local mime_domain = ''
@@ -471,6 +471,8 @@ local function clickhouse_collect(task)
     ip_str = ipnet:to_string()
   end
 
+  local helo = task:get_helo() or ''
+
   local rcpt_user = ''
   local rcpt_domain = ''
   if task:has_recipients('smtp') then
@@ -637,6 +639,7 @@ local function clickhouse_collect(task)
     from_domain,
     mime_domain,
     ip_str,
+    helo,
     score,
     nrcpts,
     task:get_size(),