Module lua_maps

This module contains helper functions for managing rspamd maps

Brief content:

Functions:

Function Description
lua_maps.map_add_from_ucl(opt, mtype, description) Creates a map from static data.
lua_maps.map_add(mname, optname, mtype, description) Creates a map from configuration elements (static data or URL).
lua_maps.fill_config_maps(mname, options, defs) Fill maps that could be defined in defs, from the config in the options.

Functions

The module lua_maps defines the following functions.

Function lua_maps.map_add_from_ucl(opt, mtype, description)

Creates a map from static data Returns true if map was added or nil

Parameters:

  • opt {string or table}: data for map (or URL)
  • mtype {string}: type of map (set, map, radix, regexp)
  • description {string}: human-readable description of map
  • callback {function}: optional callback that will be called on map match (required for external maps)

Returns:

  • {bool}: true on success, or nil

Back to module description.

Function lua_maps.map_add(mname, optname, mtype, description)

Creates a map from configuration elements (static data or URL) Returns true if map was added or nil

Parameters:

  • mname {string}: config section to use
  • optname {string}: option name to use
  • mtype {string}: type of map (‘set’, ‘hash’, ‘radix’, ‘regexp’, ‘glob’)
  • description {string}: human-readable description of map
  • callback {function}: optional callback that will be called on map match (required for external maps)

Returns:

  • {bool}: true on success, or nil

Back to module description.

Function lua_maps.fill_config_maps(mname, options, defs)

Fill maps that could be defined in defs, from the config in the options Defs is a table indexed by a map’s parameter name and defining it’s config,

Parameters:

No parameters

Returns:

No return

Example:

defs = {
  my_map = {
    type = 'map',
    description = 'my cool map',
    optional = true,
  }
}
-- Then this function will look for opts.my_map parameter and try to replace it with
-- a map with the specific type, description but not failing if it was empty.
-- It will also set options.my_map_orig to the original value defined in the map.

Back to module description.

Back to top.