]>
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 | |
12 | #define MAXUSERGLINEDURATION 90 * 86400 | |
13 | #define MINUSERGLINEREASON 10 | |
a473a1be | 14 | |
cb581522 GB |
15 | #define MAXGLINEUSERHITS 500 |
16 | #define MAXGLINECHANNELHITS 50 | |
a44fc5f7 | 17 | |
a473a1be | 18 | #define GLINE_IGNORE_TRUST 1 |
8f128e0d GB |
19 | #define GLINE_ALWAYS_NICK 2 |
20 | #define GLINE_ALWAYS_USER 4 | |
21 | #define GLINE_NO_LIMIT 8 | |
22 | #define GLINE_SIMULATE 16 | |
a473a1be | 23 | |
96662a86 GB |
24 | #define GLINE_HOSTMASK 1 /* Gline includes a host mask */ |
25 | #define GLINE_IPMASK 2 /* Gline includes an CIDR mask */ | |
26 | #define GLINE_BADCHAN 4 /* Gline includes a badchan */ | |
27 | #define GLINE_REALNAME 8 /* Gline includes a realname */ | |
28 | #define GLINE_ACTIVATE 16 /* Gline should be activated */ | |
29 | #define GLINE_DEACTIVATE 32 /* Gline should be deactivated */ | |
20447d72 GB |
30 | #define GLINE_DESTROY 64 /* Gline should be destroyed */ |
31 | #define GLINE_ACTIVE 128 /* Gline is active */ | |
32 | #define GLINE_DESTROYED 256 /* Gline is destroyed */ | |
a44fc5f7 GB |
33 | |
34 | /** | |
35 | * glist flags | |
36 | */ | |
37 | #define GLIST_COUNT 0x01 /* -c */ | |
38 | #define GLIST_EXACT 0x02 /* -x */ | |
39 | #define GLIST_FIND 0x04 /* -f */ | |
40 | #define GLIST_REASON 0x10 /* -r */ | |
41 | #define GLIST_OWNER 0x20 /* -o */ | |
42 | #define GLIST_REALNAME 0x40 /* -R */ | |
43 | #define GLIST_INACTIVE 0x80 /* -i */ | |
44 | ||
580103bc GB |
45 | #define GLSTORE_PATH_PREFIX "data/glines" |
46 | #define GLSTORE_SAVE_FILES 5 | |
47 | #define GLSTORE_SAVE_INTERVAL 3600 | |
48 | ||
a44fc5f7 GB |
49 | /** |
50 | * Interpret absolute/relative timestamps with same method as snircd | |
51 | * If the expiration value, interpreted as an absolute timestamp, is | |
52 | * more recent than 5 years in the past, we interpret it as an | |
53 | * absolute timestamp; otherwise, we assume it's relative and convert | |
54 | * it to an absolute timestamp. | |
55 | */ | |
56 | #define abs_expire(exp) ((exp) >= getnettime() - 157680000 ? (exp) : (exp) + getnettime()) | |
57 | ||
c684f472 | 58 | #define gline_max(a, b) (((a)<(b)) ? (b) : (a)) |
a44fc5f7 GB |
59 | |
60 | typedef struct gline { | |
61 | sstring *nick; | |
62 | sstring *user; | |
63 | sstring *host; | |
64 | sstring *reason; | |
65 | sstring *creator; | |
66 | ||
67 | struct irc_in_addr ip; | |
68 | unsigned char bits; | |
69 | ||
70 | time_t expire; | |
71 | time_t lastmod; | |
72 | time_t lifetime; | |
73 | ||
74 | unsigned int flags; | |
75 | ||
76 | struct gline *next; | |
77 | } gline; | |
78 | ||
cb581522 GB |
79 | typedef struct glinebuf { |
80 | gline *head; | |
81 | int merge; | |
82 | } glinebuf; | |
8f128e0d | 83 | |
cb581522 | 84 | extern gline *glinelist; |
8f128e0d | 85 | |
a44fc5f7 | 86 | /* glines.c */ |
96662a86 | 87 | gline *findgline(const char *); |
a44fc5f7 | 88 | void gline_propagate(gline *); |
331ecd41 | 89 | void gline_deactivate(gline *, time_t, int); |
20447d72 | 90 | void gline_destroy(gline *, time_t, int); |
331ecd41 | 91 | void gline_activate(gline *agline, time_t lastmod, int propagate); |
a44fc5f7 GB |
92 | int glineequal(gline *, gline *); |
93 | int gline_match_mask(gline *gla, gline *glb); | |
94 | int gline_match_nick(gline *gl, nick *np); | |
95 | int gline_match_channel(gline *gl, channel *cp); | |
a86fc0c4 GB |
96 | int isglinesane(gline *gl, const char **hint); |
97 | ||
98 | /* glines_formats.c */ | |
99 | gline *makegline(const char *); | |
100 | char *glinetostring(gline *g); | |
a44fc5f7 | 101 | |
a86fc0c4 | 102 | /* glines_util.c */ |
dd1aa3fb GB |
103 | int glinebyip(const char *user, struct irc_in_addr *ip, unsigned char bits, int duration, const char *reason, int flags, const char *creator); |
104 | int glinebynick(nick *np, int duration, const char *reason, int flags, const char *creator); | |
cb581522 GB |
105 | |
106 | /* glines_buf.c */ | |
107 | void glinebufinit(glinebuf *gbuf, int merge); | |
108 | gline *glinebufadd(glinebuf *gbuf, const char *mask, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime); | |
109 | 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); | |
110 | void glinebufaddbynick(glinebuf *gbuf, nick *, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime); | |
111 | void glinebufcounthits(glinebuf *gbuf, int *users, int *channels); | |
a86fc0c4 GB |
112 | int glinebufsanitize(glinebuf *gbuf); |
113 | void glinebufspew(glinebuf *gbuf, nick *np); | |
cb581522 GB |
114 | void glinebufflush(glinebuf *gbuf, int propagate); |
115 | void glinebufabandon(glinebuf *gbuf); | |
116 | ||
a44fc5f7 GB |
117 | /* glines_alloc.c */ |
118 | void freegline(gline *); | |
119 | gline *newgline(); | |
120 | void removegline(gline *); | |
121 | ||
122 | /* glines_handler.c */ | |
123 | int handleglinemsg(void *, int, char **); | |
124 | void handleglinestats(int hooknum, void *arg); | |
125 | ||
580103bc GB |
126 | /* glines_store.c */ |
127 | int glstore_save(void); | |
128 | int glstore_load(void); | |
129 | ||
813c5b73 | 130 | #endif |