]>
Commit | Line | Data |
---|---|---|
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 | ||
18 | static int _modinit(void); | |
19 | static void _moddeinit(void); | |
20 | static void h_gcn_new_remote_user(struct Client *); | |
21 | static void h_gcn_client_exit(hook_data_client_exit *); | |
22 | ||
23 | mapi_hfn_list_av1 gcn_hfnlist[] = { | |
24 | { "new_remote_user", (hookfn) h_gcn_new_remote_user }, | |
25 | { "client_exit", (hookfn) h_gcn_client_exit }, | |
26 | { NULL, NULL } | |
27 | }; | |
28 | ||
84b4c058 EM |
29 | static const char sno_desc[] = |
30 | "Adds server notice mask +F that allows operators to receive notices for connections on other servers"; | |
31 | ||
32 | DECLARE_MODULE_AV2(globalconnexit, _modinit, _moddeinit, NULL, NULL, gcn_hfnlist, NULL, NULL, sno_desc); | |
212380e3 AC |
33 | |
34 | static 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 */ | |
41 | opers_see_all_users = 1; | |
42 | ||
43 | return 0; | |
44 | } | |
45 | ||
46 | static void | |
47 | _moddeinit(void) | |
48 | { | |
49 | /* disable the snomask and remove it from the available list */ | |
50 | snomask_modes['F'] = 0; | |
51 | } | |
52 | ||
53 | static void | |
54 | h_gcn_new_remote_user(struct Client *source_p) | |
55 | { | |
56 | ||
57 | if (!HasSentEob(source_p->servptr)) | |
58 | return; | |
59 | sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr, | |
60 | "Client connecting: %s (%s@%s) [%s] {%s} [%s]", | |
61 | source_p->name, source_p->username, source_p->orighost, | |
62 | show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255", | |
63 | "?", source_p->info); | |
64 | } | |
65 | ||
66 | static void | |
67 | h_gcn_client_exit(hook_data_client_exit *hdata) | |
68 | { | |
69 | struct Client *source_p; | |
70 | ||
71 | source_p = hdata->target; | |
72 | ||
73 | if (MyConnect(source_p) || !IsClient(source_p)) | |
74 | return; | |
75 | if (!HasSentEob(source_p->servptr)) | |
76 | return; | |
77 | sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr, | |
78 | "Client exiting: %s (%s@%s) [%s] [%s]", | |
79 | source_p->name, | |
80 | source_p->username, source_p->host, hdata->comment, | |
81 | show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255"); | |
82 | } |