struct rspamd_xml_userdata *ctx;
};
+struct wrk_param {
+ gboolean is_list;
+ union {
+ gchar *param;
+ GList *list;
+ } d;
+};
+
static void
worker_foreach_callback (gpointer k, gpointer v, gpointer ud)
{
struct wrk_cbdata *cd = ud;
+ struct wrk_param *param = v;
struct xml_config_param *cparam;
+ GList *cur;
GHashTable *worker_config;
if (!worker_options || (worker_config = g_hash_table_lookup (worker_options, &cd->wrk->type)) == NULL ||
else {
if (cd->wrk->ctx != NULL) {
- cparam->handler (cd->cfg, cd->ctx, NULL, v, NULL, cd->wrk->ctx, cparam->offset);
+ if (param->is_list) {
+ cur = param->d.list;
+ while (cur) {
+ cparam->handler (cd->cfg, cd->ctx, NULL, cur->data, NULL, cd->wrk->ctx, cparam->offset);
+ cur = g_list_next (cur);
+ }
+ }
+ else {
+ cparam->handler (cd->cfg, cd->ctx, NULL, param->d.param, NULL, cd->wrk->ctx, cparam->offset);
+ }
}
else {
- msg_err ("Bad error detected: module %s has not initialized its context", g_quark_to_string (cd->wrk->type));
+ msg_err ("Bad error detected: worker %s has not initialized its context", g_quark_to_string (cd->wrk->type));
}
}
}
worker_handle_param (struct config_file *cfg, struct rspamd_xml_userdata *ctx, const gchar *tag, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
{
struct worker_conf *wrk = ctx->section_pointer;
- const gchar *name;
+ const gchar *name, *tmp;
+ struct wrk_param *param;
if (g_ascii_strcasecmp (tag, "option") == 0 || g_ascii_strcasecmp (tag, "param") == 0) {
if (attrs == NULL || (name = g_hash_table_lookup (attrs, "name")) == NULL) {
name = memory_pool_strdup (cfg->cfg_pool, tag);
}
- g_hash_table_insert (wrk->params, (char *)name, memory_pool_strdup (cfg->cfg_pool, data));
+ if ((param = g_hash_table_lookup (wrk->params, name)) == NULL) {
+ param = memory_pool_alloc (cfg->cfg_pool, sizeof (struct wrk_param));
+ param->is_list = FALSE;
+ param->d.param = memory_pool_strdup (cfg->cfg_pool, data);
+ g_hash_table_insert (wrk->params, (char *)name, param);
+ }
+ else {
+ if (param->is_list) {
+ param->d.list = g_list_append (param->d.list, memory_pool_strdup (cfg->cfg_pool, data));
+ }
+ else {
+ /* Convert to list */
+ param->is_list = TRUE;
+ tmp = param->d.param;
+ param->d.list = g_list_prepend (NULL, (gpointer)tmp);
+ memory_pool_add_destructor (cfg->cfg_pool, (pool_destruct_func)g_list_free, param->d.list);
+ }
+ }
return TRUE;
}
#define DEFAULT_UPSTREAM_DEAD_TIME 300
#define DEFAULT_UPSTREAM_MAXERRORS 10
+#define DEFAULT_PROXY_BUF_LEN 100 * 1024
+
static sig_atomic_t wanna_die = 0;
/* Init functions */
guint32 smtp_timeout_raw;
struct timeval smtp_timeout;
+ gboolean use_xclient;
+
+ gsize proxy_buf_len;
+
struct rspamd_dns_resolver *resolver;
struct event_base *ev_base;
};
/* Create a proxy for upstream connection */
rspamd_dispatcher_pause (session->dispatcher);
session->proxy = rspamd_create_proxy (session->sock, session->upstream_sock, session->pool,
- session->ev_base, BUFSIZ, &session->ctx->smtp_timeout, smtp_proxy_err_proxy, session);
+ session->ev_base, session->ctx->proxy_buf_len,
+ &session->ctx->smtp_timeout, smtp_proxy_err_proxy, session);
return TRUE;
}
G_STRUCT_OFFSET (struct smtp_proxy_ctx, smtp_delay));
register_worker_opt (type, "jitter", xml_handle_seconds, ctx,
G_STRUCT_OFFSET (struct smtp_proxy_ctx, delay_jitter));
+ register_worker_opt (type, "xclient", xml_handle_boolean, ctx,
+ G_STRUCT_OFFSET (struct smtp_proxy_ctx, use_xclient));
+ register_worker_opt (type, "proxy_buffer", xml_handle_size, ctx,
+ G_STRUCT_OFFSET (struct smtp_proxy_ctx, proxy_buf_len));
return ctx;
}
return FALSE;
}
+ if (ctx->proxy_buf_len == 0) {
+ ctx->proxy_buf_len = DEFAULT_PROXY_BUF_LEN;
+ }
+
return TRUE;
}