#include "hash.h"
#include "ircd.h"
#include "ircd_alloc.h"
-#include "ircd_policy.h"
+#include "ircd_features.h"
#include "ircd_reply.h"
#include "ircd_string.h"
#include "list.h"
* the TS in the BURST message, then we cancel all existing modes.
* If its is smaller then the received BURST message is ignored.
* If it's equal, then the received modes are just added.
+ *
+ * BURST is also accepted outside a netburst now because it
+ * is sent upstream as reaction to a DESTRUCT message. For
+ * these BURST messages it is possible that the listed channel
+ * members are already joined.
*/
int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
{
struct ModeBuf modebuf, *mbuf = 0;
struct Channel *chptr;
time_t timestamp;
- struct Membership *member;
+ struct Membership *member, *nmember;
struct SLink *lp, **lp_p;
unsigned int parse_flags = (MODE_PARSE_FORCE | MODE_PARSE_BURST);
int param, nickpos = 0, banpos = 0;
if (parc < 3)
return protocol_violation(sptr,"Too few parameters for BURST");
- if (!IsBurst(sptr)) /* don't allow BURST outside of burst */
- return exit_client_msg(cptr, cptr, &me, "HACK: BURST message outside "
- "net.burst from %s", cli_name(sptr));
-
if (!(chptr = get_channel(sptr, parv[1], CGT_CREATE)))
return 0; /* can't create the channel? */
timestamp = atoi(parv[2]);
+ if (!chptr->creationtime || chptr->creationtime > timestamp) {
+ /*
+ * Kick local members if channel is +i or +k and our TS was larger
+ * than the burst TS (anti net.ride). The modes hack is here because
+ * we have to do this before mode_parse, as chptr may go away.
+ */
+ for (param = 3; param < parc; param++)
+ {
+ if (parv[param][0] != '+')
+ continue;
+ if (strchr(parv[param], 'i') || strchr(parv[param], 'k'))
+ {
+ /* Clear any outstanding rogue invites */
+ mode_invite_clear(chptr);
+ for (member = chptr->members; member; member = nmember)
+ {
+ nmember = member->next_member;
+ if (!MyUser(member->user) || IsZombie(member))
+ continue;
+ sendcmdto_serv_butone(&me, CMD_KICK, NULL, "%H %C :Net Rider", chptr, member->user);
+ sendcmdto_channel_butserv_butone(&me, CMD_KICK, chptr, NULL, 0, "%H %C :Net Rider", chptr, member->user);
+ make_zombie(member, member->user, &me, &me, chptr);
+ }
+ }
+ break;
+ }
+
+ /* If the channel had only locals, it went away by now. */
+ if (!(chptr = get_channel(sptr, parv[1], CGT_CREATE)))
+ return 0; /* can't create the channel? */
+ }
+
/* turn off burst joined flag */
for (member = chptr->members; member; member = member->next_member)
- member->status &= ~CHFL_BURST_JOINED;
+ member->status &= ~(CHFL_BURST_JOINED|CHFL_BURST_ALREADY_OPPED|CHFL_BURST_ALREADY_VOICED);
if (!chptr->creationtime) /* mark channel as created during BURST */
chptr->mode.mode |= MODE_BURSTADDED;
if (!chptr->creationtime || chptr->creationtime > timestamp) {
chptr->creationtime = timestamp;
- modebuf_init(mbuf = &modebuf, &me, cptr, chptr, MODEBUF_DEST_CHANNEL);
+ modebuf_init(mbuf = &modebuf, &me, cptr, chptr,
+ MODEBUF_DEST_CHANNEL | MODEBUF_DEST_NOKEY);
modebuf_mode(mbuf, MODE_DEL | chptr->mode.mode); /* wipeout modes */
chptr->mode.mode &= ~(MODE_ADD | MODE_DEL | MODE_PRIVATE | MODE_SECRET |
MODE_MODERATED | MODE_TOPICLIMIT | MODE_INVITEONLY |
- MODE_NOPRIVMSGS);
+ MODE_NOPRIVMSGS | MODE_DELJOINS);
parse_flags |= (MODE_PARSE_SET | MODE_PARSE_WIPEOUT); /* wipeout keys */
/* mark bans for wipeout */
for (lp = chptr->banlist; lp; lp = lp->next)
lp->flags |= CHFL_BURST_BAN_WIPEOUT;
+
+ /* clear topic set by netrider (if set) */
+ if (*chptr->topic) {
+ *chptr->topic = '\0';
+ *chptr->topic_nick = '\0';
+ chptr->topic_time = 0;
+ sendcmdto_channel_butserv_butone(&me, CMD_TOPIC, chptr, NULL, 0,
+ "%H :%s", chptr, chptr->topic);
+ }
} else if (chptr->creationtime == timestamp) {
- modebuf_init(mbuf = &modebuf, &me, cptr, chptr, MODEBUF_DEST_CHANNEL);
+ modebuf_init(mbuf = &modebuf, &me, cptr, chptr,
+ MODEBUF_DEST_CHANNEL | MODEBUF_DEST_NOKEY);
parse_flags |= MODE_PARSE_SET; /* set new modes */
}
newban = make_link(); /* create new ban */
DupString(newban->value.ban.banstr, ban);
-#ifdef HEAD_IN_SAND_BANWHO
- DupString(newban->value.ban.who, cli_name(&me));
-#else
- DupString(newban->value.ban.who, cli_name(sptr));
-#endif
+
+ DupString(newban->value.ban.who,
+ cli_name(feature_bool(FEAT_HIS_BANWHO) ? &me : sptr));
newban->value.ban.when = TStime();
newban->flags = CHFL_BAN | CHFL_BURST_BAN; /* set flags */
{
struct Client *acptr;
char *nicklist = parv[param], *p = 0, *nick, *ptr;
- int current_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
- int last_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
+ int current_mode, last_mode, base_mode;
int oplevel = -1; /* Mark first field with digits: means the same as 'o' (but with level). */
int last_oplevel = 0;
+ struct Membership* member;
+
+ base_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
+ if (chptr->mode.mode & MODE_DELJOINS)
+ base_mode |= CHFL_DELAYED;
+ current_mode = last_mode = base_mode;
for (nick = ircd_strtok(&p, nicklist, ","); nick;
nick = ircd_strtok(&p, 0, ",")) {
*/
oplevel = MAXOPLEVEL;
if (current_mode_needs_reset) {
- current_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
+ current_mode = base_mode;
current_mode_needs_reset = 0;
}
- current_mode = (current_mode & ~CHFL_DEOPPED) | CHFL_CHANOP;
+ current_mode = (current_mode & ~(CHFL_DEOPPED | CHFL_DELAYED)) | CHFL_CHANOP;
}
else if (*ptr == 'v') { /* has voice status */
if (current_mode_needs_reset) {
- current_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
+ current_mode = base_mode;
current_mode_needs_reset = 0;
}
- current_mode |= CHFL_VOICE;
+ current_mode = (current_mode & ~CHFL_DELAYED) | CHFL_VOICE;
oplevel = -1; /* subsequential digits are an absolute op-level value. */
}
else if (isdigit(*ptr)) {
int level_increment = 0;
if (oplevel == -1) { /* op-level is absolute value? */
if (current_mode_needs_reset) {
- current_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
+ current_mode = base_mode;
current_mode_needs_reset = 0;
}
oplevel = 0;
}
- current_mode = (current_mode & ~CHFL_DEOPPED) | CHFL_CHANOP;
+ current_mode = (current_mode & ~(CHFL_DEOPPED | CHFL_DELAYED)) | CHFL_CHANOP;
do {
level_increment = 10 * level_increment + *ptr++ - '0';
} while(isdigit(*ptr));
last_oplevel = oplevel;
}
- add_user_to_channel(chptr, acptr, current_mode, oplevel);
- sendcmdto_channel_butserv_butone(acptr, CMD_JOIN, chptr, NULL, "%H", chptr);
+ if (IsBurst(sptr) || !(member = find_member_link(chptr, acptr)))
+ {
+ add_user_to_channel(chptr, acptr, current_mode, oplevel);
+ if (!(current_mode & CHFL_DELAYED))
+ sendcmdto_channel_butserv_butone(acptr, CMD_JOIN, chptr, NULL, 0, "%H", chptr);
+ }
+ else
+ {
+ /* The member was already joined (either by CREATE or JOIN).
+ Remember the current mode. */
+ if (member->status & CHFL_CHANOP)
+ member->status |= CHFL_BURST_ALREADY_OPPED;
+ if (member->status & CHFL_VOICE)
+ member->status |= CHFL_BURST_ALREADY_VOICED;
+ /* Synchronize with the burst. */
+ member->status |= CHFL_BURST_JOINED | (current_mode & (CHFL_CHANOP|CHFL_VOICE));
+ member->oplevel = oplevel;
+ }
}
}
param++;
break;
- } /* switch (*parv[param]) { */
- } /* while (param < parc) { */
+ } /* switch (*parv[param]) */
+ } /* while (param < parc) */
nickstr[nickpos] = '\0';
banstr[banpos] = '\0';
/* first deal with channel members */
for (member = chptr->members; member; member = member->next_member) {
if (member->status & CHFL_BURST_JOINED) { /* joined during burst */
- if (member->status & CHFL_CHANOP)
+ if ((member->status & CHFL_CHANOP) && !(member->status & CHFL_BURST_ALREADY_OPPED))
modebuf_mode_client(mbuf, MODE_ADD | CHFL_CHANOP, member->user);
- if (member->status & CHFL_VOICE)
+ if ((member->status & CHFL_VOICE) && !(member->status & CHFL_BURST_ALREADY_VOICED))
modebuf_mode_client(mbuf, MODE_ADD | CHFL_VOICE, member->user);
} else if (parse_flags & MODE_PARSE_WIPEOUT) { /* wipeout old ops */
if (member->status & CHFL_CHANOP)