]>
Commit | Line | Data |
---|---|---|
539a2cbc GB |
1 | #ifndef __regexgline_H |
2 | #define __regexgline_H | |
3 | ||
4 | #include <stdio.h> | |
5 | #include <stdlib.h> | |
6 | #include <stdarg.h> | |
7 | #include <errno.h> | |
8 | #include <pcre.h> | |
9 | #include <string.h> | |
10 | #include <strings.h> | |
11 | ||
12 | #include "../core/config.h" | |
13 | #include "../control/control.h" | |
14 | #include "../lib/irc_string.h" | |
15 | #include "../localuser/localuserchannel.h" | |
16 | #include "../lib/sstring.h" | |
17 | #include "../core/schedule.h" | |
18 | ||
19 | #define RG_QUERY_BUF_SIZE 5120 | |
20 | #define RG_MAX_CASUALTIES_DEFAULT 5000 | |
21 | #define RG_MAX_SPEW_DEFAULT 300 | |
22 | #define RG_REGEXGLINE_MAX 512 | |
23 | #define RG_REASON_MAX 255 | |
24 | #define RG_EXPIRY_BUFFER 200 | |
25 | #define RG_MASKLEN HOSTLEN + USERLEN + NICKLEN + REALLEN + 5 /* includes NULL terminator */ | |
26 | #define RG_PCREFLAGS PCRE_CASELESS | |
27 | #define RG_MIN_MASK_LEN 5 | |
28 | #define RG_MAX_PER_GLINE_DEFAULT 5 | |
29 | #define RG_MINIMUM_DELAY_TIME 5 | |
30 | #define RG_MAXIMUM_RAND_TIME 15 | |
31 | #define RG_EXPIRY_TIME_DEFAULT 1800 | |
32 | #define RG_NETWORK_WIDE_MAX_GLINES_PER_8_SEC 625*8 /* 5000 / 8 */ | |
33 | ||
34 | #define RGStringise(x) #x | |
35 | #define RGBuildHostname(buf, np) snprintf(buf, sizeof(buf), "%s!%s@%s\r%s", np->nick, np->ident, np->host->name->content, np->realname->name->content); | |
36 | #define RGMasksEqual(a, b) !strcasecmp(a, b) | |
37 | ||
38 | typedef struct rg_struct { | |
39 | int id; /* database id */ | |
40 | sstring *mask; /* gline mask */ | |
41 | sstring *setby; /* who it's set by */ | |
42 | sstring *reason; /* reason for gline */ | |
43 | time_t expires; /* when it expires */ | |
44 | int type; /* gline type (user@ip or *@ip) */ | |
45 | pcre *regex; /* pcre expression */ | |
46 | pcre_extra *hint; /* pcre hint */ | |
47 | long glineid; /* gline ID */ | |
48 | const char *class; /* class of gline */ | |
49 | unsigned long hits; /* hits since we were loaded */ | |
50 | unsigned long hitssaved; /* hits (persistent) */ | |
51 | unsigned int marker; /* newserv style marker */ | |
52 | time_t lastseen; /* ... */ | |
53 | short dirty; /* whether or not we need to flush to the db */ | |
54 | struct rg_struct *next; /* ... pointer to next item */ | |
55 | } rg_struct; | |
56 | ||
57 | struct rg_struct *rg_list = NULL; | |
58 | ||
59 | int rg_max_casualties, rg_max_spew, rg_expiry_time, rg_max_per_gline; | |
60 | void *rg_schedule = NULL; | |
61 | ||
62 | void rg_nick(int hooknum, void *arg); | |
63 | void rg_lostnick(int hooknum, void *arg); | |
64 | void rg_rename(int hooknum, void *arg); | |
65 | void rg_startup(void); | |
66 | ||
67 | int rg_gline(void *source, int cargc, char **cargv); | |
68 | int rg_delgline(void *source, int cargc, char **cargv); | |
69 | int rg_glist(void *source, int cargc, char **cargv); | |
70 | int rg_idlist(void *source, int cargc, char **cargv); | |
71 | int rg_spew(void *source, int cargc, char **cargv); | |
72 | int rg_sanitycheck(char *mask, int *count); | |
73 | ||
74 | ||
75 | int rg_dbconnect(void); | |
76 | void rg_dbload(void); | |
77 | ||
78 | void rg_freestruct(struct rg_struct *rp); | |
79 | struct rg_struct *rg_newstruct(time_t expires); | |
80 | struct rg_struct *rg_newsstruct(unsigned long id, char *mask, char *setby, char *reason, char *expires, char *type, time_t iexpires, char *class, time_t lastseen, unsigned int hitssaved); | |
81 | ||
82 | void rg_displaygline(nick *np, struct rg_struct *rp, int longest); | |
83 | ||
84 | void rg_checkexpiry(void *arg); | |
85 | ||
86 | void rg_logevent(nick *np, char *event, char *details, ...) __attribute__ ((format (printf, 3, 4))); | |
87 | void rg_loggline(struct rg_struct *rg, nick *np); | |
88 | ||
89 | unsigned char rc_hexlookup[256] = { | |
90 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
91 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
92 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
93 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
94 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, | |
95 | 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xff, 0xff, | |
96 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | |
97 | 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
98 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
99 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0a, 0x0b, 0x0c, | |
100 | 0x0d, 0x0e, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
101 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
102 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
103 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
104 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
105 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
106 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
107 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
108 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
109 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
110 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
111 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
112 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
113 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
114 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
115 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff | |
116 | }; | |
117 | ||
118 | #endif |