SHARE
TWEET

Untitled

a guest Oct 18th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local u = require "lua_util"
  2. local m = require "lua_magic"
  3. local l = require "rspamd_logger"
  4. local text = require "rspamd_text"
  5. local rspamd_task = require "rspamd_task"
  6. local rspamd_util = require "rspamd_util"
  7.  
  8. local function load_task(opts, fname)
  9.   if not fname then
  10.     fname = '-'
  11.   end
  12.  
  13.   local f = io.open(fname, "r"):read("*a")
  14.   f = [[From: <>
  15. Content-Type: application/octet-stream
  16.  
  17. ]] .. f
  18.   local res,task = rspamd_task.load_from_string(f, rspamd_config)
  19.  
  20.   if not res then
  21.     assert(false, string.format('cannot read message from %s: %s', fname,
  22.         task))
  23.   end
  24.  
  25.   if not task:process_message() then
  26.     assert(false, string.format('cannot read message from %s: %s', fname,
  27.         'failed to parse'))
  28.   end
  29.  
  30.   return task
  31. end
  32.  
  33. task = load_task(nil, arg[1])
  34.  
  35. local part = task:get_parts()[1]
  36. local t1 = rspamd_util.get_ticks()
  37. local det = m.detect_mime_part(part, task)
  38. local t2 = rspamd_util.get_ticks()
  39. l.errx('detected: %s; %s msec', det, (t2 - t1) * 1000)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top