}
struct Ban *
-allocate_ban(const char *banstr, const char *who)
+allocate_ban(const char *banstr, const char *who, const char *forward)
{
struct Ban *bptr;
bptr = rb_bh_alloc(ban_heap);
bptr->banstr = rb_strdup(banstr);
bptr->who = rb_strdup(who);
+ bptr->forward = forward ? rb_strdup(forward) : NULL;
return (bptr);
}
{
rb_free(bptr->banstr);
rb_free(bptr->who);
+ rb_free(bptr->forward);
rb_bh_free(ban_heap, bptr);
}
*/
int
is_banned(struct Channel *chptr, struct Client *who, struct membership *msptr,
- const char *s, const char *s2)
+ const char *s, const char *s2, const char **forward)
{
char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
}
}
+ if (actualBan && actualBan->forward && forward)
+ *forward = actualBan->forward;
+
return ((actualBan ? CHFL_BAN : 0));
}
/* can_join()
*
* input - client to check, channel to check for, key
- * output - reason for not being able to join, else 0
+ * output - reason for not being able to join, else 0, channel name to forward to
* side effects -
* caveats - this function should only be called on a local user.
*/
int
-can_join(struct Client *source_p, struct Channel *chptr, char *key)
+can_join(struct Client *source_p, struct Channel *chptr, char *key, char **forward)
{
rb_dlink_node *invite = NULL;
rb_dlink_node *ptr;
}
}
- if((is_banned(chptr, source_p, NULL, src_host, src_iphost)) == CHFL_BAN)
+ if((is_banned(chptr, source_p, NULL, src_host, src_iphost, forward)) == CHFL_BAN)
{
moduledata.approved = ERR_BANNEDFROMCHAN;
goto finish_join_check;
}
+ if(*chptr->mode.key && (EmptyString(key) || irccmp(chptr->mode.key, key)))
+ {
+ moduledata.approved = ERR_BADCHANNELKEY;
+ goto finish_join_check;
+ }
+
+ /* All checks from this point on will forward... */
+ if(forward)
+ *forward = chptr->mode.forward;
+
if(chptr->mode.mode & MODE_INVITEONLY)
{
RB_DLINK_FOREACH(invite, source_p->user->invited.head)
}
}
- if(*chptr->mode.key && (EmptyString(key) || irccmp(chptr->mode.key, key)))
- moduledata.approved = ERR_BADCHANNELKEY;
-
if(chptr->mode.limit &&
rb_dlink_list_length(&chptr->members) >= (unsigned long) chptr->mode.limit)
i = ERR_CHANNELISFULL;
if(can_send_banned(msptr))
moduledata.approved = CAN_SEND_NO;
}
- else if(is_banned(chptr, source_p, msptr, NULL, NULL) == CHFL_BAN
+ else if(is_banned(chptr, source_p, msptr, NULL, NULL, NULL) == CHFL_BAN
|| is_quieted(chptr, source_p, msptr, NULL, NULL) == CHFL_BAN)
moduledata.approved = CAN_SEND_NO;
}
if (can_send_banned(msptr))
return chptr;
}
- else if (is_banned(chptr, client_p, msptr, src_host, src_iphost) == CHFL_BAN
+ else if (is_banned(chptr, client_p, msptr, src_host, src_iphost, NULL) == CHFL_BAN
|| is_quieted(chptr, client_p, msptr, src_host, src_iphost) == CHFL_BAN)
return chptr;
}
chptr->mode.join_time);
}
- if(*chptr->mode.forward && (ConfigChannel.use_forward || !IsClient(client_p)))
+ if(*chptr->mode.forward &&
+ (ConfigChannel.use_forward || !IsClient(client_p)))
{
*mbuf++ = 'f';