diff options
Diffstat (limited to 'src/libserver/protocol.c')
-rw-r--r-- | src/libserver/protocol.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index f4e8da09d..d735d62fd 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -90,6 +90,7 @@ #define QUEUE_ID_HEADER "Queue-ID" #define ERROR_HEADER "Error" #define USER_HEADER "User" +#define URLS_HEADER "URL-Format" #define PASS_HEADER "Pass" #define JSON_HEADER "Json" #define HOSTNAME_HEADER "Hostname" @@ -383,6 +384,13 @@ rspamd_protocol_handle_headers (struct rspamd_task *task, if (g_ascii_strcasecmp (headern, USER_HEADER) == 0) { task->user = h->value->str; } + if (g_ascii_strcasecmp (headern, URLS_HEADER) == 0) { + if (h->value->len == sizeof ("extended") - 1 && + g_ascii_strcasecmp (h->value->str, "extended") == 0) { + task->extended_urls = TRUE; + debug_task ("extended urls information"); + } + } else { validh = FALSE; } @@ -485,9 +493,31 @@ urls_protocol_cb (gpointer key, gpointer value, gpointer ud) { struct tree_cb_data *cb = ud; struct uri *url = value; - ucl_object_t *obj; + ucl_object_t *obj, *elt; + + if (!cb->task->extended_urls) { + obj = ucl_object_fromlstring (url->host, url->hostlen); + } + else { + obj = ucl_object_typed_new (UCL_OBJECT); - obj = ucl_object_fromlstring (url->host, url->hostlen); + elt = ucl_object_fromstring (url->string); + ucl_object_insert_key (obj, elt, "url", 0, false); + + elt = ucl_object_fromlstring (url->host, url->hostlen); + ucl_object_insert_key (obj, elt, "host", 0, false); + + elt = ucl_object_fromlstring (url->data, url->datalen); + ucl_object_insert_key (obj, elt, "data", 0, false); + + if (url->surbl) { + elt = ucl_object_fromlstring (url->surbl, url->surbllen); + ucl_object_insert_key (obj, elt, "surbl", 0, false); + } + + elt = ucl_object_frombool (url->is_phished); + ucl_object_insert_key (obj, elt, "phished", 0, false); + } DL_APPEND (cb->top->value.av, obj); if (cb->task->cfg->log_urls) { |