g_string_free (conn->key, TRUE);
}
if (conn->keypair) {
- rspamd_http_connection_key_destroy (conn->keypair);
+ rspamd_http_connection_key_unref (conn->keypair);
}
g_string_free (conn->server_name, TRUE);
g_slice_free1 (sizeof (struct rspamd_client_connection), conn);
const gchar *ctype = "application/json";
msg = rspamd_http_new_message (HTTP_RESPONSE);
+
+ if (task->peer_key) {
+ msg->peer_key = g_string_new (task->peer_key->str);
+ msg_info ("<%s> writing encrypted reply", task->message_id);
+ }
if (!task->is_json) {
/* Turn compatibility on */
msg->method = HTTP_SYMBOLS;
if (task->settings != NULL) {
ucl_object_unref (task->settings);
}
+ if (task->peer_key != NULL) {
+ g_string_free (task->peer_key, TRUE);
+ }
rspamd_mempool_delete (task->task_pool);
g_slice_free1 (sizeof (struct rspamd_task), task);
}
} pre_result; /**< Result of pre-filters */
ucl_object_t *settings; /**< Settings applied to task */
+ GString *peer_key; /**< Peer's pubkey */
};
/**
new->port = 80;
new->type = type;
new->method = HTTP_GET;
+ new->peer_key = NULL;
return new;
}
}
void
-rspamd_http_connection_key_destroy (gpointer key)
+rspamd_http_connection_key_unref (gpointer key)
{
struct rspamd_http_keypair *kp = (struct rspamd_http_keypair *)key;
REF_RELEASE (kp);
}
+gpointer
+rspamd_http_connection_key_ref (gpointer key)
+{
+ struct rspamd_http_keypair *kp = (struct rspamd_http_keypair *)key;
+
+ g_assert (key != NULL);
+ REF_RETAIN (kp);
+
+ return kp;
+}
+
GString *
rspamd_http_connection_make_peer_key (const gchar *key)
{
* Release key pointed by an opaque pointer
* @param key opaque key structure
*/
-void rspamd_http_connection_key_destroy (gpointer key);
+void rspamd_http_connection_key_unref (gpointer key);
+
+/**
+ * Increase refcount for a key pointed by an opaque pointer
+ * @param key opaque key structure
+ */
+gpointer rspamd_http_connection_key_ref (gpointer key);
GString *rspamd_http_connection_make_peer_key (const gchar *key);
return 0;
}
+ if (msg->peer_key) {
+ task->peer_key = g_string_new (msg->peer_key->str);
+ }
+
if (!rspamd_task_process (task, msg, ctx->classify_pool, TRUE)) {
task->state = WRITE_REPLY;
}
rspamd_log_close (rspamd_main->logger);
if (ctx->key) {
- rspamd_http_connection_key_destroy (ctx->key);
+ rspamd_http_connection_key_unref (ctx->key);
}
exit (EXIT_SUCCESS);