1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-12-12 09:50:29 +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
* 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
* 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 */
if (! Channel_IsValidName(Name)) {
IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG,
IRC_WriteErrClient(Client, ERR_NOSUCHCHANNEL_MSG,
Client_ID(Client), Name);
return false;
}
@ -268,14 +268,14 @@ Channel_Part(CLIENT * Client, CLIENT * Origin, const char *Name, const char *Rea
/* Check that specified channel exists */
chan = Channel_Search(Name);
if (!chan) {
IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG,
IRC_WriteErrClient(Client, ERR_NOSUCHCHANNEL_MSG,
Client_ID(Client), Name);
return false;
}
/* Check that the client is in the channel */
if (!Get_Cl2Chan(chan, Client)) {
IRC_WriteStrClient(Client, ERR_NOTONCHANNEL_MSG,
IRC_WriteErrClient(Client, ERR_NOTONCHANNEL_MSG,
Client_ID(Client), Name);
return false;
}
@ -309,9 +309,9 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
/* Check that channel exists */
chan = Channel_Search( Name );
if( ! chan )
{
IRC_WriteStrClient( Origin, ERR_NOSUCHCHANNEL_MSG, Client_ID( Origin ), Name );
if (!chan) {
IRC_WriteErrClient(Origin, ERR_NOSUCHCHANNEL_MSG,
Client_ID(Origin), Name);
return;
}
@ -319,15 +319,15 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
Client_Type(Origin) != CLIENT_SERVICE) {
/* Check that user is on the specified channel */
if (!Channel_IsMemberOf(chan, Origin)) {
IRC_WriteStrClient( Origin, ERR_NOTONCHANNEL_MSG,
Client_ID(Origin), Name);
IRC_WriteErrClient(Origin, ERR_NOTONCHANNEL_MSG,
Client_ID(Origin), Name);
return;
}
}
/* Check that the client to be kicked is on the specified channel */
if (!Channel_IsMemberOf(chan, Target)) {
IRC_WriteStrClient(Origin, ERR_USERNOTINCHANNEL_MSG,
IRC_WriteErrClient(Origin, ERR_USERNOTINCHANNEL_MSG,
Client_ID(Origin), Client_ID(Target), Name );
return;
}
@ -339,7 +339,7 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
|| Client_HasMode(Target, 'q')
|| Client_Type(Target) == CLIENT_SERVICE)
&& !Client_HasMode(Origin, 'o')) {
IRC_WriteStrClient(Origin, ERR_KICKDENY_MSG,
IRC_WriteErrClient(Origin, ERR_KICKDENY_MSG,
Client_ID(Origin), Name,
Client_ID(Target));
return;
@ -370,8 +370,8 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
can_kick = true;
if(!can_kick) {
IRC_WriteStrClient(Origin, ERR_CHANOPPRIVTOOLOW_MSG,
Client_ID(Origin), Name);
IRC_WriteErrClient(Origin, ERR_CHANOPPRIVTOOLOW_MSG,
Client_ID(Origin), Name);
return;
}
}
@ -921,10 +921,10 @@ Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Command,
if (! SendErrors)
return CONNECTED; /* no error, see RFC 2812 */
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));
else
return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG,
return IRC_WriteErrClient(From, ERR_CANNOTSENDTOCHAN_MSG,
Client_ID(From), Channel_Name(Chan));
}

View File

@ -1,6 +1,6 @@
/*
* 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
* 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 (strlen(Nick ) >= Conf_MaxNickLength)
IRC_WriteStrClient(Client, ERR_NICKNAMETOOLONG_MSG,
IRC_WriteErrClient(Client, ERR_NICKNAMETOOLONG_MSG,
Client_ID(Client), Nick,
Conf_MaxNickLength - 1);
else
IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
IRC_WriteErrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
Client_ID(Client), Nick);
return false;
}
@ -1004,7 +1004,7 @@ Client_CheckNick(CLIENT *Client, char *Nick)
&& Client_Type(Client) != CLIENT_SERVICE) {
/* Make sure that this isn't a restricted/forbidden nickname */
if (Conf_NickIsBlocked(Nick)) {
IRC_WriteStrClient(Client, ERR_FORBIDDENNICKNAME_MSG,
IRC_WriteErrClient(Client, ERR_FORBIDDENNICKNAME_MSG,
Client_ID(Client), Nick);
return false;
}
@ -1012,7 +1012,7 @@ Client_CheckNick(CLIENT *Client, char *Nick)
/* Nickname already registered? */
if (Client_Search(Nick)) {
IRC_WriteStrClient(Client, ERR_NICKNAMEINUSE_MSG,
IRC_WriteErrClient(Client, ERR_NICKNAMEINUSE_MSG,
Client_ID(Client), Nick);
return false;
}
@ -1033,7 +1033,8 @@ Client_CheckID( CLIENT *Client, char *ID )
/* ID too long? */
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;
}

View File

@ -274,7 +274,7 @@ IRC_CAP(CLIENT *Client, REQUEST *Req)
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]);
}

