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