commit b0fb051: [Minor] Mx check: Emit quit command
Vsevolod Stakhov
vsevolod at highsecure.ru
Sun Nov 21 16:42:05 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-11-21 16:33:41 +0000
URL: https://github.com/rspamd/rspamd/commit/b0fb0517a7537fa53d23c274861116f1dcefbe59
[Minor] Mx check: Emit quit command
Issue: #3966
---
lualib/lua_smtp.lua | 4 ++--
src/plugins/lua/mx_check.lua | 12 +++++++++---
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/lualib/lua_smtp.lua b/lualib/lua_smtp.lua
index a15f1ae17..256da0522 100644
--- a/lualib/lua_smtp.lua
+++ b/lualib/lua_smtp.lua
@@ -59,7 +59,7 @@ local function sendmail(opts, message, callback)
mdata = tostring(mdata)
end
if string.sub(mdata, 1, 1) ~= wantcode then
- callback(false, string.format('bad smtp responce on stage %s: "%s" when "%s" expected',
+ callback(false, string.format('bad smtp response on stage %s: "%s" when "%s" expected',
stage, mdata, wantcode))
if conn then
conn:close()
@@ -169,7 +169,7 @@ local function sendmail(opts, message, callback)
end
end
- -- HELLO stage
+ -- HELO stage
local function hello_cb(merr)
if no_error_write(merr) then
conn:add_read(hello_done_cb, CRLF)
diff --git a/src/plugins/lua/mx_check.lua b/src/plugins/lua/mx_check.lua
index c88aa5601..678c21566 100644
--- a/src/plugins/lua/mx_check.lua
+++ b/src/plugins/lua/mx_check.lua
@@ -43,6 +43,7 @@ local redis_params
local exclude_domains
local E = {}
+local CRLF = '\r\n'
local function mx_check(task)
local ip_addr = task:get_ip()
@@ -130,26 +131,30 @@ local function mx_check(task)
return function(_, _, results, err)
mxes[name].ips = results
- local function io_cb(io_err)
+ local function io_cb(io_err, _, conn)
if io_err then
mxes[name].checked = true
+ conn:close()
else
mxes[name].checked = true
mxes[name].working = true
valid = true
end
check_results(mxes)
+ conn:add_write(function(_)
+ conn:close()
+ end, string.format('QUIT%s', CRLF))
end
local function on_connect_cb(conn)
if err then
mxes[name].checked = true
+ conn:close()
+ check_results(mxes)
else
mxes[name].checked = true
valid = true
mxes[name].working = true
end
- conn:close()
- check_results(mxes)
end
if err or not results or #results == 0 then
@@ -162,6 +167,7 @@ local function mx_check(task)
task = task,
host = results[1]:to_string(),
callback = io_cb,
+ stop_pattern = CRLF,
on_connect = on_connect_cb,
timeout = settings.timeout,
port = 25
More information about the Commits
mailing list