/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors.
+ * Copyright (c)2001-2012 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
}
+GLOBAL struct list_head *
+Channel_GetListExcepts(CHANNEL *c)
+{
+ assert(c != NULL);
+ return &c->list_excepts;
+}
+
+
GLOBAL struct list_head *
Channel_GetListInvites(CHANNEL *c)
{
array_free(&chan->topic);
array_free(&chan->keyfile);
Lists_Free(&chan->list_bans);
+ Lists_Free(&chan->list_excepts);
Lists_Free(&chan->list_invites);
free(chan);
} /* Channel_SetMaxUsers */
+/**
+ * Check if a client is allowed to send to a specific channel.
+ *
+ * @param Chan The channel to check.
+ * @param From The client that wants to send.
+ * @return true if the client is allowed to send, false otherwise.
+ */
static bool
Can_Send_To_Channel(CHANNEL *Chan, CLIENT *From)
{
if (strchr(Channel_Modes(Chan), 'm'))
return false;
+ if (Lists_Check(&Chan->list_excepts, From))
+ return true;
+
return !Lists_Check(&Chan->list_bans, From);
}
Channel_AddBan(CHANNEL *c, const char *mask )
{
struct list_head *h = Channel_GetListBans(c);
- LogDebug("Adding \"%s\" to \"%s\" %s list", mask, Channel_Name(c), "ban");
+ LogDebug("Adding \"%s\" to \"%s\" ban list", mask, Channel_Name(c));
+ return Lists_Add(h, mask, false, NULL);
+}
+
+
+GLOBAL bool
+Channel_AddExcept(CHANNEL *c, const char *mask )
+{
+ 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);
}
Channel_AddInvite(CHANNEL *c, const char *mask, bool onlyonce)
{
struct list_head *h = Channel_GetListInvites(c);
- LogDebug("Adding \"%s\" to \"%s\" %s list", mask, Channel_Name(c), "invite");
+ LogDebug("Adding \"%s\" to \"%s\" invite list", mask, Channel_Name(c));
return Lists_Add(h, mask, onlyonce, NULL);
}
}
+GLOBAL bool
+Channel_ShowExcepts( CLIENT *Client, CHANNEL *Channel )
+{
+ struct list_head *h;
+
+ assert( Channel != NULL );
+
+ h = Channel_GetListExcepts(Channel);
+ return ShowChannelList(h, Client, Channel, RPL_EXCEPTLIST_MSG,
+ RPL_ENDOFEXCEPTLIST_MSG);
+}
+
+
GLOBAL bool
Channel_ShowInvites( CLIENT *Client, CHANNEL *Channel )
{
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors.
+ * Copyright (c)2001-2012 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
char key[CLIENT_PASS_LEN]; /* Channel key ("password", mode "k" ) */
unsigned long maxusers; /* Maximum number of members (mode "l") */
struct list_head list_bans; /* list head of banned users */
+ struct list_head list_excepts; /* list head of (ban) exception list */
struct list_head list_invites; /* list head of invited users */
array keyfile; /* Name of the channel key file */
} CHANNEL;
#endif
GLOBAL struct list_head *Channel_GetListBans PARAMS((CHANNEL *c));
+GLOBAL struct list_head *Channel_GetListExcepts PARAMS((CHANNEL *c));
GLOBAL struct list_head *Channel_GetListInvites PARAMS((CHANNEL *c));
GLOBAL void Channel_Init PARAMS(( void ));
GLOBAL unsigned int Channel_CreationTime PARAMS(( CHANNEL *Chan ));
#endif
-GLOBAL bool Channel_AddInvite PARAMS((CHANNEL *c, const char *Mask, bool OnlyOnce ));
-GLOBAL bool Channel_AddBan PARAMS((CHANNEL *c, const char *Mask ));
+GLOBAL bool Channel_AddBan PARAMS((CHANNEL *c, const char *Mask));
+GLOBAL bool Channel_AddExcept PARAMS((CHANNEL *c, const char *Mask));
+GLOBAL bool Channel_AddInvite PARAMS((CHANNEL *c, const char *Mask,
+ bool OnlyOnce));
GLOBAL bool Channel_ShowBans PARAMS((CLIENT *client, CHANNEL *c));
+GLOBAL bool Channel_ShowExcepts PARAMS((CLIENT *client, CHANNEL *c));
GLOBAL bool Channel_ShowInvites PARAMS((CLIENT *client, CHANNEL *c));
GLOBAL void Channel_LogServer PARAMS((const char *msg));
#define USERMODES "acCiorRswx"
/** Supported channel modes. */
-#define CHANMODES "biIklmnoOPRstvz"
+#define CHANMODES "beiIklmnoOPRstvz"
/** Away message for users connected to linked servers. */
#define DEFAULT_AWAY_MSG "Away"
join_allowed(CLIENT *Client, CHANNEL *chan, const char *channame,
const char *key)
{
- bool is_invited, is_banned;
+ bool is_invited, is_banned, is_exception;;
const char *channel_modes;
/* Allow IRC operators to overwrite channel limits */
return true;
is_banned = Lists_Check(Channel_GetListBans(chan), Client);
+ is_exception = Lists_Check(Channel_GetListExcepts(chan), Client);
is_invited = Lists_Check(Channel_GetListInvites(chan), Client);
- if (is_banned && !is_invited) {
+ if (is_banned && !is_invited && !is_exception) {
/* Client is banned from channel (and not on invite list) */
IRC_WriteStrClient(Client, ERR_BANNEDFROMCHAN_MSG,
Client_ID(Client), channame);
/* --- Channel lists --- */
case 'I': /* Invite lists */
case 'b': /* Ban lists */
+ case 'e': /* Channel exception lists */
if (Mode_Limit_Reached(Client, mode_arg_count++))
goto chan_exit;
if (arg_arg > mode_arg) {
Req->argv[arg_arg][0] = '\0';
arg_arg++;
} else {
- if (*mode_ptr == 'I')
+ switch (*mode_ptr) {
+ case 'I':
Channel_ShowInvites(Origin, Channel);
- else
+ break;
+ case 'b':
Channel_ShowBans(Origin, Channel);
+ break;
+ case 'e':
+ Channel_ShowExcepts(Origin, Channel);
+ break;
+ }
}
break;
default:
/**
* Add entries to channel invite, ban and exception lists.
*
- * @param what Can be 'I' for invite or 'b' for ban list.
+ * @param what Can be 'I' for invite, 'b' for ban, and 'e' for exception list.
* @param Prefix The originator of the command.
* @param Client The sender of the command.
* @param Channel The channel of which the list should be modified.
assert(Client != NULL);
assert(Channel != NULL);
assert(Pattern != NULL);
- assert(what == 'I' || what == 'b');
+ assert(what == 'I' || what == 'b' || what == 'e');
mask = Lists_MakeMask(Pattern);
case 'b':
list = Channel_GetListBans(Channel);
break;
+ case 'e':
+ list = Channel_GetListExcepts(Channel);
+ break;
}
if (Lists_CheckDupeMask(list, mask))
if (!Channel_AddBan(Channel, mask))
return CONNECTED;
break;
+ case 'e':
+ if (!Channel_AddExcept(Channel, mask))
+ return CONNECTED;
+ break;
}
return Send_ListChange(true, what, Prefix, Client, Channel, mask);
}
/**
* Delete entries from channel invite, ban and exeption lists.
*
- * @param what Can be 'I' for invite or 'b' for ban list.
+ * @param what Can be 'I' for invite, 'b' for ban, and 'e' for exception list.
* @param Prefix The originator of the command.
* @param Client The sender of the command.
* @param Channel The channel of which the list should be modified.
assert(Client != NULL);
assert(Channel != NULL);
assert(Pattern != NULL);
- assert(what == 'I' || what == 'b');
+ assert(what == 'I' || what == 'b' || what == 'e');
mask = Lists_MakeMask(Pattern);
case 'b':
list = Channel_GetListBans(Channel);
break;
+ case 'e':
+ list = Channel_GetListExcepts(Channel);
+ break;
}
if (!Lists_CheckDupeMask(list, mask))
/**
- * Send information about changed channel ban/invite lists to clients.
+ * Send information about changed channel invite/ban/exception lists to clients.
*
* @param IsAdd true if the list item has been added, false otherwise.
* @param ModeChar The mode to use (e. g. 'b' or 'I')
#define RPL_YOURHOST_MSG "002 %s :Your host is %s, running version ngircd-%s (%s/%s/%s)"
#define RPL_CREATED_MSG "003 %s :This server has been started %s"
#define RPL_MYINFO_MSG "004 %s %s ngircd-%s %s %s"
-#define RPL_ISUPPORT1_MSG "005 %s RFC2812 IRCD=ngIRCd CASEMAPPING=ascii PREFIX=(ov)@+ CHANTYPES=#&+ CHANMODES=bI,k,l,imnOPRstz CHANLIMIT=#&+:%d :are supported on this server"
-#define RPL_ISUPPORT2_MSG "005 %s CHANNELLEN=%d NICKLEN=%d TOPICLEN=%d AWAYLEN=%d KICKLEN=%d MODES=%d MAXLIST=bI:%d PENALTY :are supported on this server"
+#define RPL_ISUPPORT1_MSG "005 %s RFC2812 IRCD=ngIRCd CASEMAPPING=ascii PREFIX=(ov)@+ CHANTYPES=#&+ CHANMODES=beI,k,l,imnOPRstz CHANLIMIT=#&+:%d :are supported on this server"
+#define RPL_ISUPPORT2_MSG "005 %s CHANNELLEN=%d NICKLEN=%d TOPICLEN=%d AWAYLEN=%d KICKLEN=%d MODES=%d MAXLIST=beI:%d PENALTY :are supported on this server"
#define RPL_TRACELINK_MSG "200 %s Link %s-%s %s %s V%s %ld %d %d"
#define RPL_TRACEOPERATOR_MSG "204 %s Oper 2 :%s"
#define RPL_INVITING_MSG "341 %s %s %s%s"
#define RPL_INVITELIST_MSG "346 %s %s %s"
#define RPL_ENDOFINVITELIST_MSG "347 %s %s :End of channel invite list"
+#define RPL_EXCEPTLIST_MSG "348 %s %s %s"
+#define RPL_ENDOFEXCEPTLIST_MSG "349 %s %s :End of channel exception list"
#define RPL_VERSION_MSG "351 %s %s-%s.%s %s :%s"
#define RPL_WHOREPLY_MSG "352 %s %s %s %s %s %s %s :%d %s"
#define RPL_NAMREPLY_MSG "353 %s %s %s :"