stop_pattern = CRLF,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule.timeout,
task = task
}
upstream = rule.upstreams:get_upstream_round_robin()
addr = upstream:get_addr()
+ tcp_opts.upstream = upstream
tcp_opts.callback = avast_helo_cb
local is_succ, err = tcp.request(tcp_opts)
end
elseif beg == '200' then
-- Final line
- upstream:ok()
if tcp_conn then
tcp_conn:close()
tcp_conn = nil
local function clamav_callback(err, data)
if err then
- -- set current upstream to fail because an error occurred
- upstream:fail()
-
-- retry with another upstream until retransmits exceeds
if retransmits > 0 then
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
callback = clamav_callback,
data = { header, content, footer },
end
else
- upstream:ok()
data = tostring(data)
local cached
lua_util.debugm(rule.name, task, '%s: got reply: %s',
port = addr:get_port(),
timeout = rule['timeout'],
callback = clamav_callback,
+ upstream = upstream,
data = { header, content, footer },
stop_pattern = '\0'
})
local function dcc_callback(err, data, conn)
local function dcc_requery()
- -- set current upstream to fail because an error occurred
- upstream:fail()
-
-- retry with another upstream until retransmits exceeds
if retransmits > 0 then
host = addr:to_string(),
port = addr:get_port(),
timeout = rule.timeout or 2.0,
+ upstream = upstream,
shutdown = true,
data = request_data,
callback = dcc_callback,
else
-- Parse the response
- if upstream then upstream:ok() end
local _,_,result,disposition,header = tostring(data):find("(.-)\n(.-)\n(.-)$")
lua_util.debugm(rule.name, task, 'DCC result=%1 disposition=%2 header="%3"',
result, disposition, header)
port = addr:get_port(),
timeout = rule.timeout or 2.0,
shutdown = true,
+ upstream = upstream,
data = request_data,
callback = dcc_callback,
body_max = 999999,
local function fprot_callback(err, data)
if err then
- -- set current upstream to fail because an error occurred
- upstream:fail()
-
-- retry with another upstream until retransmits exceeds
if retransmits > 0 then
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
callback = fprot_callback,
data = { header, content, footer },
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
callback = fprot_callback,
data = { header, content, footer },
local function icap_callback(err, conn)
local function icap_requery(err_m, info)
- -- set current upstream to fail because an error occurred
- upstream:fail()
-
-- retry with another upstream until retransmits exceeds
if retransmits > 0 then
tcp_options.port = addr:get_port()
tcp_options.callback = icap_callback
tcp_options.data = options_request
+ tcp_options.upstream = upstream
tcp.request(tcp_options)
if err or conn == nil then
icap_requery(err, "options_request")
else
- -- set upstream ok
- if upstream then upstream:ok() end
conn:add_read(icap_r_options_cb, '\r\n\r\n')
end
end
tcp_options.host = addr:to_string()
tcp_options.port = addr:get_port()
+ tcp_options.upstream = upstream
tcp.request(tcp_options)
end
local function kaspersky_callback(err, data)
if err then
- -- set current upstream to fail because an error occurred
- upstream:fail()
-- retry with another upstream until retransmits exceeds
if retransmits > 0 then
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
callback = kaspersky_callback,
data = { clamav_compat_cmd },
end
else
- upstream:ok()
data = tostring(data)
local cached
lua_util.debugm(rule.name, task,
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
callback = kaspersky_callback,
data = { clamav_compat_cmd },
local function oletools_callback(err, data, conn)
local function oletools_requery(error)
- -- set current upstream to fail because an error occurred
- upstream:fail()
-- retry with another upstream until retransmits exceeds
if retransmits > 0 then
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule.timeout,
shutdown = true,
data = { protocol, content },
oletools_requery(err)
else
- -- Parse the response
- if upstream then upstream:ok() end
-
json_response = json_response .. tostring(data)
if not string.find(json_response, '\t\n\n\t') and #data == 8192 then
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule.timeout,
shutdown = true,
data = { protocol, content },
if err then
- -- set current upstream to fail because an error occurred
- upstream:fail()
-
-- retry with another upstream until retransmits exceeds
if retransmits > 0 then
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
shutdown = true,
data = content,
'failed to scan and retransmits exceed')
end
else
- -- Parse the response
- if upstream then upstream:ok() end
-- pyzor output is unicode (\x09 -> tab, \0a -> newline)
-- public.pyzor.org:24441 (200, 'OK') 21285091 206759
-- server:port Code Diag Count WL-Count
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule.timeout,
shutdown = true,
data = content,
local function razor_callback(err, data, conn)
local function razor_requery()
- -- set current upstream to fail because an error occurred
- upstream:fail()
-
-- retry with another upstream until retransmits exceeds
if retransmits > 0 then
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule.timeout or 2.0,
shutdown = true,
data = content,
razor_requery()
else
- -- Parse the response
- if upstream then upstream:ok() end
-
--[[
@todo: Razorsocket currently only returns ham or spam. When the wrapper is fixed we should add dynamic scores here.
Maybe check spamassassin implementation.
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule.timeout or 2.0,
shutdown = true,
data = content,
local function savapi_callback_init(err, data, conn)
if err then
- -- set current upstream to fail because an error occurred
- upstream:fail()
-
-- retry with another upstream until retransmits exceeds
if retransmits > 0 then
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
callback = savapi_callback_init,
stop_pattern = {'\n'},
common.yield_result(task, rule, 'failed to scan and retransmits exceed', 0.0, 'fail')
end
else
- upstream:ok()
local result = tostring(data)
-- 100 SAVAPI:4.0 greeting
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
callback = savapi_callback_init,
stop_pattern = {'\n'},
local function sophos_callback(err, data, conn)
if err then
- -- set current upstream to fail because an error occurred
- upstream:fail()
-
-- retry with another upstream until retransmits exceeds
if retransmits > 0 then
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
callback = sophos_callback,
data = { protocol, streamsize, content, bye }
0.0, 'fail', maybe_part)
end
else
- upstream:ok()
data = tostring(data)
lua_util.debugm(rule.name, task,
'%s [%s]: got reply: %s', rule['symbol'], rule['type'], data)
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
callback = sophos_callback,
data = { protocol, streamsize, content, bye }
local function spamassassin_callback(err, data)
local function spamassassin_requery(error)
- -- set current upstream to fail because an error occurred
- upstream:fail()
-- retry with another upstream until retransmits exceeds
if retransmits > 0 then
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
data = request_data,
callback = spamassassin_callback,
spamassassin_requery(err)
else
- -- Parse the response
- if upstream then upstream:ok() end
-
--lua_util.debugm(rule.N, task, '%s: returned result: %s', rule.log_prefix, data)
--[[
task = task,
host = addr:to_string(),
port = addr:get_port(),
+ upstream = upstream,
timeout = rule['timeout'],
data = request_data,
callback = spamassassin_callback,