comparison src/context.h @ 321:e172dc10fe24

add dkim white/black listing
author Carl Byington <carl@five-ten-sg.com>
date Sat, 17 Dec 2016 13:47:28 -0800
parents e27c24c1974a
children 9f8411f3919c
comparison
equal deleted inserted replaced
320:e27c24c1974a 321:e172dc10fe24
12 enum status {oksofar, // not rejected yet 12 enum status {oksofar, // not rejected yet
13 white, // whitelisted 13 white, // whitelisted
14 black, // blacklisted 14 black, // blacklisted
15 reject}; // rejected by a dns list 15 reject}; // rejected by a dns list
16 16
17 class DKIM;
17 class DNSBL; 18 class DNSBL;
18 class DNSWL; 19 class DNSWL;
19 class CONTEXT; 20 class CONTEXT;
20 class VERIFY; 21 class VERIFY;
21 class SMTP; 22 class SMTP;
26 typedef map<const char *, const char *, ltstr> string_map; 27 typedef map<const char *, const char *, ltstr> string_map;
27 typedef set<int> int_set; 28 typedef set<int> int_set;
28 typedef set<int32_t> int32_t_set; 29 typedef set<int32_t> int32_t_set;
29 typedef int32_t_set * int32_t_set_p; 30 typedef int32_t_set * int32_t_set_p;
30 typedef list<SMTP *> smtp_list; 31 typedef list<SMTP *> smtp_list;
32 typedef DKIM * DKIMP;
31 typedef DNSBL * DNSBLP; 33 typedef DNSBL * DNSBLP;
32 typedef DNSWL * DNSWLP; 34 typedef DNSWL * DNSWLP;
33 typedef VERIFY * VERIFYP; 35 typedef VERIFY * VERIFYP;
34 typedef WHITELISTER * WHITELISTERP; 36 typedef WHITELISTER * WHITELISTERP;
35 typedef DELAYWHITE * DELAYWHITEP; 37 typedef DELAYWHITE * DELAYWHITEP;
38 typedef map<const char *, DKIMP, ltstr> dkimp_map;
36 typedef list<DNSBLP> dnsblp_list; 39 typedef list<DNSBLP> dnsblp_list;
37 typedef map<const char *, DNSBLP, ltstr> dnsblp_map; 40 typedef map<const char *, DNSBLP, ltstr> dnsblp_map;
38 typedef list<DNSWLP> dnswlp_list; 41 typedef list<DNSWLP> dnswlp_list;
39 typedef map<const char *, DNSWLP, ltstr> dnswlp_map; 42 typedef map<const char *, DNSWLP, ltstr> dnswlp_map;
40 typedef CONTEXT * CONTEXTP; 43 typedef CONTEXT * CONTEXTP;
122 public: 125 public:
123 DELAYWHITE(const char *loto_, WHITELISTERP w_, CONTEXTP con_); 126 DELAYWHITE(const char *loto_, WHITELISTERP w_, CONTEXTP con_);
124 const char *get_loto() {return loto;}; 127 const char *get_loto() {return loto;};
125 WHITELISTERP get_w() {return w;}; 128 WHITELISTERP get_w() {return w;};
126 CONTEXTP get_con() {return con;}; 129 CONTEXTP get_con() {return con;};
130 };
131
132 struct DKIM {
133 const char *action;
134 const char *signer;
135 public:
136 DKIM(const char *action_, const char *signer_);
127 }; 137 };
128 138
129 struct DNSBL { 139 struct DNSBL {
130 const char *name; // nickname for this dns based list 140 const char *name; // nickname for this dns based list
131 const char *suffix; // blacklist suffix like blackholes.five-ten-sg.com 141 const char *suffix; // blacklist suffix like blackholes.five-ten-sg.com
177 int spamassassin_limit; // max score from spamassassin 187 int spamassassin_limit; // max score from spamassassin
178 bool require_match; // require matching context filtering context 188 bool require_match; // require matching context filtering context
179 bool require_rdns; // require proper rdns on client ip 189 bool require_rdns; // require proper rdns on client ip
180 bool dcc_greylist; // should we do dcc greylisting? 190 bool dcc_greylist; // should we do dcc greylisting?
181 int dcc_bulk_threshold; // off = 0, many = 1000 191 int dcc_bulk_threshold; // off = 0, many = 1000
192 dkimp_map dkim_from_names; // map header from domains to dkim constraints
193 string_map dkim_signer_names; // map dkim signers to actions
182 dnsblp_map dnsbl_names; // name to dnsbl mapping for lists that are available in this context and children 194 dnsblp_map dnsbl_names; // name to dnsbl mapping for lists that are available in this context and children
183 dnsblp_list dnsbl_list; // list of dnsbls to be used in this context 195 dnsblp_list dnsbl_list; // list of dnsbls to be used in this context
184 bool dnsbl_list_parsed; // true iff we have actually parsed a dnsbl_list 196 bool dnsbl_list_parsed; // true iff we have actually parsed a dnsbl_list
185 dnswlp_map dnswl_names; // name to dnswl mapping for lists that are available in this context and children 197 dnswlp_map dnswl_names; // name to dnswl mapping for lists that are available in this context and children
186 dnswlp_list dnswl_list; // list of dnswls to be used in this context 198 dnswlp_list dnswl_list; // list of dnswls to be used in this context
249 void set_host_random(bool random) {host_random = random; }; 261 void set_host_random(bool random) {host_random = random; };
250 void set_spamassassin_limit(int limit) {spamassassin_limit = limit; }; 262 void set_spamassassin_limit(int limit) {spamassassin_limit = limit; };
251 void set_tag_limit(int limit) {tag_limit = limit; }; 263 void set_tag_limit(int limit) {tag_limit = limit; };
252 void set_tag_message(const char *message) {tag_limit_message = message;}; 264 void set_tag_message(const char *message) {tag_limit_message = message;};
253 void add_tag(const char *tag) {html_tags.insert(tag); }; 265 void add_tag(const char *tag) {html_tags.insert(tag); };
266
267 const char *find_dkim_signer(const char *name);
268 void add_dkim_signer(const char *signer, const char *action)
269 {dkim_signer_names[signer] = action;};
270 DKIMP find_dkim_from(const char *name);
271 void add_dkim_from(const char *from, const char *action, const char *signer)
272 {dkim_from_names[from] = new DKIM(action,signer);};
254 273
255 void add_dnsbl(const char *name, DNSBLP dns) {dnsbl_names[name] = dns; }; 274 void add_dnsbl(const char *name, DNSBLP dns) {dnsbl_names[name] = dns; };
256 void add_dnsbl(DNSBLP dns) {dnsbl_list.push_back(dns);}; 275 void add_dnsbl(DNSBLP dns) {dnsbl_list.push_back(dns);};
257 DNSBLP find_dnsbl(const char *name); 276 DNSBLP find_dnsbl(const char *name);
258 void set_dnsbll_parsed() {dnsbl_list_parsed = true;}; 277 void set_dnsbll_parsed() {dnsbl_list_parsed = true;};
368 extern const char *token_uribl; 387 extern const char *token_uribl;
369 extern const char *token_verify; 388 extern const char *token_verify;
370 extern const char *token_white; 389 extern const char *token_white;
371 extern const char *token_white_regex; 390 extern const char *token_white_regex;
372 extern const char *token_yes; 391 extern const char *token_yes;
392 extern const char *token_dkim;
393 extern const char *token_signed_white;
394 extern const char *token_signed_black;
395 extern const char *token_require_signed;
373 396
374 extern pthread_mutex_t verifier_mutex; // protect the verifier map 397 extern pthread_mutex_t verifier_mutex; // protect the verifier map
375 extern pthread_mutex_t whitelister_mutex; // protect the 398 extern pthread_mutex_t whitelister_mutex; // protect the
376 399
377 void discard(string_set &s); 400 void discard(string_set &s);