1
0
mirror of https://github.com/osmarks/ngircd.git synced 2025-05-21 08:34:10 +00:00

Introduce new function IRC_WriteErrClient()

This function is used to send "error messages", including numerics,
back to clients and to automatically enforce a 2 second penalty. With
this patch, all error results enforces a delay for the client.

All callers of IRC_WriteStrClient(ERR_xxx) have been converted.

Please note that this patch prolongs the time "make check" needs
to complete its tests, because of lots of new enforced penalties ...
This commit is contained in:
Alexander Barton 2013-08-06 23:37:21 +02:00
parent b86e33ef49
commit 904c8a4375
17 changed files with 228 additions and 194 deletions

View File

@ -1,6 +1,6 @@
/* /*
* ngIRCd -- The Next Generation IRC Daemon * ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors. * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -223,7 +223,7 @@ Channel_Join( CLIENT *Client, const char *Name )
/* Check that the channel name is valid */ /* Check that the channel name is valid */
if (! Channel_IsValidName(Name)) { if (! Channel_IsValidName(Name)) {
IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG, IRC_WriteErrClient(Client, ERR_NOSUCHCHANNEL_MSG,
Client_ID(Client), Name); Client_ID(Client), Name);
return false; return false;
} }
@ -268,14 +268,14 @@ Channel_Part(CLIENT * Client, CLIENT * Origin, const char *Name, const char *Rea
/* Check that specified channel exists */ /* Check that specified channel exists */
chan = Channel_Search(Name); chan = Channel_Search(Name);
if (!chan) { if (!chan) {
IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG, IRC_WriteErrClient(Client, ERR_NOSUCHCHANNEL_MSG,
Client_ID(Client), Name); Client_ID(Client), Name);
return false; return false;
} }
/* Check that the client is in the channel */ /* Check that the client is in the channel */
if (!Get_Cl2Chan(chan, Client)) { if (!Get_Cl2Chan(chan, Client)) {
IRC_WriteStrClient(Client, ERR_NOTONCHANNEL_MSG, IRC_WriteErrClient(Client, ERR_NOTONCHANNEL_MSG,
Client_ID(Client), Name); Client_ID(Client), Name);
return false; return false;
} }
@ -309,9 +309,9 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
/* Check that channel exists */ /* Check that channel exists */
chan = Channel_Search( Name ); chan = Channel_Search( Name );
if( ! chan ) if (!chan) {
{ IRC_WriteErrClient(Origin, ERR_NOSUCHCHANNEL_MSG,
IRC_WriteStrClient( Origin, ERR_NOSUCHCHANNEL_MSG, Client_ID( Origin ), Name ); Client_ID(Origin), Name);
return; return;
} }
@ -319,15 +319,15 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
Client_Type(Origin) != CLIENT_SERVICE) { Client_Type(Origin) != CLIENT_SERVICE) {
/* Check that user is on the specified channel */ /* Check that user is on the specified channel */
if (!Channel_IsMemberOf(chan, Origin)) { if (!Channel_IsMemberOf(chan, Origin)) {
IRC_WriteStrClient( Origin, ERR_NOTONCHANNEL_MSG, IRC_WriteErrClient(Origin, ERR_NOTONCHANNEL_MSG,
Client_ID(Origin), Name); Client_ID(Origin), Name);
return; return;
} }
} }
/* Check that the client to be kicked is on the specified channel */ /* Check that the client to be kicked is on the specified channel */
if (!Channel_IsMemberOf(chan, Target)) { if (!Channel_IsMemberOf(chan, Target)) {
IRC_WriteStrClient(Origin, ERR_USERNOTINCHANNEL_MSG, IRC_WriteErrClient(Origin, ERR_USERNOTINCHANNEL_MSG,
Client_ID(Origin), Client_ID(Target), Name ); Client_ID(Origin), Client_ID(Target), Name );
return; return;
} }
@ -339,7 +339,7 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
|| Client_HasMode(Target, 'q') || Client_HasMode(Target, 'q')
|| Client_Type(Target) == CLIENT_SERVICE) || Client_Type(Target) == CLIENT_SERVICE)
&& !Client_HasMode(Origin, 'o')) { && !Client_HasMode(Origin, 'o')) {
IRC_WriteStrClient(Origin, ERR_KICKDENY_MSG, IRC_WriteErrClient(Origin, ERR_KICKDENY_MSG,
Client_ID(Origin), Name, Client_ID(Origin), Name,
Client_ID(Target)); Client_ID(Target));
return; return;
@ -370,8 +370,8 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
can_kick = true; can_kick = true;
if(!can_kick) { if(!can_kick) {
IRC_WriteStrClient(Origin, ERR_CHANOPPRIVTOOLOW_MSG, IRC_WriteErrClient(Origin, ERR_CHANOPPRIVTOOLOW_MSG,
Client_ID(Origin), Name); Client_ID(Origin), Name);
return; return;
} }
} }
@ -921,10 +921,10 @@ Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Command,
if (! SendErrors) if (! SendErrors)
return CONNECTED; /* no error, see RFC 2812 */ return CONNECTED; /* no error, see RFC 2812 */
if (Channel_HasMode(Chan, 'M')) if (Channel_HasMode(Chan, 'M'))
return IRC_WriteStrClient(From, ERR_NEEDREGGEDNICK_MSG, return IRC_WriteErrClient(From, ERR_NEEDREGGEDNICK_MSG,
Client_ID(From), Channel_Name(Chan)); Client_ID(From), Channel_Name(Chan));
else else
return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG, return IRC_WriteErrClient(From, ERR_CANNOTSENDTOCHAN_MSG,
Client_ID(From), Channel_Name(Chan)); Client_ID(From), Channel_Name(Chan));
} }

View File

@ -1,6 +1,6 @@
/* /*
* ngIRCd -- The Next Generation IRC Daemon * ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2012 Alexander Barton (alex@barton.de) * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -991,11 +991,11 @@ Client_CheckNick(CLIENT *Client, char *Nick)
if (!Client_IsValidNick(Nick)) { if (!Client_IsValidNick(Nick)) {
if (strlen(Nick ) >= Conf_MaxNickLength) if (strlen(Nick ) >= Conf_MaxNickLength)
IRC_WriteStrClient(Client, ERR_NICKNAMETOOLONG_MSG, IRC_WriteErrClient(Client, ERR_NICKNAMETOOLONG_MSG,
Client_ID(Client), Nick, Client_ID(Client), Nick,
Conf_MaxNickLength - 1); Conf_MaxNickLength - 1);
else else
IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG, IRC_WriteErrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
Client_ID(Client), Nick); Client_ID(Client), Nick);
return false; return false;
} }
@ -1004,7 +1004,7 @@ Client_CheckNick(CLIENT *Client, char *Nick)
&& Client_Type(Client) != CLIENT_SERVICE) { && Client_Type(Client) != CLIENT_SERVICE) {
/* Make sure that this isn't a restricted/forbidden nickname */ /* Make sure that this isn't a restricted/forbidden nickname */
if (Conf_NickIsBlocked(Nick)) { if (Conf_NickIsBlocked(Nick)) {
IRC_WriteStrClient(Client, ERR_FORBIDDENNICKNAME_MSG, IRC_WriteErrClient(Client, ERR_FORBIDDENNICKNAME_MSG,
Client_ID(Client), Nick); Client_ID(Client), Nick);
return false; return false;
} }
@ -1012,7 +1012,7 @@ Client_CheckNick(CLIENT *Client, char *Nick)
/* Nickname already registered? */ /* Nickname already registered? */
if (Client_Search(Nick)) { if (Client_Search(Nick)) {
IRC_WriteStrClient(Client, ERR_NICKNAMEINUSE_MSG, IRC_WriteErrClient(Client, ERR_NICKNAMEINUSE_MSG,
Client_ID(Client), Nick); Client_ID(Client), Nick);
return false; return false;
} }
@ -1033,7 +1033,8 @@ Client_CheckID( CLIENT *Client, char *ID )
/* ID too long? */ /* ID too long? */
if (strlen(ID) > CLIENT_ID_LEN) { if (strlen(ID) > CLIENT_ID_LEN) {
IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID(Client), ID); IRC_WriteErrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
Client_ID(Client), ID);
return false; return false;
} }

View File

@ -274,7 +274,7 @@ IRC_CAP(CLIENT *Client, REQUEST *Req)
return Handle_CAP_ACK(Client, Req->argv[1]); return Handle_CAP_ACK(Client, Req->argv[1]);
} }
return IRC_WriteStrClient(Client, ERR_INVALIDCAP_MSG, return IRC_WriteErrClient(Client, ERR_INVALIDCAP_MSG,
Client_ID(Client), Req->argv[0]); Client_ID(Client), Req->argv[0]);
} }

