diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-09-26 15:21:41 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-09-26 15:21:41 +0100 |
commit | 24f8a11882751f6901adfc66c31bf86fcf981940 (patch) | |
tree | 9a198de13de4050453cf2d073c13a475e826c2d2 /src/libserver/protocol.c | |
parent | 917d71d6d4dd7edacfa3d4bbe7737ad5a4496876 (diff) | |
download | rspamd-24f8a11882751f6901adfc66c31bf86fcf981940.tar.gz rspamd-24f8a11882751f6901adfc66c31bf86fcf981940.zip |
[Rework] Remove control block supportvstakhov-remove-control-block
It has been buggy and never really used by anyone I suppose.
Diffstat (limited to 'src/libserver/protocol.c')
-rw-r--r-- | src/libserver/protocol.c | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index ee2192913..a86111ff2 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -720,12 +720,6 @@ rspamd_protocol_handle_headers(struct rspamd_task *task, break; case 'm': case 'M': - IF_HEADER(MLEN_HEADER) - { - msg_debug_protocol("read message length header, value: %T", - hv_tok); - task->protocol_flags |= RSPAMD_TASK_PROTOCOL_FLAG_HAS_CONTROL; - } IF_HEADER(MTA_TAG_HEADER) { char *mta_tag; @@ -782,120 +776,6 @@ if (!has_ip) { return TRUE; } -#define BOOL_TO_FLAG(val, flags, flag) \ - do { \ - if ((val)) (flags) |= (flag); \ - else \ - (flags) &= ~(flag); \ - } while (0) - -gboolean -rspamd_protocol_parse_task_flags(rspamd_mempool_t *pool, - const ucl_object_t *obj, - gpointer ud, - struct rspamd_rcl_section *section, - GError **err) -{ - struct rspamd_rcl_struct_parser *pd = ud; - int *target; - const char *key; - gboolean value; - - target = (int *) (((char *) pd->user_struct) + pd->offset); - key = ucl_object_key(obj); - value = ucl_object_toboolean(obj); - - if (key != NULL) { - if (g_ascii_strcasecmp(key, "pass_all") == 0) { - BOOL_TO_FLAG(value, *target, RSPAMD_TASK_FLAG_PASS_ALL); - } - else if (g_ascii_strcasecmp(key, "no_log") == 0) { - BOOL_TO_FLAG(value, *target, RSPAMD_TASK_FLAG_NO_LOG); - } - } - - return TRUE; -} - -static struct rspamd_rcl_sections_map *control_parser = NULL; - -RSPAMD_CONSTRUCTOR(rspamd_protocol_control_parser_ctor) -{ - - struct rspamd_rcl_section *sub = rspamd_rcl_add_section(&control_parser, NULL, - "*", - NULL, - NULL, - UCL_OBJECT, - FALSE, - TRUE); - /* Default handlers */ - rspamd_rcl_add_default_handler(sub, - "ip", - rspamd_rcl_parse_struct_addr, - G_STRUCT_OFFSET(struct rspamd_task, from_addr), - 0, - NULL); - rspamd_rcl_add_default_handler(sub, - "from", - rspamd_rcl_parse_struct_mime_addr, - G_STRUCT_OFFSET(struct rspamd_task, from_envelope), - 0, - NULL); - rspamd_rcl_add_default_handler(sub, - "rcpt", - rspamd_rcl_parse_struct_mime_addr, - G_STRUCT_OFFSET(struct rspamd_task, rcpt_envelope), - 0, - NULL); - rspamd_rcl_add_default_handler(sub, - "helo", - rspamd_rcl_parse_struct_string, - G_STRUCT_OFFSET(struct rspamd_task, helo), - 0, - NULL); - rspamd_rcl_add_default_handler(sub, - "user", - rspamd_rcl_parse_struct_string, - G_STRUCT_OFFSET(struct rspamd_task, auth_user), - 0, - NULL); - rspamd_rcl_add_default_handler(sub, - "pass_all", - rspamd_protocol_parse_task_flags, - G_STRUCT_OFFSET(struct rspamd_task, flags), - 0, - NULL); - rspamd_rcl_add_default_handler(sub, - "json", - rspamd_protocol_parse_task_flags, - G_STRUCT_OFFSET(struct rspamd_task, flags), - 0, - NULL); -} - -RSPAMD_DESTRUCTOR(rspamd_protocol_control_parser_dtor) -{ - rspamd_rcl_sections_free(control_parser); -} - -gboolean -rspamd_protocol_handle_control(struct rspamd_task *task, - const ucl_object_t *control) -{ - GError *err = NULL; - - if (!rspamd_rcl_parse(control_parser, task->cfg, task, task->task_pool, - control, &err)) { - msg_warn_protocol("cannot parse control block: %e", err); - g_error_free(err); - - return FALSE; - } - - return TRUE; -} - gboolean rspamd_protocol_handle_request(struct rspamd_task *task, struct rspamd_http_message *msg) |