]> jfr.im git - solanum.git/blob - modules/m_tginfo.c
Merge pull request #169 from staticfox/chghost_sync
[solanum.git] / modules / m_tginfo.c
1 /*
2 * m_tginfo.c: propagates target-change status information
3 *
4 * Copyright (C) 2012 Keith Buck
5 * Copyright (C) 2012 charybdis development team
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * 1.Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * 2.Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #include "stdinc.h"
31 #include "client.h"
32 #include "common.h"
33 #include "match.h"
34 #include "hash.h"
35 #include "ircd.h"
36 #include "numeric.h"
37 #include "send.h"
38 #include "msg.h"
39 #include "modules.h"
40 #include "s_newconf.h" /* add_tgchange */
41
42 static const char tginfo_desc[] = "Processes target change notifications from other servers";
43
44 static void me_tginfo(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
45
46 struct Message tginfo_msgtab = {
47 "TGINFO", 0, 0, 0, 0,
48 {mg_unreg, mg_ignore, mg_ignore, mg_ignore, {me_tginfo, 2}, mg_ignore}
49 };
50
51 mapi_clist_av1 tginfo_clist[] = { &tginfo_msgtab, NULL };
52
53 DECLARE_MODULE_AV2(tginfo, NULL, NULL, tginfo_clist, NULL, NULL, NULL, NULL, tginfo_desc);
54
55 /*
56 ** me_tginfo
57 ** parv[1] = 0, reserved for future use (number of remaining targets)
58 */
59 static void
60 me_tginfo(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
61 {
62 if (!IsPerson(source_p))
63 return;
64
65 int remaining = atoi(parv[1]);
66 if (remaining != 0)
67 return; /* not implemented */
68
69 if (!EmptyString(source_p->sockhost) && strcmp(source_p->sockhost, "0"))
70 {
71 /* We can't really add the tgchange if we don't have their IP... */
72 add_tgchange(source_p->sockhost);
73 }
74
75 if (!IsTGExcessive(source_p))
76 {
77 SetTGExcessive(source_p);
78 sendto_realops_snomask_from(SNO_BOTS, L_ALL, source_p->servptr,
79 "Excessive target change from %s (%s@%s)",
80 source_p->name, source_p->username, source_p->orighost);
81 }
82 }