View File

@ -1,6 +1,6 @@
/* /*
* ngIRCd -- The Next Generation IRC Daemon * ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2013 Alexander Barton (alex@barton.de) * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -93,14 +93,14 @@ join_allowed(CLIENT *Client, CHANNEL *chan, const char *channame,
if (is_banned && !is_invited && !is_exception) { if (is_banned && !is_invited && !is_exception) {
/* Client is banned from channel (and not on invite list) */ /* Client is banned from channel (and not on invite list) */
IRC_WriteStrClient(Client, ERR_BANNEDFROMCHAN_MSG, IRC_WriteErrClient(Client, ERR_BANNEDFROMCHAN_MSG,
Client_ID(Client), channame); Client_ID(Client), channame);
return false; return false;
} }
if (Channel_HasMode(chan, 'i') && !is_invited) { if (Channel_HasMode(chan, 'i') && !is_invited) {
/* Channel is "invite-only" and client is not on invite list */ /* Channel is "invite-only" and client is not on invite list */
IRC_WriteStrClient(Client, ERR_INVITEONLYCHAN_MSG, IRC_WriteErrClient(Client, ERR_INVITEONLYCHAN_MSG,
Client_ID(Client), channame); Client_ID(Client), channame);
return false; return false;
} }
@ -108,7 +108,7 @@ join_allowed(CLIENT *Client, CHANNEL *chan, const char *channame,
if (!Channel_CheckKey(chan, Client, key ? key : "")) { if (!Channel_CheckKey(chan, Client, key ? key : "")) {
/* Channel is protected by a channel key and the client /* Channel is protected by a channel key and the client
* didn't specify the correct one */ * didn't specify the correct one */
IRC_WriteStrClient(Client, ERR_BADCHANNELKEY_MSG, IRC_WriteErrClient(Client, ERR_BADCHANNELKEY_MSG,
Client_ID(Client), channame); Client_ID(Client), channame);
return false; return false;
} }
@ -116,7 +116,7 @@ join_allowed(CLIENT *Client, CHANNEL *chan, const char *channame,
if (Channel_HasMode(chan, 'l') && if (Channel_HasMode(chan, 'l') &&
(Channel_MaxUsers(chan) <= Channel_MemberCount(chan))) { (Channel_MaxUsers(chan) <= Channel_MemberCount(chan))) {
/* There are more clints joined to this channel than allowed */ /* There are more clints joined to this channel than allowed */
IRC_WriteStrClient(Client, ERR_CHANNELISFULL_MSG, IRC_WriteErrClient(Client, ERR_CHANNELISFULL_MSG,
Client_ID(Client), channame); Client_ID(Client), channame);
return false; return false;
} }
@ -124,21 +124,21 @@ join_allowed(CLIENT *Client, CHANNEL *chan, const char *channame,
if (Channel_HasMode(chan, 'z') && !Conn_UsesSSL(Client_Conn(Client))) { if (Channel_HasMode(chan, 'z') && !Conn_UsesSSL(Client_Conn(Client))) {
/* Only "secure" clients are allowed, but clients doesn't /* Only "secure" clients are allowed, but clients doesn't
* use SSL encryption */ * use SSL encryption */
IRC_WriteStrClient(Client, ERR_SECURECHANNEL_MSG, IRC_WriteErrClient(Client, ERR_SECURECHANNEL_MSG,
Client_ID(Client), channame); Client_ID(Client), channame);
return false; return false;
} }
if (Channel_HasMode(chan, 'O') && !Client_OperByMe(Client)) { if (Channel_HasMode(chan, 'O') && !Client_OperByMe(Client)) {
/* Only IRC operators are allowed! */ /* Only IRC operators are allowed! */
IRC_WriteStrClient(Client, ERR_OPONLYCHANNEL_MSG, IRC_WriteErrClient(Client, ERR_OPONLYCHANNEL_MSG,
Client_ID(Client), channame); Client_ID(Client), channame);
return false; return false;
} }
if (Channel_HasMode(chan, 'R') && !Client_HasMode(Client, 'R')) { if (Channel_HasMode(chan, 'R') && !Client_HasMode(Client, 'R')) {
/* Only registered users are allowed! */ /* Only registered users are allowed! */
IRC_WriteStrClient(Client, ERR_REGONLYCHANNEL_MSG, IRC_WriteErrClient(Client, ERR_REGONLYCHANNEL_MSG,
Client_ID(Client), channame); Client_ID(Client), channame);
return false; return false;
} }
@ -326,7 +326,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
/* Make sure that "channame" is not the empty string ("JOIN :") */ /* Make sure that "channame" is not the empty string ("JOIN :") */
if (! channame) if (! channame)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
while (channame) { while (channame) {
@ -344,7 +344,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
chan = Channel_Search(channame); chan = Channel_Search(channame);
if (!chan && !strchr(Conf_AllowedChannelTypes, channame[0])) { if (!chan && !strchr(Conf_AllowedChannelTypes, channame[0])) {
/* channel must be created, but forbidden by config */ /* channel must be created, but forbidden by config */
IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG, IRC_WriteErrClient(Client, ERR_NOSUCHCHANNEL_MSG,
Client_ID(Client), channame); Client_ID(Client), channame);
goto join_next; goto join_next;
} }
@ -360,7 +360,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
/* Test if the user has reached the channel limit */ /* Test if the user has reached the channel limit */
if ((Conf_MaxJoins > 0) && if ((Conf_MaxJoins > 0) &&
(Channel_CountForUser(Client) >= Conf_MaxJoins)) { (Channel_CountForUser(Client) >= Conf_MaxJoins)) {
if (!IRC_WriteStrClient(Client, if (!IRC_WriteErrClient(Client,
ERR_TOOMANYCHANNELS_MSG, ERR_TOOMANYCHANNELS_MSG,
Client_ID(Client), channame)) Client_ID(Client), channame))
return DISCONNECTED; return DISCONNECTED;
@ -447,7 +447,7 @@ IRC_PART(CLIENT * Client, REQUEST * Req)
/* Make sure that "chan" is not the empty string ("PART :") */ /* Make sure that "chan" is not the empty string ("PART :") */
if (! chan) if (! chan)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
while (chan) { while (chan) {
@ -489,7 +489,7 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
chan = Channel_Search(Req->argv[0]); chan = Channel_Search(Req->argv[0]);
if (!chan) if (!chan)
return IRC_WriteStrClient(from, ERR_NOSUCHCHANNEL_MSG, return IRC_WriteErrClient(from, ERR_NOSUCHCHANNEL_MSG,
Client_ID(from), Req->argv[0]); Client_ID(from), Req->argv[0]);
/* Only remote servers and channel members are allowed to change the /* Only remote servers and channel members are allowed to change the
@ -499,7 +499,7 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
topic_power = Client_HasMode(from, 'o'); topic_power = Client_HasMode(from, 'o');
if (!Channel_IsMemberOf(chan, from) if (!Channel_IsMemberOf(chan, from)
&& !(Conf_OperCanMode && topic_power)) && !(Conf_OperCanMode && topic_power))
return IRC_WriteStrClient(from, ERR_NOTONCHANNEL_MSG, return IRC_WriteErrClient(from, ERR_NOTONCHANNEL_MSG,
Client_ID(from), Req->argv[0]); Client_ID(from), Req->argv[0]);
} else } else
topic_power = true; topic_power = true;
@ -535,7 +535,7 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
!Channel_UserHasMode(chan, from, 'o') && !Channel_UserHasMode(chan, from, 'o') &&
!Channel_UserHasMode(chan, from, 'a') && !Channel_UserHasMode(chan, from, 'a') &&
!Channel_UserHasMode(chan, from, 'q')) !Channel_UserHasMode(chan, from, 'q'))
return IRC_WriteStrClient(from, ERR_CHANOPRIVSNEEDED_MSG, return IRC_WriteErrClient(from, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(from), Client_ID(from),
Channel_Name(chan)); Channel_Name(chan));
} }
@ -595,7 +595,7 @@ IRC_LIST( CLIENT *Client, REQUEST *Req )
/* Forward to other server? */ /* Forward to other server? */
target = Client_Search(Req->argv[1]); target = Client_Search(Req->argv[1]);
if (! target || Client_Type(target) != CLIENT_SERVER) if (! target || Client_Type(target) != CLIENT_SERVER)
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG, return IRC_WriteErrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Client_ID(Client),
Req->argv[1]); Req->argv[1]);
@ -667,7 +667,7 @@ IRC_CHANINFO( CLIENT *Client, REQUEST *Req )
/* Bad number of parameters? */ /* Bad number of parameters? */
if (Req->argc < 2 || Req->argc == 4 || Req->argc > 5) if (Req->argc < 2 || Req->argc == 4 || Req->argc > 5)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
/* Compatibility kludge */ /* Compatibility kludge */

View File

@ -1,6 +1,6 @@
/* /*
* ngIRCd -- The Next Generation IRC Daemon * ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors. * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -49,14 +49,14 @@ IRC_CHARCONV(CLIENT *Client, REQUEST *Req)
assert (Req != NULL); assert (Req != NULL);
if (Req->argc != 1) if (Req->argc != 1)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
strlcpy(encoding, Req->argv[0], sizeof(encoding)); strlcpy(encoding, Req->argv[0], sizeof(encoding));
ngt_UpperStr(encoding); ngt_UpperStr(encoding);
if (!Conn_SetEncoding(Client_Conn(Client), encoding)) if (!Conn_SetEncoding(Client_Conn(Client), encoding))
return IRC_WriteStrClient(Client, ERR_IP_CHARCONV_MSG, return IRC_WriteErrClient(Client, ERR_IP_CHARCONV_MSG,
Client_ID(Client), encoding); Client_ID(Client), encoding);
return IRC_WriteStrClient(Client, RPL_IP_CHARCONV_MSG, return IRC_WriteStrClient(Client, RPL_IP_CHARCONV_MSG,

View File

@ -903,7 +903,7 @@ IRC_STATS( CLIENT *Client, REQUEST *Req )
case 'k': /* Server-local bans ("K-Lines") */ case 'k': /* Server-local bans ("K-Lines") */
case 'K': case 'K':
if (!Client_HasMode(from, 'o')) if (!Client_HasMode(from, 'o'))
return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG, return IRC_WriteErrClient(from, ERR_NOPRIVILEGES_MSG,
Client_ID(from)); Client_ID(from));
if (query == 'g' || query == 'G') if (query == 'g' || query == 'G')
list = Class_GetList(CLASS_GLINE); list = Class_GetList(CLASS_GLINE);
@ -997,9 +997,7 @@ IRC_SUMMON(CLIENT * Client, UNUSED REQUEST * Req)
{ {
assert(Client != NULL); assert(Client != NULL);
IRC_SetPenalty(Client, 1); return IRC_WriteErrClient(Client, ERR_SUMMONDISABLED_MSG,
return IRC_WriteStrClient(Client, ERR_SUMMONDISABLED_MSG,
Client_ID(Client)); Client_ID(Client));
} /* IRC_SUMMON */ } /* IRC_SUMMON */
@ -1101,9 +1099,7 @@ IRC_USERS(CLIENT * Client, UNUSED REQUEST * Req)
{ {
assert(Client != NULL); assert(Client != NULL);
IRC_SetPenalty(Client, 1); return IRC_WriteErrClient(Client, ERR_USERSDISABLED_MSG,
return IRC_WriteStrClient(Client, ERR_USERSDISABLED_MSG,
Client_ID(Client)); Client_ID(Client));
} /* IRC_USERS */ } /* IRC_USERS */
@ -1168,7 +1164,7 @@ IRC_WHO(CLIENT *Client, REQUEST *Req)
only_ops = true; only_ops = true;
#ifdef STRICT_RFC #ifdef STRICT_RFC
else else
return IRC_WriteStrClient(Client, return IRC_WriteErrClient(Client,
ERR_NEEDMOREPARAMS_MSG, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Client_ID(Client),
Req->command); Req->command);
@ -1217,7 +1213,7 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
/* Bad number of parameters? */ /* Bad number of parameters? */
if (Req->argc < 1 || Req->argc > 2) if (Req->argc < 1 || Req->argc > 2)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client) _IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
@ -1259,7 +1255,7 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
if (!IRC_WHOIS_SendReply(Client, from, c)) if (!IRC_WHOIS_SendReply(Client, from, c))
return DISCONNECTED; return DISCONNECTED;
} else { } else {
if (!IRC_WriteStrClient(Client, if (!IRC_WriteErrClient(Client,
ERR_NOSUCHNICK_MSG, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Client_ID(Client),
query)) query))
@ -1269,7 +1265,7 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
} }
if (got_wildcard) { if (got_wildcard) {
/* we already handled one wildcard query */ /* we already handled one wildcard query */
if (!IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, if (!IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), query)) Client_ID(Client), query))
return DISCONNECTED; return DISCONNECTED;
continue; continue;
@ -1293,7 +1289,7 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
} }
if (match_count == 0) if (match_count == 0)
IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Client_ID(Client),
Req->argv[Req->argc - 1]); Req->argv[Req->argc - 1]);
} }
@ -1326,7 +1322,7 @@ IRC_WHOWAS( CLIENT *Client, REQUEST *Req )
/* Wrong number of parameters? */ /* Wrong number of parameters? */
if (Req->argc < 1) if (Req->argc < 1)
return IRC_WriteStrClient(Client, ERR_NONICKNAMEGIVEN_MSG, return IRC_WriteErrClient(Client, ERR_NONICKNAMEGIVEN_MSG,
Client_ID(Client)); Client_ID(Client));
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 3) _IRC_ARGC_LE_OR_RETURN_(Client, Req, 3)
@ -1381,7 +1377,7 @@ IRC_WHOWAS( CLIENT *Client, REQUEST *Req )
break; break;
} while (i != last); } while (i != last);
if (nc == 0 && !IRC_WriteStrClient(prefix, ERR_WASNOSUCHNICK_MSG, if (nc == 0 && !IRC_WriteErrClient(prefix, ERR_WASNOSUCHNICK_MSG,
Client_ID(prefix), nick)) Client_ID(prefix), nick))
return DISCONNECTED; return DISCONNECTED;
} }
@ -1471,7 +1467,7 @@ IRC_Show_MOTD( CLIENT *Client )
len_tot = array_bytes(&Conf_Motd); len_tot = array_bytes(&Conf_Motd);
if (len_tot == 0 && !Conn_UsesSSL(Client_Conn(Client))) if (len_tot == 0 && !Conn_UsesSSL(Client_Conn(Client)))
return IRC_WriteStrClient(Client, ERR_NOMOTD_MSG, Client_ID(Client)); return IRC_WriteErrClient(Client, ERR_NOMOTD_MSG, Client_ID(Client));
if (!IRC_WriteStrClient(Client, RPL_MOTDSTART_MSG, Client_ID(Client), if (!IRC_WriteStrClient(Client, RPL_MOTDSTART_MSG, Client_ID(Client),
Client_ID(Client_ThisServer()))) Client_ID(Client_ThisServer())))