View File

@ -1,6 +1,6 @@
/*
* 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
* 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) {
/* 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);
return false;
}
if (Channel_HasMode(chan, 'i') && !is_invited) {
/* 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);
return false;
}
@ -108,7 +108,7 @@ join_allowed(CLIENT *Client, CHANNEL *chan, const char *channame,
if (!Channel_CheckKey(chan, Client, key ? key : "")) {
/* Channel is protected by a channel key and the client
* didn't specify the correct one */
IRC_WriteStrClient(Client, ERR_BADCHANNELKEY_MSG,
IRC_WriteErrClient(Client, ERR_BADCHANNELKEY_MSG,
Client_ID(Client), channame);
return false;
}
@ -116,7 +116,7 @@ join_allowed(CLIENT *Client, CHANNEL *chan, const char *channame,
if (Channel_HasMode(chan, 'l') &&
(Channel_MaxUsers(chan) <= Channel_MemberCount(chan))) {
/* 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);
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))) {
/* Only "secure" clients are allowed, but clients doesn't
* use SSL encryption */
IRC_WriteStrClient(Client, ERR_SECURECHANNEL_MSG,
IRC_WriteErrClient(Client, ERR_SECURECHANNEL_MSG,
Client_ID(Client), channame);
return false;
}
if (Channel_HasMode(chan, 'O') && !Client_OperByMe(Client)) {
/* Only IRC operators are allowed! */
IRC_WriteStrClient(Client, ERR_OPONLYCHANNEL_MSG,
IRC_WriteErrClient(Client, ERR_OPONLYCHANNEL_MSG,
Client_ID(Client), channame);
return false;
}
if (Channel_HasMode(chan, 'R') && !Client_HasMode(Client, 'R')) {
/* Only registered users are allowed! */
IRC_WriteStrClient(Client, ERR_REGONLYCHANNEL_MSG,
IRC_WriteErrClient(Client, ERR_REGONLYCHANNEL_MSG,
Client_ID(Client), channame);
return false;
}
@ -326,7 +326,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
/* Make sure that "channame" is not the empty string ("JOIN :") */
if (! channame)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
while (channame) {
@ -344,7 +344,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
chan = Channel_Search(channame);
if (!chan && !strchr(Conf_AllowedChannelTypes, channame[0])) {
/* channel must be created, but forbidden by config */
IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG,
IRC_WriteErrClient(Client, ERR_NOSUCHCHANNEL_MSG,
Client_ID(Client), channame);
goto join_next;
}
@ -360,7 +360,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
/* Test if the user has reached the channel limit */
if ((Conf_MaxJoins > 0) &&
(Channel_CountForUser(Client) >= Conf_MaxJoins)) {
if (!IRC_WriteStrClient(Client,
if (!IRC_WriteErrClient(Client,
ERR_TOOMANYCHANNELS_MSG,
Client_ID(Client), channame))
return DISCONNECTED;
@ -447,7 +447,7 @@ IRC_PART(CLIENT * Client, REQUEST * Req)
/* Make sure that "chan" is not the empty string ("PART :") */
if (! chan)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
while (chan) {
@ -489,7 +489,7 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
chan = Channel_Search(Req->argv[0]);
if (!chan)
return IRC_WriteStrClient(from, ERR_NOSUCHCHANNEL_MSG,
return IRC_WriteErrClient(from, ERR_NOSUCHCHANNEL_MSG,
Client_ID(from), Req->argv[0]);
/* 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');
if (!Channel_IsMemberOf(chan, from)
&& !(Conf_OperCanMode && topic_power))
return IRC_WriteStrClient(from, ERR_NOTONCHANNEL_MSG,
return IRC_WriteErrClient(from, ERR_NOTONCHANNEL_MSG,
Client_ID(from), Req->argv[0]);
} else
topic_power = true;
@ -535,7 +535,7 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
!Channel_UserHasMode(chan, from, 'o') &&
!Channel_UserHasMode(chan, from, 'a') &&
!Channel_UserHasMode(chan, from, 'q'))
return IRC_WriteStrClient(from, ERR_CHANOPRIVSNEEDED_MSG,
return IRC_WriteErrClient(from, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(from),
Channel_Name(chan));
}
@ -595,7 +595,7 @@ IRC_LIST( CLIENT *Client, REQUEST *Req )
/* Forward to other server? */
target = Client_Search(Req->argv[1]);
if (! target || Client_Type(target) != CLIENT_SERVER)
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
return IRC_WriteErrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(Client),
Req->argv[1]);
@ -667,7 +667,7 @@ IRC_CHANINFO( CLIENT *Client, REQUEST *Req )
/* Bad number of parameters? */
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);
/* Compatibility kludge */

View File

@ -1,6 +1,6 @@
/*
* 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
* 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);
if (Req->argc != 1)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
strlcpy(encoding, Req->argv[0], sizeof(encoding));
ngt_UpperStr(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);
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':
if (!Client_HasMode(from, 'o'))
return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG,
return IRC_WriteErrClient(from, ERR_NOPRIVILEGES_MSG,
Client_ID(from));
if (query == 'g' || query == 'G')
list = Class_GetList(CLASS_GLINE);
@ -997,9 +997,7 @@ IRC_SUMMON(CLIENT * Client, UNUSED REQUEST * Req)
{
assert(Client != NULL);
IRC_SetPenalty(Client, 1);
return IRC_WriteStrClient(Client, ERR_SUMMONDISABLED_MSG,
return IRC_WriteErrClient(Client, ERR_SUMMONDISABLED_MSG,
Client_ID(Client));
} /* IRC_SUMMON */
@ -1101,9 +1099,7 @@ IRC_USERS(CLIENT * Client, UNUSED REQUEST * Req)
{
assert(Client != NULL);
IRC_SetPenalty(Client, 1);
return IRC_WriteStrClient(Client, ERR_USERSDISABLED_MSG,
return IRC_WriteErrClient(Client, ERR_USERSDISABLED_MSG,
Client_ID(Client));
} /* IRC_USERS */
@ -1168,7 +1164,7 @@ IRC_WHO(CLIENT *Client, REQUEST *Req)
only_ops = true;
#ifdef STRICT_RFC
else
return IRC_WriteStrClient(Client,
return IRC_WriteErrClient(Client,
ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client),
Req->command);
@ -1217,7 +1213,7 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
/* Bad number of parameters? */
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);
_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))
return DISCONNECTED;
} else {
if (!IRC_WriteStrClient(Client,
if (!IRC_WriteErrClient(Client,
ERR_NOSUCHNICK_MSG,
Client_ID(Client),
query))
@ -1269,7 +1265,7 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
}
if (got_wildcard) {
/* we already handled one wildcard query */
if (!IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
if (!IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), query))
return DISCONNECTED;
continue;
@ -1293,7 +1289,7 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
}
if (match_count == 0)
IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client),
Req->argv[Req->argc - 1]);
}
@ -1326,7 +1322,7 @@ IRC_WHOWAS( CLIENT *Client, REQUEST *Req )
/* Wrong number of parameters? */
if (Req->argc < 1)
return IRC_WriteStrClient(Client, ERR_NONICKNAMEGIVEN_MSG,
return IRC_WriteErrClient(Client, ERR_NONICKNAMEGIVEN_MSG,
Client_ID(Client));
_IRC_ARGC_LE_OR_RETURN_(Client, Req, 3)
@ -1381,7 +1377,7 @@ IRC_WHOWAS( CLIENT *Client, REQUEST *Req )
break;
} 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))
return DISCONNECTED;
}
@ -1471,7 +1467,7 @@ IRC_Show_MOTD( CLIENT *Client )
len_tot = array_bytes(&Conf_Motd);
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),
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 */
if (Client_Conn(Client) <= NONE)
return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
return IRC_WriteErrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
Client_ID(Client), Req->command);
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 ||
Client_Type(Client) == CLIENT_UNKNOWNSERVER) {
/* Unregistered connection, but wrong number of arguments: */
IRC_SetPenalty(Client, 2);
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
} else {
/* Registered connection, PASS command is not allowed! */
IRC_SetPenalty(Client, 2);
return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
return IRC_WriteErrClient(Client, ERR_ALREADYREGISTRED_MSG,
Client_ID(Client));
}
@ -203,18 +201,16 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
if (Client_Type(Client) == CLIENT_SERVER) {
target = Client_Search(Req->prefix);
if (!target)
return IRC_WriteStrClient( Client,
ERR_NOSUCHNICK_MSG,
Client_ID( Client ),
Req->argv[0] );
return IRC_WriteErrClient(Client,
ERR_NOSUCHNICK_MSG,
Client_ID(Client),
Req->argv[0]);
} else {
/* Is this a restricted client? */
if (Client_HasMode(Client, 'r')) {
IRC_SetPenalty(Client, 2);
return IRC_WriteStrClient( Client,
ERR_RESTRICTED_MSG,
Client_ID( Client ));
}
if (Client_HasMode(Client, 'r'))
return IRC_WriteErrClient(Client,
ERR_RESTRICTED_MSG,
Client_ID(Client));
target = Client;
}
@ -275,7 +271,7 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
/* Bad number of parameters? */
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);
if (Req->argc >= 7) {
@ -343,7 +339,7 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
return CONNECTED;
}
else
return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
return IRC_WriteErrClient(Client, ERR_ALREADYREGISTRED_MSG,
Client_ID(Client));
} /* IRC_NICK */
@ -372,7 +368,7 @@ IRC_SVSNICK(CLIENT *Client, REQUEST *Req)
/* Search the target */
target = Client_Search(Req->argv[0]);
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]);
}
@ -470,7 +466,7 @@ IRC_USER(CLIENT * Client, REQUEST * Req)
c = Client_Search(Req->prefix);
if (!c)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client),
Req->prefix);
@ -490,13 +486,11 @@ IRC_USER(CLIENT * Client, REQUEST * Req)
return CONNECTED;
} else if (Client_Type(Client) == CLIENT_USER) {
/* Already registered connection */
IRC_SetPenalty(Client, 2);
return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
return IRC_WriteErrClient(Client, ERR_ALREADYREGISTRED_MSG,
Client_ID(Client));
} else {
/* Unexpected/invalid connection state? */
IRC_SetPenalty(Client, 2);
return IRC_WriteStrClient(Client, ERR_NOTREGISTERED_MSG,
return IRC_WriteErrClient(Client, ERR_NOTREGISTERED_MSG,
Client_ID(Client));
}
} /* IRC_USER */
@ -523,16 +517,14 @@ IRC_SERVICE(CLIENT *Client, REQUEST *Req)
assert(Req != NULL);
if (Client_Type(Client) != CLIENT_GOTPASS &&
Client_Type(Client) != CLIENT_SERVER) {
IRC_SetPenalty(Client, 2);
return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
Client_Type(Client) != CLIENT_SERVER)
return IRC_WriteErrClient(Client, ERR_ALREADYREGISTRED_MSG,
Client_ID(Client));
}
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 6)
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]);
nick = Req->argv[0];
@ -609,7 +601,7 @@ IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 4)
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));
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);
if (Req->argc < 1)
return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
return IRC_WriteErrClient(Client, ERR_NOORIGIN_MSG,
Client_ID(Client));
#ifdef STRICT_RFC
/* 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]);
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]);
if (target != Client_ThisServer()) {
@ -737,7 +729,7 @@ IRC_PING(CLIENT *Client, REQUEST *Req)
else
from = Client;
if (!from)
return IRC_WriteStrClient(Client,
return IRC_WriteErrClient(Client,
ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->prefix);
@ -755,7 +747,7 @@ IRC_PING(CLIENT *Client, REQUEST *Req)
} else
from = Client_ThisServer();
if (!from)
return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
return IRC_WriteErrClient(Client, ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->prefix);
Log(LOG_DEBUG, "Connection %d: got PING, sending PONG ...",
@ -795,7 +787,7 @@ IRC_PONG(CLIENT *Client, REQUEST *Req)
/* Wrong number of arguments? */
if (Req->argc < 1) {
if (Client_Type(Client) == CLIENT_USER)
return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
return IRC_WriteErrClient(Client, ERR_NOORIGIN_MSG,
Client_ID(Client));
else
return CONNECTED;
@ -808,7 +800,7 @@ IRC_PONG(CLIENT *Client, REQUEST *Req)
if (Req->argc == 2 && Client_Type(Client) == CLIENT_SERVER) {
target = Client_Search(Req->argv[0]);
if (!target)
return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
return IRC_WriteErrClient(Client, ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->argv[0]);
from = Client_Search(Req->prefix);
@ -816,7 +808,7 @@ IRC_PONG(CLIENT *Client, REQUEST *Req)
if (target != Client_ThisServer() && target != from) {
/* Ok, we have to forward the message. */
if (!from)
return IRC_WriteStrClient(Client,
return IRC_WriteErrClient(Client,
ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->prefix);

View File

@ -1,6 +1,6 @@
/*
* 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
* 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);
if (Req->argc != 3)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
prefix = Client_Search(Req->prefix);
if (!prefix)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix);
target = Client_Search(Req->argv[0]);
if (!target)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->argv[0]);
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);
/* No target found! */
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->argv[0]);
} /* IRC_MODE */
@ -131,7 +131,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
if (Client_Type(Client) == CLIENT_USER) {
/* Users are only allowed to manipulate their own modes! */
if (Target != Client)
return IRC_WriteStrClient(Client,
return IRC_WriteErrClient(Client,
ERR_USERSDONTMATCH_MSG,
Client_ID(Client));
}
@ -153,7 +153,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
set = false;
strcpy(the_modes, "-");
} else
return IRC_WriteStrClient(Origin, ERR_UMODEUNKNOWNFLAG_MSG,
return IRC_WriteErrClient(Origin, ERR_UMODEUNKNOWNFLAG_MSG,
Client_ID(Origin));
x[1] = '\0';
@ -212,13 +212,13 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
x[0] = 'a';
Client_SetAway(Origin, DEFAULT_AWAY_MSG);
} else
ok = IRC_WriteStrClient(Origin,
ok = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG,
Client_ID(Origin));
break;
case 'B': /* Bot */
if (Client_HasMode(Client, 'r'))
ok = IRC_WriteStrClient(Origin,
ok = IRC_WriteErrClient(Origin,
ERR_RESTRICTED_MSG,
Client_ID(Origin));
else
@ -230,7 +230,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
|| Client_OperByMe(Origin))
x[0] = 'c';
else
ok = IRC_WriteStrClient(Origin,
ok = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG,
Client_ID(Origin));
break;
@ -239,7 +239,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
Client_SetOperByMe(Target, false);
x[0] = 'o';
} else
ok = IRC_WriteStrClient(Origin,
ok = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG,
Client_ID(Origin));
break;
@ -248,7 +248,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
|| Client_OperByMe(Origin))
x[0] = 'q';
else
ok = IRC_WriteStrClient(Origin,
ok = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG,
Client_ID(Origin));
break;
@ -256,7 +256,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
if (set || Client_Type(Client) == CLIENT_SERVER)
x[0] = 'r';
else
ok = IRC_WriteStrClient(Origin,
ok = IRC_WriteErrClient(Origin,
ERR_RESTRICTED_MSG,
Client_ID(Origin));
break;
@ -264,13 +264,13 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
if (Client_Type(Client) == CLIENT_SERVER)
x[0] = 'R';
else
ok = IRC_WriteStrClient(Origin,
ok = IRC_WriteErrClient(Origin,
ERR_NICKREGISTER_MSG,
Client_ID(Origin));
break;
case 'x': /* Cloak hostname */
if (Client_HasMode(Client, 'r'))
ok = IRC_WriteStrClient(Origin,
ok = IRC_WriteErrClient(Origin,
ERR_RESTRICTED_MSG,
Client_ID(Origin));
else if (!set || Conf_CloakHostModeX[0]
@ -279,7 +279,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
x[0] = 'x';
send_RPL_HOSTHIDDEN_MSG = true;
} else
ok = IRC_WriteStrClient(Origin,
ok = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG,
Client_ID(Origin));
break;
@ -289,7 +289,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
"Unknown mode \"%c%c\" from \"%s\"!?",
set ? '+' : '-', *mode_ptr,
Client_ID(Origin));
ok = IRC_WriteStrClient(Origin,
ok = IRC_WriteErrClient(Origin,
ERR_UMODEUNKNOWNFLAG2_MSG,
Client_ID(Origin),
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;
if (Channel_IsModeless(Channel))
return IRC_WriteStrClient(Client, ERR_NOCHANMODES_MSG,
return IRC_WriteErrClient(Client, ERR_NOCHANMODES_MSG,
Client_ID(Client), Channel_Name(Channel));
/* 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 */
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),
Channel_Name(Channel));
@ -568,7 +568,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
case 'z': /* Secure connections only */
if(!is_oper && !is_machine && !is_owner &&
!is_admin && !is_op) {
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Channel_Name(Channel));
goto chan_exit;
@ -584,7 +584,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
is_admin || is_op || is_halfop)
x[0] = *mode_ptr;
else
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Channel_Name(Channel));
break;
@ -596,7 +596,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
is_admin || is_op || is_halfop)
x[0] = *mode_ptr;
else
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@ -612,7 +612,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
sizeof(argadd));
x[0] = *mode_ptr;
} else {
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@ -623,7 +623,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
#ifdef STRICT_RFC
/* Only send error message in "strict" mode,
* this is how ircd2.11 and others behave ... */
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command);
#endif
@ -638,7 +638,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
is_admin || is_op || is_halfop)
x[0] = *mode_ptr;
else
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@ -656,7 +656,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
x[0] = *mode_ptr;
}
} else {
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@ -667,7 +667,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
#ifdef STRICT_RFC
/* Only send error message in "strict" mode,
* this is how ircd2.11 and others behave ... */
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command);
#endif
@ -681,14 +681,14 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if(is_oper || is_machine)
x[0] = 'O';
else
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG,
Client_ID(Origin));
} else if(is_oper || is_machine || is_owner ||
is_admin || is_op)
x[0] = 'O';
else
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@ -700,14 +700,14 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if(is_oper || is_machine)
x[0] = 'P';
else
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_NOPRIVILEGES_MSG,
Client_ID(Origin));
} else if(is_oper || is_machine || is_owner ||
is_admin || is_op)
x[0] = 'P';
else
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@ -716,7 +716,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
case 'q': /* Owner */
case 'a': /* Channel admin */
if(!is_oper && !is_machine && !is_owner && !is_admin) {
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPPRIVTOOLOW_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@ -725,7 +725,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
case 'o': /* Channel operator */
if(!is_oper && !is_machine && !is_owner &&
!is_admin && !is_op) {
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@ -734,7 +734,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
case 'h': /* Half Op */
if(!is_oper && !is_machine && !is_owner &&
!is_admin && !is_op) {
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@ -748,12 +748,12 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (client)
x[0] = *mode_ptr;
else
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_NOSUCHNICK_MSG,
Client_ID(Origin),
Req->argv[arg_arg]);
} else {
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
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
* it as well and some clients send "wired"
* MODE commands like "MODE #chan -ooo nick". */
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command);
#endif
@ -793,7 +793,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Client, Channel,
Req->argv[arg_arg]);
} else {
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
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!?",
set ? '+' : '-', *mode_ptr,
Client_ID(Origin), Channel_Name(Channel));
connected = IRC_WriteStrClient(Origin,
connected = IRC_WriteErrClient(Origin,
ERR_UNKNOWNMODE_MSG,
Client_ID(Origin), *mode_ptr,
Channel_Name(Channel));
@ -843,12 +843,11 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
/* Validate target client */
if (client && (!Channel_IsMemberOf(Channel, client))) {
if (!IRC_WriteStrClient
(Origin, ERR_USERNOTINCHANNEL_MSG,
Client_ID(Origin), Client_ID(client),
Channel_Name(Channel)))
if (!IRC_WriteErrClient(Origin, ERR_USERNOTINCHANNEL_MSG,
Client_ID(Origin),
Client_ID(client),
Channel_Name(Channel)))
break;
continue;
}
@ -1008,7 +1007,7 @@ Add_To_List(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
return CONNECTED;
if (Client_Type(Client) == CLIENT_USER &&
current_count >= MAX_HNDL_CHANNEL_LISTS)
return IRC_WriteStrClient(Client, ERR_LISTFULL_MSG,
return IRC_WriteErrClient(Client, ERR_LISTFULL_MSG,
Client_ID(Client),
Channel_Name(Channel), mask,
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);
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);
return true;
@ -122,7 +123,7 @@ IRC_KICK(CLIENT *Client, REQUEST *Req)
nickCount--;
}
} else {
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
}
return true;
@ -152,19 +153,22 @@ IRC_INVITE(CLIENT *Client, REQUEST *Req)
/* Search user */
target = Client_Search(Req->argv[0]);
if (!target || (Client_Type(target) != CLIENT_USER))
return IRC_WriteStrClient(from, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->argv[0]);
return IRC_WriteErrClient(from, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->argv[0]);
chan = Channel_Search(Req->argv[1]);
if (chan) {
/* Channel exists. Is the user a valid member of the channel? */
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"? */
if (Channel_HasMode(chan, 'V'))
return IRC_WriteStrClient(from, ERR_NOINVITE_MSG,
Client_ID(from), Channel_Name(chan));
return IRC_WriteErrClient(from, ERR_NOINVITE_MSG,
Client_ID(from),
Channel_Name(chan));
/* Is the channel "invite-only"? */
if (Channel_HasMode(chan, 'i')) {
@ -173,15 +177,18 @@ IRC_INVITE(CLIENT *Client, REQUEST *Req)
!Channel_UserHasMode(chan, from, 'a') &&
!Channel_UserHasMode(chan, from, 'o') &&
!Channel_UserHasMode(chan, from, 'h'))
return IRC_WriteStrClient(from, ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(from), Channel_Name(chan));
return IRC_WriteErrClient(from,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(from),
Channel_Name(chan));
remember = true;
}
/* Is the target user already member of the channel? */
if (Channel_IsMemberOf(chan, target))
return IRC_WriteStrClient(from, ERR_USERONCHANNEL_MSG,
Client_ID(from), Req->argv[0], Req->argv[1]);
return IRC_WriteErrClient(from, ERR_USERONCHANNEL_MSG,
Client_ID(from),
Req->argv[0], Req->argv[1]);
/* If the target user is banned on that channel: remember invite */
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",
Client_Mask(Client), errtoken, errmsg);
IRC_SetPenalty(Client, 3);
return IRC_WriteStrClient(Client, ERR_PASSWDMISMATCH_MSG,
return IRC_WriteErrClient(Client, ERR_PASSWDMISMATCH_MSG,
Client_ID(Client));
} /* Bad_OperPass */
@ -197,7 +196,7 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req )
/* Bad number of parameters? */
if (Req->argc != 0)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
Log(LOG_NOTICE|LOG_snotice, "Got RESTART command from \"%s\" ...",
@ -229,12 +228,12 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
/* Bad number of parameters? */
if (Req->argc != 1 && Req->argc != 2 && Req->argc != 3 &&
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);
/* Invalid port number? */
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);
from = Client;
@ -245,14 +244,14 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
if (Client_Type(Client) == CLIENT_SERVER && Req->prefix)
from = Client_Search(Req->prefix);
if (! from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix);
return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix);
target = (Req->argc == 3) ? Client_Search(Req->argv[2])
: Client_Search(Req->argv[5]);
if (! target || Client_Type(target) != CLIENT_SERVER)
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from), Req->argv[0]);
return IRC_WriteErrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from), Req->argv[0]);
}
if (target != Client_ThisServer()) {
@ -275,7 +274,7 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
switch (Req->argc) {
case 1:
if (!Conf_EnablePassiveServer(Req->argv[0]))
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
return IRC_WriteErrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from),
Req->argv[0]);
break;
@ -284,7 +283,7 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
/* Connect configured server */
if (!Conf_EnableServer
(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),
Req->argv[0]);
break;
@ -293,7 +292,7 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
if (!Conf_AddServer
(Req->argv[0], (UINT16) atoi(Req->argv[1]), Req->argv[2],
Req->argv[3], Req->argv[4]))
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
return IRC_WriteErrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from),
Req->argv[0]);
}
@ -331,7 +330,7 @@ IRC_DISCONNECT(CLIENT * Client, REQUEST * Req)
/* Bad number of parameters? */
if (Req->argc != 1)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
IRC_SendWallops(Client_ThisServer(), Client_ThisServer(),
@ -347,7 +346,7 @@ IRC_DISCONNECT(CLIENT * Client, REQUEST * Req)
/* Disconnect configured server */
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]);
/* Are we still connected or were we killed, too? */
@ -377,7 +376,7 @@ IRC_WALLOPS( CLIENT *Client, REQUEST *Req )
switch (Client_Type(Client)) {
case CLIENT_USER:
if (!Client_OperByMe(Client))
return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
return IRC_WriteErrClient(Client, ERR_NOPRIVILEGES_MSG,
Client_ID(Client));
from = Client;
break;
@ -389,7 +388,7 @@ IRC_WALLOPS( CLIENT *Client, REQUEST *Req )
}
if (!from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix);
IRC_SendWallops(Client, from, "%s", Req->argv[0]);
@ -419,7 +418,7 @@ IRC_xLINE(CLIENT *Client, REQUEST *Req)
/* Bad number of parameters? */
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);
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 */
if (Client_Conn(Client) <= NONE)
return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
return IRC_WriteErrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
Client_ID(Client), Req->command);
if (Client_Type(Client) == CLIENT_GOTPASS ||
@ -73,7 +73,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
Client_Conn(Client));
if (Req->argc != 2 && Req->argc != 3)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client),
Req->command);
@ -183,7 +183,9 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
{
/* 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 */
if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
@ -213,7 +215,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
return CONNECTED;
} else
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
} /* IRC_SERVER */
@ -336,7 +338,7 @@ IRC_SQUIT(CLIENT * Client, REQUEST * Req)
} else
from = Client;
if (!from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix);
if (Client_Type(Client) == CLIENT_USER)

