diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-19 17:57:13 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-19 17:57:13 +0000 |
commit | 3f00d108df7c99edd5cb45e34d232a80e159caa3 (patch) | |
tree | 1095abc2ae37c9020eeb3ea7af2b87cd16f3c1de /src/client | |
parent | b13907192f14c0a5171b225c21ffbcedfec3d501 (diff) | |
download | rspamd-3f00d108df7c99edd5cb45e34d232a80e159caa3.tar.gz rspamd-3f00d108df7c99edd5cb45e34d232a80e159caa3.zip |
[Project] Adopt plugins, workers, rspamadm and rspamc for http_context
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/rspamc.c | 12 | ||||
-rw-r--r-- | src/client/rspamdclient.c | 13 | ||||
-rw-r--r-- | src/client/rspamdclient.h | 12 |
3 files changed, 24 insertions, 13 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c index 588496d46..d9af90b7f 100644 --- a/src/client/rspamc.c +++ b/src/client/rspamc.c @@ -67,6 +67,7 @@ static gchar *key = NULL; static gchar *user_agent = "rspamc"; static GList *children; static GPatternSpec **exclude_compiled = NULL; +static struct rspamd_http_context *http_ctx; static gint retcode = EXIT_SUCCESS; @@ -1668,7 +1669,7 @@ rspamc_process_input (struct event_base *ev_base, struct rspamc_command *cmd, } - conn = rspamd_client_init (ev_base, hostbuf, port, timeout, key); + conn = rspamd_client_init (http_ctx, ev_base, hostbuf, port, timeout, key); if (conn != NULL) { cbdata = g_malloc0 (sizeof (struct rspamc_callback_data)); @@ -1894,6 +1895,15 @@ main (gint argc, gchar **argv, gchar **env) rspamd_init_libs (); ev_base = event_base_new (); + struct rspamd_http_context_cfg http_config; + + memset (&http_config, 0, sizeof (http_config)); + http_config.kp_cache_size_client = 32; + http_config.kp_cache_size_server = 0; + http_config.user_agent = user_agent; + http_ctx = rspamd_http_context_create_config (&http_config, + ev_base); + /* Ignore sigpipe */ sigemptyset (&sigpipe_act.sa_mask); sigaddset (&sigpipe_act.sa_mask, SIGPIPE); diff --git a/src/client/rspamdclient.c b/src/client/rspamdclient.c index b1b550024..54cd490e6 100644 --- a/src/client/rspamdclient.c +++ b/src/client/rspamdclient.c @@ -241,8 +241,9 @@ rspamd_client_finish_handler (struct rspamd_http_connection *conn, } struct rspamd_client_connection * -rspamd_client_init (struct event_base *ev_base, const gchar *name, - guint16 port, gdouble timeout, const gchar *key) +rspamd_client_init (struct rspamd_http_context *http_ctx, + struct event_base *ev_base, const gchar *name, + guint16 port, gdouble timeout, const gchar *key) { struct rspamd_client_connection *conn; gint fd; @@ -256,14 +257,12 @@ rspamd_client_init (struct event_base *ev_base, const gchar *name, conn->ev_base = ev_base; conn->fd = fd; conn->req_sent = FALSE; - conn->keys_cache = rspamd_keypair_cache_new (32); - conn->http_conn = rspamd_http_connection_new (rspamd_client_body_handler, + conn->http_conn = rspamd_http_connection_new (http_ctx, + rspamd_client_body_handler, rspamd_client_error_handler, rspamd_client_finish_handler, 0, - RSPAMD_HTTP_CLIENT, - conn->keys_cache, - NULL); + RSPAMD_HTTP_CLIENT); conn->server_name = g_string_new (name); if (port != 0) { diff --git a/src/client/rspamdclient.h b/src/client/rspamdclient.h index 129ee39a1..c2a3c1886 100644 --- a/src/client/rspamdclient.h +++ b/src/client/rspamdclient.h @@ -47,6 +47,7 @@ typedef void (*rspamd_client_callback) ( gdouble send_time, GError *err); +struct rspamd_http_context; /** * Start rspamd worker or controller command * @param ev_base event base @@ -56,11 +57,12 @@ typedef void (*rspamd_client_callback) ( * @return */ struct rspamd_client_connection * rspamd_client_init ( - struct event_base *ev_base, - const gchar *name, - guint16 port, - gdouble timeout, - const gchar *key); + struct rspamd_http_context *http_ctx, + struct event_base *ev_base, + const gchar *name, + guint16 port, + gdouble timeout, + const gchar *key); /** * |