Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local u = require "lua_util"
- local m = require "lua_magic"
- local l = require "rspamd_logger"
- local text = require "rspamd_text"
- local rspamd_task = require "rspamd_task"
- local rspamd_util = require "rspamd_util"
- local function load_task(opts, fname)
- if not fname then
- fname = '-'
- end
- local f = io.open(fname, "r"):read("*a")
- f = [[From: <>
- Content-Type: application/octet-stream
- ]] .. f
- local res,task = rspamd_task.load_from_string(f, rspamd_config)
- if not res then
- assert(false, string.format('cannot read message from %s: %s', fname,
- task))
- end
- if not task:process_message() then
- assert(false, string.format('cannot read message from %s: %s', fname,
- 'failed to parse'))
- end
- return task
- end
- task = load_task(nil, arg[1])
- local part = task:get_parts()[1]
- local t1 = rspamd_util.get_ticks()
- local det = m.detect_mime_part(part, task)
- local t2 = rspamd_util.get_ticks()
- l.errx('detected: %s; %s msec', det, (t2 - t1) * 1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement