X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=blobdiff_plain;f=ircd%2Fm_relay.c;h=8aa687e0b6b6ebff06e7dc53c482e403eba78a7b;hp=30731fb58c3fe066543cfd9516d78e001648b78e;hb=b5b5189a02dd7ff20e7bf7eed952a014a2a10edd;hpb=14045325c8d02cb91066ca1507bec55276c3264b diff --git a/ircd/m_relay.c b/ircd/m_relay.c index 30731fb..8aa687e 100644 --- a/ircd/m_relay.c +++ b/ircd/m_relay.c @@ -39,7 +39,7 @@ static void loc_handler_LR(const char *num, char *parv[], signed int parc) { static void loc_handler_LA(const char *num, char *parv[], signed int parc) { if(num[0] != '!' || parc < 1) return; char *fakehost = NULL; - if (parc > 1 && parv[1] != "0") + if (parc > 1 && !strcmp(parv[1], "0")) // 0 = no fakehost fakehost=parv[1]; if(parc > 2) @@ -77,15 +77,51 @@ static void mode_a_join(struct Client* cptr, char *channel, int flags) { } } - -static void mode_a_check_altchan(struct Client* cptr, char *channel) { - struct Channel *chptr; - if (!(chptr = FindChannel(channel))) - return; - - if(chptr->mode.altchan && IsChannelName(chptr->mode.altchan) && strIsIrcCh(chptr->mode.altchan)) { - mode_a_join(cptr,chptr->mode.altchan,CHFL_DEOPPED); - } +static void mode_a_check_altchan(struct Client* sptr, char *channel) { + struct Channel *chptrb; + if (!(chptrb = FindChannel(channel))) { + if (((channel[0] == '&') && !feature_bool(FEAT_LOCAL_CHANNELS)) || strlen(channel) > IRCD_MIN(CHANNELLEN, feature_int(FEAT_CHANNELLEN))) { + //we don't send an error message here - that would be very strange for the user, because they normaly don't know that mode +F is set + } else if ((chptrb = get_channel(sptr, channel, CGT_CREATE))) { + struct JoinBuf create; + joinbuf_init(&create, sptr, sptr, JOINBUF_TYPE_CREATE, 0, TStime()); + joinbuf_join(&create, chptrb, CHFL_CHANOP | CHFL_CHANNEL_MANAGER); + do_names(sptr, chptrb, NAMES_ALL|NAMES_EON); + joinbuf_flush(&create); + } + } else { + //first of all check if we may even join this channel + int err2 = 0; + int flags = 0; + if (chptrb->users == 0 && !chptrb->mode.apass[0] && !(chptrb->mode.mode & MODE_PERSIST)) { + /* Joining a zombie channel (zannel): give ops and increment TS. */ + flags = CHFL_CHANOP; + chptrb->creationtime++; + } else if (IsInvited(sptr, chptrb)) { + /* Invites and key=OVERRIDE bypass these other checks. */ + } else if (chptrb->mode.mode & MODE_INVITEONLY) + err2 = ERR_INVITEONLYCHAN; + else if (chptrb->mode.limit && (chptrb->users >= chptrb->mode.limit)) + err2 = ERR_CHANNELISFULL; + else if ((chptrb->mode.mode & MODE_REGONLY) && !IsAccount(sptr)) + err2 = ERR_NEEDREGGEDNICK; + else if (find_ban(sptr, chptrb->banlist)) + err2 = ERR_BANNEDFROMCHAN; + else if (*chptrb->mode.key) //Fix this! + err2 = ERR_BADCHANNELKEY; + if(!err2) { + struct JoinBuf join; + joinbuf_init(&join, sptr, sptr, JOINBUF_TYPE_JOIN, 0, 0); + joinbuf_join(&join, chptrb, flags); + del_invite(sptr, chptrb); + if (chptrb->topic[0]) { + send_reply(sptr, RPL_TOPIC, chptrb->chname, chptrb->topic); + send_reply(sptr, RPL_TOPICWHOTIME, chptrb->chname, chptrb->topic_nick, chptrb->topic_time); + } + do_names(sptr, chptrb, NAMES_ALL|NAMES_EON); /* send /names list */ + joinbuf_flush(&join); + } + } } /** RELAY @@ -192,8 +228,13 @@ signed int ms_relay(struct Client* cptr, struct Client* sptr, signed int parc, c } } else if(strcmp("JAR", parv[2]) == 0 && parc > 2) { struct Client *acptr; + struct Channel *chptr; if(acptr = findNUser(parv[1])) { - mode_a_check_altchan(acptr,parv[3]); + if(IsChannelName(parv[3]) && strIsIrcCh(parv[3]) && + (chptr = FindChannel(parv[3])) && chptr->mode.altchan && + IsChannelName(chptr->mode.altchan) && strIsIrcCh(chptr->mode.altchan)) { + mode_a_check_altchan(acptr,chptr->mode.altchan); + } send_reply(acptr, ERR_JOINACCESS, parv[3]); } }