| 1 |
michael |
947 |
/* |
| 2 |
michael |
2820 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
michael |
947 |
* |
| 4 |
michael |
10024 |
* Copyright (c) 1997-2022 ircd-hybrid development team |
| 5 |
michael |
947 |
* |
| 6 |
|
|
* This program is free software; you can redistribute it and/or modify |
| 7 |
|
|
* it under the terms of the GNU General Public License as published by |
| 8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
|
|
* (at your option) any later version. |
| 10 |
|
|
* |
| 11 |
|
|
* This program is distributed in the hope that it will be useful, |
| 12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
|
|
* GNU General Public License for more details. |
| 15 |
|
|
* |
| 16 |
|
|
* You should have received a copy of the GNU General Public License |
| 17 |
|
|
* along with this program; if not, write to the Free Software |
| 18 |
michael |
4564 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 19 |
michael |
947 |
* USA |
| 20 |
|
|
*/ |
| 21 |
|
|
|
| 22 |
michael |
2820 |
/*! \file m_error.c |
| 23 |
|
|
* \brief Includes required functions for processing the ERROR command. |
| 24 |
|
|
* \version $Id$ |
| 25 |
|
|
*/ |
| 26 |
|
|
|
| 27 |
michael |
947 |
#include "stdinc.h" |
| 28 |
|
|
#include "client.h" |
| 29 |
|
|
#include "ircd.h" |
| 30 |
|
|
#include "send.h" |
| 31 |
|
|
#include "modules.h" |
| 32 |
michael |
1309 |
#include "log.h" |
| 33 |
michael |
1243 |
#include "parse.h" |
| 34 |
michael |
2008 |
#include "irc_string.h" |
| 35 |
michael |
947 |
|
| 36 |
|
|
|
| 37 |
michael |
7899 |
/*! \brief ERROR command handler |
| 38 |
michael |
947 |
* |
| 39 |
michael |
7899 |
* \param source_p Pointer to allocated Client struct from which the message |
| 40 |
|
|
* originally comes from. This can be a local or remote client. |
| 41 |
|
|
* \param parc Integer holding the number of supplied arguments. |
| 42 |
|
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
| 43 |
|
|
* pointers. |
| 44 |
|
|
* \note Valid arguments for this command are: |
| 45 |
|
|
* - parv[0] = command |
| 46 |
|
|
* - parv[1] = error message |
| 47 |
michael |
947 |
*/ |
| 48 |
michael |
9078 |
static void |
| 49 |
michael |
3156 |
mr_error(struct Client *source_p, int parc, char *parv[]) |
| 50 |
michael |
947 |
{ |
| 51 |
michael |
3156 |
assert(MyConnect(source_p)); |
| 52 |
michael |
947 |
|
| 53 |
michael |
2008 |
if (!IsHandshake(source_p) && !IsConnecting(source_p)) |
| 54 |
michael |
9078 |
return; |
| 55 |
michael |
2008 |
|
| 56 |
michael |
9364 |
const char *message = "<>"; |
| 57 |
michael |
9382 |
if (!EmptyString(parv[1])) |
| 58 |
michael |
9364 |
message = parv[1]; |
| 59 |
|
|
|
| 60 |
michael |
1247 |
ilog(LOG_TYPE_IRCD, "Received ERROR message from %s: %s", |
| 61 |
michael |
10174 |
client_get_name(source_p, SHOW_IP), message); |
| 62 |
michael |
947 |
|
| 63 |
michael |
6317 |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
| 64 |
michael |
3156 |
"ERROR :from %s -- %s", |
| 65 |
michael |
7996 |
client_get_name(source_p, HIDE_IP), message); |
| 66 |
michael |
6317 |
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, |
| 67 |
michael |
3156 |
"ERROR :from %s -- %s", |
| 68 |
michael |
7996 |
client_get_name(source_p, MASK_IP), message); |
| 69 |
michael |
947 |
} |
| 70 |
|
|
|
| 71 |
michael |
7899 |
/*! \brief ERROR command handler |
| 72 |
|
|
* |
| 73 |
|
|
* \param source_p Pointer to allocated Client struct from which the message |
| 74 |
|
|
* originally comes from. This can be a local or remote client. |
| 75 |
|
|
* \param parc Integer holding the number of supplied arguments. |
| 76 |
|
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
| 77 |
|
|
* pointers. |
| 78 |
|
|
* \note Valid arguments for this command are: |
| 79 |
|
|
* - parv[0] = command |
| 80 |
|
|
* - parv[1] = error message |
| 81 |
|
|
*/ |
| 82 |
michael |
9078 |
static void |
| 83 |
michael |
3156 |
ms_error(struct Client *source_p, int parc, char *parv[]) |
| 84 |
michael |
947 |
{ |
| 85 |
michael |
9364 |
const char *message = "<>"; |
| 86 |
michael |
9382 |
if (!EmptyString(parv[1])) |
| 87 |
michael |
9364 |
message = parv[1]; |
| 88 |
michael |
947 |
|
| 89 |
michael |
1247 |
ilog(LOG_TYPE_IRCD, "Received ERROR message from %s: %s", |
| 90 |
michael |
10174 |
client_get_name(source_p, SHOW_IP), message); |
| 91 |
michael |
947 |
|
| 92 |
michael |
3156 |
if (MyConnect(source_p)) |
| 93 |
michael |
6317 |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
| 94 |
michael |
1618 |
"ERROR :from %s -- %s", |
| 95 |
michael |
7996 |
client_get_name(source_p->from, MASK_IP), message); |
| 96 |
michael |
947 |
else |
| 97 |
michael |
6317 |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
| 98 |
michael |
1618 |
"ERROR :from %s via %s -- %s", |
| 99 |
michael |
947 |
source_p->name, |
| 100 |
michael |
7996 |
client_get_name(source_p->from, MASK_IP), message); |
| 101 |
michael |
947 |
} |
| 102 |
michael |
1230 |
|
| 103 |
michael |
2820 |
static struct Message error_msgtab = |
| 104 |
|
|
{ |
| 105 |
michael |
5880 |
.cmd = "ERROR", |
| 106 |
michael |
9373 |
.handlers[UNREGISTERED_HANDLER] = { .handler = mr_error }, |
| 107 |
|
|
.handlers[CLIENT_HANDLER] = { .handler = m_ignore }, |
| 108 |
|
|
.handlers[SERVER_HANDLER] = { .handler = ms_error }, |
| 109 |
|
|
.handlers[ENCAP_HANDLER] = { .handler = m_ignore }, |
| 110 |
|
|
.handlers[OPER_HANDLER] = { .handler = m_ignore } |
| 111 |
michael |
1230 |
}; |
| 112 |
|
|
|
| 113 |
|
|
static void |
| 114 |
|
|
module_init(void) |
| 115 |
|
|
{ |
| 116 |
|
|
mod_add_cmd(&error_msgtab); |
| 117 |
|
|
} |
| 118 |
|
|
|
| 119 |
|
|
static void |
| 120 |
|
|
module_exit(void) |
| 121 |
|
|
{ |
| 122 |
|
|
mod_del_cmd(&error_msgtab); |
| 123 |
|
|
} |
| 124 |
|
|
|
| 125 |
michael |
2820 |
struct module module_entry = |
| 126 |
|
|
{ |
| 127 |
michael |
1230 |
.version = "$Revision$", |
| 128 |
|
|
.modinit = module_init, |
| 129 |
|
|
.modexit = module_exit, |
| 130 |
michael |
8723 |
.is_core = true |
| 131 |
michael |
1230 |
}; |