diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-08-06 16:37:30 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-08-06 16:37:30 +0100 |
commit | ae794569d7722c2b59bd2c4468cf41dae1d14121 (patch) | |
tree | 1da94a4414bf916a8c7b5fe8979464bf3c2c983b | |
parent | 5fe80e02c8e13ff5d556eb4801087166103ae4a1 (diff) | |
download | rspamd-ae794569d7722c2b59bd2c4468cf41dae1d14121.tar.gz rspamd-ae794569d7722c2b59bd2c4468cf41dae1d14121.zip |
[Minor] Mx_check: Fix issue with multiple IPs per MX name
Issue: #3839
-rw-r--r-- | src/plugins/lua/mx_check.lua | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/plugins/lua/mx_check.lua b/src/plugins/lua/mx_check.lua index e131d16d4..c88aa5601 100644 --- a/src/plugins/lua/mx_check.lua +++ b/src/plugins/lua/mx_check.lua @@ -152,24 +152,23 @@ local function mx_check(task) check_results(mxes) end - if err or not results then + if err or not results or #results == 0 then mxes[name].checked = true else - -- Try to open TCP connection to port 25 - - for _,res in ipairs(results) do - local t_ret = rspamd_tcp.new({ - task = task, - host = res:to_string(), - callback = io_cb, - on_connect = on_connect_cb, - timeout = settings.timeout, - port = 25 - }) + -- Try to open TCP connection to port 25 for a random IP address + -- see #3839 on GitHub + lua_util.shuffle(results) + local t_ret = rspamd_tcp.new({ + task = task, + host = results[1]:to_string(), + callback = io_cb, + on_connect = on_connect_cb, + timeout = settings.timeout, + port = 25 + }) - if not t_ret then - mxes[name].checked = true - end + if not t_ret then + mxes[name].checked = true end end check_results(mxes) |