]>
Commit | Line | Data |
---|---|---|
1 | #ifndef __GLINES_H | |
2 | #define __GLINES_H | |
3 | ||
4 | #include "../lib/sstring.h" | |
5 | #include "../nick/nick.h" | |
6 | #include "../channel/channel.h" | |
7 | ||
8 | #define SNIRCD_VERSION 134 | |
9 | ||
10 | #define MAXUSERGLINEUSERHITS 100 | |
11 | #define MAXUSERGLINECHANNELHITS 10 | |
12 | ||
13 | #define MAXGLINEDURATION 90 * 86400 | |
14 | #define MINGLINEREASONLEN 10 | |
15 | ||
16 | #define MAXGLINEUSERHITS 500 | |
17 | #define MAXGLINECHANNELHITS 50 | |
18 | ||
19 | #define MAXGLINELOG 500 | |
20 | ||
21 | #define GLINE_IGNORE_TRUST 1 | |
22 | #define GLINE_ALWAYS_NICK 2 | |
23 | #define GLINE_ALWAYS_USER 4 | |
24 | #define GLINE_SIMULATE 8 | |
25 | ||
26 | #define GLINE_HOSTMASK 1 /* Gline includes a host mask */ | |
27 | #define GLINE_IPMASK 2 /* Gline includes an CIDR mask */ | |
28 | #define GLINE_BADCHAN 4 /* Gline includes a badchan */ | |
29 | #define GLINE_REALNAME 8 /* Gline includes a realname */ | |
30 | #define GLINE_ACTIVATE 16 /* Gline should be activated */ | |
31 | #define GLINE_DEACTIVATE 32 /* Gline should be deactivated */ | |
32 | #define GLINE_DESTROY 64 /* Gline should be destroyed */ | |
33 | #define GLINE_ACTIVE 128 /* Gline is active */ | |
34 | #define GLINE_DESTROYED 256 /* Gline is destroyed */ | |
35 | ||
36 | /** | |
37 | * glist flags | |
38 | */ | |
39 | #define GLIST_COUNT 0x01 /* -c */ | |
40 | #define GLIST_EXACT 0x02 /* -x */ | |
41 | #define GLIST_FIND 0x04 /* -f */ | |
42 | #define GLIST_REASON 0x10 /* -r */ | |
43 | #define GLIST_OWNER 0x20 /* -o */ | |
44 | #define GLIST_REALNAME 0x40 /* -R */ | |
45 | #define GLIST_INACTIVE 0x80 /* -i */ | |
46 | ||
47 | #define GLSTORE_PATH_PREFIX "data/glines" | |
48 | #define GLSTORE_SAVE_FILES 5 | |
49 | #define GLSTORE_SAVE_INTERVAL 3600 | |
50 | ||
51 | /** | |
52 | * Interpret absolute/relative timestamps with same method as snircd | |
53 | * If the expiration value, interpreted as an absolute timestamp, is | |
54 | * more recent than 5 years in the past, we interpret it as an | |
55 | * absolute timestamp; otherwise, we assume it's relative and convert | |
56 | * it to an absolute timestamp. | |
57 | */ | |
58 | #define abs_expire(exp) ((exp) >= getnettime() - 157680000 ? (exp) : (exp) + getnettime()) | |
59 | ||
60 | #define gline_max(a, b) (((a)<(b)) ? (b) : (a)) | |
61 | ||
62 | typedef struct gline { | |
63 | sstring *nick; | |
64 | sstring *user; | |
65 | sstring *host; | |
66 | sstring *reason; | |
67 | sstring *creator; | |
68 | ||
69 | struct irc_in_addr ip; | |
70 | unsigned char bits; | |
71 | ||
72 | time_t expire; | |
73 | time_t lastmod; | |
74 | time_t lifetime; | |
75 | ||
76 | unsigned int flags; | |
77 | int glinebufid; | |
78 | ||
79 | struct gline *next; | |
80 | } gline; | |
81 | ||
82 | typedef struct glinebuf { | |
83 | int id; | |
84 | sstring *comment; | |
85 | time_t commit; | |
86 | time_t amend; | |
87 | ||
88 | gline *glines; | |
89 | ||
90 | int hitsvalid; | |
91 | int userhits; | |
92 | int channelhits; | |
93 | ||
94 | array hits; | |
95 | } glinebuf; | |
96 | ||
97 | extern gline *glinelist; | |
98 | extern glinebuf *glinebuflog[MAXGLINELOG]; | |
99 | extern int glinebuflogoffset; | |
100 | ||
101 | /* glines.c */ | |
102 | gline *findgline(const char *); | |
103 | void gline_propagate(gline *); | |
104 | void gline_deactivate(gline *, time_t, int); | |
105 | void gline_destroy(gline *, time_t, int); | |
106 | void gline_activate(gline *agline, time_t lastmod, int propagate); | |
107 | int glineequal(gline *, gline *); | |
108 | int gline_match_mask(gline *gla, gline *glb); | |
109 | int gline_match_nick(gline *gl, nick *np); | |
110 | int gline_match_channel(gline *gl, channel *cp); | |
111 | int isglinesane(gline *gl, const char **hint); | |
112 | gline *glinedup(gline *gl); | |
113 | ||
114 | /* glines_formats.c */ | |
115 | gline *makegline(const char *); | |
116 | char *glinetostring(gline *g); | |
117 | ||
118 | /* glines_util.c */ | |
119 | int glinebyip(const char *user, struct irc_in_addr *ip, unsigned char bits, int duration, const char *reason, int flags, const char *creator); | |
120 | int glinebynick(nick *np, int duration, const char *reason, int flags, const char *creator); | |
121 | void glineunsetmask(const char *mask); | |
122 | ||
123 | /* glines_buf.c */ | |
124 | void glinebufinit(glinebuf *gbuf, int id); | |
125 | gline *glinebufadd(glinebuf *gbuf, const char *mask, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime); | |
126 | void glinebufaddbyip(glinebuf *gbuf, const char *user, struct irc_in_addr *ip, unsigned char bits, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime); | |
127 | void glinebufaddbynick(glinebuf *gbuf, nick *, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime); | |
128 | void glinebufcounthits(glinebuf *gbuf, int *users, int *channels); | |
129 | int glinebufchecksane(glinebuf *gbuf, nick *spewto, int overridesanity, int overridelimit); | |
130 | void glinebufspew(glinebuf *gbuf, nick *spewto); | |
131 | void glinebufmerge(glinebuf *gbuf); | |
132 | int glinebufcommit(glinebuf *gbuf, int propagate); | |
133 | void glinebufabort(glinebuf *gbuf); | |
134 | int glinebufundo(int id); | |
135 | void glinebufcommentf(glinebuf *gbuf, const char *format, ...); | |
136 | void glinebufcommentv(glinebuf *gbuf, const char *prefix, int cargc, char **cargv); | |
137 | ||
138 | /* glines_alloc.c */ | |
139 | void freegline(gline *); | |
140 | gline *newgline(); | |
141 | void removegline(gline *); | |
142 | ||
143 | /* glines_handler.c */ | |
144 | int handleglinemsg(void *, int, char **); | |
145 | void handleglinestats(int hooknum, void *arg); | |
146 | ||
147 | /* glines_store.c */ | |
148 | int glstore_save(void); | |
149 | int glstore_load(void); | |
150 | ||
151 | #endif |