From 3b8cd373886c3bc80cc8e23133eaa1cda3d6ae6c Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 1 Jul 2017 16:28:06 +0100 Subject: [PATCH] [Feature] Allow to specify custom User-Agent for rspamc --- src/client/rspamc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/rspamc.c b/src/client/rspamc.c index 4bc9dd9cc..b8865b9c1 100644 --- a/src/client/rspamc.c +++ b/src/client/rspamc.c @@ -63,6 +63,7 @@ static gboolean profile = FALSE; static gboolean skip_images = FALSE; static gboolean skip_attachments = FALSE; static gchar *key = NULL; +static gchar *user_agent = "rspamc"; static GList *children; #define ADD_CLIENT_HEADER(o, n, v) do { \ @@ -131,7 +132,7 @@ static GOptionEntry entries[] = "Use specified pubkey to encrypt request", NULL }, { "exec", 'e', 0, G_OPTION_ARG_STRING, &execute, "Execute the specified command and pass output to it", NULL }, - { "mime", 'e', 0, G_OPTION_ARG_NONE, &mime_output, + { "mime", 'm', 0, G_OPTION_ARG_NONE, &mime_output, "Write mime body of message with headers instead of just a scan's result", NULL }, {"header", 0, 0, G_OPTION_ARG_STRING_ARRAY, &http_headers, "Add custom HTTP header to query (can be repeated)", NULL}, @@ -151,6 +152,8 @@ static GOptionEntry entries[] = "Skip images when learning/unlearning fuzzy", NULL }, { "skip-attachments", '\0', 0, G_OPTION_ARG_NONE, &skip_attachments, "Skip attachments when learning/unlearning fuzzy", NULL }, + { "user-agent", 'U', 0, G_OPTION_ARG_STRING, &user_agent, + "Use specific User-Agent instead of \"rspamc\"", NULL }, { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } }; @@ -553,7 +556,9 @@ add_options (GQueue *opts) GString *numbuf; gchar **hdr, **rcpt; - ADD_CLIENT_HEADER (opts, "User-Agent", "rspamc"); + if (user_agent) { + ADD_CLIENT_HEADER (opts, "User-Agent", user_agent); + } if (ip != NULL) { rspamd_inet_addr_t *addr = NULL; -- 2.39.5