]> jfr.im git - solanum.git/blame - extensions/sno_farconnect.c
m_stats: z: remove unnecessary casting and fix format strings
[solanum.git] / extensions / sno_farconnect.c
CommitLineData
212380e3
AC
1/*
2 * Remote client connect/exit notices on snomask +F (far).
3 * To avoid flooding, connects/exits part of netjoins/netsplits are not shown.
4 * Consequently, it is not possible to use these notices to keep track
5 * of all clients.
6 * -- jilles
212380e3
AC
7 */
8
9#include "stdinc.h"
10#include "modules.h"
11#include "client.h"
12#include "hook.h"
13#include "ircd.h"
14#include "send.h"
15#include "s_conf.h"
16#include "snomask.h"
17
eeabf33a
EM
18static const char sno_desc[] =
19 "Adds server notice mask +F that allows operators to receive notices for connections on other servers";
20
212380e3
AC
21static int _modinit(void);
22static void _moddeinit(void);
82436efb
EM
23static void h_gcn_new_remote_user(void *);
24static void h_gcn_client_exit(void *);
212380e3
AC
25
26mapi_hfn_list_av1 gcn_hfnlist[] = {
82436efb
EM
27 { "new_remote_user", h_gcn_new_remote_user },
28 { "client_exit", h_gcn_client_exit },
212380e3
AC
29 { NULL, NULL }
30};
31
84b4c058 32DECLARE_MODULE_AV2(globalconnexit, _modinit, _moddeinit, NULL, NULL, gcn_hfnlist, NULL, NULL, sno_desc);
212380e3
AC
33
34static int
35_modinit(void)
36{
37 /* add the snomask to the available slot */
38 snomask_modes['F'] = find_snomask_slot();
39
40 /* show the fact that we are showing user information in /version */
503727d1 41 opers_see_all_users = true;
212380e3
AC
42
43 return 0;
44}
45
46static void
47_moddeinit(void)
48{
49 /* disable the snomask and remove it from the available list */
50 snomask_modes['F'] = 0;
51}
52
53static void
82436efb 54h_gcn_new_remote_user(void *data)
212380e3 55{
82436efb 56 struct Client *source_p = data;
212380e3
AC
57
58 if (!HasSentEob(source_p->servptr))
59 return;
60 sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
e62ec6f1 61 "Client connecting: %s (%s@%s) [%s] {%s} <%s> [%s]",
212380e3
AC
62 source_p->name, source_p->username, source_p->orighost,
63 show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255",
e62ec6f1
DS
64 "?", *source_p->user->suser ? source_p->user->suser : "*",
65 source_p->info);
212380e3
AC
66}
67
68static void
82436efb 69h_gcn_client_exit(void *data)
212380e3 70{
82436efb 71 hook_data_client_exit *hdata = data;
212380e3
AC
72 struct Client *source_p;
73
74 source_p = hdata->target;
75
76 if (MyConnect(source_p) || !IsClient(source_p))
77 return;
78 if (!HasSentEob(source_p->servptr))
79 return;
80 sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
81 "Client exiting: %s (%s@%s) [%s] [%s]",
82 source_p->name,
83 source_p->username, source_p->host, hdata->comment,
84 show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255");
85}