comparison src/context.h @ 249:15bf4f68a0b2

Add dnswl support
author Carl Byington <carl@five-ten-sg.com>
date Sun, 08 Apr 2012 11:42:59 -0700
parents d8ee4c97b9ab
children d6d5c50b9278
comparison
equal deleted inserted replaced
248:b0738685bf51 249:15bf4f68a0b2
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 DNSBL; 17 class DNSBL;
18 class DNSWL;
18 class CONTEXT; 19 class CONTEXT;
19 class VERIFY; 20 class VERIFY;
20 class SMTP; 21 class SMTP;
21 class WHITELISTER; 22 class WHITELISTER;
22 class DELAYWHITE; 23 class DELAYWHITE;
25 typedef map<const char *, const char *, ltstr> string_map; 26 typedef map<const char *, const char *, ltstr> string_map;
26 typedef set<int> int_set; 27 typedef set<int> int_set;
27 typedef set<int32_t> int32_t_set; 28 typedef set<int32_t> int32_t_set;
28 typedef list<SMTP *> smtp_list; 29 typedef list<SMTP *> smtp_list;
29 typedef DNSBL * DNSBLP; 30 typedef DNSBL * DNSBLP;
31 typedef DNSWL * DNSWLP;
30 typedef VERIFY * VERIFYP; 32 typedef VERIFY * VERIFYP;
31 typedef WHITELISTER * WHITELISTERP; 33 typedef WHITELISTER * WHITELISTERP;
32 typedef DELAYWHITE * DELAYWHITEP; 34 typedef DELAYWHITE * DELAYWHITEP;
33 typedef list<DNSBLP> dnsblp_list; 35 typedef list<DNSBLP> dnsblp_list;
34 typedef map<const char *, DNSBLP, ltstr> dnsblp_map; 36 typedef map<const char *, DNSBLP, ltstr> dnsblp_map;
37 typedef list<DNSWLP> dnswlp_list;
38 typedef map<const char *, DNSWLP, ltstr> dnswlp_map;
35 typedef CONTEXT * CONTEXTP; 39 typedef CONTEXT * CONTEXTP;
36 typedef list<CONTEXTP> context_list; 40 typedef list<CONTEXTP> context_list;
37 typedef map<const char *, CONTEXTP, ltstr> context_map; 41 typedef map<const char *, CONTEXTP, ltstr> context_map;
38 typedef map<const char *, int32_t, ltstr> ns_mapper; // name to ipv4 address 42 typedef map<const char *, int32_t, ltstr> ns_mapper; // name to ipv4 address
39 typedef map<const char *, int, ltstr> rcpt_rates; 43 typedef map<const char *, int, ltstr> rcpt_rates;
122 const char *name; // nickname for this dns based list 126 const char *name; // nickname for this dns based list
123 const char *suffix; // blacklist suffix like blackholes.five-ten-sg.com 127 const char *suffix; // blacklist suffix like blackholes.five-ten-sg.com
124 const char *message; // error message with one or two %s operators for the ip address replacement 128 const char *message; // error message with one or two %s operators for the ip address replacement
125 DNSBL(const char *n, const char *s, const char *m); 129 DNSBL(const char *n, const char *s, const char *m);
126 bool operator==(const DNSBL &rhs); 130 bool operator==(const DNSBL &rhs);
131 };
132
133 struct DNSWL {
134 const char *name; // nickname for this dns based list
135 const char *suffix; // whitelist suffix like list.dnswl.org
136 int level; // matches 127.0.x.y where y >= level
137 DNSWL(const char *n, const char *s, const int l);
138 bool operator==(const DNSWL &rhs);
127 }; 139 };
128 140
129 class CONTEXT { 141 class CONTEXT {
130 CONTEXTP parent; 142 CONTEXTP parent;
131 const char * name; 143 const char * name;
161 bool require_match; // require matching context filtering context 173 bool require_match; // require matching context filtering context
162 bool dcc_greylist; // should we do dcc greylisting? 174 bool dcc_greylist; // should we do dcc greylisting?
163 int dcc_bulk_threshold; // off = 0, many = 1000 175 int dcc_bulk_threshold; // off = 0, many = 1000
164 dnsblp_map dnsbl_names; // name to dnsbl mapping for lists that are available in this context and children 176 dnsblp_map dnsbl_names; // name to dnsbl mapping for lists that are available in this context and children
165 dnsblp_list dnsbl_list; // list of dnsbls to be used in this context 177 dnsblp_list dnsbl_list; // list of dnsbls to be used in this context
178 dnswlp_map dnswl_names; // name to dnswl mapping for lists that are available in this context and children
179 dnswlp_list dnswl_list; // list of dnswls to be used in this context
166 int default_rcpt_rate; // if not specified per user 180 int default_rcpt_rate; // if not specified per user
167 rcpt_rates rcpt_per_hour; // per user limits on number of recipients per hour 181 rcpt_rates rcpt_per_hour; // per user limits on number of recipients per hour
168 182
169 183
170 public: 184 public:
218 void add_tag(const char *tag) {html_tags.insert(tag); }; 232 void add_tag(const char *tag) {html_tags.insert(tag); };
219 233
220 void add_dnsbl(const char *name, DNSBLP dns) {dnsbl_names[name] = dns; }; 234 void add_dnsbl(const char *name, DNSBLP dns) {dnsbl_names[name] = dns; };
221 void add_dnsbl(DNSBLP dns) {dnsbl_list.push_back(dns);}; 235 void add_dnsbl(DNSBLP dns) {dnsbl_list.push_back(dns);};
222 DNSBLP find_dnsbl(const char *name); 236 DNSBLP find_dnsbl(const char *name);
237
238 void add_dnswl(const char *name, DNSWLP dns) {dnswl_names[name] = dns; };
239 void add_dnswl(DNSWLP dns) {dnswl_list.push_back(dns);};
240 DNSWLP find_dnswl(const char *name);
223 241
224 bool set_white(const char *regx); 242 bool set_white(const char *regx);
225 bool white_match(const char *from); 243 bool white_match(const char *from);
226 244
227 bool set_generic(const char *regx, const char *msg); 245 bool set_generic(const char *regx, const char *msg);
245 string_set& get_content_host_ignore(); 263 string_set& get_content_host_ignore();
246 string_set& get_content_tlds(); 264 string_set& get_content_tlds();
247 string_set& get_content_cctlds(); 265 string_set& get_content_cctlds();
248 string_set& get_html_tags(); 266 string_set& get_html_tags();
249 dnsblp_list& get_dnsbl_list(); 267 dnsblp_list& get_dnsbl_list();
268 dnswlp_list& get_dnswl_list();
250 269
251 bool acceptable_content(recorder &memory, int score, int bulk, string& msg); 270 bool acceptable_content(recorder &memory, int score, int bulk, string& msg);
252 bool ignore_host(const char *host); 271 bool ignore_host(const char *host);
253 272
254 void dump(bool isdefault, bool &spamass, int level = 0); 273 void dump(bool isdefault, bool &spamass, int level = 0);
286 extern const char *token_dccgrey; 305 extern const char *token_dccgrey;
287 extern const char *token_dccto; 306 extern const char *token_dccto;
288 extern const char *token_default; 307 extern const char *token_default;
289 extern const char *token_dnsbl; 308 extern const char *token_dnsbl;
290 extern const char *token_dnsbll; 309 extern const char *token_dnsbll;
310 extern const char *token_dnswl;
311 extern const char *token_dnswll;
291 extern const char *token_envfrom; 312 extern const char *token_envfrom;
292 extern const char *token_envto; 313 extern const char *token_envto;
293 extern const char *token_filter; 314 extern const char *token_filter;
294 extern const char *token_generic; 315 extern const char *token_generic;
295 extern const char *token_host_limit; 316 extern const char *token_host_limit;