aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/surbl.h
blob: 1df6fae3175735f00324b108e16e837a4e125f15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef RSPAMD_MODULE_SURBL
#define RSPAMD_MODULE_SURBL

#include "../config.h"
#include "../main.h"
#include "../modules.h"
#include "../cfg_file.h"
#include "../memcached.h"
#include "../trie.h"

#define DEFAULT_REDIRECTOR_PORT 8080
#define DEFAULT_SURBL_WEIGHT 10
#define DEFAULT_REDIRECTOR_CONNECT_TIMEOUT 1000
#define DEFAULT_REDIRECTOR_READ_TIMEOUT 5000
#define DEFAULT_SURBL_MAX_URLS 1000
#define DEFAULT_SURBL_URL_EXPIRE 86400
#define DEFAULT_SURBL_SYMBOL "SURBL_DNS"
#define DEFAULT_SURBL_SUFFIX "multi.surbl.org"
#define MAX_LEVELS 10

struct redirector_upstream {
	struct upstream up;
	struct in_addr ina;
	guint16 port;
	gchar *name;
};

struct surbl_ctx {
	int (*filter)(struct worker_task *task);
	uint16_t weight;
	unsigned int connect_timeout;
	unsigned int read_timeout;
	unsigned int max_urls;
	unsigned int url_expire;
	GList *suffixes;
	GList *bits;
	char *metric;
	const char *tld2_file;
	const char *whitelist_file;
	GHashTable **exceptions;
	GHashTable *whitelist;
	GHashTable *redirector_hosts;
	rspamd_trie_t *redirector_trie;
	GPtrArray *redirector_ptrs;
	unsigned use_redirector;
	struct redirector_upstream *redirectors;
	guint32 redirectors_number;
	memory_pool_t *surbl_pool;
};

struct suffix_item {
	const char *suffix;
	const char *symbol;
};

struct dns_param {
	struct uri *url;
	struct worker_task *task;
	char *host_resolve;
	struct suffix_item *suffix;
};

struct redirector_param {
	struct uri *url;
	struct worker_task *task;
	struct redirector_upstream *redirector;
	enum {
		STATE_CONNECT,
		STATE_READ,
	} state;
	struct event ev;
	int sock;
	GTree *tree;
	struct suffix_item *suffix;
};

struct memcached_param {
	struct uri *url;
	struct worker_task *task;
	memcached_ctx_t *ctx;
	GTree *tree;
	struct suffix_item *suffix;
};

struct surbl_bit_item {
	uint32_t bit;
	const char *symbol;
};

#endif