View File

@ -61,7 +61,7 @@ IRC_PASS( CLIENT *Client, REQUEST *Req )
/* Return an error if this is not a local client */ /* Return an error if this is not a local client */
if (Client_Conn(Client) <= NONE) if (Client_Conn(Client) <= NONE)
return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG, return IRC_WriteErrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
if (Client_Type(Client) == CLIENT_UNKNOWN && Req->argc == 1) { if (Client_Type(Client) == CLIENT_UNKNOWN && Req->argc == 1) {
@ -81,13 +81,11 @@ IRC_PASS( CLIENT *Client, REQUEST *Req )
} else if (Client_Type(Client) == CLIENT_UNKNOWN || } else if (Client_Type(Client) == CLIENT_UNKNOWN ||
Client_Type(Client) == CLIENT_UNKNOWNSERVER) { Client_Type(Client) == CLIENT_UNKNOWNSERVER) {
/* Unregistered connection, but wrong number of arguments: */ /* Unregistered connection, but wrong number of arguments: */
IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
} else { } else {
/* Registered connection, PASS command is not allowed! */ /* Registered connection, PASS command is not allowed! */
IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_ALREADYREGISTRED_MSG,
return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
Client_ID(Client)); Client_ID(Client));
} }
@ -203,18 +201,16 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
if (Client_Type(Client) == CLIENT_SERVER) { if (Client_Type(Client) == CLIENT_SERVER) {
target = Client_Search(Req->prefix); target = Client_Search(Req->prefix);
if (!target) if (!target)
return IRC_WriteStrClient( Client, return IRC_WriteErrClient(Client,
ERR_NOSUCHNICK_MSG, ERR_NOSUCHNICK_MSG,
Client_ID( Client ), Client_ID(Client),
Req->argv[0] ); Req->argv[0]);
} else { } else {
/* Is this a restricted client? */ /* Is this a restricted client? */
if (Client_HasMode(Client, 'r')) { if (Client_HasMode(Client, 'r'))
IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client,
return IRC_WriteStrClient( Client, ERR_RESTRICTED_MSG,
ERR_RESTRICTED_MSG, Client_ID(Client));
Client_ID( Client ));
}
target = Client; target = Client;
} }
@ -275,7 +271,7 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
/* Bad number of parameters? */ /* Bad number of parameters? */
if (Req->argc != 2 && Req->argc != 7) if (Req->argc != 2 && Req->argc != 7)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
if (Req->argc >= 7) { if (Req->argc >= 7) {
@ -343,7 +339,7 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
return CONNECTED; return CONNECTED;
} }
else else
return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG, return IRC_WriteErrClient(Client, ERR_ALREADYREGISTRED_MSG,
Client_ID(Client)); Client_ID(Client));
} /* IRC_NICK */ } /* IRC_NICK */
@ -372,7 +368,7 @@ IRC_SVSNICK(CLIENT *Client, REQUEST *Req)
/* Search the target */ /* Search the target */
target = Client_Search(Req->argv[0]); target = Client_Search(Req->argv[0]);
if (!target || Client_Type(target) != CLIENT_USER) { if (!target || Client_Type(target) != CLIENT_USER) {
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->argv[0]); Client_ID(Client), Req->argv[0]);
} }
@ -470,7 +466,7 @@ IRC_USER(CLIENT * Client, REQUEST * Req)
c = Client_Search(Req->prefix); c = Client_Search(Req->prefix);
if (!c) if (!c)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Client_ID(Client),
Req->prefix); Req->prefix);
@ -490,13 +486,11 @@ IRC_USER(CLIENT * Client, REQUEST * Req)
return CONNECTED; return CONNECTED;
} else if (Client_Type(Client) == CLIENT_USER) { } else if (Client_Type(Client) == CLIENT_USER) {
/* Already registered connection */ /* Already registered connection */
IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_ALREADYREGISTRED_MSG,
return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
Client_ID(Client)); Client_ID(Client));
} else { } else {
/* Unexpected/invalid connection state? */ /* Unexpected/invalid connection state? */
IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_NOTREGISTERED_MSG,
return IRC_WriteStrClient(Client, ERR_NOTREGISTERED_MSG,
Client_ID(Client)); Client_ID(Client));
} }
} /* IRC_USER */ } /* IRC_USER */
@ -523,16 +517,14 @@ IRC_SERVICE(CLIENT *Client, REQUEST *Req)
assert(Req != NULL); assert(Req != NULL);
if (Client_Type(Client) != CLIENT_GOTPASS && if (Client_Type(Client) != CLIENT_GOTPASS &&
Client_Type(Client) != CLIENT_SERVER) { Client_Type(Client) != CLIENT_SERVER)
IRC_SetPenalty(Client, 2); return IRC_WriteErrClient(Client, ERR_ALREADYREGISTRED_MSG,
return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
Client_ID(Client)); Client_ID(Client));
}
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 6) _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 6)
if (Client_Type(Client) != CLIENT_SERVER) if (Client_Type(Client) != CLIENT_SERVER)
return IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG, return IRC_WriteErrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
Client_ID(Client), Req->argv[0]); Client_ID(Client), Req->argv[0]);
nick = Req->argv[0]; nick = Req->argv[0];
@ -609,7 +601,7 @@ IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 4) _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 4)
if (!Conf_WebircPwd[0] || strcmp(Req->argv[0], Conf_WebircPwd) != 0) if (!Conf_WebircPwd[0] || strcmp(Req->argv[0], Conf_WebircPwd) != 0)
return IRC_WriteStrClient(Client, ERR_PASSWDMISMATCH_MSG, return IRC_WriteErrClient(Client, ERR_PASSWDMISMATCH_MSG,
Client_ID(Client)); Client_ID(Client));
LogDebug("Connection %d: got valid WEBIRC command: user=%s, host=%s, ip=%s", LogDebug("Connection %d: got valid WEBIRC command: user=%s, host=%s, ip=%s",
@ -715,7 +707,7 @@ IRC_PING(CLIENT *Client, REQUEST *Req)
assert(Req != NULL); assert(Req != NULL);
if (Req->argc < 1) if (Req->argc < 1)
return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG, return IRC_WriteErrClient(Client, ERR_NOORIGIN_MSG,
Client_ID(Client)); Client_ID(Client));
#ifdef STRICT_RFC #ifdef STRICT_RFC
/* Don't ignore additional arguments when in "strict" mode */ /* Don't ignore additional arguments when in "strict" mode */
@ -727,7 +719,7 @@ IRC_PING(CLIENT *Client, REQUEST *Req)
target = Client_Search(Req->argv[1]); target = Client_Search(Req->argv[1]);
if (!target || Client_Type(target) != CLIENT_SERVER) if (!target || Client_Type(target) != CLIENT_SERVER)
return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->argv[1]); Client_ID(Client), Req->argv[1]);
if (target != Client_ThisServer()) { if (target != Client_ThisServer()) {
@ -737,7 +729,7 @@ IRC_PING(CLIENT *Client, REQUEST *Req)
else else
from = Client; from = Client;
if (!from) if (!from)
return IRC_WriteStrClient(Client, return IRC_WriteErrClient(Client,
ERR_NOSUCHSERVER_MSG, ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->prefix); Client_ID(Client), Req->prefix);
@ -755,7 +747,7 @@ IRC_PING(CLIENT *Client, REQUEST *Req)
} else } else
from = Client_ThisServer(); from = Client_ThisServer();
if (!from) if (!from)
return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->prefix); Client_ID(Client), Req->prefix);
Log(LOG_DEBUG, "Connection %d: got PING, sending PONG ...", Log(LOG_DEBUG, "Connection %d: got PING, sending PONG ...",
@ -795,7 +787,7 @@ IRC_PONG(CLIENT *Client, REQUEST *Req)
/* Wrong number of arguments? */ /* Wrong number of arguments? */
if (Req->argc < 1) { if (Req->argc < 1) {
if (Client_Type(Client) == CLIENT_USER) if (Client_Type(Client) == CLIENT_USER)
return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG, return IRC_WriteErrClient(Client, ERR_NOORIGIN_MSG,
Client_ID(Client)); Client_ID(Client));
else else
return CONNECTED; return CONNECTED;
@ -808,7 +800,7 @@ IRC_PONG(CLIENT *Client, REQUEST *Req)
if (Req->argc == 2 && Client_Type(Client) == CLIENT_SERVER) { if (Req->argc == 2 && Client_Type(Client) == CLIENT_SERVER) {
target = Client_Search(Req->argv[0]); target = Client_Search(Req->argv[0]);
if (!target) if (!target)
return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->argv[0]); Client_ID(Client), Req->argv[0]);
from = Client_Search(Req->prefix); from = Client_Search(Req->prefix);
@ -816,7 +808,7 @@ IRC_PONG(CLIENT *Client, REQUEST *Req)
if (target != Client_ThisServer() && target != from) { if (target != Client_ThisServer() && target != from) {
/* Ok, we have to forward the message. */ /* Ok, we have to forward the message. */
if (!from) if (!from)
return IRC_WriteStrClient(Client, return IRC_WriteErrClient(Client,
ERR_NOSUCHSERVER_MSG, ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->prefix); Client_ID(Client), Req->prefix);

View File

@ -1,6 +1,6 @@
/* /*
* ngIRCd -- The Next Generation IRC Daemon * ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors. * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -52,17 +52,17 @@ IRC_METADATA(CLIENT *Client, REQUEST *Req)
assert(Req != NULL); assert(Req != NULL);
if (Req->argc != 3) if (Req->argc != 3)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
prefix = Client_Search(Req->prefix); prefix = Client_Search(Req->prefix);
if (!prefix) if (!prefix)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix); Client_ID(Client), Req->prefix);
target = Client_Search(Req->argv[0]); target = Client_Search(Req->argv[0]);
if (!target) if (!target)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->argv[0]); Client_ID(Client), Req->argv[0]);
LogDebug("Got \"METADATA\" command from \"%s\" for client \"%s\": \"%s=%s\".", LogDebug("Got \"METADATA\" command from \"%s\" for client \"%s\": \"%s=%s\".",

View File

@ -85,7 +85,7 @@ IRC_MODE( CLIENT *Client, REQUEST *Req )
return Channel_Mode(Client, Req, origin, chan); return Channel_Mode(Client, Req, origin, chan);
/* No target found! */ /* No target found! */
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->argv[0]); Client_ID(Client), Req->argv[0]);
} /* IRC_MODE */ } /* IRC_MODE */
@ -131,7 +131,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
if (Client_Type(Client) == CLIENT_USER) { if (Client_Type(Client) == CLIENT_USER) {
/* Users are only allowed to manipulate their own modes! */ /* Users are only allowed to manipulate their own modes! */
if (Target != Client) if (Target != Client)
return IRC_WriteStrClient(Client, return IRC_WriteErrClient(Client,
ERR_USERSDONTMATCH_MSG, ERR_USERSDONTMATCH_MSG,
Client_ID(Client)); Client_ID(Client));
} }
@ -153,7 +153,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
set = false; set = false;
strcpy(the_modes, "-"); strcpy(the_modes, "-");
} else } else
return IRC_WriteStrClient(Origin, ERR_UMODEUNKNOWNFLAG_MSG, return IRC_WriteErrClient(Origin, ERR_UMODEUNKNOWNFLAG_MSG,
Client_ID(Origin)); Client_ID(Origin));
x[1] = '\0'; x[1] = '\0';
@ -212,13 +212,13 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
x[0] = 'a'; x[0] = 'a';
Client_SetAway(Origin, DEFAULT_AWAY_MSG); Client_SetAway(Origin, DEFAULT_AWAY_MSG);
} else } else
ok = IRC_WriteStrClient(Origin, ok = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG, ERR_NOPRIVILEGES_MSG,
Client_ID(Origin)); Client_ID(Origin));
break; break;
case 'B': /* Bot */ case 'B': /* Bot */
if (Client_HasMode(Client, 'r')) if (Client_HasMode(Client, 'r'))
ok = IRC_WriteStrClient(Origin, ok = IRC_WriteErrClient(Origin,
ERR_RESTRICTED_MSG, ERR_RESTRICTED_MSG,
Client_ID(Origin)); Client_ID(Origin));
else else
@ -230,7 +230,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
|| Client_OperByMe(Origin)) || Client_OperByMe(Origin))
x[0] = 'c'; x[0] = 'c';
else else
ok = IRC_WriteStrClient(Origin, ok = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG, ERR_NOPRIVILEGES_MSG,
Client_ID(Origin)); Client_ID(Origin));
break; break;
@ -239,7 +239,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
Client_SetOperByMe(Target, false); Client_SetOperByMe(Target, false);
x[0] = 'o'; x[0] = 'o';
} else } else
ok = IRC_WriteStrClient(Origin, ok = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG, ERR_NOPRIVILEGES_MSG,
Client_ID(Origin)); Client_ID(Origin));
break; break;
@ -248,7 +248,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
|| Client_OperByMe(Origin)) || Client_OperByMe(Origin))
x[0] = 'q'; x[0] = 'q';
else else
ok = IRC_WriteStrClient(Origin, ok = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG, ERR_NOPRIVILEGES_MSG,
Client_ID(Origin)); Client_ID(Origin));
break; break;
@ -256,7 +256,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
if (set || Client_Type(Client) == CLIENT_SERVER) if (set || Client_Type(Client) == CLIENT_SERVER)
x[0] = 'r'; x[0] = 'r';
else else
ok = IRC_WriteStrClient(Origin, ok = IRC_WriteErrClient(Origin,
ERR_RESTRICTED_MSG, ERR_RESTRICTED_MSG,
Client_ID(Origin)); Client_ID(Origin));
break; break;
@ -264,13 +264,13 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
if (Client_Type(Client) == CLIENT_SERVER) if (Client_Type(Client) == CLIENT_SERVER)
x[0] = 'R'; x[0] = 'R';
else else
ok = IRC_WriteStrClient(Origin, ok = IRC_WriteErrClient(Origin,
ERR_NICKREGISTER_MSG, ERR_NICKREGISTER_MSG,
Client_ID(Origin)); Client_ID(Origin));
break; break;
case 'x': /* Cloak hostname */ case 'x': /* Cloak hostname */
if (Client_HasMode(Client, 'r')) if (Client_HasMode(Client, 'r'))
ok = IRC_WriteStrClient(Origin, ok = IRC_WriteErrClient(Origin,
ERR_RESTRICTED_MSG, ERR_RESTRICTED_MSG,
Client_ID(Origin)); Client_ID(Origin));
else if (!set || Conf_CloakHostModeX[0] else if (!set || Conf_CloakHostModeX[0]
@ -279,7 +279,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
x[0] = 'x'; x[0] = 'x';
send_RPL_HOSTHIDDEN_MSG = true; send_RPL_HOSTHIDDEN_MSG = true;
} else } else
ok = IRC_WriteStrClient(Origin, ok = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG, ERR_NOPRIVILEGES_MSG,
Client_ID(Origin)); Client_ID(Origin));
break; break;
@ -289,7 +289,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
"Unknown mode \"%c%c\" from \"%s\"!?", "Unknown mode \"%c%c\" from \"%s\"!?",
set ? '+' : '-', *mode_ptr, set ? '+' : '-', *mode_ptr,
Client_ID(Origin)); Client_ID(Origin));
ok = IRC_WriteStrClient(Origin, ok = IRC_WriteErrClient(Origin,
ERR_UMODEUNKNOWNFLAG2_MSG, ERR_UMODEUNKNOWNFLAG2_MSG,
Client_ID(Origin), Client_ID(Origin),
set ? '+' : '-', set ? '+' : '-',
@ -447,7 +447,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
is_halfop = is_op = is_admin = is_owner = is_machine = is_oper = false; is_halfop = is_op = is_admin = is_owner = is_machine = is_oper = false;
if (Channel_IsModeless(Channel)) if (Channel_IsModeless(Channel))
return IRC_WriteStrClient(Client, ERR_NOCHANMODES_MSG, return IRC_WriteErrClient(Client, ERR_NOCHANMODES_MSG,
Client_ID(Client), Channel_Name(Channel)); Client_ID(Client), Channel_Name(Channel));
/* Mode request: let's answer it :-) */ /* Mode request: let's answer it :-) */
@ -468,7 +468,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
/* Check if client is member of channel or an oper or an server/service */ /* Check if client is member of channel or an oper or an server/service */
if(!Channel_IsMemberOf(Channel, Client) && !is_oper && !is_machine) if(!Channel_IsMemberOf(Channel, Client) && !is_oper && !is_machine)
return IRC_WriteStrClient(Origin, ERR_NOTONCHANNEL_MSG, return IRC_WriteErrClient(Origin, ERR_NOTONCHANNEL_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -568,7 +568,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
case 'z': /* Secure connections only */ case 'z': /* Secure connections only */
if(!is_oper && !is_machine && !is_owner && if(!is_oper && !is_machine && !is_owner &&
!is_admin && !is_op) { !is_admin && !is_op) {
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Channel_Name(Channel)); Client_ID(Origin), Channel_Name(Channel));
goto chan_exit; goto chan_exit;
@ -584,7 +584,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
is_admin || is_op || is_halfop) is_admin || is_op || is_halfop)
x[0] = *mode_ptr; x[0] = *mode_ptr;
else else
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Channel_Name(Channel)); Client_ID(Origin), Channel_Name(Channel));
break; break;
@ -596,7 +596,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
is_admin || is_op || is_halfop) is_admin || is_op || is_halfop)
x[0] = *mode_ptr; x[0] = *mode_ptr;
else else
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -612,7 +612,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
sizeof(argadd)); sizeof(argadd));
x[0] = *mode_ptr; x[0] = *mode_ptr;
} else { } else {
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -623,7 +623,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
#ifdef STRICT_RFC #ifdef STRICT_RFC
/* Only send error message in "strict" mode, /* Only send error message in "strict" mode,
* this is how ircd2.11 and others behave ... */ * this is how ircd2.11 and others behave ... */
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_NEEDMOREPARAMS_MSG, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command); Client_ID(Origin), Req->command);
#endif #endif
@ -638,7 +638,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
is_admin || is_op || is_halfop) is_admin || is_op || is_halfop)
x[0] = *mode_ptr; x[0] = *mode_ptr;
else else
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -656,7 +656,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
x[0] = *mode_ptr; x[0] = *mode_ptr;
} }
} else { } else {
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -667,7 +667,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
#ifdef STRICT_RFC #ifdef STRICT_RFC
/* Only send error message in "strict" mode, /* Only send error message in "strict" mode,
* this is how ircd2.11 and others behave ... */ * this is how ircd2.11 and others behave ... */
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_NEEDMOREPARAMS_MSG, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command); Client_ID(Origin), Req->command);
#endif #endif
@ -681,14 +681,14 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if(is_oper || is_machine) if(is_oper || is_machine)
x[0] = 'O'; x[0] = 'O';
else else
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG, ERR_NOPRIVILEGES_MSG,
Client_ID(Origin)); Client_ID(Origin));
} else if(is_oper || is_machine || is_owner || } else if(is_oper || is_machine || is_owner ||
is_admin || is_op) is_admin || is_op)
x[0] = 'O'; x[0] = 'O';
else else
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -700,14 +700,14 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if(is_oper || is_machine) if(is_oper || is_machine)
x[0] = 'P'; x[0] = 'P';
else else
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG, ERR_NOPRIVILEGES_MSG,
Client_ID(Origin)); Client_ID(Origin));
} else if(is_oper || is_machine || is_owner || } else if(is_oper || is_machine || is_owner ||
is_admin || is_op) is_admin || is_op)
x[0] = 'P'; x[0] = 'P';
else else
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -716,7 +716,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
case 'q': /* Owner */ case 'q': /* Owner */
case 'a': /* Channel admin */ case 'a': /* Channel admin */
if(!is_oper && !is_machine && !is_owner && !is_admin) { if(!is_oper && !is_machine && !is_owner && !is_admin) {
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPPRIVTOOLOW_MSG, ERR_CHANOPPRIVTOOLOW_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -725,7 +725,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
case 'o': /* Channel operator */ case 'o': /* Channel operator */
if(!is_oper && !is_machine && !is_owner && if(!is_oper && !is_machine && !is_owner &&
!is_admin && !is_op) { !is_admin && !is_op) {
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -734,7 +734,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
case 'h': /* Half Op */ case 'h': /* Half Op */
if(!is_oper && !is_machine && !is_owner && if(!is_oper && !is_machine && !is_owner &&
!is_admin && !is_op) { !is_admin && !is_op) {
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -748,12 +748,12 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (client) if (client)
x[0] = *mode_ptr; x[0] = *mode_ptr;
else else
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_NOSUCHNICK_MSG, ERR_NOSUCHNICK_MSG,
Client_ID(Origin), Client_ID(Origin),
Req->argv[arg_arg]); Req->argv[arg_arg]);
} else { } else {
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -768,7 +768,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
* mode, because most other servers don't do * mode, because most other servers don't do
* it as well and some clients send "wired" * it as well and some clients send "wired"
* MODE commands like "MODE #chan -ooo nick". */ * MODE commands like "MODE #chan -ooo nick". */
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_NEEDMOREPARAMS_MSG, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command); Client_ID(Origin), Req->command);
#endif #endif
@ -793,7 +793,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Client, Channel, Client, Channel,
Req->argv[arg_arg]); Req->argv[arg_arg]);
} else { } else {
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Client_ID(Origin),
Channel_Name(Channel)); Channel_Name(Channel));
@ -820,7 +820,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
"Unknown mode \"%c%c\" from \"%s\" on %s!?", "Unknown mode \"%c%c\" from \"%s\" on %s!?",
set ? '+' : '-', *mode_ptr, set ? '+' : '-', *mode_ptr,
Client_ID(Origin), Channel_Name(Channel)); Client_ID(Origin), Channel_Name(Channel));
connected = IRC_WriteStrClient(Origin, connected = IRC_WriteErrClient(Origin,
ERR_UNKNOWNMODE_MSG, ERR_UNKNOWNMODE_MSG,
Client_ID(Origin), *mode_ptr, Client_ID(Origin), *mode_ptr,
Channel_Name(Channel)); Channel_Name(Channel));
@ -843,12 +843,11 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
/* Validate target client */ /* Validate target client */
if (client && (!Channel_IsMemberOf(Channel, client))) { if (client && (!Channel_IsMemberOf(Channel, client))) {
if (!IRC_WriteStrClient if (!IRC_WriteErrClient(Origin, ERR_USERNOTINCHANNEL_MSG,
(Origin, ERR_USERNOTINCHANNEL_MSG, Client_ID(Origin),
Client_ID(Origin), Client_ID(client), Client_ID(client),
Channel_Name(Channel))) Channel_Name(Channel)))
break; break;
continue; continue;
} }
@ -1008,7 +1007,7 @@ Add_To_List(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
return CONNECTED; return CONNECTED;
if (Client_Type(Client) == CLIENT_USER && if (Client_Type(Client) == CLIENT_USER &&
current_count >= MAX_HNDL_CHANNEL_LISTS) current_count >= MAX_HNDL_CHANNEL_LISTS)
return IRC_WriteStrClient(Client, ERR_LISTFULL_MSG, return IRC_WriteErrClient(Client, ERR_LISTFULL_MSG,
Client_ID(Client), Client_ID(Client),
Channel_Name(Channel), mask, Channel_Name(Channel), mask,
MAX_HNDL_CHANNEL_LISTS); MAX_HNDL_CHANNEL_LISTS);

View File

@ -43,7 +43,8 @@ try_kick(CLIENT *peer, CLIENT* from, const char *nick, const char *channel,
CLIENT *target = Client_Search(nick); CLIENT *target = Client_Search(nick);
if (!target) if (!target)
return IRC_WriteStrClient(from, ERR_NOSUCHNICK_MSG, Client_ID(from), nick); return IRC_WriteErrClient(from, ERR_NOSUCHNICK_MSG,
Client_ID(from), nick);
Channel_Kick(peer, target, from, channel, reason); Channel_Kick(peer, target, from, channel, reason);
return true; return true;
@ -122,7 +123,7 @@ IRC_KICK(CLIENT *Client, REQUEST *Req)
nickCount--; nickCount--;
} }
} else { } else {
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
} }
return true; return true;
@ -152,19 +153,22 @@ IRC_INVITE(CLIENT *Client, REQUEST *Req)
/* Search user */ /* Search user */
target = Client_Search(Req->argv[0]); target = Client_Search(Req->argv[0]);
if (!target || (Client_Type(target) != CLIENT_USER)) if (!target || (Client_Type(target) != CLIENT_USER))
return IRC_WriteStrClient(from, ERR_NOSUCHNICK_MSG, return IRC_WriteErrClient(from, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->argv[0]); Client_ID(Client), Req->argv[0]);
chan = Channel_Search(Req->argv[1]); chan = Channel_Search(Req->argv[1]);
if (chan) { if (chan) {
/* Channel exists. Is the user a valid member of the channel? */ /* Channel exists. Is the user a valid member of the channel? */
if (!Channel_IsMemberOf(chan, from)) if (!Channel_IsMemberOf(chan, from))
return IRC_WriteStrClient(from, ERR_NOTONCHANNEL_MSG, Client_ID(Client), Req->argv[1]); return IRC_WriteErrClient(from, ERR_NOTONCHANNEL_MSG,
Client_ID(Client),
Req->argv[1]);
/* Is the channel "invite-disallow"? */ /* Is the channel "invite-disallow"? */
if (Channel_HasMode(chan, 'V')) if (Channel_HasMode(chan, 'V'))
return IRC_WriteStrClient(from, ERR_NOINVITE_MSG, return IRC_WriteErrClient(from, ERR_NOINVITE_MSG,
Client_ID(from), Channel_Name(chan)); Client_ID(from),
Channel_Name(chan));
/* Is the channel "invite-only"? */ /* Is the channel "invite-only"? */
if (Channel_HasMode(chan, 'i')) { if (Channel_HasMode(chan, 'i')) {
@ -173,15 +177,18 @@ IRC_INVITE(CLIENT *Client, REQUEST *Req)
!Channel_UserHasMode(chan, from, 'a') && !Channel_UserHasMode(chan, from, 'a') &&
!Channel_UserHasMode(chan, from, 'o') && !Channel_UserHasMode(chan, from, 'o') &&
!Channel_UserHasMode(chan, from, 'h')) !Channel_UserHasMode(chan, from, 'h'))
return IRC_WriteStrClient(from, ERR_CHANOPRIVSNEEDED_MSG, return IRC_WriteErrClient(from,
Client_ID(from), Channel_Name(chan)); ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(from),
Channel_Name(chan));
remember = true; remember = true;
} }
/* Is the target user already member of the channel? */ /* Is the target user already member of the channel? */
if (Channel_IsMemberOf(chan, target)) if (Channel_IsMemberOf(chan, target))
return IRC_WriteStrClient(from, ERR_USERONCHANNEL_MSG, return IRC_WriteErrClient(from, ERR_USERONCHANNEL_MSG,
Client_ID(from), Req->argv[0], Req->argv[1]); Client_ID(from),
Req->argv[0], Req->argv[1]);
/* If the target user is banned on that channel: remember invite */ /* If the target user is banned on that channel: remember invite */
if (Lists_Check(Channel_GetListBans(chan), target)) if (Lists_Check(Channel_GetListBans(chan), target))

