Очень надеюсь на Вашу помощь!
Написал такую конструкцию и она работает -
------------ЭТО РАБОТАЕТ-----------
local dw = require "drweb" function milter_hook(ctx) -- Reject the message if it is likely spam if ctx.message.spam.score >= 100 then dw.notice("Spam score: " .. ctx.message.spam.score) return {action = "reject"} else -- Assign X-Drweb-Spam headers in accordance with spam report ctx.modifier.add_header_field("X-DrWeb-SpamScore", ctx.message.spam.score) ctx.modifier.add_header_field("X-DrWeb-SpamState", ctx.message.spam.type) ctx.modifier.add_header_field("X-DrWeb-SpamDetail", ctx.message.spam.reason) ctx.modifier.add_header_field("X-DrWeb-SpamVersion", ctx.message.spam.version) end -- Check if the message contains viruses, repack if so for threat, path in ctx.message.threats{category = {"known_virus", "virus_modification", "unknown_virus", "adware", "dialer"}} do ctx.modifier.repack() dw.notice(threat.name .. " found in " .. (ctx.message.part_at(path).name or path)) end -- Repack if unwanted URL has been found for url in ctx.message.urls{category = {"infection_source", "not_recommended", "owners_notice"}} do ctx.modifier.repack() dw.notice("URL found: " .. url .. "(" .. url.categories[1] .. ")") end -- Assign X-AntiVirus header ctx.modifier.add_header_field("X-AntiVirus", "Checked by Dr.Web [MailD version: ]") -- Accept the message with all scheduled transformations applied return {action = 'accept'} end
Далее из примеров решил прикрутить к ней черный и белые листы, и все перестало работать, postfix и milterd валятся.
Где моя ошибка?
------------ЭТО НЕ РАБОТАЕТ-----------
local dw = require "drweb" local regex = require "drweb.regex" -- Load regexp patterns from files local whitelist = drweb.load_set("/etc/postfix/whitemails.txt") local blacklist = drweb.load_set("/etc/postfix/blackmails.txt") function milter_hook(ctx) -- Stop checks if mail_from matchs one of the patterns loaded from file for pattern, _ in pairs(whitelist) do if regex.match(pattern, ctx.from, regex.ignore_case) then return {action = "accept"} end end -- Stop checks if mail_from matchs one of the patterns loaded from file for pattern, _ in pairs(blacklist) do if regex.match(pattern, ctx.from, regex.ignore_case) then return {action = "reject", "Blacklist"} end end -- Reject the message if it is likely spam if ctx.message.spam.score >= 100 then dw.notice("Spam score: " .. ctx.message.spam.score) return {action = "reject"} else -- Assign X-Drweb-Spam headers in accordance with spam report ctx.modifier.add_header_field("X-DrWeb-SpamScore", ctx.message.spam.score) ctx.modifier.add_header_field("X-DrWeb-SpamState", ctx.message.spam.type) ctx.modifier.add_header_field("X-DrWeb-SpamDetail", ctx.message.spam.reason) ctx.modifier.add_header_field("X-DrWeb-SpamVersion", ctx.message.spam.version) end -- Check if the message contains viruses, repack if so for threat, path in ctx.message.threats{category = {"known_virus", "virus_modification", "unknown_virus", "adware", "dialer"}} do ctx.modifier.repack() dw.notice(threat.name .. " found in " .. (ctx.message.part_at(path).name or path)) end -- Repack if unwanted URL has been found for url in ctx.message.urls{category = {"infection_source", "not_recommended", "owners_notice"}} do ctx.modifier.repack() dw.notice("URL found: " .. url .. "(" .. url.categories[1] .. ")") end -- Assign X-AntiVirus header ctx.modifier.add_header_field("X-AntiVirus", "Checked by Dr.Web [MailD version: ]") -- Accept the message with all scheduled transformations applied return {action = 'accept'} end
Сообщение было изменено Konstantin Yudin: 27 Март 2019 - 13:45