]>
Commit | Line | Data |
---|---|---|
813c5b73 CP |
1 | #ifndef __GLINES_H |
2 | #define __GLINES_H | |
3 | ||
a44fc5f7 GB |
4 | #include "../lib/sstring.h" |
5 | #include "../nick/nick.h" | |
6 | #include "../channel/channel.h" | |
7 | ||
22833ec3 | 8 | #define SNIRCD_VERSION 134 |
c684f472 | 9 | |
cb581522 GB |
10 | #define MAXUSERGLINEUSERHITS 100 |
11 | #define MAXUSERGLINECHANNELHITS 10 | |
18845894 GB |
12 | |
13 | #define MAXGLINEDURATION 90 * 86400 | |
14 | #define MINGLINEREASONLEN 10 | |
a473a1be | 15 | |
cb581522 GB |
16 | #define MAXGLINEUSERHITS 500 |
17 | #define MAXGLINECHANNELHITS 50 | |
a44fc5f7 | 18 | |
ce11a200 GB |
19 | #define MAXGLINELOG 500 |
20 | ||
a473a1be | 21 | #define GLINE_IGNORE_TRUST 1 |
8f128e0d GB |
22 | #define GLINE_ALWAYS_NICK 2 |
23 | #define GLINE_ALWAYS_USER 4 | |
18845894 | 24 | #define GLINE_SIMULATE 8 |
a473a1be | 25 | |
96662a86 GB |
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 */ | |
20447d72 GB |
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 */ | |
a44fc5f7 GB |
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 | ||
580103bc GB |
47 | #define GLSTORE_PATH_PREFIX "data/glines" |
48 | #define GLSTORE_SAVE_FILES 5 | |
49 | #define GLSTORE_SAVE_INTERVAL 3600 | |
50 | ||
a44fc5f7 GB |
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 | ||
c684f472 | 60 | #define gline_max(a, b) (((a)<(b)) ? (b) : (a)) |
a44fc5f7 GB |
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 | ||
78 | struct gline *next; | |
79 | } gline; | |
80 | ||
cb581522 | 81 | typedef struct glinebuf { |
ce11a200 GB |
82 | int id; |
83 | sstring *comment; | |
324b4e11 | 84 | time_t commit; |
9f47116c | 85 | time_t amend; |
ce11a200 | 86 | |
bbb80250 GB |
87 | gline *glines; |
88 | ||
33e09c2c | 89 | int hitsvalid; |
bbb80250 GB |
90 | int userhits; |
91 | int channelhits; | |
a887af59 GB |
92 | |
93 | array hits; | |
cb581522 | 94 | } glinebuf; |
8f128e0d | 95 | |
cb581522 | 96 | extern gline *glinelist; |
ce11a200 GB |
97 | extern glinebuf *glinebuflog[MAXGLINELOG]; |
98 | extern int glinebuflogoffset; | |
8f128e0d | 99 | |
a44fc5f7 | 100 | /* glines.c */ |
96662a86 | 101 | gline *findgline(const char *); |
a44fc5f7 | 102 | void gline_propagate(gline *); |
331ecd41 | 103 | void gline_deactivate(gline *, time_t, int); |
20447d72 | 104 | void gline_destroy(gline *, time_t, int); |
331ecd41 | 105 | void gline_activate(gline *agline, time_t lastmod, int propagate); |
a44fc5f7 GB |
106 | int glineequal(gline *, gline *); |
107 | int gline_match_mask(gline *gla, gline *glb); | |
108 | int gline_match_nick(gline *gl, nick *np); | |
109 | int gline_match_channel(gline *gl, channel *cp); | |
a86fc0c4 | 110 | int isglinesane(gline *gl, const char **hint); |
ce11a200 | 111 | gline *glinedup(gline *gl); |
a86fc0c4 GB |
112 | |
113 | /* glines_formats.c */ | |
114 | gline *makegline(const char *); | |
115 | char *glinetostring(gline *g); | |
a44fc5f7 | 116 | |
a86fc0c4 | 117 | /* glines_util.c */ |
dd1aa3fb GB |
118 | int glinebyip(const char *user, struct irc_in_addr *ip, unsigned char bits, int duration, const char *reason, int flags, const char *creator); |
119 | int glinebynick(nick *np, int duration, const char *reason, int flags, const char *creator); | |
18845894 | 120 | void glineunsetmask(const char *mask); |
cb581522 GB |
121 | |
122 | /* glines_buf.c */ | |
324b4e11 | 123 | void glinebufinit(glinebuf *gbuf, int id); |
cb581522 GB |
124 | gline *glinebufadd(glinebuf *gbuf, const char *mask, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime); |
125 | 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); | |
126 | void glinebufaddbynick(glinebuf *gbuf, nick *, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime); | |
33e09c2c GB |
127 | void glinebufcounthits(glinebuf *gbuf, int *users, int *channels); |
128 | int glinebufchecksane(glinebuf *gbuf, nick *spewto, int overridesanity, int overridelimit); | |
56af56be | 129 | void glinebufspew(glinebuf *gbuf, nick *spewto); |
324b4e11 | 130 | void glinebufmerge(glinebuf *gbuf); |
0c925dc0 | 131 | int glinebufcommit(glinebuf *gbuf, int propagate); |
0b2e8a55 GB |
132 | void glinebufabort(glinebuf *gbuf); |
133 | int glinebufundo(int id); | |
ce11a200 GB |
134 | void glinebufcommentf(glinebuf *gbuf, const char *format, ...); |
135 | void glinebufcommentv(glinebuf *gbuf, const char *prefix, int cargc, char **cargv); | |
cb581522 | 136 | |
a44fc5f7 GB |
137 | /* glines_alloc.c */ |
138 | void freegline(gline *); | |
139 | gline *newgline(); | |
140 | void removegline(gline *); | |
141 | ||
142 | /* glines_handler.c */ | |
143 | int handleglinemsg(void *, int, char **); | |
144 | void handleglinestats(int hooknum, void *arg); | |
145 | ||
580103bc GB |
146 | /* glines_store.c */ |
147 | int glstore_save(void); | |
148 | int glstore_load(void); | |
149 | ||
813c5b73 | 150 | #endif |