]> jfr.im git - irc/quakenet/snircd.git/blame - doc/api/gline.txt
sync undernet upstream ircu changes.
[irc/quakenet/snircd.git] / doc / api / gline.txt
CommitLineData
189935b1 1Some users can be very annoying, as any IRC operator can attest. Some
2can in fact be downright abusive. Sometimes the best way of dealing
3with these users is to ban them from the entire network. The G-line
4system permits this.
5
6G-lines are fairly complicated. A G-line can be active or inactive,
7either locally or globally. It can be a purely local G-line, or
8global. It could be based on IP address or on host name. In short,
9there are many variations on the basic G-line. Worse, there is also
10the concept of a "bad channel," or BADCHAN, that has been tacked onto
11the G-line subsystem, when it should have been a separate command in
12the first place.
13
14Different types of G-lines are differentiated from each other through
15the use of various flags. Some of these flags are maintained solely
16by the G-line subsystem, where as others are passed to various
17functions in the API.
18
19<macro>
20#define GLINE_MAX_EXPIRE 604800 /* max expire: 7 days */
21
22This macro lists the maximum expire time a G-line is permitted to
23have. This value is limited to 7 days to prevent abuse of the system.
24</macro>
25
26<macro>
27#define GLINE_ACTIVE 0x0001
28
29This flag is used to indicate that a given G-line is globally active.
30</macro>
31
32<macro>
33#define GLINE_IPMASK 0x0002
34
35This flag is used to indicate that a given G-line is an IP mask. This
36flag is maintained internally by the G-line subsystem.
37</macro>
38
39<macro>
40#define GLINE_BADCHAN 0x0004
41
42This flag is used to indicate that a given G-line specifies a BADCHAN,
43a channel that users are not permitted to join. This flag is
44maintained internally, but is also used in gline_find() to search for
45a BADCHAN for a particular channel.
46</macro>
47
48<macro>
49#define GLINE_LOCAL 0x0008
50
51This flag is used to indicate that a given G-line is a local G-line.
52Local G-lines do not affect users on other servers.
53</macro>
54
55<macro>
56#define GLINE_ANY 0x0010
57
58This flag is passed to gline_find() to signal that function to return
59any G-line or BADCHAN that matches the passed mask string. It is
60never set on a real G-line.
61</macro>
62
63<macro>
64#define GLINE_FORCE 0x0020
65
66This flag is passed to gline_add() to force the server to accept an
67expire time that might be out of bounds. It is never set on a real
68G-line.
69</macro>
70
71<macro>
72#define GLINE_EXACT 0x0040
73
74This flag is passed to gline_find() to signal that function to return
75only G-lines that exactly match the passed mask string. That is, the
76ircd_strcmp() function is called to compare the G-line to the mask,
77rather than the match() function. This flag is never set on a real
78G-line.
79</macro>
80
81<macro>
82#define GLINE_LDEACT 0x0080 /* locally deactivated */
83
84This flag is set on global G-lines that have been locally
85deactivated. This flag is maintained internally by the G-line
86subsystem.
87</macro>
88
89<macro>
90#define GLINE_GLOBAL 0x0100 /* find only global glines */
91
92This flag is passed to gline_find() or gline_lookup() to specify that
93the caller is only interested in global G-lines. This flag is never
94set on a real G-line.
95</macro>
96
97<macro>
98#define GLINE_LASTMOD 0x0200 /* find only glines with non-zero lastmod */
99
100This flag is passed to gline_find() or gline_lookup() to specify that
101the caller is only interested in G-lines with a non-zero lastmod time,
102that is, G-lines that were not set by a U-lined service. This flag is
103never set on a real G-line.
104</macro>
105
106<struct>
107struct Gline;
108
109The struct Gline describes everything about a given G-line. None of
110its fields may be directly accessed by the application; use the
111functions and macros described below instead.
112</struct>
113
114<function>
115int GlineIsActive(struct Gline* g);
116
117This macro returns a non-zero value if the G-line is active, or 0
118otherwise. If a G-line is locally deactivated, this macro will always
119return 0.
120</function>
121
122<function>
123int GlineIsRemActive(struct Gline* g);
124
125This macro returns a non-zero value if the G-line is active, ignoring
126whether or not it is locally deactivated.
127</function>
128
129<function>
130int GlineIsIpMask(struct Gline* g);
131
132This macro returns a non-zero value if the G-line is an IP mask.
133</function>
134
135<function>
136int GlineIsBadChan(struct Gline* g);
137
138This macro returns a non-zero value if a G-line actually represents a
139BADCHAN.
140</function>
141
142<function>
143int GlineIsLocal(struct Gline* g);
144
145This macro returns a non-zero value if a G-line is local only.
146</function>
147
148<function>
149char* GlineUser(struct Gline* g);
150
151This macro returns the user name associated with the G-line. If the
152G-line represents a BADCHAN, this will contain the channel name.
153</function>
154
155<function>
156char* GlineHost(struct Gline* g);
157
158This macro returns the host name associated with the G-line. If the
159G-line represents a BADCHAN, this will be a NULL pointer.
160</function>
161
162<function>
163char* GlineReason(struct Gline* g);
164
165This macro returns the reason that was given when the G-line was set.
166</function>
167
168<function>
169time_t GlineLastMod(struct Gline* g);
170
171G-lines that were not set by a U-lined service have a modification
172time that must be monotonically increasing. This macro simply returns
173that modification time.
174</function>
175
176<function>
177int gline_propagate(struct Client *cptr, struct Client *sptr,
178 struct Gline *gline);
179
180When a global G-line is set or modified, all other servers must be
181notified of the new G-line. This function takes care of propagating
182the G-line specified by _gline_, originated by the client _sptr_, to
183all servers except _cptr_ (which may be a NULL pointer).
184</function>
185
186<function>
187int gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
188 char *reason, time_t expire, time_t lastmod, unsigned int flags);
189
190This function simply adds a G-line, set by _sptr_ and with a
191_userhost_, _reason_, _expire_, and _lastmod_ as specified. The
192_flags_ parameter is a bit mask consisting of the binary OR of
193GLINE_FORCE, GLINE_LOCAL, or GLINE_ACTIVE, as appropriate. The
194gline_add() function also calls gline_propagate() to propagate the
195G-line, and kills off any local users matching the G-line if it is
196active.
197</function>
198
199<function>
200int gline_activate(struct Client *cptr, struct Client *sptr,
201 struct Gline *gline, time_t lastmod, unsigned int flags);
202
203This function activates the G-line specified by _gline_, setting its
204_lastmod_ time as specified. If _flags_ is GLINE_LOCAL and if the
205G-line is locally deactivated, this function will turn off the local
206deactivation flag, but will not modify _lastmod_. If the G-line is
207globally deactivated, passing this function the GLINE_LOCAL flag will
208have no effect.
209</function>
210
211<function>
212int gline_deactivate(struct Client *cptr, struct Client *sptr,
213 struct Gline *gline, time_t lastmod, unsigned int flags);
214
215This function is similar to gline_activate() except that it
216deactivates the G-line. If the given G-line is local, or if it was
217set by a U-lined service (and GLINE_LOCAL was not passed via _flags_),
218then the G-line is deleted from memory. In all other cases, the
219G-line is simply deactivated, either locally (if GLINE_LOCAL was
220passed via _flags_) or globally. Global deactivation will update the
221_lastmod_ time.
222</function>
223
224<function>
225struct Gline *gline_find(char *userhost, unsigned int flags);
226
227This function looks up a G-line matching the given _userhost_ value,
228under control of the _flags_ parameter. Valid _flags_ that may be
229passed are: GLINE_BADCHAN, GLINE_ANY, GLINE_GLOBAL, GLINE_LASTMOD, or
230GLINE_EXACT, each described above.
231</function>
232
233<function>
234struct Gline *gline_lookup(struct Client *cptr, unsigned int flags);
235
236This function looks up a G-line matching the given client, specified
237by _cptr_, under the control of the _flags_. Valid values for _flags_
238are GLINE_GLOBAL and GLINE_LASTMOD, as described above.
239</function>
240
241<function>
242void gline_free(struct Gline *gline);
243
244This function releases all storage associated with a given G-line.
245</function>
246
247<function>
248void gline_burst(struct Client *cptr);
249
250This function generates a burst of all existing global G-lines and
251BADCHANs and sends them to the server specified by _cptr_.
252</function>
253
254<function>
255int gline_resend(struct Client *cptr, struct Gline *gline);
256
257This function resends the _gline_ to a server specified by _cptr_.
258This may be used if, for instance, it is discovered that a server is
259not synchronized with respect to a particular G-line.
260</function>
261
262<function>
263int gline_list(struct Client *sptr, char *userhost);
264
265This function sends the information about a G-line matching _userhost_
266to the client specified by _sptr_. If _userhost_ is a NULL pointer, a
267list of all G-lines is sent.
268</function>
269
270<function>
271void gline_stats(struct Client *sptr);
272
273This function generates a list of all G-lines, sending them to the
274user _sptr_ by a /STATS G response.
275</function>
276
277<authors>
278Kev <klmitch@mit.edu>
279</authors>
280
281<changelog>
282[2001-6-15 Kev] Initial documentation for the G-line API.
283</changelog>