]>
jfr.im git - irc/quakenet/newserv.git/blob - glines/glines.h
4 #include "../lib/sstring.h"
5 #include "../nick/nick.h"
6 #include "../channel/channel.h"
7 #include "../whowas/whowas.h"
9 #define SNIRCD_VERSION 134
11 #define MAXUSERGLINEUSERHITS 100
12 #define MAXUSERGLINECHANNELHITS 10
14 #define MAXGLINEDURATION 90 * 86400
15 #define MINGLINEREASONLEN 10
17 #define MAXGLINEUSERHITS 500
18 #define MAXGLINECHANNELHITS 50
20 #define MAXGLINELOG 500
22 #define GLINE_IGNORE_TRUST 1
23 #define GLINE_ALWAYS_NICK 2
24 #define GLINE_ALWAYS_USER 4
25 #define GLINE_SIMULATE 8
27 #define GLINE_HOSTMASK 1 /* Gline includes a host mask */
28 #define GLINE_IPMASK 2 /* Gline includes an CIDR mask */
29 #define GLINE_BADCHAN 4 /* Gline includes a badchan */
30 #define GLINE_REALNAME 8 /* Gline includes a realname */
31 #define GLINE_ACTIVATE 16 /* Gline should be activated */
32 #define GLINE_DEACTIVATE 32 /* Gline should be deactivated */
33 #define GLINE_DESTROY 64 /* Gline should be destroyed */
34 #define GLINE_ACTIVE 128 /* Gline is active */
35 #define GLINE_DESTROYED 256 /* Gline is destroyed */
40 #define GLIST_COUNT 0x01 /* -c */
41 #define GLIST_EXACT 0x02 /* -x */
42 #define GLIST_FIND 0x04 /* -f */
43 #define GLIST_REASON 0x10 /* -r */
44 #define GLIST_OWNER 0x20 /* -o */
45 #define GLIST_REALNAME 0x40 /* -R */
46 #define GLIST_INACTIVE 0x80 /* -i */
48 #define GLSTORE_PATH_PREFIX "data/glines"
49 #define GLSTORE_SAVE_FILES 5
50 #define GLSTORE_SAVE_INTERVAL 3600
53 * Interpret absolute/relative timestamps with same method as snircd
54 * If the expiration value, interpreted as an absolute timestamp, is
55 * more recent than 5 years in the past, we interpret it as an
56 * absolute timestamp; otherwise, we assume it's relative and convert
57 * it to an absolute timestamp.
59 #define abs_expire(exp) ((exp) >= getnettime() - 157680000 ? (exp) : (exp) + getnettime())
61 #define gline_max(a, b) (((a)<(b)) ? (b) : (a))
63 typedef struct gline
{
70 struct irc_in_addr ip
;
83 typedef struct glinebuf
{
98 extern gline
*glinelist
;
99 extern glinebuf
*glinebuflog
[MAXGLINELOG
];
100 extern int glinebuflogoffset
;
103 gline
*findgline(const char *);
104 void gline_propagate(gline
*);
105 void gline_deactivate(gline
*, time_t, int);
106 void gline_destroy(gline
*, time_t, int);
107 void gline_activate(gline
*agline
, time_t lastmod
, int propagate
);
108 int glineequal(gline
*, gline
*);
109 int gline_match_mask(gline
*gla
, gline
*glb
);
110 int gline_match_nick(gline
*gl
, nick
*np
);
111 int gline_match_channel(gline
*gl
, channel
*cp
);
112 int isglinesane(gline
*gl
, const char **hint
);
113 gline
*glinedup(gline
*gl
);
115 /* glines_formats.c */
116 gline
*makegline(const char *);
117 char *glinetostring(gline
*g
);
120 int glinebyip(const char *user
, struct irc_in_addr
*ip
, unsigned char bits
, int duration
, const char *reason
, int flags
, const char *creator
);
121 int glinebynick(nick
*np
, int duration
, const char *reason
, int flags
, const char *creator
);
122 void glineunsetmask(const char *mask
);
125 void glinebufinit(glinebuf
*gbuf
, int id
);
126 gline
*glinebufadd(glinebuf
*gbuf
, const char *mask
, const char *creator
, const char *reason
, time_t expire
, time_t lastmod
, time_t lifetime
);
127 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
);
128 void glinebufaddbynick(glinebuf
*gbuf
, nick
*, int flags
, const char *creator
, const char *reason
, time_t expire
, time_t lastmod
, time_t lifetime
);
129 void glinebufaddbywhowas(glinebuf
*gbuf
, whowas
*, int flags
, const char *creator
, const char *reason
, time_t expire
, time_t lastmod
, time_t lifetime
);
130 void glinebufcounthits(glinebuf
*gbuf
, int *users
, int *channels
);
131 int glinebufchecksane(glinebuf
*gbuf
, nick
*spewto
, int overridesanity
, int overridelimit
);
132 void glinebufspew(glinebuf
*gbuf
, nick
*spewto
);
133 void glinebufmerge(glinebuf
*gbuf
);
134 int glinebufcommit(glinebuf
*gbuf
, int propagate
);
135 void glinebufabort(glinebuf
*gbuf
);
136 int glinebufundo(int id
);
137 void glinebufcommentf(glinebuf
*gbuf
, const char *format
, ...);
138 void glinebufcommentv(glinebuf
*gbuf
, const char *prefix
, int cargc
, char **cargv
);
139 int glinebufwritelog(glinebuf
*gbuf
, int propagating
);
142 void freegline(gline
*);
144 void removegline(gline
*);
146 /* glines_handler.c */
147 int handleglinemsg(void *, int, char **);
148 void handleglinestats(int hooknum
, void *arg
);
151 int glstore_save(void);
152 int glstore_load(void);