View File

@ -48,8 +48,7 @@ Bad_OperPass(CLIENT *Client, char *errtoken, char *errmsg)
{ {
Log(LOG_WARNING, "Got invalid OPER from \"%s\": \"%s\" -- %s", Log(LOG_WARNING, "Got invalid OPER from \"%s\": \"%s\" -- %s",
Client_Mask(Client), errtoken, errmsg); Client_Mask(Client), errtoken, errmsg);
IRC_SetPenalty(Client, 3); return IRC_WriteErrClient(Client, ERR_PASSWDMISMATCH_MSG,
return IRC_WriteStrClient(Client, ERR_PASSWDMISMATCH_MSG,
Client_ID(Client)); Client_ID(Client));
} /* Bad_OperPass */ } /* Bad_OperPass */
@ -197,7 +196,7 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req )
/* Bad number of parameters? */ /* Bad number of parameters? */
if (Req->argc != 0) if (Req->argc != 0)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
Log(LOG_NOTICE|LOG_snotice, "Got RESTART command from \"%s\" ...", Log(LOG_NOTICE|LOG_snotice, "Got RESTART command from \"%s\" ...",
@ -229,12 +228,12 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
/* Bad number of parameters? */ /* Bad number of parameters? */
if (Req->argc != 1 && Req->argc != 2 && Req->argc != 3 && if (Req->argc != 1 && Req->argc != 2 && Req->argc != 3 &&
Req->argc != 5 && Req->argc != 6) Req->argc != 5 && Req->argc != 6)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
/* Invalid port number? */ /* Invalid port number? */
if ((Req->argc > 1) && atoi(Req->argv[1]) < 1) if ((Req->argc > 1) && atoi(Req->argv[1]) < 1)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
from = Client; from = Client;
@ -245,14 +244,14 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
if (Client_Type(Client) == CLIENT_SERVER && Req->prefix) if (Client_Type(Client) == CLIENT_SERVER && Req->prefix)
from = Client_Search(Req->prefix); from = Client_Search(Req->prefix);
if (! from) if (! from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix); Client_ID(Client), Req->prefix);
target = (Req->argc == 3) ? Client_Search(Req->argv[2]) target = (Req->argc == 3) ? Client_Search(Req->argv[2])
: Client_Search(Req->argv[5]); : Client_Search(Req->argv[5]);
if (! target || Client_Type(target) != CLIENT_SERVER) if (! target || Client_Type(target) != CLIENT_SERVER)
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG, return IRC_WriteErrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from), Req->argv[0]); Client_ID(from), Req->argv[0]);
} }
if (target != Client_ThisServer()) { if (target != Client_ThisServer()) {
@ -275,7 +274,7 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
switch (Req->argc) { switch (Req->argc) {
case 1: case 1:
if (!Conf_EnablePassiveServer(Req->argv[0])) if (!Conf_EnablePassiveServer(Req->argv[0]))
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG, return IRC_WriteErrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from), Client_ID(from),
Req->argv[0]); Req->argv[0]);
break; break;
@ -284,7 +283,7 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
/* Connect configured server */ /* Connect configured server */
if (!Conf_EnableServer if (!Conf_EnableServer
(Req->argv[0], (UINT16) atoi(Req->argv[1]))) (Req->argv[0], (UINT16) atoi(Req->argv[1])))
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG, return IRC_WriteErrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from), Client_ID(from),
Req->argv[0]); Req->argv[0]);
break; break;
@ -293,7 +292,7 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
if (!Conf_AddServer if (!Conf_AddServer
(Req->argv[0], (UINT16) atoi(Req->argv[1]), Req->argv[2], (Req->argv[0], (UINT16) atoi(Req->argv[1]), Req->argv[2],
Req->argv[3], Req->argv[4])) Req->argv[3], Req->argv[4]))
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG, return IRC_WriteErrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from), Client_ID(from),
Req->argv[0]); Req->argv[0]);
} }
@ -331,7 +330,7 @@ IRC_DISCONNECT(CLIENT * Client, REQUEST * Req)
/* Bad number of parameters? */ /* Bad number of parameters? */
if (Req->argc != 1) if (Req->argc != 1)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
IRC_SendWallops(Client_ThisServer(), Client_ThisServer(), IRC_SendWallops(Client_ThisServer(), Client_ThisServer(),
@ -347,7 +346,7 @@ IRC_DISCONNECT(CLIENT * Client, REQUEST * Req)
/* Disconnect configured server */ /* Disconnect configured server */
if (!Conf_DisableServer(Req->argv[0])) if (!Conf_DisableServer(Req->argv[0]))
return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->argv[0]); Client_ID(Client), Req->argv[0]);
/* Are we still connected or were we killed, too? */ /* Are we still connected or were we killed, too? */
@ -377,7 +376,7 @@ IRC_WALLOPS( CLIENT *Client, REQUEST *Req )
switch (Client_Type(Client)) { switch (Client_Type(Client)) {
case CLIENT_USER: case CLIENT_USER:
if (!Client_OperByMe(Client)) if (!Client_OperByMe(Client))
return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG, return IRC_WriteErrClient(Client, ERR_NOPRIVILEGES_MSG,
Client_ID(Client)); Client_ID(Client));
from = Client; from = Client;
break; break;
@ -389,7 +388,7 @@ IRC_WALLOPS( CLIENT *Client, REQUEST *Req )
} }
if (!from) if (!from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix); Client_ID(Client), Req->prefix);
IRC_SendWallops(Client, from, "%s", Req->argv[0]); IRC_SendWallops(Client, from, "%s", Req->argv[0]);
@ -419,7 +418,7 @@ IRC_xLINE(CLIENT *Client, REQUEST *Req)
/* Bad number of parameters? */ /* Bad number of parameters? */
if (Req->argc != 1 && Req->argc != 3) if (Req->argc != 1 && Req->argc != 3)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
switch(Req->command[0]) { switch(Req->command[0]) {

View File

@ -62,7 +62,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
/* Return an error if this is not a local client */ /* Return an error if this is not a local client */
if (Client_Conn(Client) <= NONE) if (Client_Conn(Client) <= NONE)
return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG, return IRC_WriteErrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
if (Client_Type(Client) == CLIENT_GOTPASS || if (Client_Type(Client) == CLIENT_GOTPASS ||
@ -73,7 +73,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
Client_Conn(Client)); Client_Conn(Client));
if (Req->argc != 2 && Req->argc != 3) if (Req->argc != 2 && Req->argc != 3)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Client_ID(Client),
Req->command); Req->command);
@ -183,7 +183,9 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
{ {
/* New server is being introduced to the network */ /* New server is being introduced to the network */
if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); if (Req->argc != 4)
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
/* check for existing server with same ID */ /* check for existing server with same ID */
if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED; if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
@ -213,7 +215,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
return CONNECTED; return CONNECTED;
} else } else
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
} /* IRC_SERVER */ } /* IRC_SERVER */
@ -336,7 +338,7 @@ IRC_SQUIT(CLIENT * Client, REQUEST * Req)
} else } else
from = Client; from = Client;
if (!from) if (!from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix); Client_ID(Client), Req->prefix);
if (Client_Type(Client) == CLIENT_USER) if (Client_Type(Client) == CLIENT_USER)

