rspamd_trie
Rspamd trie module provides the data structure suitable for searching of many
patterns in arbitrary texts (or binary chunks). The algorithmic complexity of
this algorithm is at most O(n + m + z), where n
is the length of text, m
is a length of pattern and z
is a number of patterns in the text.
Here is a typical example of trie usage:
Methods:
Method | Description |
---|---|
trie:match(input, [cb][, report_start]) |
Search for patterns in input invoking cb optionally ignoring case. |
trie:search_mime(task, cb) |
This is a helper mehthod to search pattern within text parts of a message in rspamd task. |
trie:search_rawmsg(task, cb[, caseless]) |
This is a helper mehthod to search pattern within the whole undecoded content of rspamd task. |
trie:search_rawbody(task, cb[, caseless]) |
This is a helper mehthod to search pattern within the whole undecoded content of task’s body (not including headers). |
The module rspamd_trie
defines the following methods.
trie:match(input, [cb][, report_start])
Search for patterns in input
invoking cb
optionally ignoring case
Parameters:
input {table or string}
: one or several (if input
is an array) strings of input textcb {function}
: callback called on each pattern match in form function (idx, pos)
where idx
is a numeric index of pattern (starting from 1) and pos
is a numeric offset where the pattern endsreport_start {boolean}
: report both start and end offset when matching patternsReturns:
{boolean}
: true
if any pattern has been found (cb
might be called multiple times however). If cb
is not defined then it returns a table of match positions indexed by pattern numberBack to module description.
trie:search_mime(task, cb)
This is a helper mehthod to search pattern within text parts of a message in rspamd task
Parameters:
task {task}
: objectcb {function}
: callback called on each pattern match @see trie:matchcaseless {boolean}
: if true
then match ignores symbols case (ASCII only)Returns:
{boolean}
: true
if any pattern has been found (cb
might be called multiple times however)Back to module description.
trie:search_rawmsg(task, cb[, caseless])
This is a helper mehthod to search pattern within the whole undecoded content of rspamd task
Parameters:
task {task}
: objectcb {function}
: callback called on each pattern match @see trie:matchcaseless {boolean}
: if true
then match ignores symbols case (ASCII only)Returns:
{boolean}
: true
if any pattern has been found (cb
might be called multiple times however)Back to module description.
trie:search_rawbody(task, cb[, caseless])
This is a helper mehthod to search pattern within the whole undecoded content of task’s body (not including headers)
Parameters:
task {task}
: objectcb {function}
: callback called on each pattern match @see trie:matchcaseless {boolean}
: if true
then match ignores symbols case (ASCII only)Returns:
{boolean}
: true
if any pattern has been found (cb
might be called multiple times however)Back to module description.
Back to top.