You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rspamd.luadoc 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. --- Rspamd interaction package
  2. -- contains several subclasses:
  3. -- config - for parsing config files
  4. -- metric - for handling metrics callbacks
  5. -- task - for interaction with task object
  6. -- message - gate to GMime functions
  7. -- textpart - a single textual part of message
  8. module Rspamd
  9. --- Each lua module has global rspamd_config that can be used for getting config
  10. -- options and registering callbacks (via metric interface)
  11. ------------------------------------- CONFIG -----------------------------------------
  12. --
  13. --- Get module option from config
  14. -- @param mname module name
  15. -- @param option option
  16. -- @return string with value
  17. function config:get_module_opt (mname, option)
  18. --- Get all module options as a table like ['param' => 'value']
  19. -- @param mname module name
  20. -- @return table with options
  21. function config:get_all_opt (mname)
  22. --- Get specified metric
  23. -- @param name metric name
  24. -- @return metric object
  25. function config:get_metric (name)
  26. ------------------------------------- METRIC -----------------------------------------
  27. --- Register symbol in metric
  28. -- @param symbol name of symbol
  29. -- @param weight weight of symbol
  30. -- @param callback function that would be called as callback for symbol
  31. function metric:register_symbol (symbol, weight, callback)
  32. ------------------------------------- TASK -------------------------------------------
  33. --- Get message object from task
  34. -- @return message object
  35. function task:get_message ()
  36. --- Insert result to specified metric with specified weight (obsoleted)
  37. -- @param metric metric name
  38. -- @param symbol symbol name
  39. -- @param weight weight of symbol
  40. function task:insert_result (metric, symbol, weight)
  41. --- Get all urls as array
  42. -- @return array of urls in textual form
  43. function task:get_urls ()
  44. --- Get all text parts
  45. -- @return array of textpart objects
  46. function task:get_text_parts ()
  47. --- Get raw headers
  48. -- @return string that contains raw headers
  49. function task:get_raw_headers ()
  50. --- Get array of received headers
  51. -- @return array of received headers that are tables itself
  52. function task:get_received_headers ()
  53. --- Resolve A record using rspamd async resolver
  54. -- @param host host to resolve
  55. -- @param callback name of callback function
  56. function task:resolve_dns_a (host, callback)
  57. --- Resolve PTR record using rspamd async resolver
  58. -- @param host host to resolve
  59. -- @param callback name of callback function
  60. function task:resolve_dns_ptr (host, callback)
  61. --- Callback function for dns resolving
  62. -- @param task task object
  63. -- @param to_resolve ptr or a record that was resolved
  64. -- @param results results of dns query (array or nil)
  65. -- @param err resolver error or nil
  66. function dns_cb(task, to_resolve, results, err)
  67. ------------------------------------- TEXTPART ---------------------------------------
  68. --- Get part's content
  69. -- @return string that contains part's content
  70. function textpart:get_content ()
  71. --- Check if part is empty
  72. -- @return boolean value
  73. function textpart:is_empty ()
  74. --- Check if part is html
  75. -- @return boolean value
  76. function textpart:is_html ()
  77. --- Get part's fuzzy
  78. -- @return string that contains part's fuzzy
  79. function textpart:get_fuzzy ()
  80. ------------------------------------- MESSAGE ----------------------------------------
  81. --- Get message subject
  82. -- @return message subject
  83. function message:get_subject ()
  84. --- Get message id
  85. -- @return message id
  86. function message:get_message_id ()
  87. --- Get sender of message
  88. -- @return sender's credits
  89. function message:get_sender ()
  90. --- Get reply-to field
  91. -- @return value of reply-to header
  92. function message:get_reply_to ()
  93. --- Get header
  94. -- @param header_name name of header
  95. -- @return array of headers with specified name
  96. function message:get_header (header_name)