]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add ability to pass filename from Rspamc
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 13 Mar 2018 17:28:42 +0000 (17:28 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 13 Mar 2018 17:28:42 +0000 (17:28 +0000)
src/client/rspamc.c
src/client/rspamdclient.c
src/client/rspamdclient.h
src/libserver/protocol.c
src/libserver/protocol_internal.h

index ff5f23819ead105a800a66954956edf84911f54b..2bd1376072329d165f682dd8e4ed53d059cc5a22 100644 (file)
@@ -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 {
index ad801c182f57e82741176f4c4ad0a8d07dd7b816..490e5c36941937c80d6f58a8b5a4b1385f47a2a6 100644 (file)
@@ -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));
 
index e5fe64d9138dad7f2485fd260187a9860b891aa5..129ee39a135ebfe6f33ba767abc2dc852d18baff 100644 (file)
@@ -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
index ef14e45ff6fc2404ec6e5d90c4c6d72ffd9eb749..640d778e67e8816c492f513587b28dc9fe7ad33c 100644 (file)
@@ -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);
                                }
index 41ba13d86798cc534387bd2f9ca3ee9fe01a5c88..2b6c1e377f207de8930fe49a2ef2358111b7a8a8 100644 (file)
@@ -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