rspamd_map
This module is used to manage rspamd maps and map like objects
All maps could be obtained by function rspamd_config:get_maps()
Also see lua_maps
module description.
Important notice maps cannot be queried outside of the worker context.
For example, you cannot add even a file map and query some keys from it during
some module initialisation, you need to add the appropriate event loop context
for a worker (e.g. you cannot use get_key
outside of the symbols callbacks or
a worker on_load
scripts).
Methods:
Method | Description |
---|---|
map:get_key(in) |
Variable method for different types of maps. |
map:is_signed() |
Returns True if a map is signed. |
map:get_proto() |
Returns protocol of map as string. |
map:get_sign_key() |
Returns pubkey used for signing as base32 string or nil. |
map:set_sign_key(key) |
Set trusted key for signatures for this map. |
map:set_callback(cb) |
Set callback for a specified callback map. |
map:get_uri() |
Get uri for a specified map. |
map:get_stats(reset) |
Get statistics for specific map. |
map:foreach(callback, is_text) |
Iterate over map elements and call callback for each element. |
map:on_load(callback) |
Sets a callback for a map that is called when map is loaded. |
map:get_data_digest() |
Get data digest for specific map. |
map:get_nelts() |
Get number of elements for specific map. |
The module rspamd_map
defines the following methods.
map:get_key(in)
Variable method for different types of maps:
Parameters:
in {vary}
: input to checkReturns:
{bool|string}
: if a value is found then this function returns string or True
if not - then it returns nil
or False
Back to module description.
map:is_signed()
Returns True
if a map is signed
Parameters:
No parameters
Returns:
{bool}
: signed valueBack to module description.
map:get_proto()
Returns protocol of map as string:
http
: for HTTP mapfile
: for file mapParameters:
No parameters
Returns:
{string}
: string representation of the map protocolBack to module description.
map:get_sign_key()
Returns pubkey used for signing as base32 string or nil
Parameters:
No parameters
Returns:
{string}
: base32 encoded string or nilBack to module description.
map:set_sign_key(key)
Set trusted key for signatures for this map
Parameters:
key {string}
: base32 encoded string or nilReturns:
No return
Back to module description.
map:set_callback(cb)
Set callback for a specified callback map.
Parameters:
cb {function}
: map callback functionReturns:
No return
Back to module description.
map:get_uri()
Get uri for a specified map
Parameters:
No parameters
Returns:
{string}
: map’s URIBack to module description.
map:get_stats(reset)
Get statistics for specific map. It returns table in form: [key] => [nhits]
Parameters:
reset {boolean}
: reset stats if trueReturns:
{table}
: map’s statBack to module description.
map:foreach(callback, is_text)
Iterate over map elements and call callback for each element.
Parameters:
callback {function}
: callback function, that accepts two arguments: key and value, if it returns true then iteration is stoppedis_text {boolean}
: if true then callback accepts rspamd_text instead of Lua stringsReturns:
{number}
: number of elements iteratedBack to module description.
map:on_load(callback)
Sets a callback for a map that is called when map is loaded
Parameters:
callback {function}
: callback function, that accepts no arguments (pass maps in a closure if needed)Returns:
No return
Back to module description.
map:get_data_digest()
Get data digest for specific map
Parameters:
No parameters
Returns:
{string}
: 64 bit number represented as string (due to Lua limitations)Back to module description.
map:get_nelts()
Get number of elements for specific map
Parameters:
No parameters
Returns:
{number}
: number of elements in the mapBack to module description.
Back to top.