View File

@ -41,6 +41,43 @@ static void cb_writeStrServersPrefixFlag PARAMS((CLIENT *Client,
CLIENT *Prefix, void *Buffer)); CLIENT *Prefix, void *Buffer));
static void Send_Marked_Connections PARAMS((CLIENT *Prefix, const char *Buffer)); static void Send_Marked_Connections PARAMS((CLIENT *Prefix, const char *Buffer));
/**
* Send an error message to a client and enforce a penalty time.
*
* @param Client The target client.
* @param Format Format string.
* @return CONNECTED or DISCONNECTED.
*/
#ifdef PROTOTYPES
GLOBAL bool
IRC_WriteErrClient( CLIENT *Client, const char *Format, ... )
#else
GLOBAL bool
IRC_WriteErrClient( Client, Format, va_alist )
CLIENT *Client;
const char *Format;
va_dcl
#endif
{
char buffer[1000];
va_list ap;
assert(Client != NULL);
assert(Format != NULL);
#ifdef PROTOTYPES
va_start(ap, Format);
#else
va_start(ap);
#endif
vsnprintf(buffer, 1000, Format, ap);
va_end(ap);
IRC_SetPenalty(Client, 2);
return IRC_WriteStrClientPrefix(Client, Client_ThisServer(),
"%s", buffer);
}
/** /**
* Send a message to a client. * Send a message to a client.
* *

View File

@ -17,6 +17,8 @@
* Sending IRC commands over the network (header) * Sending IRC commands over the network (header)
*/ */
GLOBAL bool IRC_WriteErrClient PARAMS((CLIENT *Client, const char *Format, ...));
GLOBAL bool IRC_WriteStrClient PARAMS((CLIENT *Client, const char *Format, ...)); GLOBAL bool IRC_WriteStrClient PARAMS((CLIENT *Client, const char *Format, ...));
GLOBAL bool IRC_WriteStrClientPrefix PARAMS((CLIENT *Client, CLIENT *Prefix, GLOBAL bool IRC_WriteStrClientPrefix PARAMS((CLIENT *Client, CLIENT *Prefix,
const char *Format, ...)); const char *Format, ...));

