소스 검색

Add support of encryption to the worker.

tags/0.9.0
Vsevolod Stakhov 9 년 전
부모
커밋
4acd548e91
3개의 변경된 파일39개의 추가작업 그리고 3개의 파일을 삭제
  1. 21
    2
      src/libserver/cfg_rcl.c
  2. 1
    1
      src/libutil/util.c
  3. 17
    0
      src/worker.c

+ 21
- 2
src/libserver/cfg_rcl.c 파일 보기

@@ -1793,22 +1793,37 @@ rspamd_rcl_parse_struct_keypair (struct rspamd_config *cfg,
*target = key;
return TRUE;
}

g_set_error (err,
CFG_RCL_ERROR,
EINVAL,
"invalid string with keypair content");
return FALSE;
}
}
else if (obj->type == UCL_OBJECT) {
elt = ucl_object_find_key (obj, "pubkey");
if (elt == NULL || !ucl_object_tostring_safe (elt, &pk)) {
g_set_error (err,
CFG_RCL_ERROR,
EINVAL,
"no sane pubkey found in the keypair");
return FALSE;
}
elt = ucl_object_find_key (obj, "privkey");
if (elt == NULL || !ucl_object_tostring_safe (elt, &sk)) {
g_set_error (err,
CFG_RCL_ERROR,
EINVAL,
"no sane privkey found in the keypair");
return FALSE;
}
}

if (sk == NULL || pk == NULL) {
g_set_error (err,
CFG_RCL_ERROR,
EINVAL,
"no sane pubkey or privkey found in the keypair");
return FALSE;
}

@@ -1819,13 +1834,17 @@ rspamd_rcl_parse_struct_keypair (struct rspamd_config *cfg,
rspamd_snprintf (keybuf, sizeof (keybuf), "%*s%s", sem - sk, sk, pk);
}

key = rspamd_http_connection_make_key (keybuf, strlen (val));
key = rspamd_http_connection_make_key (keybuf, strlen (keybuf));
if (key != NULL) {
/* XXX: clean buffer after usage */
*target = key;
return TRUE;
}

g_set_error (err,
CFG_RCL_ERROR,
EINVAL,
"cannot load the keypair specified");
return FALSE;
}


+ 1
- 1
src/libutil/util.c 파일 보기

@@ -2186,7 +2186,7 @@ rspamd_decode_base32 (gchar *in, gsize inlen, gsize *outlen)
res[olen++] = (acc & 0xFF);
}

*outlen = olen;
*outlen = olen > 0 ? olen - 1 : 0;

return res;
}

+ 17
- 0
src/worker.c 파일 보기

@@ -86,6 +86,8 @@ struct rspamd_worker_ctx {
GThreadPool *classify_pool;
/* Events base */
struct event_base *ev_base;
/* Encryption key */
gpointer key;
};

/*
@@ -243,6 +245,10 @@ accept_socket (gint fd, short what, void *arg)

new_task->classify_pool = ctx->classify_pool;

if (ctx->key) {
rspamd_http_connection_set_key (new_task->http_conn, ctx->key);
}

rspamd_http_connection_read_message (new_task->http_conn,
new_task,
nfd,
@@ -295,6 +301,12 @@ init_worker (struct rspamd_config *cfg)
G_STRUCT_OFFSET (struct rspamd_worker_ctx,
classify_threads), RSPAMD_CL_FLAG_INT_32);


rspamd_rcl_register_worker_option (cfg, type, "keypair",
rspamd_rcl_parse_struct_keypair, ctx,
G_STRUCT_OFFSET (struct rspamd_worker_ctx,
key), 0);

return ctx;
}

@@ -340,6 +352,11 @@ start_worker (struct rspamd_worker *worker)

g_mime_shutdown ();
rspamd_log_close (rspamd_main->logger);

if (ctx->key) {
rspamd_http_connection_key_destroy (ctx->key);
}

exit (EXIT_SUCCESS);
}


Loading…
취소
저장