diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-13 17:28:42 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-13 17:28:42 +0000 |
commit | eb91f13938c023c1e7cb5db4fae0f5d83ec74e1a (patch) | |
tree | 7a7460fe9fb6bb65cb15a21563884d8cb74d66a4 | |
parent | 0e24e4a9daadde2af987f19d30f78856b0d833c6 (diff) | |
download | rspamd-eb91f13938c023c1e7cb5db4fae0f5d83ec74e1a.tar.gz rspamd-eb91f13938c023c1e7cb5db4fae0f5d83ec74e1a.zip |
[Minor] Add ability to pass filename from Rspamc
-rw-r--r-- | src/client/rspamc.c | 24 | ||||
-rw-r--r-- | src/client/rspamdclient.c | 5 | ||||
-rw-r--r-- | src/client/rspamdclient.h | 19 | ||||
-rw-r--r-- | src/libserver/protocol.c | 6 | ||||
-rw-r--r-- | src/libserver/protocol_internal.h | 1 |
5 files changed, 36 insertions, 19 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c index ff5f23819..2bd137607 100644 --- a/src/client/rspamc.c +++ b/src/client/rspamc.c @@ -1630,22 +1630,26 @@ rspamc_process_input (struct event_base *ev_base, struct rspamc_command *cmd, if (conn != NULL) { cbdata = g_malloc0 (sizeof (struct rspamc_callback_data)); cbdata->cmd = cmd; - cbdata->filename = g_strdup (name); + + if (name) { + cbdata->filename = g_strdup (name); + } if (cmd->need_input) { rspamd_client_command (conn, cmd->path, attrs, in, rspamc_client_cb, - cbdata, compressed, dictionary, &err); + cbdata, compressed, dictionary, cbdata->filename, &err); } else { rspamd_client_command (conn, - cmd->path, - attrs, - NULL, - rspamc_client_cb, - cbdata, - compressed, - dictionary, - &err); + cmd->path, + attrs, + NULL, + rspamc_client_cb, + cbdata, + compressed, + dictionary, + cbdata->filename, + &err); } } else { diff --git a/src/client/rspamdclient.c b/src/client/rspamdclient.c index ad801c182..490e5c369 100644 --- a/src/client/rspamdclient.c +++ b/src/client/rspamdclient.c @@ -296,6 +296,7 @@ rspamd_client_command (struct rspamd_client_connection *conn, FILE *in, rspamd_client_callback cb, gpointer ud, gboolean compressed, const gchar *comp_dictionary, + const gchar *filename, GError **err) { struct rspamd_client_request *req; @@ -431,6 +432,10 @@ rspamd_client_command (struct rspamd_client_connection *conn, } } + if (filename) { + rspamd_http_message_add_header (req->msg, "Filename", filename); + } + req->msg->url = rspamd_fstring_append (req->msg->url, "/", 1); req->msg->url = rspamd_fstring_append (req->msg->url, command, strlen (command)); diff --git a/src/client/rspamdclient.h b/src/client/rspamdclient.h index e5fe64d91..129ee39a1 100644 --- a/src/client/rspamdclient.h +++ b/src/client/rspamdclient.h @@ -73,15 +73,16 @@ struct rspamd_client_connection * rspamd_client_init ( * @return */ gboolean rspamd_client_command ( - struct rspamd_client_connection *conn, - const gchar *command, - GQueue *attrs, - FILE *in, - rspamd_client_callback cb, - gpointer ud, - gboolean compressed, - const gchar *comp_dictionary, - GError **err); + struct rspamd_client_connection *conn, + const gchar *command, + GQueue *attrs, + FILE *in, + rspamd_client_callback cb, + gpointer ud, + gboolean compressed, + const gchar *comp_dictionary, + const gchar *filename, + GError **err); /** * Destroy a connection to rspamd diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index ef14e45ff..640d778e6 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -24,6 +24,7 @@ #include "unix-std.h" #include "protocol_internal.h" #include "libserver/mempool_vars_internal.h" +#include "task.h" #include <math.h> static GQuark @@ -260,6 +261,11 @@ rspamd_protocol_handle_headers (struct rspamd_task *task, task->flags |= RSPAMD_TASK_FLAG_BROKEN_HEADERS; } } + IF_HEADER (FILENAME_HEADER) { + task->msg.fpath = rspamd_mempool_ftokdup (task->task_pool, + hv_tok); + debug_task ("read filename header, value: %s", task->msg.fpath); + } else { debug_task ("wrong header: %V", hn); } diff --git a/src/libserver/protocol_internal.h b/src/libserver/protocol_internal.h index 41ba13d86..2b6c1e377 100644 --- a/src/libserver/protocol_internal.h +++ b/src/libserver/protocol_internal.h @@ -80,5 +80,6 @@ #define TLS_VERSION_HEADER "TLS-Version" #define MTA_NAME_HEADER "MTA-Name" #define MILTER_HEADER "Milter" +#define FILENAME_HEADER "Filename" #endif //RSPAMD_PROTOCOL_INTERNAL_H |