View File

@ -135,7 +135,7 @@ IRC_KILL(CLIENT *Client, REQUEST *Req)
assert (Req != NULL); assert (Req != NULL);
if (Client_Type(Client) != CLIENT_SERVER && !Client_OperByMe(Client)) if (Client_Type(Client) != CLIENT_SERVER && !Client_OperByMe(Client))
return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG, return IRC_WriteErrClient(Client, ERR_NOPRIVILEGES_MSG,
Client_ID(Client)); Client_ID(Client));
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2) _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
@ -192,7 +192,7 @@ IRC_KILL(CLIENT *Client, REQUEST *Req)
msg = ERR_CANTKILLSERVER_MSG; msg = ERR_CANTKILLSERVER_MSG;
else else
msg = ERR_NOPRIVILEGES_MSG; msg = ERR_NOPRIVILEGES_MSG;
return IRC_WriteStrClient(Client, msg, return IRC_WriteErrClient(Client, msg,
Client_ID(Client)); Client_ID(Client));
} }
@ -282,7 +282,7 @@ IRC_TRACE(CLIENT *Client, REQUEST *Req)
/* Bad number of arguments? */ /* Bad number of arguments? */
if (Req->argc > 1) if (Req->argc > 1)
return IRC_WriteStrClient(Client, ERR_NORECIPIENT_MSG, return IRC_WriteErrClient(Client, ERR_NORECIPIENT_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
_IRC_GET_SENDER_OR_RETURN_(from, Req, Client) _IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
@ -490,19 +490,19 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
if (Req->argc == 0) { if (Req->argc == 0) {
if (!SendErrors) if (!SendErrors)
return CONNECTED; return CONNECTED;
return IRC_WriteStrClient(Client, ERR_NORECIPIENT_MSG, return IRC_WriteErrClient(Client, ERR_NORECIPIENT_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
} }
if (Req->argc == 1) { if (Req->argc == 1) {
if (!SendErrors) if (!SendErrors)
return CONNECTED; return CONNECTED;
return IRC_WriteStrClient(Client, ERR_NOTEXTTOSEND_MSG, return IRC_WriteErrClient(Client, ERR_NOTEXTTOSEND_MSG,
Client_ID(Client)); Client_ID(Client));
} }
if (Req->argc > 2) { if (Req->argc > 2) {
if (!SendErrors) if (!SendErrors)
return CONNECTED; return CONNECTED;
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command); Client_ID(Client), Req->command);
} }
@ -511,7 +511,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
else else
from = Client; from = Client;
if (!from) if (!from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix); Client_ID(Client), Req->prefix);
#ifdef ICONV #ifdef ICONV
@ -606,7 +606,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
#else #else
if (Client_Type(cl) != ForceType) { if (Client_Type(cl) != ForceType) {
#endif #endif
if (SendErrors && !IRC_WriteStrClient( if (SendErrors && !IRC_WriteErrClient(
from, ERR_NOSUCHNICK_MSG,Client_ID(from), from, ERR_NOSUCHNICK_MSG,Client_ID(from),
currentTarget)) currentTarget))
return DISCONNECTED; return DISCONNECTED;
@ -627,7 +627,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
!Client_HasMode(from, 'o') && !Client_HasMode(from, 'o') &&
!(Client_Type(from) == CLIENT_SERVER) && !(Client_Type(from) == CLIENT_SERVER) &&
!(Client_Type(from) == CLIENT_SERVICE)) { !(Client_Type(from) == CLIENT_SERVICE)) {
if (SendErrors && !IRC_WriteStrClient(from, if (SendErrors && !IRC_WriteErrClient(from,
ERR_NONONREG_MSG, ERR_NONONREG_MSG,
Client_ID(from), Client_ID(cl))) Client_ID(from), Client_ID(cl)))
return DISCONNECTED; return DISCONNECTED;
@ -643,7 +643,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
cl2chan = Channel_NextChannelOf(cl, cl2chan); cl2chan = Channel_NextChannelOf(cl, cl2chan);
} }
if (!cl2chan) { if (!cl2chan) {
if (SendErrors && !IRC_WriteStrClient( if (SendErrors && !IRC_WriteErrClient(
from, ERR_NOTONSAMECHANNEL_MSG, from, ERR_NOTONSAMECHANNEL_MSG,
Client_ID(from), Client_ID(cl))) Client_ID(from), Client_ID(cl)))
return DISCONNECTED; return DISCONNECTED;
@ -683,7 +683,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
} else { } else {
if (!SendErrors) if (!SendErrors)
return CONNECTED; return CONNECTED;
if (!IRC_WriteStrClient(from, ERR_NOSUCHNICK_MSG, if (!IRC_WriteErrClient(from, ERR_NOSUCHNICK_MSG,
Client_ID(from), currentTarget)) Client_ID(from), currentTarget))
return DISCONNECTED; return DISCONNECTED;
} }
@ -711,7 +711,7 @@ Send_Message_Mask(CLIENT * from, char * command, char * targetMask,
if (!Client_HasMode(from, 'o')) { if (!Client_HasMode(from, 'o')) {
if (!SendErrors) if (!SendErrors)
return true; return true;
return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG, return IRC_WriteErrClient(from, ERR_NOPRIVILEGES_MSG,
Client_ID(from)); Client_ID(from));
} }
@ -726,7 +726,7 @@ Send_Message_Mask(CLIENT * from, char * command, char * targetMask,
{ {
if (!SendErrors) if (!SendErrors)
return true; return true;
return IRC_WriteStrClient(from, ERR_WILDTOPLEVEL, targetMask); return IRC_WriteErrClient(from, ERR_WILDTOPLEVEL, targetMask);
} }
/* #: hostmask, see RFC 2812, sec. 3.3.1 */ /* #: hostmask, see RFC 2812, sec. 3.3.1 */

View File

@ -1,6 +1,6 @@
/* /*
* ngIRCd -- The Next Generation IRC Daemon * ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de) * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -46,12 +46,12 @@ Op_NoPrivileges(CLIENT * Client, REQUEST * Req)
if (from) { if (from) {
Log(LOG_NOTICE, "No privileges: client \"%s\" (%s), command \"%s\"", Log(LOG_NOTICE, "No privileges: client \"%s\" (%s), command \"%s\"",
Req->prefix, Client_Mask(Client), Req->command); Req->prefix, Client_Mask(Client), Req->command);
return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG, return IRC_WriteErrClient(from, ERR_NOPRIVILEGES_MSG,
Client_ID(from)); Client_ID(from));
} else { } else {
Log(LOG_NOTICE, "No privileges: client \"%s\", command \"%s\"", Log(LOG_NOTICE, "No privileges: client \"%s\", command \"%s\"",
Client_Mask(Client), Req->command); Client_Mask(Client), Req->command);
return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG, return IRC_WriteErrClient(Client, ERR_NOPRIVILEGES_MSG,
Client_ID(Client)); Client_ID(Client));
} }
} /* Op_NoPrivileges */ } /* Op_NoPrivileges */

View File

@ -1,6 +1,6 @@
/* /*
* ngIRCd -- The Next Generation IRC Daemon * ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2010 Alexander Barton (alex@barton.de) * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -515,11 +515,11 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
if (!(client_type & cmd->type)) { if (!(client_type & cmd->type)) {
if (client_type == CLIENT_USER if (client_type == CLIENT_USER
&& cmd->type & CLIENT_SERVER) && cmd->type & CLIENT_SERVER)
return IRC_WriteStrClient(client, return IRC_WriteErrClient(client,
ERR_NOTREGISTEREDSERVER_MSG, ERR_NOTREGISTEREDSERVER_MSG,
Client_ID(client)); Client_ID(client));
else else
return IRC_WriteStrClient(client, return IRC_WriteErrClient(client,
ERR_NOTREGISTERED_MSG, ERR_NOTREGISTERED_MSG,
Client_ID(client)); Client_ID(client));
} }
@ -549,11 +549,10 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
Req->argc == 1 ? "parameter" : "parameters", Req->argc == 1 ? "parameter" : "parameters",
Req->prefix ? "" : " no" ); Req->prefix ? "" : " no" );
if (Client_Type(client) != CLIENT_SERVER) { if (Client_Type(client) != CLIENT_SERVER)
result = IRC_WriteStrClient(client, ERR_UNKNOWNCOMMAND_MSG, result = IRC_WriteErrClient(client, ERR_UNKNOWNCOMMAND_MSG,
Client_ID(client), Req->command); Client_ID(client), Req->command);
Conn_SetPenalty(Idx, 1);
}
return result; return result;
} /* Handle_Request */ } /* Handle_Request */