struct rspamd_worker_cfg_parser {
struct rspamd_worker_param_parser *parsers; /**< parsers hash */
gint type; /**< workers quark */
- gboolean (*def_obj_parser)(ucl_object_t *obj, gpointer ud); /**< default object parser */
+ gboolean (*def_obj_parser)(const ucl_object_t *obj, gpointer ud); /**< default object parser */
gpointer def_ud;
UT_hash_handle hh; /**< hash by type */
};
* @param opt_name name of option to get
* @return module value or NULL if option does not defined
*/
-ucl_object_t* get_module_opt (struct config_file *cfg, const gchar *module_name,
+const ucl_object_t* get_module_opt (struct config_file *cfg, const gchar *module_name,
const gchar *opt_name);
/**
* Common section handlers
*/
static gboolean
-rspamd_rcl_logging_handler (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_logging_handler (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
- ucl_object_t *val;
+ const ucl_object_t *val;
const gchar *facility, *log_type, *log_level;
val = ucl_object_find_key (obj, "type");
}
static gboolean
-rspamd_rcl_options_handler (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_options_handler (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
- ucl_object_t *val;
+ const ucl_object_t *val;
const gchar *user_settings, *domain_settings;
/* Handle user and domain settings */
*/
static gboolean
rspamd_rcl_insert_symbol (struct config_file *cfg, struct metric *metric,
- ucl_object_t *obj, gboolean is_legacy, GError **err)
+ const ucl_object_t *obj, gboolean is_legacy, GError **err)
{
const gchar *group = "ungrouped", *description = NULL, *sym_name;
gdouble symbol_score, *score_ptr;
- ucl_object_t *val;
+ const ucl_object_t *val;
struct symbols_group *sym_group;
struct symbol_def *sym_def;
GList *metric_list, *group_list;
}
static gboolean
-rspamd_rcl_metric_handler (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_metric_handler (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
- ucl_object_t *val, *cur;
+ const ucl_object_t *val, *cur;
const gchar *metric_name, *subject_name, *semicolon, *act_str;
struct metric *metric;
struct metric_action *action;
}
static gboolean
-rspamd_rcl_worker_handler (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_worker_handler (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
- ucl_object_t *val, *cur;
+ const ucl_object_t *val, *cur;
ucl_object_iter_t it = NULL;
const gchar *worker_type, *worker_bind;
GQuark qtype;
}
}
- wrk->options = obj;
+ wrk->options = (ucl_object_t *)obj;
if (!rspamd_rcl_section_parse_defaults (section, cfg, obj, wrk, err)) {
return FALSE;
}
static gboolean
-rspamd_rcl_lua_handler (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_lua_handler (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
const gchar *lua_src = memory_pool_strdup (cfg->cfg_pool, ucl_object_tostring (obj));
}
static gboolean
-rspamd_rcl_modules_handler (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_modules_handler (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
- ucl_object_t *val, *cur;
+ const ucl_object_t *val, *cur;
const gchar *data;
if (obj->type == UCL_OBJECT) {
}
static gboolean
-rspamd_rcl_statfile_handler (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_statfile_handler (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct classifier_config *ccf = ud;
- ucl_object_t *val;
+ const ucl_object_t *val;
struct statfile *st;
const gchar *data;
gdouble binlog_rotate;
return FALSE;
}
- st->opts = obj;
+ st->opts = (ucl_object_t *)obj;
val = ucl_object_find_key (obj, "spam");
if (val == NULL) {
}
static gboolean
-rspamd_rcl_classifier_handler (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_classifier_handler (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
- ucl_object_t *val, *cur;
+ const ucl_object_t *val, *cur;
ucl_object_iter_t it = NULL;
const gchar *key, *type;
struct classifier_config *ccf, *found = NULL;
}
static gboolean
-rspamd_rcl_composite_handler (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_composite_handler (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
- ucl_object_t *val;
+ const ucl_object_t *val;
struct expression *expr;
struct rspamd_composite *composite;
const gchar *composite_name, *composite_expression;
}
static gboolean
-rspamd_rcl_view_handler (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_view_handler (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
- ucl_object_t *val, *cur;
+ const ucl_object_t *val, *cur;
struct rspamd_view *view;
const gchar *view_ip, *view_client_ip, *view_symbols,
*view_rcpt, *view_from;
* for default handlers
*/
static gboolean
-rspamd_rcl_empty_handler (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_empty_handler (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
return rspamd_rcl_section_parse_defaults (section, cfg, obj, cfg, err);
gboolean
rspamd_read_rcl_config (struct rspamd_rcl_section *top,
- struct config_file *cfg, ucl_object_t *obj, GError **err)
+ struct config_file *cfg, const ucl_object_t *obj, GError **err)
{
- ucl_object_t *found, *cur_obj;
+ const ucl_object_t *found, *cur_obj;
struct rspamd_rcl_section *cur, *tmp;
if (obj->type != UCL_OBJECT) {
}
}
- cfg->rcl_obj = obj;
+ cfg->rcl_obj = (ucl_object_t *)obj;
return TRUE;
}
gboolean rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section,
- struct config_file *cfg, ucl_object_t *obj, gpointer ptr,
+ struct config_file *cfg, const ucl_object_t *obj, gpointer ptr,
GError **err)
{
- ucl_object_t *found;
+ const ucl_object_t *found;
struct rspamd_rcl_default_handler_data *cur, *tmp;
if (obj->type != UCL_OBJECT) {
}
gboolean
-rspamd_rcl_parse_struct_string (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_parse_struct_string (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
}
gboolean
-rspamd_rcl_parse_struct_integer (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_parse_struct_integer (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
}
gboolean
-rspamd_rcl_parse_struct_double (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_parse_struct_double (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
}
gboolean
-rspamd_rcl_parse_struct_time (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_parse_struct_time (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
}
gboolean
-rspamd_rcl_parse_struct_string_list (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_parse_struct_string_list (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
GList **target;
gchar *val;
- ucl_object_t *cur;
+ const ucl_object_t *cur;
const gsize num_str_len = 32;
ucl_object_iter_t iter = NULL;
}
gboolean
-rspamd_rcl_parse_struct_boolean (struct config_file *cfg, ucl_object_t *obj,
+rspamd_rcl_parse_struct_boolean (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
* @param err error object
* @return TRUE if a section has been parsed
*/
-typedef gboolean (*rspamd_rcl_handler_t) (struct config_file *cfg, ucl_object_t *obj,
+typedef gboolean (*rspamd_rcl_handler_t) (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
* @return TRUE if an object can be parsed
*/
gboolean rspamd_read_rcl_config (struct rspamd_rcl_section *top,
- struct config_file *cfg, ucl_object_t *obj, GError **err);
+ struct config_file *cfg, const ucl_object_t *obj, GError **err);
/**
* @return TRUE if the object has been parsed
*/
gboolean rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section,
- struct config_file *cfg, ucl_object_t *obj, gpointer ptr,
+ struct config_file *cfg, const ucl_object_t *obj, gpointer ptr,
GError **err);
/**
* Here is a section of common handlers that accepts rcl_struct_parser
* @param err error pointer
* @return TRUE if a string value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_string (struct config_file *cfg, ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_string (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
* @param err error pointer
* @return TRUE if a value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_integer (struct config_file *cfg, ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_integer (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
* @param err error pointer
* @return TRUE if a value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_double (struct config_file *cfg, ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_double (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
* @param err error pointer
* @return TRUE if a value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_time (struct config_file *cfg, ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_time (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
* @param err error pointer
* @return TRUE if a value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_string_list (struct config_file *cfg, ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_string_list (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
* @param err error pointer
* @return TRUE if a value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_boolean (struct config_file *cfg, ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_boolean (struct config_file *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
memory_pool_delete (cfg->cfg_pool);
}
-ucl_object_t *
+const ucl_object_t *
get_module_opt (struct config_file *cfg, const gchar *module_name, const gchar *opt_name)
{
- ucl_object_t *res = NULL, *sec;
+ const ucl_object_t *res = NULL, *sec;
sec = ucl_obj_get_key (cfg->rcl_obj, module_name);
if (sec != NULL) {
}
static void
-rspamc_symbol_ouptut (ucl_object_t *obj)
+rspamc_symbol_ouptut (const ucl_object_t *obj)
{
- ucl_object_t *cur, *it;
+ const ucl_object_t *cur, *it;
rspamd_fprintf (stdout, "Symbol: %s ", ucl_object_key (obj));
cur = ucl_object_find_key (obj, "score");
}
static void
-rspamc_metric_output (ucl_object_t *obj)
+rspamc_metric_output (const ucl_object_t *obj)
{
ucl_object_iter_t it = NULL;
- ucl_object_t *cur;
+ const ucl_object_t *cur;
gdouble score, required_score;
gint got_scores = 0;
rspamc_symbols_output (ucl_object_t *obj)
{
ucl_object_iter_t it = NULL;
- ucl_object_t *cur;
+ const ucl_object_t *cur;
gchar *emitted;
while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) {
if (name != NULL && lua_istable (L, -1)) {
obj = lua_rcl_obj_get (L, -1);
if (obj != NULL) {
- cfg->rcl_obj = ucl_object_insert_key_merged (cfg->rcl_obj, obj, name, keylen, true);
+ ucl_object_insert_key_merged (cfg->rcl_obj, obj, name, keylen, true);
}
}
}
{
struct statfile *st = lua_check_statfile (L);
const gchar *param;
- ucl_object_t *value;
+ const ucl_object_t *value;
param = luaL_checkstring (L, 2);
* @param L lua state
* @param obj object to push
*/
-gint lua_rcl_obj_push (lua_State *L, ucl_object_t *obj, gboolean allow_array);
+gint lua_rcl_obj_push (lua_State *L, const ucl_object_t *obj, gboolean allow_array);
/**
* Extract rcl object from lua object
{
struct config_file *cfg = lua_check_config (L);
const gchar *mname, *optname;
- ucl_object_t *obj;
+ const ucl_object_t *obj;
if (cfg) {
mname = luaL_checkstring (L, 2);
{
struct config_file *cfg = lua_check_config (L);
const gchar *mname;
- ucl_object_t *obj;
+ const ucl_object_t *obj;
if (cfg) {
mname = luaL_checkstring (L, 2);
* @file lua rcl bindings
*/
-static gint lua_rcl_obj_push_array (lua_State *L, ucl_object_t *obj);
-static gint lua_rcl_obj_push_simple (lua_State *L, ucl_object_t *obj, gboolean allow_array);
+static gint lua_rcl_obj_push_array (lua_State *L, const ucl_object_t *obj);
+static gint lua_rcl_obj_push_simple (lua_State *L, const ucl_object_t *obj, gboolean allow_array);
static ucl_object_t* lua_rcl_table_get (lua_State *L, gint idx);
static ucl_object_t* lua_rcl_elt_get (lua_State *L, gint idx);
* @param obj
*/
static void
-lua_rcl_obj_push_elt (lua_State *L, const char *key, ucl_object_t *obj)
+lua_rcl_obj_push_elt (lua_State *L, const char *key, const ucl_object_t *obj)
{
lua_pushstring (L, key);
lua_rcl_obj_push (L, obj, TRUE);
* @return
*/
static gint
-lua_rcl_obj_push_obj (lua_State *L, ucl_object_t *obj, gboolean allow_array)
+lua_rcl_obj_push_obj (lua_State *L, const ucl_object_t *obj, gboolean allow_array)
{
- ucl_object_t *cur;
+ const ucl_object_t *cur;
ucl_object_iter_t it = NULL;
if (allow_array && obj->next != NULL) {
* @return
*/
static gint
-lua_rcl_obj_push_array (lua_State *L, ucl_object_t *obj)
+lua_rcl_obj_push_array (lua_State *L, const ucl_object_t *obj)
{
- ucl_object_t *cur;
+ const ucl_object_t *cur;
gint i = 1;
lua_newtable (L);
* Push a simple object to lua depending on its actual type
*/
static gint
-lua_rcl_obj_push_simple (lua_State *L, ucl_object_t *obj, gboolean allow_array)
+lua_rcl_obj_push_simple (lua_State *L, const ucl_object_t *obj, gboolean allow_array)
{
if (allow_array && obj->next != NULL) {
/* Actually we need to push this as an array */
* @param obj object to push
*/
gint
-lua_rcl_obj_push (lua_State *L, ucl_object_t *obj, gboolean allow_array)
+lua_rcl_obj_push (lua_State *L, const ucl_object_t *obj, gboolean allow_array)
{
switch (obj->type) {
case UCL_OBJECT:
/* Table iterate */
lua_pushvalue (L, idx);
lua_pushnil (L);
+ top = ucl_object_typed_new (UCL_OBJECT);
while (lua_next (L, -2) != 0) {
/* copy key to avoid modifications */
lua_pushvalue (L, -2);
k = lua_tolstring (L, -1, &keylen);
obj = lua_rcl_elt_get (L, -2);
- top = ucl_object_insert_key (top, obj, k, keylen, true);
+ ucl_object_insert_key (top, obj, k, keylen, true);
lua_pop (L, 2);
}
lua_pop (L, 1);
lua_worker_get_option (lua_State *L)
{
struct rspamd_lua_worker_ctx *ctx = lua_check_lua_worker (L);
- ucl_object_t *val;
+ const ucl_object_t *val;
const gchar *name;
if (ctx) {
gint
chartable_module_config (struct config_file *cfg)
{
- ucl_object_t *value;
+ const ucl_object_t *value;
gint res = TRUE;
if ((value = get_module_opt (cfg, "chartable", "symbol")) != NULL) {
gint
dkim_module_config (struct config_file *cfg)
{
- ucl_object_t *value;
+ const ucl_object_t *value;
gint res = TRUE;
guint cache_size, cache_expire;
gboolean got_trusted = FALSE;
};
static void
-parse_flags (struct fuzzy_rule *rule, struct config_file *cfg, ucl_object_t *val)
+parse_flags (struct fuzzy_rule *rule, struct config_file *cfg, const ucl_object_t *val)
{
- ucl_object_t *elt;
+ const ucl_object_t *elt;
struct fuzzy_mapping *map;
const gchar *sym = NULL;
}
static gint
-fuzzy_parse_rule (struct config_file *cfg, ucl_object_t *obj)
+fuzzy_parse_rule (struct config_file *cfg, const ucl_object_t *obj)
{
- ucl_object_t *value, *cur;
+ const ucl_object_t *value, *cur;
struct fuzzy_rule *rule;
ucl_object_iter_t it = NULL;
gint
fuzzy_check_module_config (struct config_file *cfg)
{
- ucl_object_t *value, *cur;
+ const ucl_object_t *value, *cur;
gint res = TRUE;
if ((value = get_module_opt (cfg, "fuzzy_check", "symbol")) != NULL) {
regexp_module_config (struct config_file *cfg)
{
struct regexp_module_item *cur_item;
- ucl_object_t *sec, *value;
+ const ucl_object_t *sec, *value;
ucl_object_iter_t it = NULL;
gint res = TRUE;
struct regexp_json_buf *jb, **pjb;
gint
spf_module_config (struct config_file *cfg)
{
- ucl_object_t *value;
+ const ucl_object_t *value;
gint res = TRUE;
guint cache_size, cache_expire;
struct suffix_item *new_suffix, *cur_suffix = NULL;
struct surbl_bit_item *new_bit;
- ucl_object_t *value, *cur, *cur_rule, *cur_bit;
+ const ucl_object_t *value, *cur, *cur_rule, *cur_bit;
ucl_object_iter_t it = NULL;
const gchar *redir_val;
guint32 bit;
rspamd_printf_gstring (logbuf, "%s,", sym->name);
description = g_hash_table_lookup (m->descriptions, sym->name);
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (sym->name), "name", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromdouble (sym->score), "score", 0, false);
+ obj = ucl_object_typed_new (UCL_OBJECT);
+ ucl_object_insert_key (obj, ucl_object_fromstring (sym->name), "name", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromdouble (sym->score), "score", 0, false);
if (description) {
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (description), "description", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromstring (description), "description", 0, false);
}
if (sym->options != NULL) {
- obj = ucl_object_insert_key (obj, rspamd_str_list_ucl (sym->options), "options", 0, false);
+ ucl_object_insert_key (obj, rspamd_str_list_ucl (sym->options), "options", 0, false);
}
return obj;
str_action_metric (action),
mres->score, required_score);
- obj = ucl_object_insert_key (obj, ucl_object_frombool (is_spam),
+ obj = ucl_object_typed_new (UCL_OBJECT);
+ ucl_object_insert_key (obj, ucl_object_frombool (is_spam),
"is_spam", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_frombool (task->is_skipped),
+ ucl_object_insert_key (obj, ucl_object_frombool (task->is_skipped),
"is_skipped", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromdouble (mres->score),
+ ucl_object_insert_key (obj, ucl_object_fromdouble (mres->score),
"score", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromdouble (required_score),
+ ucl_object_insert_key (obj, ucl_object_fromdouble (required_score),
"required_score", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (str_action_metric (action)),
+ ucl_object_insert_key (obj, ucl_object_fromstring (str_action_metric (action)),
"action", 0, false);
if (action == METRIC_ACTION_REWRITE_SUBJECT) {
subject = make_rewritten_subject (m, task);
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (subject),
+ ucl_object_insert_key (obj, ucl_object_fromstring (subject),
"subject", 0, false);
}
/* Now handle symbols */
while (g_hash_table_iter_next (&hiter, &h, &v)) {
sym = (struct symbol *)v;
sobj = rspamd_metric_symbol_ucl (task, m, sym, logbuf);
- obj = ucl_object_insert_key (obj, sobj, h, 0, false);
+ ucl_object_insert_key (obj, sobj, h, 0, false);
}
/* Cut the trailing comma if needed */
static void
rspamd_ucl_tolegacy_output (struct worker_task *task, ucl_object_t *top, GString *out)
{
- ucl_object_t *metric, *score, *required_score, *is_spam, *elt, *symbols;
+ const ucl_object_t *metric, *score,
+ *required_score, *is_spam, *elt, *symbols;
ucl_object_iter_t iter = NULL;
metric = ucl_object_find_key (top, DEFAULT_METRIC);
symbols = ucl_object_find_key (metric, "symbols");
while ((elt = ucl_iterate_object (symbols, &iter, true)) != NULL) {
- ucl_object_t *sym_score;
+ const ucl_object_t *sym_score;
sym_score = ucl_object_find_key (elt, "score");
g_string_append_printf (out, "Symbol: %s; %.2f\r\n",
ucl_object_key (elt),
}
g_hash_table_iter_init (&hiter, task->results);
+ top = ucl_object_typed_new (UCL_OBJECT);
/* Convert results to an ucl object */
while (g_hash_table_iter_next (&hiter, &h, &v)) {
metric_res = (struct metric_result *)v;
obj = rspamd_metric_result_ucl (task, metric_res, logbuf);
- top = ucl_object_insert_key (top, obj, h, 0, false);
+ ucl_object_insert_key (top, obj, h, 0, false);
}
if (task->messages != NULL) {
- top = ucl_object_insert_key (top, rspamd_str_list_ucl (task->messages), "messages", 0, false);
+ ucl_object_insert_key (top, rspamd_str_list_ucl (task->messages), "messages", 0, false);
}
if (g_tree_nnodes (task->urls) > 0) {
- top = ucl_object_insert_key (top, rspamd_urls_tree_ucl (task->urls, task), "urls", 0, false);
+ ucl_object_insert_key (top, rspamd_urls_tree_ucl (task->urls, task), "urls", 0, false);
}
if (g_tree_nnodes (task->emails) > 0) {
- top = ucl_object_insert_key (top, rspamd_emails_tree_ucl (task->emails, task), "emails", 0, false);
+ ucl_object_insert_key (top, rspamd_emails_tree_ucl (task->emails, task),
+ "emails", 0, false);
}
- top = ucl_object_insert_key (top, ucl_object_fromstring (task->message_id), "message-id", 0, false);
+ ucl_object_insert_key (top, ucl_object_fromstring (task->message_id),
+ "message-id", 0, false);
write_hashes_to_log (task, logbuf);
if (!task->no_log) {
task->state = CLOSING_CONNECTION;
+ top = ucl_object_typed_new (UCL_OBJECT);
debug_task ("writing reply to client");
if (task->error_code != 0) {
msg->code = task->error_code;
- top = ucl_object_insert_key (top, ucl_object_fromstring (task->last_error), "error", 0, false);
+ ucl_object_insert_key (top, ucl_object_fromstring (task->last_error), "error", 0, false);
msg->body = g_string_sized_new (256);
rspamd_ucl_emit_gstring (top, UCL_EMIT_JSON_COMPACT, msg->body);
ucl_object_unref (top);
-Subproject commit b1762224e9c8015abd195282ebd2f7728076e23d
+Subproject commit 2838695f608ed5bb4ef3ed9dfd4d0a095bca2059
-Subproject commit 8eb6d5601a8eec27cffa84479281207f726482d3
+Subproject commit 80ec7720f562baccc9d0205ca2fa54d70549a2e7
/* Get uptime */
uptime = time (NULL) - session->ctx->start_time;
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (RVERSION), "version", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromstring ("ok"), "auth", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromint (uptime), "uptime", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromint (data[0]), "clean", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromint (data[1]), "probable", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromint (data[2]), "greylist", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromint (data[3]), "reject", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromint (st->messages_scanned), "scanned", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromint (st->messages_learned), "learned", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromstring (RVERSION), "version", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromstring ("ok"), "auth", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromint (uptime), "uptime", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromint (data[0]), "clean", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromint (data[1]), "probable", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromint (data[2]), "greylist", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromint (data[3]), "reject", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromint (st->messages_scanned), "scanned", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromint (st->messages_learned), "learned", 0, false);
rspamd_webui_send_ucl (conn_ent, obj);
ucl_object_unref (obj);
while (cur_gr) {
gr = cur_gr->data;
obj = ucl_object_typed_new (UCL_OBJECT);
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (gr->name), "group", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromstring (gr->name), "group", 0, false);
/* Iterate through all symbols */
cur_sym = gr->symbols;
while (cur_sym) {
sym_obj = ucl_object_typed_new (UCL_OBJECT);
sym = cur_sym->data;
- sym_obj = ucl_object_insert_key (sym_obj, ucl_object_fromstring (sym->name),
+ ucl_object_insert_key (sym_obj, ucl_object_fromstring (sym->name),
"symbol", 0, false);
- sym_obj = ucl_object_insert_key (sym_obj, ucl_object_fromdouble (*sym->weight_ptr),
+ ucl_object_insert_key (sym_obj, ucl_object_fromdouble (*sym->weight_ptr),
"weight", 0, false);
if (sym->description) {
- sym_obj = ucl_object_insert_key (sym_obj, ucl_object_fromstring (sym->description),
+ ucl_object_insert_key (sym_obj, ucl_object_fromstring (sym->description),
"description", 0, false);
}
- obj = ucl_object_insert_key (obj, sym_obj, "rules", 0, false);
+ ucl_object_insert_key (obj, sym_obj, "rules", 0, false);
cur_sym = g_list_next (cur_sym);
}
cur_gr = g_list_next (cur_gr);
- top = ucl_array_append (top, obj);
+ ucl_array_append (top, obj);
}
rspamd_webui_send_ucl (conn_ent, top);
act = &metric->actions[i];
if (act->score > 0) {
obj = ucl_object_typed_new (UCL_OBJECT);
- obj = ucl_object_insert_key (obj,
+ ucl_object_insert_key (obj,
ucl_object_fromstring (str_action_metric (act->action)), "action", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromdouble (act->score), "value", 0, false);
- top = ucl_array_append (top, obj);
+ ucl_object_insert_key (obj, ucl_object_fromdouble (act->score), "value", 0, false);
+ ucl_array_append (top, obj);
}
}
}
editable = (access (map->uri, W_OK) == 0);
obj = ucl_object_typed_new (UCL_OBJECT);
- obj = ucl_object_insert_key (obj, ucl_object_fromint (map->id),
+ ucl_object_insert_key (obj, ucl_object_fromint (map->id),
"map", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (map->description),
+ ucl_object_insert_key (obj, ucl_object_fromstring (map->description),
"description", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_frombool (editable),
+ ucl_object_insert_key (obj, ucl_object_frombool (editable),
"editable", 0, false);
- top = ucl_array_append (top, obj);
+ ucl_array_append (top, obj);
cur = g_list_next (cur);
}
data[2] = ctx->srv->stat->actions_stat[METRIC_ACTION_GREYLIST] / total * 100.;
data[3] = ctx->srv->stat->actions_stat[METRIC_ACTION_REJECT] / total * 100.;
- obj = ucl_array_append (obj, ucl_object_fromstring ("Clean messages"));
- obj = ucl_array_append (obj, ucl_object_fromdouble (data[0]));
- top = ucl_array_append (top, obj);
- obj = ucl_array_append (obj, ucl_object_fromstring ("Probable spam messages"));
- obj = ucl_array_append (obj, ucl_object_fromdouble (data[1]));
- top = ucl_array_append (top, obj);
- obj = ucl_array_append (obj, ucl_object_fromstring ("Greylisted messages"));
- obj = ucl_array_append (obj, ucl_object_fromdouble (data[2]));
- top = ucl_array_append (top, obj);
- obj = ucl_array_append (obj, ucl_object_fromstring ("Rejected messages"));
- obj = ucl_array_append (obj, ucl_object_fromdouble (data[3]));
- top = ucl_array_append (top, obj);
+ ucl_array_append (obj, ucl_object_fromstring ("Clean messages"));
+ ucl_array_append (obj, ucl_object_fromdouble (data[0]));
+ ucl_array_append (top, obj);
+ ucl_array_append (obj, ucl_object_fromstring ("Probable spam messages"));
+ ucl_array_append (obj, ucl_object_fromdouble (data[1]));
+ ucl_array_append (top, obj);
+ ucl_array_append (obj, ucl_object_fromstring ("Greylisted messages"));
+ ucl_array_append (obj, ucl_object_fromdouble (data[2]));
+ ucl_array_append (top, obj);
+ ucl_array_append (obj, ucl_object_fromstring ("Rejected messages"));
+ ucl_array_append (obj, ucl_object_fromdouble (data[3]));
+ ucl_array_append (top, obj);
}
else {
obj = ucl_object_typed_new (UCL_ARRAY);
- obj = ucl_array_append (obj, ucl_object_fromstring ("Scanned messages"));
- obj = ucl_array_append (obj, ucl_object_fromdouble (0));
- top = ucl_array_append (top, obj);
+ ucl_array_append (obj, ucl_object_fromstring ("Scanned messages"));
+ ucl_array_append (obj, ucl_object_fromdouble (0));
+ ucl_array_append (top, obj);
}
rspamd_webui_send_ucl (conn_ent, top);
rspamd_strlcpy (ip_buf, inet_ntoa (task->from_addr), sizeof (ip_buf));
#endif
obj = ucl_object_typed_new (UCL_OBJECT);
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (timebuf), "time", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (row->message_id), "id", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (ip_buf), "ip", 0, false);
- obj = ucl_object_insert_key (obj,
+ ucl_object_insert_key (obj, ucl_object_fromstring (timebuf), "time", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromstring (row->message_id), "id", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromstring (ip_buf), "ip", 0, false);
+ ucl_object_insert_key (obj,
ucl_object_fromstring (str_action_metric (row->action)), "action", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromdouble (row->score), "score", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromdouble (row->required_score), "required_score", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (row->symbols), "symbols", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromint (row->len), "size", 0, false);
- obj = ucl_object_insert_key (obj, ucl_object_fromint (row->scan_time), "scan_time", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromdouble (row->score), "score", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromdouble (row->required_score), "required_score", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromstring (row->symbols), "symbols", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromint (row->len), "size", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromint (row->scan_time), "scan_time", 0, false);
if (row->user[0] != '\0') {
- obj = ucl_object_insert_key (obj, ucl_object_fromstring (row->user), "user", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromstring (row->user), "user", 0, false);
}
- top = ucl_array_append (top, obj);
+ ucl_array_append (top, obj);
rows_proc ++;
}
}