/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
+ * Copyright (c)2001-2014 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
* Channel management
*/
-#include "imp.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <strings.h>
+#include <time.h>
-#include "defines.h"
#include "conn-func.h"
-#include "exp.h"
#include "channel.h"
-#include "imp.h"
#include "irc-write.h"
#include "conf.h"
#include "hash.h"
-#include "lists.h"
#include "log.h"
#include "messages.h"
#include "match.h"
-#include "exp.h"
-
-
#define REMOVE_PART 0
#define REMOVE_QUIT 1
#define REMOVE_KICK 2
-
static CHANNEL *My_Channels;
static CL2CHAN *My_Cl2Chan;
-
static CL2CHAN *Get_Cl2Chan PARAMS(( CHANNEL *Chan, CLIENT *Client ));
static CL2CHAN *Add_Client PARAMS(( CHANNEL *Chan, CLIENT *Client ));
static bool Remove_Client PARAMS(( int Type, CHANNEL *Chan, CLIENT *Client, CLIENT *Origin, const char *Reason, bool InformServer ));
/* 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;
}
/* 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;
}
/* 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;
}
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;
}
|| 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;
!Channel_UserHasMode(chan, Target, 'a') &&
!Channel_UserHasMode(chan, Target, 'o'))
can_kick = true;
+
+ /* IRC operators & IRCd with OperCanMode enabled
+ * can kick anyways regardless of privilege */
+ else if(Client_HasMode(Origin, 'o') && Conf_OperCanMode)
+ 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;
}
}
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));
}
if (Client_Conn(From) > NONE)
Conn_UpdateIdle(Client_Conn(From));
- return IRC_WriteStrChannelPrefix(Client, Chan, From, true,
- "%s %s :%s", Command, Channel_Name(Chan), Text);
+ IRC_WriteStrChannelPrefix(Client, Chan, From, true, "%s %s :%s",
+ Command, Channel_Name(Chan), Text);
+ return CONNECTED;
}
GLOBAL bool
-Channel_AddBan(CHANNEL *c, const char *mask )
+Channel_AddBan(CHANNEL *c, const char *mask, const char *who )
{
struct list_head *h = Channel_GetListBans(c);
LogDebug("Adding \"%s\" to \"%s\" ban list", mask, Channel_Name(c));
- return Lists_Add(h, mask, false, NULL);
+ return Lists_Add(h, mask, time(NULL), who, false);
}
GLOBAL bool
-Channel_AddExcept(CHANNEL *c, const char *mask )
+Channel_AddExcept(CHANNEL *c, const char *mask, const char *who )
{
struct list_head *h = Channel_GetListExcepts(c);
LogDebug("Adding \"%s\" to \"%s\" exception list", mask, Channel_Name(c));
- return Lists_Add(h, mask, false, NULL);
+ return Lists_Add(h, mask, time(NULL), who, false);
}
GLOBAL bool
-Channel_AddInvite(CHANNEL *c, const char *mask, bool onlyonce)
+Channel_AddInvite(CHANNEL *c, const char *mask, bool onlyonce, const char *who )
{
struct list_head *h = Channel_GetListInvites(c);
LogDebug("Adding \"%s\" to \"%s\" invite list", mask, Channel_Name(c));
- return Lists_Add(h, mask, onlyonce, NULL);
+ return Lists_Add(h, mask, time(NULL), who, onlyonce);
}
while (e) {
if (!IRC_WriteStrClient(Client, msg, Client_ID(Client),
Channel_Name(Channel),
- Lists_GetMask(e)))
+ Lists_GetMask(e),
+ Lists_GetReason(e),
+ Lists_GetValidity(e)))
return DISCONNECTED;
e = Lists_GetNext(e);
}