summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-12 16:57:55 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-12 16:57:55 +0100
commita08844879949bcc30cba8e84102f1a6674b38a43 (patch)
tree304846f0c5ed5256f564391ae478ecd738254df0
parent8a1eb9cf212ca97822c86d48bc3f9735815dd320 (diff)
downloadrspamd-a08844879949bcc30cba8e84102f1a6674b38a43.tar.gz
rspamd-a08844879949bcc30cba8e84102f1a6674b38a43.zip
[Minor] Move more magic constants to defines
-rw-r--r--src/libserver/mempool_vars_internal.h7
-rw-r--r--src/libserver/protocol.c5
-rw-r--r--src/libserver/spf.c10
-rw-r--r--src/libserver/task.c15
-rw-r--r--src/lua/lua_task.c4
-rw-r--r--src/plugins/dkim_check.c8
-rw-r--r--src/plugins/spf.c8
7 files changed, 40 insertions, 17 deletions
diff --git a/src/libserver/mempool_vars_internal.h b/src/libserver/mempool_vars_internal.h
index d73d530e3..23011770e 100644
--- a/src/libserver/mempool_vars_internal.h
+++ b/src/libserver/mempool_vars_internal.h
@@ -24,6 +24,11 @@
#define RSPAMD_MEMPOOL_SETTINGS_HASH "settings_hash"
#define RSPAMD_MEMPOOL_MTA_TAG "MTA-Tag"
#define RSPAMD_MEMPOOL_CACHED_REPLY "cached_reply"
-
+#define RSPAMD_MEMPOOL_SPF_DOMAIN "spf_domain"
+#define RSPAMD_MEMPOOL_PRINCIPAL_RECIPIENT "principal_recipient"
+#define RSPAMD_MEMPOOL_PROFILE "profile"
+#define RSPAMD_MEMPOOL_RMILTER_REPLY "rmilter_reply"
+#define RSPAMD_MEMPOOL_DKIM_SIGNATURE "dkim-signature"
+#define RSPAMD_MEMPOOL_DMARC_CHECKS "dmarc_checks"
#endif
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 404e75ce4..7a9a74afa 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -1157,7 +1157,8 @@ rspamd_protocol_write_ucl (struct rspamd_task *task,
}
if (flags & RSPAMD_PROTOCOL_DKIM) {
- dkim_sig = rspamd_mempool_get_variable (task->task_pool, "dkim-signature");
+ dkim_sig = rspamd_mempool_get_variable (task->task_pool,
+ RSPAMD_MEMPOOL_DKIM_SIGNATURE);
if (dkim_sig) {
GString *folded_header = rspamd_header_value_fold ("DKIM-Signature",
@@ -1172,7 +1173,7 @@ rspamd_protocol_write_ucl (struct rspamd_task *task,
if (flags & RSPAMD_PROTOCOL_RMILTER) {
rmilter_reply = rspamd_mempool_get_variable (task->task_pool,
- "rmilter-reply");
+ RSPAMD_MEMPOOL_RMILTER_REPLY);
if (rmilter_reply) {
ucl_object_insert_key (top, ucl_object_ref (rmilter_reply),
diff --git a/src/libserver/spf.c b/src/libserver/spf.c
index fdd4a5136..2bbb737eb 100644
--- a/src/libserver/spf.c
+++ b/src/libserver/spf.c
@@ -19,6 +19,7 @@
#include "rspamd.h"
#include "message.h"
#include "utlist.h"
+#include "libserver/mempool_vars_internal.h"
#define SPF_VER1_STR "v=spf1"
#define SPF_VER2_STR "spf2."
@@ -1984,7 +1985,8 @@ rspamd_spf_cache_domain (struct rspamd_task *task)
}
if (cred) {
- rspamd_mempool_set_variable (task->task_pool, "spf_domain", cred, NULL);
+ rspamd_mempool_set_variable (task->task_pool, RSPAMD_MEMPOOL_SPF_DOMAIN,
+ cred, NULL);
}
return cred;
@@ -1996,7 +1998,8 @@ rspamd_spf_get_domain (struct rspamd_task *task)
gchar *domain = NULL;
struct rspamd_spf_cred *cred;
- cred = rspamd_mempool_get_variable (task->task_pool, "spf_domain");
+ cred = rspamd_mempool_get_variable (task->task_pool,
+ RSPAMD_MEMPOOL_SPF_DOMAIN);
if (!cred) {
cred = rspamd_spf_cache_domain (task);
@@ -2016,7 +2019,8 @@ rspamd_spf_resolve (struct rspamd_task *task, spf_cb_t callback,
struct spf_record *rec;
struct rspamd_spf_cred *cred;
- cred = rspamd_mempool_get_variable (task->task_pool, "spf_domain");
+ cred = rspamd_mempool_get_variable (task->task_pool,
+ RSPAMD_MEMPOOL_SPF_DOMAIN);
if (!cred) {
cred = rspamd_spf_cache_domain (task);
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 032e6caba..2c9f134bc 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -25,6 +25,7 @@
#include "unix-std.h"
#include "utlist.h"
#include "contrib/zstd/zstd.h"
+#include "libserver/mempool_vars_internal.h"
#include <math.h>
/*
@@ -829,7 +830,8 @@ rspamd_task_cache_principal_recipient (struct rspamd_task *task,
rspamd_strlcpy (rcpt_lc, rcpt, len + 1);
rspamd_str_lc (rcpt_lc, len);
- rspamd_mempool_set_variable (task->task_pool, "recipient", rcpt_lc, NULL);
+ rspamd_mempool_set_variable (task->task_pool,
+ RSPAMD_MEMPOOL_PRINCIPAL_RECIPIENT, rcpt_lc, NULL);
return rcpt_lc;
}
@@ -840,7 +842,8 @@ rspamd_task_get_principal_recipient (struct rspamd_task *task)
const gchar *val;
struct rspamd_email_address *addr;
- val = rspamd_mempool_get_variable (task->task_pool, "recipient");
+ val = rspamd_mempool_get_variable (task->task_pool,
+ RSPAMD_MEMPOOL_PRINCIPAL_RECIPIENT);
if (val) {
return val;
@@ -1494,12 +1497,12 @@ rspamd_task_profile_set (struct rspamd_task *task, const gchar *key,
return;
}
- tbl = rspamd_mempool_get_variable (task->task_pool, "profile");
+ tbl = rspamd_mempool_get_variable (task->task_pool, RSPAMD_MEMPOOL_PROFILE);
if (tbl == NULL) {
tbl = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
- rspamd_mempool_set_variable (task->task_pool, "profile", tbl,
- (rspamd_mempool_destruct_t)g_hash_table_unref);
+ rspamd_mempool_set_variable (task->task_pool, RSPAMD_MEMPOOL_PROFILE,
+ tbl, (rspamd_mempool_destruct_t)g_hash_table_unref);
}
pval = g_hash_table_lookup (tbl, key);
@@ -1520,7 +1523,7 @@ rspamd_task_profile_get (struct rspamd_task *task, const gchar *key)
GHashTable *tbl;
gdouble *pval = NULL;
- tbl = rspamd_mempool_get_variable (task->task_pool, "profile");
+ tbl = rspamd_mempool_get_variable (task->task_pool, RSPAMD_MEMPOOL_PROFILE);
if (tbl != NULL) {
pval = g_hash_table_lookup (tbl, key);
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index f58a6068e..0cb531c09 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -20,6 +20,7 @@
#include "utlist.h"
#include "unix-std.h"
#include "libmime/smtp_parsers.h"
+#include "libserver/mempool_vars_internal.h"
#include <math.h>
/***
@@ -3517,7 +3518,8 @@ lua_task_set_rmilter_reply (lua_State *L)
reply = ucl_object_lua_import (L, 2);
if (reply != NULL && task != NULL) {
- rspamd_mempool_set_variable (task->task_pool, "rmilter-reply",
+ rspamd_mempool_set_variable (task->task_pool,
+ RSPAMD_MEMPOOL_RMILTER_REPLY,
reply, (rspamd_mempool_destruct_t)ucl_object_unref);
}
else {
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index 8dc8ee1ec..e83137339 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -30,6 +30,7 @@
* - skip_mutli (flag): skip messages with multiply dkim signatures
*/
+
#include "config.h"
#include "libmime/message.h"
#include "libserver/dkim.h"
@@ -38,6 +39,7 @@
#include "rspamd.h"
#include "utlist.h"
#include "lua/lua_common.h"
+#include "libserver/mempool_vars_internal.h"
#define DEFAULT_SYMBOL_REJECT "R_DKIM_REJECT"
#define DEFAULT_SYMBOL_TEMPFAIL "R_DKIM_TEMPFAIL"
@@ -873,7 +875,8 @@ dkim_symbol_callback (struct rspamd_task *task, void *unused)
guint checked = 0, i, *dmarc_checks;
/* Allow dmarc */
- dmarc_checks = rspamd_mempool_get_variable (task->task_pool, "dmarc_checks");
+ dmarc_checks = rspamd_mempool_get_variable (task->task_pool,
+ RSPAMD_MEMPOOL_DMARC_CHECKS);
if (dmarc_checks) {
(*dmarc_checks) ++;
@@ -882,7 +885,8 @@ dkim_symbol_callback (struct rspamd_task *task, void *unused)
dmarc_checks = rspamd_mempool_alloc (task->task_pool,
sizeof (*dmarc_checks));
*dmarc_checks = 1;
- rspamd_mempool_set_variable (task->task_pool, "dmarc_checks",
+ rspamd_mempool_set_variable (task->task_pool,
+ RSPAMD_MEMPOOL_DMARC_CHECKS,
dmarc_checks, NULL);
}
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index c9bc5d67d..275f937ce 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -26,12 +26,14 @@
* - whitelist (map): map of whitelisted networks
*/
+
#include "config.h"
#include "libmime/message.h"
#include "libserver/spf.h"
#include "libutil/hash.h"
#include "libutil/map.h"
#include "rspamd.h"
+#include "libserver/mempool_vars_internal.h"
#define DEFAULT_SYMBOL_FAIL "R_SPF_FAIL"
#define DEFAULT_SYMBOL_SOFTFAIL "R_SPF_SOFTFAIL"
@@ -552,7 +554,8 @@ spf_symbol_callback (struct rspamd_task *task, void *unused)
gint *dmarc_checks;
/* Allow dmarc */
- dmarc_checks = rspamd_mempool_get_variable (task->task_pool, "dmarc_checks");
+ dmarc_checks = rspamd_mempool_get_variable (task->task_pool,
+ RSPAMD_MEMPOOL_DMARC_CHECKS);
if (dmarc_checks) {
(*dmarc_checks) ++;
@@ -561,7 +564,8 @@ spf_symbol_callback (struct rspamd_task *task, void *unused)
dmarc_checks = rspamd_mempool_alloc (task->task_pool,
sizeof (*dmarc_checks));
*dmarc_checks = 1;
- rspamd_mempool_set_variable (task->task_pool, "dmarc_checks",
+ rspamd_mempool_set_variable (task->task_pool,
+ RSPAMD_MEMPOOL_DMARC_CHECKS,
dmarc_checks, NULL);
}