* @param[in] banlist The list of bans to test.
* @return Pointer to a matching ban, or NULL if none exit.
*/
-struct Ban *find_ban(struct Client *cptr, struct Ban *banlist)
+static struct Ban *find_ban_with_nick(struct Client *cptr, const char *nick, struct Ban *banlist)
{
char nu[NICKLEN + USERLEN + 2];
char tmphost[HOSTLEN + 1];
/* Build nick!user and alternate host names. */
ircd_snprintf(0, nu, sizeof(nu), "%s!%s",
- cli_name(cptr), cli_user(cptr)->username);
+ (nick ? nick : cli_name(cptr)), cli_user(cptr)->username);
ircd_ntoa_r(iphost, &cli_ip(cptr));
/* Check for all three possible hosts:
return found;
}
+struct Ban *find_ban(struct Client *cptr, struct Ban *banlist) {
+ return find_ban_with_nick(cptr, NULL, banlist);
+}
+
/**
* This function returns true if the user is banned on the said channel.
* This function will check the ban cache if applicable, otherwise will
}
}
+static int is_banned_with_nick(struct Membership* member, const char *nick) {
+ if (find_ban_with_nick(member->user, nick, member->channel->banlist))
+ return 1;
+ else
+ return 0;
+}
+
/** add a user to a channel.
* adds a user to a channel by adding another link to the channels member
* chain.
*/
if (!member) {
if ((chptr->mode.mode & (MODE_NOPRIVMSGS|MODE_MODERATED)) ||
- ((chptr->mode.mode & MODE_REGONLY) && !IsAccount(cptr)))
+ ((chptr->mode.mode & MODE_REGONLY) && !IsAccount(cptr)) ||
+ ((chptr->mode.mode & MODE_SSLCHAN) && !IsSSL(cptr)))
return 0;
else
return !find_ban(cptr, chptr->banlist);
* the name of the first channel banned on.
*
* @param cptr The client
+ * @param new_nick The new nick of the client
*
* @returns the name of the first channel banned on, or NULL if the user
* can change nicks.
*/
-const char* find_no_nickchange_channel(struct Client* cptr)
+const char* find_no_nickchange_channel(struct Client* cptr, const char *new_nick)
{
if (MyUser(cptr)) {
struct Membership* member;
continue;
if ((member->channel->mode.mode & MODE_MODERATED)
|| (member->channel->mode.mode & MODE_REGONLY && !IsAccount(cptr))
- || is_banned(member))
+ || (member->channel->mode.mode & MODE_SSLCHAN && !IsSSL(cptr))
+ || is_banned(member) || (new_nick && is_banned_with_nick(member, new_nick)))
return member->channel->chname;
}
}
*mbuf++ = 'Q';
if (chptr->mode.mode & MODE_AUDITORIUM)
*mbuf++ = 'u';
+ if (chptr->mode.mode & MODE_SSLCHAN)
+ *mbuf++ = 'S';
if (chptr->mode.limit) {
*mbuf++ = 'l';
ircd_snprintf(0, pbuf, buflen, "%u", chptr->mode.limit);
assert(0 != cptr);
assert(0 != chptr);
- for (lp = chptr->banlist; lp; lp = lp->next) {
- if(!(lp->flags & BAN_EXCEPTION))
- send_reply(cptr, RPL_BANLIST, chptr->chname, lp->banstr,
- lp->who, lp->when);
- }
+ for (lp = chptr->banlist; lp; lp = lp->next)
+ send_reply(cptr, RPL_BANLIST, chptr->chname, lp->banstr, lp->who, lp->when);
send_reply(cptr, RPL_ENDOFBANLIST, chptr->chname);
}
-/** send an exceptionlist to a client for a channel
- *
- * @param cptr Client to send the exceptionlist to.
- * @param chptr Channel whose exceptionlist to send.
- */
-static void send_exception_list(struct Client* cptr, struct Channel* chptr)
-{
- struct Ban* lp;
-
- assert(0 != cptr);
- assert(0 != chptr);
-
- for (lp = chptr->banlist; lp; lp = lp->next) {
- if(lp->flags & BAN_EXCEPTION)
- send_reply(cptr, RPL_EXCEPTIONLIST, chptr->chname, lp->banstr,
- lp->who, lp->when);
- }
-
- send_reply(cptr, RPL_ENDOFEXCEPTIONLIST, chptr->chname);
-}
-
/** Get a channel block, creating if necessary.
* Get Channel block for chname (and allocate a new channel
* block, if it didn't exists before).
MODE_PERSIST, 'z',
MODE_NOCOLOUR, 'c',
MODE_NOCTCP, 'C',
-/* MODE_EXCEPTION, 'e', */
/* MODE_ALTCHAN, 'F', */
/* MODE_NOFLOOD, 'f', */
MODE_ACCESS, 'a',
MODE_NONOTICE, 'N',
MODE_QUARANTINE, 'Q',
MODE_AUDITORIUM, 'u',
+ MODE_SSLCHAN, 'S',
0x0, 0x0
};
static ulong64 local_flags[] = {
bufptr[(*bufptr_i)++] = MB_TYPE(mbuf, i) & MODE_CHANOP ? 'o' : 'v';
totalbuflen -= IRCD_MAX(9, tmp) + 1;
}
- } else if (MB_TYPE(mbuf, i) & (MODE_BAN | MODE_EXCEPTION | MODE_APASS | MODE_UPASS | MODE_ALTCHAN | MODE_NOFLOOD)) {
+ } else if (MB_TYPE(mbuf, i) & (MODE_BAN | MODE_APASS | MODE_UPASS | MODE_ALTCHAN | MODE_NOFLOOD)) {
tmp = strlen(MB_STRING(mbuf, i));
if ((totalbuflen - tmp) <= 0) /* don't overflow buffer */
MB_TYPE(mbuf, i) |= MODE_SAVE; /* save for later */
else {
char mode_char;
- switch(MB_TYPE(mbuf, i) & (MODE_BAN | MODE_EXCEPTION | MODE_APASS | MODE_UPASS | MODE_ALTCHAN | MODE_NOFLOOD))
+ switch(MB_TYPE(mbuf, i) & (MODE_BAN | MODE_APASS | MODE_UPASS | MODE_ALTCHAN | MODE_NOFLOOD))
{
case MODE_APASS:
mode_char = 'A';
case MODE_UPASS:
mode_char = 'U';
break;
- case MODE_EXCEPTION:
- mode_char = 'e';
- break;
case MODE_ALTCHAN:
mode_char = 'F';
break;
build_string(strptr, strptr_i, cli_name(MB_CLIENT(mbuf, i)), 0, ' ');
/* deal with bans... */
- else if (MB_TYPE(mbuf, i) & (MODE_BAN | MODE_EXCEPTION))
+ else if (MB_TYPE(mbuf, i) & (MODE_BAN))
build_string(strptr, strptr_i, MB_STRING(mbuf, i), 0, ' ');
/* deal with keys... */
build_string(strptr, strptr_i, NumNick(MB_CLIENT(mbuf, i)), ' ');
/* deal with modes that take strings */
- else if (MB_TYPE(mbuf, i) & (MODE_KEY | MODE_BAN | MODE_EXCEPTION | MODE_APASS | MODE_UPASS | MODE_ALTCHAN | MODE_NOFLOOD))
+ else if (MB_TYPE(mbuf, i) & (MODE_KEY | MODE_BAN | MODE_APASS | MODE_UPASS | MODE_ALTCHAN | MODE_NOFLOOD))
build_string(strptr, strptr_i, MB_STRING(mbuf, i), 0, ' ');
/*
MODE_TOPICLIMIT | MODE_INVITEONLY | MODE_NOPRIVMSGS | MODE_REGONLY |
MODE_DELJOINS | MODE_WASDELJOINS | MODE_REGISTERED | MODE_PERSIST |
MODE_NOCOLOUR | MODE_NOCTCP | MODE_NOAMSGS | MODE_NONOTICE |
- MODE_QUARANTINE | MODE_AUDITORIUM);
+ MODE_QUARANTINE | MODE_AUDITORIUM | MODE_SSLCHAN);
if (!(mode & ~(MODE_ADD | MODE_DEL))) /* don't add empty modes... */
return;
MODE_PERSIST, 'z',
MODE_NOCOLOUR, 'c',
MODE_NOCTCP, 'C',
-/* MODE_EXCEPTION, 'e', */
MODE_NOAMSGS, 'M',
MODE_NONOTICE, 'N',
MODE_QUARANTINE, 'Q',
MODE_ALTCHAN, 'F',
MODE_ACCESS, 'a',
MODE_AUDITORIUM, 'u',
+ MODE_SSLCHAN, 'S',
MODE_NOFLOOD, 'f',
0x0, 0x0
};
#define DONE_KEY_DEL 0x80 /**< We've removed the key */
#define DONE_UPASS_DEL 0x100 /**< We've removed the user pass */
#define DONE_APASS_DEL 0x200 /**< We've removed the admin pass */
-#define DONE_EXCEPTIONLIST 0x400 /**< We've sent the exception list */
#define DONE_ALTCHAN 0x800 /**< We've set the altchan */
#define DONE_ACCESS 0x1000 /**< We've set the access */
#define DONE_NOFLOOD 0x2000 /**< We've set the noflood options */
if (!IsChannelName(t_str) || !strIsIrcCh(t_str) || strlen(t_str) > IRCD_MIN(CHANNELLEN, feature_int(FEAT_CHANNELLEN)) || t_str[0] == '&') /* only parse it if it's a valid channel name! */
return;
- struct Channel *chptr;
- struct Membership *member;
- if (!(chptr = FindChannel(t_str)))
+ if(!(state->flags & MODE_PARSE_FORCE)) {
+ struct Channel *chptr;
+ struct Membership *member;
+ if (!(chptr = FindChannel(t_str)))
return;
- if(!(member = find_member_link(chptr, state->sptr)))
+ if(!(member = find_member_link(chptr, state->sptr)))
return;
- if(!IsChanOp(member)) {
+ if(!IsChanOp(member)) {
send_notoper(state);
return;
+ }
}
if (!(state->flags & MODE_PARSE_WIPEOUT) &&
modebuf_mode_string(state->mbuf, state->dir | flag_p[0], t_str, 0);
if (state->flags & MODE_PARSE_SET) {
- if (state->dir == MODE_DEL) /* remove the old altchan */
+ if (state->dir == MODE_DEL) { /* remove the old altchan */
*state->chptr->mode.altchan = '\0';
- else
+ state->chptr->mode.mode &= ~flag_p[0];
+ } else {
ircd_strncpy(state->chptr->mode.altchan, t_str, CHANNELLEN);
+ state->chptr->mode.mode |= flag_p[0];
+ }
}
}
modebuf_mode_string(state->mbuf, state->dir | flag_p[0], t_str, 0);
if (state->flags & MODE_PARSE_SET) {
- if (state->dir == MODE_DEL) /* remove the old noflood */
+ if (state->dir == MODE_DEL) { /* remove the old noflood */
*state->chptr->mode.noflood = '\0';
- else
+ state->chptr->mode.mode &= ~flag_p[0];
+ } else {
ircd_strncpy(state->chptr->mode.noflood, t_str, CHANNELLEN);
+ state->chptr->mode.mode |= flag_p[0];
+ }
}
if (state->dir == MODE_ADD) {
state->chptr->mode.noflood_value = noflood_value;
} else {
//removed the mode so free all flood objects
+ state->chptr->mode.noflood_value = 0;
struct Membership *member;
for(member = state->chptr->members; member; member = member->next_member) {
struct MemberFlood *floodnode;
- for(floodnode = member->flood; floodnode; floodnode = floodnode->next_memberflood) {} //simply walk to the end
+ for(floodnode = member->flood;floodnode ; floodnode = floodnode->next_memberflood) {
+ if(floodnode->next_memberflood == NULL) break;
+ } //simply walk to the end
+ if(!floodnode) continue;
floodnode->next_memberflood = free_MemberFlood;
free_MemberFlood = floodnode;
member->flood = NULL;
struct Ban *ban, *newban;
if (state->parc <= 0) { /* Not enough args, send ban list */
- if (MyUser(state->sptr)) {
- if (*flag_p == MODE_EXCEPTION) {
- if (!(state->done & DONE_EXCEPTIONLIST)) {
- send_exception_list(state->sptr, state->chptr);
- state->done |= DONE_EXCEPTIONLIST;
- }
- }
- else {
- if (!(state->done & DONE_BANLIST)) {
- send_ban_list(state->sptr, state->chptr);
- state->done |= DONE_BANLIST;
- }
- }
+ if (MyUser(state->sptr) && !(state->done & DONE_BANLIST)) {
+ send_ban_list(state->sptr, state->chptr);
+ state->done |= DONE_BANLIST;
}
return;
}
} else if (ban->flags & BAN_DEL) { /* Deleted a ban? */
char *bandup;
DupString(bandup, ban->banstr);
- modebuf_mode_string(state->mbuf, MODE_DEL | ((ban->flags & BAN_EXCEPTION) ? MODE_EXCEPTION : MODE_BAN),
- bandup, 1);
+ modebuf_mode_string(state->mbuf, MODE_DEL | MODE_BAN, bandup, 1);
if (state->flags & MODE_PARSE_SET) { /* Ok, make it take effect */
if (prevban) /* clip it out of the list... */
char *bandup;
/* add the ban to the buffer */
DupString(bandup, ban->banstr);
- modebuf_mode_string(state->mbuf, MODE_ADD | ((ban->flags & BAN_EXCEPTION) ? MODE_EXCEPTION : MODE_BAN),
- bandup, 1);
+ modebuf_mode_string(state->mbuf, MODE_ADD | MODE_BAN, bandup, 1);
if (state->flags & MODE_PARSE_SET) { /* create a new ban */
newban = make_ban(ban->banstr);
strcpy(newban->who, ban->who);
newban->when = ban->when;
- newban->flags = ban->flags & (BAN_IPMASK | BAN_EXCEPTION);
+ newban->flags = ban->flags & BAN_IPMASK;
newban->next = state->chptr->banlist; /* and link it in */
state->chptr->banlist = newban;
MODE_PERSIST, 'z',
MODE_NOCOLOUR, 'c',
MODE_NOCTCP, 'C',
-/* MODE_EXCEPTION, 'e',*/
MODE_NOAMSGS, 'M',
MODE_NONOTICE, 'N',
MODE_QUARANTINE, 'Q',
MODE_ALTCHAN, 'F',
MODE_ACCESS, 'a',
MODE_AUDITORIUM, 'u',
+ MODE_SSLCHAN, 'S',
MODE_NOFLOOD, 'f',
MODE_ADD, '+',
MODE_DEL, '-',
if (IsServer(cptr) || feature_bool(FEAT_OPLEVELS))
mode_parse_upass(&state, flag_p);
break;
-
-/* case 'e':
- if(MyUser(state.sptr) && !(state.flags & MODE_PARSE_FORCE) && !feature_bool(FEAT_EXCEPT_ENABLE)) break;*/
case 'b': /* deal with bans */
mode_parse_ban(&state, flag_p);
break;
strcpy(stripped_message, msg);
char p = stripped_message[0];
int p_pos = 0;
- int is_visible = 1, is_ccode = 0; j = 0;
+ int is_visible = 1, is_ccode = 0, i = 0, j = 0;
char codes[5];
- for(int i = 0; p != '\n'; p = stripped_message[++i]) {
- if(c == 3) {
+ for(i = 0; p != '\n'; p = stripped_message[++i]) {
+ if(p == 3) {
j = 0;
is_ccode = 1;
} else if(is_ccode) {
- if((c >= 48 && c <= 57) || c == 44) {
- if(ccode == 1) {
- if(c == 44) {
- ccode = 2;
+ if((p >= 48 && p <= 57) || p == 44) {
+ if(is_ccode == 1) {
+ if(p == 44) {
+ is_ccode = 2;
codes[j++] = 0;
j = 0;
} else
- codes[j++] = c;
+ codes[j++] = p;
} else {
//compare
- if(c != codes[j++]) {
- ccode = 3;
+ if(p != codes[j++]) {
+ is_ccode = 3;
}
}
} else {
//END of color code...
is_ccode = 0;
- if(ccode != 1 && codes[j] != 0) ccode = 3;
- if(ccode == 1) {
+ if(is_ccode != 1 && codes[j] != 0) is_ccode = 3;
+ if(is_ccode == 1) {
codes[j] = 0;
- for(int k = 0; k < j-1; k++) {
+ int k;
+ for(k = 0; k < j-1; k++) {
if(codes[k] != 48) {
is_visible = 1;
goto normalchar;
}
}
is_visible = 0;
- } else if(ccode == 2) {
+ } else if(is_ccode == 2) {
is_visible = 0;
- } else if(ccode == 3) {
+ } else if(is_ccode == 3) {
is_visible = 1;
goto normalchar;
}
}
} else {
- :normalchar
+ normalchar:
if(is_visible)
stripped_message[p_pos++] = p;
}
* --pk910 2011/7/1
*/
int ext_noflood_block(struct Client *cptr, struct Channel *chptr) {
- if(!chptr->mode.noflood) return 0;
+ if(!*chptr->mode.noflood) return 0;
struct Membership *member = find_member_link(chptr, cptr);
if(!member) return 0; //TODO: we've no check for -n channels implemented, yet
//check if this user is really affected by +f
unsigned int flags = (chptr->mode.noflood_value & 0x00000007); //0000 0000 0000 0000 0000 0000 0000 0111 = 0x00000007 >> 0
unsigned int count = (chptr->mode.noflood_value & 0x00001ff8) >> 3; //0000 0000 0000 0000 0001 1111 1111 1000 = 0x00001ff8 >> 3
int time = (chptr->mode.noflood_value & 0x07ffe000) >> 13; //0000 0111 1111 1111 1110 0000 0000 0000 = 0x07ffe000 >> 13
+ if(count == 0 || time == 0) return 0;
if(!(flags & FLFL_NOFLOOD) && HasPriv(cptr, PRIV_FLOOD))
return 0;
if(!(flags & FLFL_CHANOP) && (member->status & CHFL_CHANOP))