1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* m_error.c: Handles error messages from the other end. |
4 |
* |
5 |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License as published by |
9 |
* the Free Software Foundation; either version 2 of the License, or |
10 |
* (at your option) any later version. |
11 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with this program; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
* USA |
21 |
* |
22 |
* $Id$ |
23 |
*/ |
24 |
|
25 |
#include "stdinc.h" |
26 |
#include "list.h" |
27 |
#include "handlers.h" |
28 |
#include "client.h" |
29 |
#include "ircd.h" |
30 |
#include "send.h" |
31 |
#include "msg.h" |
32 |
#include "modules.h" |
33 |
#include "s_log.h" |
34 |
|
35 |
|
36 |
static void m_error(struct Client *, struct Client *, int, char *[]); |
37 |
static void ms_error(struct Client *, struct Client *, int, char *[]); |
38 |
|
39 |
struct Message error_msgtab = { |
40 |
"ERROR", 0, 0, 1, 0, MFLG_SLOW | MFLG_UNREG, 0, |
41 |
{ m_error, m_ignore, ms_error, m_ignore, m_ignore, m_ignore } |
42 |
}; |
43 |
|
44 |
void |
45 |
_modinit(void) |
46 |
{ |
47 |
mod_add_cmd(&error_msgtab); |
48 |
} |
49 |
|
50 |
void |
51 |
_moddeinit(void) |
52 |
{ |
53 |
mod_del_cmd(&error_msgtab); |
54 |
} |
55 |
|
56 |
const char *_version = "$Revision$"; |
57 |
|
58 |
/* |
59 |
* Note: At least at protocol level ERROR has only one parameter. |
60 |
* --msa |
61 |
* |
62 |
* parv[0] = sender prefix |
63 |
* parv[*] = parameters |
64 |
*/ |
65 |
void |
66 |
m_error(struct Client *client_p, struct Client *source_p, |
67 |
int parc, char *parv[]) |
68 |
{ |
69 |
const char *para; |
70 |
|
71 |
para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>"; |
72 |
|
73 |
ilog(L_ERROR, "Received ERROR message from %s: %s", |
74 |
source_p->name, para); |
75 |
|
76 |
if (client_p == source_p) |
77 |
{ |
78 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s -- %s", |
79 |
get_client_name(client_p, HIDE_IP), para); |
80 |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s -- %s", |
81 |
get_client_name(client_p, MASK_IP), para); |
82 |
} |
83 |
else |
84 |
{ |
85 |
sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s via %s -- %s", |
86 |
source_p->name, get_client_name(client_p, MASK_IP), para); |
87 |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s via %s -- %s", |
88 |
source_p->name, get_client_name(client_p, HIDE_IP), para); |
89 |
} |
90 |
|
91 |
if (MyClient(source_p)) |
92 |
exit_client(source_p, source_p, "ERROR"); |
93 |
} |
94 |
|
95 |
void |
96 |
ms_error(struct Client *client_p, struct Client *source_p, |
97 |
int parc, char *parv[]) |
98 |
{ |
99 |
const char *para; |
100 |
|
101 |
para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>"; |
102 |
|
103 |
ilog(L_ERROR, "Received ERROR message from %s: %s", |
104 |
source_p->name, para); |
105 |
|
106 |
if (client_p == source_p) |
107 |
sendto_realops_flags(UMODE_ALL, L_ALL, "ERROR :from %s -- %s", |
108 |
get_client_name(client_p, MASK_IP), para); |
109 |
else |
110 |
sendto_realops_flags(UMODE_ALL, L_ALL, "ERROR :from %s via %s -- %s", |
111 |
source_p->name, |
112 |
get_client_name(client_p, MASK_IP), para); |
113 |
} |