View File

@ -41,6 +41,43 @@ static void cb_writeStrServersPrefixFlag PARAMS((CLIENT *Client,
CLIENT *Prefix, void *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.
*

View File

@ -17,6 +17,8 @@
* 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_WriteStrClientPrefix PARAMS((CLIENT *Client, CLIENT *Prefix,
const char *Format, ...));

View File

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

View File

@ -1,6 +1,6 @@
/*
* 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
* 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) {
Log(LOG_NOTICE, "No privileges: client \"%s\" (%s), command \"%s\"",
Req->prefix, Client_Mask(Client), Req->command);
return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG,
return IRC_WriteErrClient(from, ERR_NOPRIVILEGES_MSG,
Client_ID(from));
} else {
Log(LOG_NOTICE, "No privileges: client \"%s\", command \"%s\"",
Client_Mask(Client), Req->command);
return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
return IRC_WriteErrClient(Client, ERR_NOPRIVILEGES_MSG,
Client_ID(Client));
}
} /* Op_NoPrivileges */

View File

@ -1,6 +1,6 @@
/*
* 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
* 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 == CLIENT_USER
&& cmd->type & CLIENT_SERVER)
return IRC_WriteStrClient(client,
return IRC_WriteErrClient(client,
ERR_NOTREGISTEREDSERVER_MSG,
Client_ID(client));
else
return IRC_WriteStrClient(client,
return IRC_WriteErrClient(client,
ERR_NOTREGISTERED_MSG,
Client_ID(client));
}
@ -549,11 +549,10 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
Req->argc == 1 ? "parameter" : "parameters",
Req->prefix ? "" : " no" );
if (Client_Type(client) != CLIENT_SERVER) {
result = IRC_WriteStrClient(client, ERR_UNKNOWNCOMMAND_MSG,
if (Client_Type(client) != CLIENT_SERVER)
result = IRC_WriteErrClient(client, ERR_UNKNOWNCOMMAND_MSG,
Client_ID(client), Req->command);
Conn_SetPenalty(Idx, 1);
}
return result;
} /* Handle_Request */