annotate src/context.h @ 136:f4746d8a12a3

add smtp auth rate limits
author carl
date Tue, 26 Sep 2006 13:59:14 -0700
parents d9d2f8699621
children 4028de9b46dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
1 #ifndef context_include
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
2 #define context_include
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
3
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
4 #include "tokenizer.h"
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
5 #include <map>
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
6
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
7
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
8 enum status {oksofar, // not rejected yet
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
9 white, // whitelisted
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
10 black, // blacklisted
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
11 reject}; // rejected by a dns list
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
12
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
13 class DNSBL;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
14 class CONTEXT;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
15 class VERIFY;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
16 class SMTP;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
17 class recorder;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
18
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
19 typedef map<char *, char *, ltstr> string_map;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
20 typedef set<int> int_set;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
21 typedef list<SMTP *> smtp_list;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
22 typedef list<char *> string_list;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
23 typedef DNSBL * DNSBLP;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
24 typedef VERIFY * VERIFYP;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
25 typedef list<DNSBLP> dnsblp_list;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
26 typedef map<char *, DNSBLP, ltstr> dnsblp_map;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
27 typedef CONTEXT * CONTEXTP;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
28 typedef list<CONTEXTP> context_list;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
29 typedef map<char *, CONTEXTP, ltstr> context_map;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
30 typedef map<char *, int, ltstr> ns_mapper;
136
f4746d8a12a3 add smtp auth rate limits
carl
parents: 119
diff changeset
31 typedef map<char *, int, ltstr> rcpt_rates;
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
32 typedef map<char *, VERIFYP, ltstr> verify_map;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
33
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
34 class SMTP {
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
35 static const int maxlen = 1000;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
36 int fd;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
37 bool error;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
38 time_t stamp;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
39 char efrom[maxlen]; // last envelope from sent on this socket
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
40 int pending; // unread bytes in buffer, not including the null terminator
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
41 char buffer[maxlen];
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
42 public:
99
f8963ddf7143 failed to return a value from parse_verify()
carl
parents: 97
diff changeset
43 SMTP(int f) {fd = f; error = false; now(); efrom[0] = '\0'; init();};
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
44 ~SMTP() {if (!error) quit(); closefd();};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
45 void init() {pending = 0; buffer[0] = '\0';};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
46 void append(char *c) {strncat(buffer, c, max(0, maxlen-1-(int)strlen(c)));};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
47 bool err() {return error;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
48 void now() {stamp = time(NULL);};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
49 time_t get_stamp() {return stamp;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
50 int get_fd() {return fd;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
51 int writer();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
52 int reader();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
53 int read_line();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
54 int read_response();
97
cc3b79349c9c fix int function not returning value
carl
parents: 94
diff changeset
55 void flush_line(int r);
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
56 int cmd(char *c);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
57 int helo();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
58 int rset();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
59 int from(char *f);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
60 int rcpt(char *t);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
61 int quit();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
62 void closefd();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
63 #ifdef VERIFY_DEBUG
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
64 static void log(char *m, int v);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
65 static void log(char *m, char *v);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
66 #endif
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
67 };
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
68
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
69 class VERIFY {
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
70 char *host; // host to be used to verify recipient addresses
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
71 time_t last_err; // time of last socket error
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
72 pthread_mutex_t mutex; // protect the lists of sockets and timestamps
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
73 smtp_list connections;// open sockets, ready to be used
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
74 public:
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
75 VERIFY(char *h);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
76 void closer(); // if the oldest socket is ancient, close it
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
77 SMTP *get_connection();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
78 void put_connection(SMTP *conn);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
79 bool ok(char *from, char *to);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
80 };
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
81
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
82 struct DNSBL {
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
83 char *name; // nickname for this dns based list
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
84 char *suffix; // blacklist suffix like blackholes.five-ten-sg.com
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
85 char *message; // error message with one or two %s operators for the ip address replacement
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
86 DNSBL(char *n, char *s, char *m);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
87 bool operator==(const DNSBL &rhs);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
88 };
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
89
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
90 class CONTEXT {
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
91 CONTEXTP parent;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
92 char * name;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
93 context_map children; // map child context names to their contexts
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
94 string_set env_to; // this context applies to these envelope recipients
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
95 char * verify_host; // use this smtp host to verify email addresses
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
96 string_map env_from; // map senders to white/black/unknown
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
97 context_map env_from_context; // map senders to a child context
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
98 char * env_from_default; // default value for senders that are not found in the map white/black/unknown/inherit
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
99 bool content_filtering; //
119
d9d2f8699621 uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 117
diff changeset
100 char * content_suffix; // for url body filtering based on ip addresses of hostnames in the body
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
101 char * content_message; // ""
119
d9d2f8699621 uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 117
diff changeset
102 char * uribl_suffix; // for uribl body filtering based on hostnames in the body
d9d2f8699621 uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 117
diff changeset
103 char * uribl_message; // ""
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
104 string_set content_host_ignore;// hosts to ignore for content sbl checking
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
105 string_set content_tlds; //
117
aa07452e641b uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 99
diff changeset
106 string_set content_cctlds; //
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
107 string_set html_tags; // set of valid html tags
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
108 int host_limit; // limit on host names
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
109 char * host_limit_message; // error message for excessive host names
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
110 bool host_random; // pick a random selection of host names rather than error for excessive hosts
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
111 int tag_limit; // limit on bad html tags
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
112 char * tag_limit_message; // error message for excessive bad html tags
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
113 dnsblp_map dnsbl_names; // name to dnsbl mapping for lists that are available in this context and children
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
114 dnsblp_list dnsbl_list; // list of dnsbls to be used in this context
136
f4746d8a12a3 add smtp auth rate limits
carl
parents: 119
diff changeset
115 rcpt_rates rcpt_per_hour; // per user limits on number of recipients per hour
f4746d8a12a3 add smtp auth rate limits
carl
parents: 119
diff changeset
116
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
117
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
118 public:
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
119 CONTEXT(CONTEXTP parent_, char *name_);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
120 ~CONTEXT();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
121 CONTEXTP get_parent() {return parent;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
122 bool is_parent(CONTEXTP p); // is p a parent of this?
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
123 char* get_full_name(char *buf, int size);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
124 void add_context(CONTEXTP child) {children[child->name] = child;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
125 bool allow_env_to(char *to) {return (parent) ? parent->cover_env_to(to) : true;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
126 bool cover_env_to(char *to);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
127
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
128 void set_verify(char *host) {verify_host = host;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
129 char* get_verify() {return verify_host;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
130 VERIFYP find_verify(char *to);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
131
136
f4746d8a12a3 add smtp auth rate limits
carl
parents: 119
diff changeset
132 void add_rate(char *user, int limit) {rcpt_per_hour[user] = limit;};
f4746d8a12a3 add smtp auth rate limits
carl
parents: 119
diff changeset
133 int find_rate(char *user);
f4746d8a12a3 add smtp auth rate limits
carl
parents: 119
diff changeset
134
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
135 void add_to(char *to) {env_to.insert(to);};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
136 void add_from(char *from, char *status) {env_from[from] = status;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
137 void add_from_context(char *from, CONTEXTP con) {env_from_context[from] = con;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
138 void set_from_default(char *status) {env_from_default = status;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
139 char* find_from(char *from);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
140 CONTEXTP find_context(char *from);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
141 CONTEXTP find_from_context_name(char *name);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
142
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
143 void set_content_filtering(bool filter) {content_filtering = filter;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
144 void set_content_suffix(char *suffix) {content_suffix = suffix;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
145 void set_content_message(char *message) {content_message = message;};
119
d9d2f8699621 uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 117
diff changeset
146 void set_uribl_suffix(char *suffix) {uribl_suffix = suffix;};
d9d2f8699621 uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 117
diff changeset
147 void set_uribl_message(char *message) {uribl_message = message;};
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
148 void add_ignore(char *host) {content_host_ignore.insert(host);};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
149 void add_tld(char *tld) {content_tlds.insert(tld);};
117
aa07452e641b uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 99
diff changeset
150 void add_cctld(char *cctld) {content_cctlds.insert(cctld);};
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
151
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
152 void set_host_limit(int limit) {host_limit = limit;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
153 void set_host_message(char *message) {host_limit_message = message;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
154 void set_host_random(bool random) {host_random = random;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
155 void set_tag_limit(int limit) {tag_limit = limit;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
156 void set_tag_message(char *message) {tag_limit_message = message;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
157 void add_tag(char *tag) {html_tags.insert(tag);};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
158
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
159 void add_dnsbl(char *name, DNSBLP dns) {dnsbl_names[name] = dns;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
160 void add_dnsbl(DNSBLP dns) {dnsbl_list.push_back(dns);};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
161 DNSBLP find_dnsbl(char *name);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
162
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
163 bool get_content_filtering() {return content_filtering;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
164 int get_host_limit() {return host_limit;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
165 bool get_host_random() {return host_random;};
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
166 char* get_content_suffix();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
167 char* get_content_message();
119
d9d2f8699621 uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 117
diff changeset
168 char* get_uribl_suffix();
d9d2f8699621 uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 117
diff changeset
169 char* get_uribl_message();
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
170 string_set& get_content_host_ignore();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
171 string_set& get_content_tlds();
117
aa07452e641b uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 99
diff changeset
172 string_set& get_content_cctlds();
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
173 string_set& get_html_tags();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
174 dnsblp_list& get_dnsbl_list();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
175
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
176 bool acceptable_content(recorder &memory, char *&msg);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
177 bool ignore_host(char *host);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
178
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
179 void dump(int level = 0);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
180 };
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
181
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
182
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
183 struct CONFIG {
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
184 // the only mutable stuff once it has been loaded from the config file
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
185 int reference_count; // protected by the global config_mutex
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
186 // all the rest is constant after loading from the config file
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
187 int generation;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
188 time_t load_time;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
189 string_set config_files;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
190 context_list contexts; // owns all the contexts, not just top level contexts
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
191 context_map env_to; // map recipient to a filtering context
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
192 CONTEXTP default_context;// for env_to values that don't have their own specific filtering context
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
193 // the default context is also used for some of the content filtering values
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
194
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
195 CONFIG();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
196 ~CONFIG();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
197 void add_context(CONTEXTP con);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
198 void add_to(char *to, CONTEXTP con);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
199 CONTEXTP find_context(char *to);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
200 void dump();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
201 };
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
202
136
f4746d8a12a3 add smtp auth rate limits
carl
parents: 119
diff changeset
203 struct RATELIMIT {
f4746d8a12a3 add smtp auth rate limits
carl
parents: 119
diff changeset
204
f4746d8a12a3 add smtp auth rate limits
carl
parents: 119
diff changeset
205 };
f4746d8a12a3 add smtp auth rate limits
carl
parents: 119
diff changeset
206
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
207 extern char *token_black;
117
aa07452e641b uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 99
diff changeset
208 extern char *token_cctld;
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
209 extern char *token_content;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
210 extern char *token_context;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
211 extern char *token_dccfrom;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
212 extern char *token_dccto;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
213 extern char *token_default;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
214 extern char *token_dnsbl;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
215 extern char *token_dnsbll;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
216 extern char *token_envfrom;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
217 extern char *token_envto;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
218 extern char *token_filter;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
219 extern char *token_host_limit;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
220 extern char *token_html_limit;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
221 extern char *token_html_tags;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
222 extern char *token_ignore;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
223 extern char *token_include;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
224 extern char *token_inherit;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
225 extern char *token_lbrace;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
226 extern char *token_mailhost;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
227 extern char *token_many;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
228 extern char *token_off;
117
aa07452e641b uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 99
diff changeset
229 extern char *token_ok2;
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
230 extern char *token_ok;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
231 extern char *token_on;
136
f4746d8a12a3 add smtp auth rate limits
carl
parents: 119
diff changeset
232 extern char *token_rate;
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
233 extern char *token_rbrace;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
234 extern char *token_semi;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
235 extern char *token_soft;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
236 extern char *token_substitute;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
237 extern char *token_tld;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
238 extern char *token_unknown;
119
d9d2f8699621 uribl patch from Jeff Evans <jeffe@tricab.com>
carl
parents: 117
diff changeset
239 extern char *token_uribl;
94
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
240 extern char *token_white;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
241
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
242 extern char *token_myhostname;
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
243
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
244 extern verify_map verifiers; // map of smtp hosts to verify structures, owns all the verify structures
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
245 extern string_set all_strings; // owns all the strings, only modified by the config loader thread
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
246
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
247 void discard(string_set &s);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
248 char* register_string(string_set &s, char *name);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
249 char* register_string(char *name);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
250 CONFIG *parse_config(char *fn);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
251 bool load_conf(CONFIG &dc, char *fn);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
252 void add_verify_host(char *host);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
253 void* verify_closer(void *arg);
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
254 void token_init();
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
255
e107ade3b1c0 fix dos line terminators
carl
parents: 92
diff changeset
256 #endif