]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * m_error.c: Handles error messages from the other end. | |
4 | * | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team | |
7 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
22 | * USA | |
23 | * | |
24 | * $Id: m_error.c 494 2006-01-15 16:08:28Z jilles $ | |
25 | */ | |
26 | ||
27 | #include "stdinc.h" | |
28 | #include "client.h" | |
29 | #include "common.h" /* FALSE */ | |
30 | #include "ircd.h" | |
31 | #include "numeric.h" | |
32 | #include "send.h" | |
33 | #include "msg.h" | |
34 | #include "memory.h" | |
35 | #include "modules.h" | |
36 | #include "s_log.h" | |
37 | #include "s_conf.h" | |
38 | ||
39 | static int m_error(struct Client *, struct Client *, int, const char **); | |
40 | static int ms_error(struct Client *, struct Client *, int, const char **); | |
41 | ||
42 | struct Message error_msgtab = { | |
43 | "ERROR", 0, 0, 0, MFLG_SLOW | MFLG_UNREG, | |
44 | {{m_error, 0}, mg_ignore, mg_ignore, {ms_error, 0}, mg_ignore, mg_ignore} | |
45 | }; | |
46 | ||
47 | mapi_clist_av1 error_clist[] = { | |
48 | &error_msgtab, NULL | |
49 | }; | |
50 | ||
51 | DECLARE_MODULE_AV1(error, NULL, NULL, error_clist, NULL, NULL, "$Revision: 494 $"); | |
52 | ||
53 | ||
54 | /* | |
55 | * Note: At least at protocol level ERROR has only one parameter, | |
56 | * although this is called internally from other functions | |
57 | * --msa | |
58 | * | |
59 | * parv[0] = sender prefix | |
60 | * parv[*] = parameters | |
61 | */ | |
62 | int | |
63 | m_error(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
64 | { | |
65 | const char *para; | |
66 | ||
67 | para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>"; | |
68 | ||
69 | ilog(L_SERVER, "Received ERROR message from %s: %s", | |
70 | log_client_name(source_p, SHOW_IP), para); | |
71 | ||
72 | if(IsAnyServer(client_p) && ConfigFileEntry.hide_error_messages < 2) | |
73 | { | |
74 | sendto_realops_snomask(SNO_GENERAL, L_ADMIN, | |
75 | "ERROR :from %s -- %s", | |
76 | get_server_name(client_p, HIDE_IP), para); | |
77 | ||
78 | if(!ConfigFileEntry.hide_error_messages) | |
79 | sendto_realops_snomask(SNO_GENERAL, L_OPER, | |
80 | "ERROR :from %s -- %s", | |
81 | get_server_name(client_p, HIDE_IP), para); | |
82 | } | |
83 | ||
84 | exit_client(client_p, source_p, source_p, "ERROR"); | |
85 | ||
86 | return 0; | |
87 | } | |
88 | ||
89 | static int | |
90 | ms_error(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
91 | { | |
92 | const char *para; | |
93 | ||
94 | para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>"; | |
95 | ||
96 | ilog(L_SERVER, "Received ERROR message from %s: %s", | |
97 | log_client_name(source_p, SHOW_IP), para); | |
98 | ||
99 | if(ConfigFileEntry.hide_error_messages == 2) | |
100 | return 0; | |
101 | ||
102 | if(client_p == source_p) | |
103 | { | |
104 | sendto_realops_snomask(SNO_GENERAL, L_ADMIN, "ERROR :from %s -- %s", | |
105 | get_server_name(client_p, HIDE_IP), para); | |
106 | ||
107 | if(!ConfigFileEntry.hide_error_messages) | |
108 | sendto_realops_snomask(SNO_GENERAL, L_OPER, | |
109 | "ERROR :from %s -- %s", | |
110 | get_server_name(client_p, HIDE_IP), para); | |
111 | } | |
112 | else | |
113 | { | |
114 | sendto_realops_snomask(SNO_GENERAL, L_ADMIN, "ERROR :from %s via %s -- %s", | |
115 | source_p->name, get_server_name(client_p, HIDE_IP), para); | |
116 | ||
117 | if(!ConfigFileEntry.hide_error_messages) | |
118 | sendto_realops_snomask(SNO_GENERAL, L_OPER, | |
119 | "ERROR :from %s via %s -- %s", | |
120 | source_p->name, | |
121 | get_server_name(client_p, HIDE_IP), para); | |
122 | } | |
123 | ||
124 | return 0; | |
125 | } |