}
}
+ if (priv->ctx->config.user_agent) {
+ rspamd_http_message_add_header (msg, "User-Agent",
+ priv->ctx->config.user_agent);
+ }
+
if (encrypted) {
mode = rspamd_keypair_alg (priv->local_key);
static const int default_kp_size = 1024;
static const gdouble default_rotate_time = 120;
+ static const gchar *default_user_agent = "rspamd-" RSPAMD_VERSION_FULL;
ctx = g_malloc0 (sizeof (*ctx));
ctx->config.kp_cache_size_client = default_kp_size;
ctx->config.kp_cache_size_server = default_kp_size;
ctx->config.client_key_rotate_time = default_rotate_time;
+ ctx->config.user_agent = default_user_agent;
if (cfg) {
ctx->ssl_ctx = cfg->libs_ctx->ssl_ctx;
if (rotate_time) {
ctx->config.client_key_rotate_time = ucl_object_todouble (rotate_time);
}
+
+ const ucl_object_t *user_agent;
+
+ user_agent = ucl_object_lookup (client_obj, "user_agent");
+
+ if (user_agent) {
+ ctx->config.user_agent = ucl_object_tostring (user_agent);
+
+ if (ctx->config.user_agent && strlen (ctx->config.user_agent) == 0) {
+ ctx->config.user_agent = NULL;
+ }
+ }
}
server_obj = ucl_object_lookup (http_obj, "server");
ptask = lua_newuserdata (cbd->L, sizeof (*ptask));
*ptask = task;
lua_pushboolean (cbd->L, success);
- lua_pushstring (cbd->L, error_str);
+
+ if (error_str) {
+ lua_pushstring (cbd->L, error_str);
+ }
+ else {
+ lua_pushnil (cbd->L);
+ }
if (cbd->ctx) {
if (res->domain) {