]>
Commit | Line | Data |
---|---|---|
1 | #include "../irc/irc.h" | |
2 | #include "../trusts/trusts.h" | |
3 | #include "glines.h" | |
4 | ||
5 | int glinebyip(const char *user, struct irc_in_addr *ip, unsigned char bits, int duration, const char *reason, int flags, const char *creator) { | |
6 | glinebuf gbuf; | |
7 | int hits; | |
8 | ||
9 | glinebufinit(&gbuf, 0); | |
10 | glinebufcommentf(&gbuf, "on IP mask %s@%s, set by %s", user, CIDRtostr(*ip, bits), creator); | |
11 | glinebufaddbyip(&gbuf, user, ip, bits, flags, creator, reason, getnettime() + duration, getnettime(), getnettime() + duration); | |
12 | ||
13 | glinebufcounthits(&gbuf, &hits, NULL); | |
14 | ||
15 | if (flags & GLINE_SIMULATE) | |
16 | glinebufabort(&gbuf); | |
17 | else | |
18 | glinebufcommit(&gbuf, 1); | |
19 | ||
20 | return hits; | |
21 | } | |
22 | ||
23 | int glinebynick(nick *np, int duration, const char *reason, int flags, const char *creator) { | |
24 | glinebuf gbuf; | |
25 | int hits; | |
26 | ||
27 | glinebufinit(&gbuf, 0); | |
28 | glinebufcommentf(&gbuf, "on nick %s!%s@%s, set by %s", np->nick, np->ident, np->host->name->content, creator); | |
29 | glinebufaddbynick(&gbuf, np, flags, creator, reason, getnettime() + duration, getnettime(), getnettime() + duration); | |
30 | ||
31 | glinebufcounthits(&gbuf, &hits, NULL); | |
32 | ||
33 | if (flags & GLINE_SIMULATE) | |
34 | glinebufabort(&gbuf); | |
35 | else | |
36 | glinebufcommit(&gbuf, 1); | |
37 | ||
38 | return hits; | |
39 | } | |
40 | ||
41 | void glineunsetmask(const char *mask) { | |
42 | gline *gl; | |
43 | ||
44 | gl = findgline(mask); | |
45 | ||
46 | if (!gl) | |
47 | return; | |
48 | ||
49 | gline_deactivate(gl, 0, 1); | |
50 | } |