]> jfr.im git - irc/quakenet/newserv.git/blob - glines/glines.c
Implement trustpolicy command.
[irc/quakenet/newserv.git] / glines / glines.c
1 #include "../irc/irc.h"
2
3 #include "../trusts/trusts.h"
4 #include "glines.h"
5
6 void glinebynick(nick *np, int duration, const char *reason) {
7 glinebyhost(np->ident, IPtostr(np->p_ipaddr), duration, reason);
8 }
9
10 void glinebyhost(const char *ident, const char *hostname, int duration, const char *reason) {
11 struct irc_in_addr ip;
12 unsigned char bits;
13 trusthost *th;
14
15 if(ipmask_parse(hostname, &ip, &bits)) {
16 th = th_getbyhost(&ip);
17
18 if(th && th->group->mode) {
19 trustgline(th->group, ident, duration, reason);
20 return;
21 }
22 }
23
24 irc_send("%s GL * +%s@%s %d %jd :%s", mynumeric->content, ident, hostname, duration, (intmax_t)getnettime(), reason);
25 }
26
27 void unglinebyhost(const char *ident, const char *hostname, int duration, const char *reason) {
28 struct irc_in_addr ip;
29 unsigned char bits;
30 trusthost *th;
31
32 if(ipmask_parse(hostname, &ip, &bits)) {
33 th = th_getbyhost(&ip);
34
35 if(th && th->group->mode) {
36 trustungline(th->group, ident, duration, reason);
37 return;
38 }
39 }
40
41 irc_send("%s GL * -%s@%s %d %jd :%s", mynumeric->content, ident, hostname, duration, (intmax_t)getnettime(), reason);
42 }