Module rspamd_udp

Rspamd UDP module is available from the version 1.9.0 and represents a generic UDP asynchronous client available from the LUA code. This module is quite simple: it can either send requests to some address or it can send requests and wait for replies, potentially handling retransmits.

Example:

local logger = require "rspamd_logger"
local udp = require "rspamd_udp"

rspamd_config.SYM = function(task)
  udp.sento{
    host = addr, -- must be ip address object (e.g. received by upstream module)
    port = 500,
    data = {'str1, 'str2'}, -- can be table, string or rspamd_text
    timeout = 0.5, -- default = 1s
    task = task, -- if has task
    session = session, -- optional
    ev_base = ev_base, -- if no task available
    -- You can include callback and then Rspamd will try to read replies
    callback = function(success, data)
      -- success is bool, data is either data or an error (string)
    end,
    retransmits = 0, -- Or more if retransmitting is necessary

end

Brief content:

Functions:

Functions

The module rspamd_udp defines the following functions.

Function rspamd_udp.sendto({params})

This function simply sends data to an external UDP service

  • task: rspamd task objects (implies pool, session and ev_base arguments)
  • ev_base: event base (if no task specified)
  • session: events session (no task, optional)
  • pool: memory pool (if no task specified)
  • host: IP or name of the peer (required)
  • port: remote port to use (if host has no port part this is required)
  • data: a table of strings or rspamd_text objects that contains data pieces
  • retransmits: number of retransmits if needed
  • callback: optional callback if reply should be read

Parameters:

No parameters

Returns:

  • {boolean}: true if request has been sent (additional string if it has not)

Back to module description.

Back to top.