Limit channel invite and ban lists to 50 entries
- New function Lists_Count(). - New limit #define MAX_HNDL_CHANNEL_LISTS = 50. - New numeric #define ERR_LISTFULL_MSG(478). - Adjust numeric RPL_ISUPPORT2_MSG(005) accordingly ("MAXLIST")
This commit is contained in:
parent
1afbf71236
commit
2f7d0c0839
@ -181,6 +181,9 @@
|
|||||||
/** Max. number of LIST replies. */
|
/** Max. number of LIST replies. */
|
||||||
#define MAX_RPL_LIST 100
|
#define MAX_RPL_LIST 100
|
||||||
|
|
||||||
|
/** Max. number of elemets allowed in channel invite and ban lists. */
|
||||||
|
#define MAX_HNDL_CHANNEL_LISTS 50
|
||||||
|
|
||||||
/** Max. number of channel modes with arguments per MODE command. */
|
/** Max. number of channel modes with arguments per MODE command. */
|
||||||
#define MAX_HNDL_MODES_ARG 5
|
#define MAX_HNDL_MODES_ARG 5
|
||||||
|
|
||||||
|
@ -1583,7 +1583,8 @@ IRC_Send_ISUPPORT(CLIENT * Client)
|
|||||||
return IRC_WriteStrClient(Client, RPL_ISUPPORT2_MSG, Client_ID(Client),
|
return IRC_WriteStrClient(Client, RPL_ISUPPORT2_MSG, Client_ID(Client),
|
||||||
CHANNEL_NAME_LEN - 1, Conf_MaxNickLength - 1,
|
CHANNEL_NAME_LEN - 1, Conf_MaxNickLength - 1,
|
||||||
COMMAND_LEN - 23, CLIENT_AWAY_LEN - 1,
|
COMMAND_LEN - 23, CLIENT_AWAY_LEN - 1,
|
||||||
COMMAND_LEN - 113, MAX_HNDL_MODES_ARG);
|
COMMAND_LEN - 113, MAX_HNDL_MODES_ARG,
|
||||||
|
MAX_HNDL_CHANNEL_LISTS);
|
||||||
} /* IRC_Send_ISUPPORT */
|
} /* IRC_Send_ISUPPORT */
|
||||||
|
|
||||||
|
|
||||||
|
@ -863,6 +863,12 @@ Add_Ban_Invite(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
|
|||||||
|
|
||||||
if (Lists_CheckDupeMask(list, mask))
|
if (Lists_CheckDupeMask(list, mask))
|
||||||
return CONNECTED;
|
return CONNECTED;
|
||||||
|
if (Client_Type(Client) == CLIENT_USER &&
|
||||||
|
Lists_Count(list) >= MAX_HNDL_CHANNEL_LISTS)
|
||||||
|
return IRC_WriteStrClient(Client, ERR_LISTFULL_MSG,
|
||||||
|
Client_ID(Client),
|
||||||
|
Channel_Name(Channel), mask,
|
||||||
|
MAX_HNDL_CHANNEL_LISTS);
|
||||||
|
|
||||||
if (what == 'I') {
|
if (what == 'I') {
|
||||||
if (!Channel_AddInvite(Channel, mask, false))
|
if (!Channel_AddInvite(Channel, mask, false))
|
||||||
|
@ -385,4 +385,26 @@ Lists_Expire(struct list_head *h, const char *ListName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the number of entries of a list.
|
||||||
|
*
|
||||||
|
* @param h List head.
|
||||||
|
* @return Number of items.
|
||||||
|
*/
|
||||||
|
GLOBAL unsigned long
|
||||||
|
Lists_Count(struct list_head *h)
|
||||||
|
{
|
||||||
|
struct list_elem *e;
|
||||||
|
unsigned long count = 0;
|
||||||
|
|
||||||
|
assert(h != NULL);
|
||||||
|
|
||||||
|
e = h->first;
|
||||||
|
while (e) {
|
||||||
|
count++;
|
||||||
|
e = e->next;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
/* -eof- */
|
/* -eof- */
|
||||||
|
@ -36,6 +36,7 @@ GLOBAL struct list_elem *Lists_CheckDupeMask PARAMS((const struct list_head *hea
|
|||||||
GLOBAL bool Lists_Add PARAMS((struct list_head *h, const char *Mask,
|
GLOBAL bool Lists_Add PARAMS((struct list_head *h, const char *Mask,
|
||||||
time_t ValidUntil, const char *Reason));
|
time_t ValidUntil, const char *Reason));
|
||||||
GLOBAL void Lists_Del PARAMS((struct list_head *head, const char *Mask));
|
GLOBAL void Lists_Del PARAMS((struct list_head *head, const char *Mask));
|
||||||
|
GLOBAL unsigned long Lists_Count PARAMS((struct list_head *h));
|
||||||
|
|
||||||
GLOBAL void Lists_Free PARAMS((struct list_head *head));
|
GLOBAL void Lists_Free PARAMS((struct list_head *head));
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#define RPL_CREATED_MSG "003 %s :This server has been started %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_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_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 PENALTY :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_TRACELINK_MSG "200 %s Link %s-%s %s %s V%s %ld %d %d"
|
#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_TRACEOPERATOR_MSG "204 %s Oper 2 :%s"
|
||||||
@ -127,6 +127,7 @@
|
|||||||
#define ERR_BANNEDFROMCHAN_MSG "474 %s %s :Cannot join channel (+b)"
|
#define ERR_BANNEDFROMCHAN_MSG "474 %s %s :Cannot join channel (+b)"
|
||||||
#define ERR_BADCHANNELKEY_MSG "475 %s %s :Cannot join channel (+k)"
|
#define ERR_BADCHANNELKEY_MSG "475 %s %s :Cannot join channel (+k)"
|
||||||
#define ERR_NOCHANMODES_MSG "477 %s %s :Channel doesn't support modes"
|
#define ERR_NOCHANMODES_MSG "477 %s %s :Channel doesn't support modes"
|
||||||
|
#define ERR_LISTFULL_MSG "478 %s %s %s: Channel list is full (%d)"
|
||||||
#define ERR_NOPRIVILEGES_MSG "481 %s :Permission denied"
|
#define ERR_NOPRIVILEGES_MSG "481 %s :Permission denied"
|
||||||
#define ERR_CHANOPRIVSNEEDED_MSG "482 %s %s :You are not channel operator"
|
#define ERR_CHANOPRIVSNEEDED_MSG "482 %s %s :You are not channel operator"
|
||||||
#define ERR_CANTKILLSERVER_MSG "483 %s :You can't kill a server!"
|
#define ERR_CANTKILLSERVER_MSG "483 %s :You can't kill a server!"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user