diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-08-10 18:54:41 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-08-10 19:05:30 +0100 |
commit | 1ffa313b81f16e8ee0431a11280291296535c6d1 (patch) | |
tree | 839e45e82f9a66206257dfe265a2efe810ac2591 /src/rspamd_proxy.c | |
parent | e9deede49746063c763039097716aaf13c99ab97 (diff) | |
download | rspamd-1ffa313b81f16e8ee0431a11280291296535c6d1.tar.gz rspamd-1ffa313b81f16e8ee0431a11280291296535c6d1.zip |
[Feature] Allow to set Settings-Id for all connections
Diffstat (limited to 'src/rspamd_proxy.c')
-rw-r--r-- | src/rspamd_proxy.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index 6474188cc..3345bd785 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -74,6 +74,7 @@ worker_t rspamd_proxy_worker = { struct rspamd_http_upstream { gchar *name; + gchar *settings_id; struct upstream_list *u; struct rspamd_cryptobox_pubkey *key; gdouble timeout; @@ -181,6 +182,7 @@ struct rspamd_proxy_session { rspamd_inet_addr_t *client_addr; struct rspamd_http_connection *client_conn; struct rspamd_milter_session *client_milter_conn; + struct rspamd_http_upstream *backend; gpointer map; gchar *fname; gpointer shmem_ref; @@ -431,6 +433,11 @@ rspamd_proxy_parse_upstream (rspamd_mempool_t *pool, ucl_object_todouble_safe (elt, &up->timeout); } + elt = ucl_object_lookup_any (obj, "settings", "settings_id", NULL); + if (elt && ucl_object_type (elt) == UCL_STRING) { + up->settings_id = rspamd_mempool_strdup (pool, ucl_object_tostring (elt)); + } + /* * Accept lua function here in form * fun :: String -> UCL @@ -1646,6 +1653,12 @@ rspamd_proxy_self_scan (struct rspamd_proxy_session *session) NULL, (event_finalizer_t )rspamd_task_free, task); data = rspamd_http_message_get_body (msg, &len); + if (session->backend->settings_id) { + rspamd_http_message_remove_header (msg, "Settings-ID"); + rspamd_http_message_add_header (msg, "Settings-ID", + session->backend->settings_id); + } + /* Process message */ if (!rspamd_protocol_handle_request (task, msg)) { msg_err_task ("cannot handle request: %e", task->err); @@ -1710,6 +1723,8 @@ proxy_send_master_message (struct rspamd_proxy_session *session) goto err; } else { + session->backend = backend; + if (backend->self_scan) { return rspamd_proxy_self_scan (session); } @@ -1765,6 +1780,12 @@ retry: session->ctx->local_key); } + if (backend->settings_id != NULL) { + rspamd_http_message_remove_header (msg, "Settings-ID"); + rspamd_http_message_add_header (msg, "Settings-ID", + backend->settings_id); + } + if (backend->local || rspamd_inet_address_is_local ( rspamd_upstream_addr (session->master_conn->up), FALSE)) { |