xref: /openbsd/libexec/spamd/grey.h (revision 5af055cd)
1 /*	$OpenBSD: grey.h,v 1.10 2013/08/21 16:13:29 millert Exp $	*/
2 
3 /*
4  * Copyright (c) 2004 Bob Beck.  All rights reserved.
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #define MAX_MAIL 1024 /* how big an email address will we consider */
20 #define PASSTIME (60 * 25) /* pass after first retry seen after 25 mins */
21 #define GREYEXP (60 * 60 * 4) /* remove grey entries after 4 hours */
22 #define WHITEEXP (60 * 60 * 24 * 36) /* remove white entries after 36 days */
23 #define TRAPEXP (60 * 60 * 24) /* hitting a spamtrap blacklists for a day */
24 #define PATH_PFCTL "/sbin/pfctl"
25 #define PATH_SPAMD_ALLOWEDDOMAINS "/etc/mail/spamd.alloweddomains"
26 #define DB_SCAN_INTERVAL 60
27 #define DB_TRAP_INTERVAL 60 * 10
28 #define PATH_SPAMD_DB "/var/db/spamd"
29 
30 /* Obsolete grey data format. */
31 struct ogdata {
32 	int32_t first;  /* when did we see it first */
33 	int32_t pass;   /* when was it whitelisted */
34 	int32_t expire; /* when will we get rid of this entry */
35 	int bcount;     /* how many times have we blocked it */
36 	int pcount;     /* how many times passed, or -1 for spamtrap */
37 };
38 
39 struct gdata {
40 	int64_t first;  /* when did we see it first */
41 	int64_t pass;   /* when was it whitelisted */
42 	int64_t expire; /* when will we get rid of this entry */
43 	int bcount;     /* how many times have we blocked it */
44 	int pcount;     /* how many times passed, or -1 for spamtrap */
45 };
46 
47 extern int greywatcher(void);
48 extern int greyupdate(char *, char *, char *, char *, char *, int, char *);
49 extern int gdcopyin(const void *, struct gdata *);
50