name = "hades.arpa";
sid = "42X";
description = "charybdis test server";
- network_name = "AthemeNET";
+ network_name = "StaticBox";
network_desc = "Your IRC network.";
hub = yes;
admin {
name = "Lazy admin (lazya)";
- description = "AthemeNET client server";
+ description = "StaticBox client server";
email = "nobody@127.0.0.1";
};
use_invex = yes;
use_except = yes;
use_knock = yes;
- use_forward = yes;
knock_delay = 5 minutes;
knock_delay_channel = 1 minute;
max_chans_per_user = 15;
* They are used in pairs of one host/rejection reason.
*
* These settings should be adequate for most networks, and are (presently)
- * required for use on AthemeNet.
+ * required for use on StaticBox.
*
* Word to the wise: Do not use blacklists like SPEWS for blocking IRC
* connections.
*/
use_except = yes;
- /* forward: Enable/disable channel mode +f, a channel to forward
- * users to if they can't join because of +i etc.
- */
- use_forward = yes;
-
/* knock: Allows users to request an invite to a channel that
* is locked somehow (+ikl). If the channel is +p or you are banned
* the knock will not be sent.
* They are used in pairs of one host/rejection reason.
*
* These settings should be adequate for most networks, and are (presently)
- * required for use on AthemeNet.
+ * required for use on StaticBox.
*
* Word to the wise: Do not use blacklists like SPEWS for blocking IRC
* connections.
return EXTBAN_INVALID;
#endif
recurse = 1;
- ret = is_banned(chptr2, client_p, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH;
+ ret = is_banned(chptr2, client_p, NULL, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH;
recurse = 0;
return ret;
}
char *banstr;
char *who;
time_t when;
+ char *forward;
rb_dlink_node node;
};
struct Channel *allocate_channel(const char *chname);
void free_channel(struct Channel *chptr);
-struct Ban *allocate_ban(const char *, const char *);
+struct Ban *allocate_ban(const char *, const char *, const char *);
void free_ban(struct Ban *bptr);
extern int flood_attack_channel(int p_or_n, struct Client *source_p,
struct Channel *chptr, char *chname);
extern int is_banned(struct Channel *chptr, struct Client *who,
- struct membership *msptr, const char *, const char *);
+ struct membership *msptr, const char *, const char *, const char **);
extern int is_quieted(struct Channel *chptr, struct Client *who,
struct membership *msptr, const char *, const char *);
-extern int can_join(struct Client *source_p, struct Channel *chptr, char *key);
+extern int can_join(struct Client *source_p, struct Channel *chptr, char *key,
+ char **forward);
extern struct membership *find_channel_membership(struct Channel *, struct Client *);
extern const char *find_channel_status(struct membership *msptr, int combine);
extern struct ChannelMode chmode_table[256];
extern int add_id(struct Client *source_p, struct Channel *chptr, const char *banid,
- rb_dlink_list * list, long mode_type);
+ const char *forward, rb_dlink_list * list, long mode_type);
-extern int del_id(struct Channel *chptr, const char *banid, rb_dlink_list * list, long mode_type);
+extern struct Ban * del_id(struct Channel *chptr, const char *banid, rb_dlink_list * list,
+ long mode_type);
extern ExtbanFunc extban_table[256];
int use_except;
int use_invex;
int use_knock;
- int use_forward;
int knock_delay;
int knock_delay_channel;
int max_bans;
*/
static struct Channel *
check_forward(struct Client *source_p, struct Channel *chptr,
- char *key)
+ char *key, int *err)
{
int depth = 0, i;
+ char *next = NULL;
+
+ /* The caller (m_join) is only interested in the reason
+ * for the original channel.
+ */
+ if ((*err = can_join(source_p, chptr, key, &next)) == 0)
+ return chptr;
/* User is +Q */
if (IsNoForward(source_p))
while (depth < 16)
{
- chptr = find_channel(chptr->mode.forward);
+ chptr = find_channel(next);
/* Can only forward to existing channels */
if (chptr == NULL)
return NULL;
/* Don't forward to +Q channel */
if (chptr->mode.mode & MODE_DISFORWARD)
return NULL;
- i = can_join(source_p, chptr, key);
+ i = can_join(source_p, chptr, key, &next);
if (i == 0)
return chptr;
- if (i != ERR_INVITEONLYCHAN && i != ERR_NEEDREGGEDNICK && i != ERR_THROTTLE && i != ERR_CHANNELISFULL)
+ if (next == NULL)
return NULL;
depth++;
}
m_join(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
static char jbuf[BUFSIZE];
- struct Channel *chptr = NULL;
+ struct Channel *chptr = NULL, *chptr2 = NULL;
struct ConfItem *aconf;
char *name;
char *key = NULL;
}
}
- /* can_join checks for +i key, bans etc */
- if((i = can_join(source_p, chptr, key)))
+ /* If check_forward returns NULL, they couldn't join and there wasn't a usable forward channel. */
+ if(!(chptr2 = check_forward(source_p, chptr, key, &i)))
{
- if ((i != ERR_NEEDREGGEDNICK && i != ERR_THROTTLE && i != ERR_INVITEONLYCHAN && i != ERR_CHANNELISFULL) ||
- (!ConfigChannel.use_forward || (chptr = check_forward(source_p, chptr, key)) == NULL))
- {
- /* might be wrong, but is there any other better location for such?
- * see extensions/chm_operonly.c for other comments on this
- * -- dwr
- */
- if(i != ERR_CUSTOM)
- sendto_one(source_p, form_str(i), me.name, source_p->name, name);
-
- continue;
- }
+ /* might be wrong, but is there any other better location for such?
+ * see extensions/chm_operonly.c for other comments on this
+ * -- dwr
+ */
+ if(i != ERR_CUSTOM)
+ sendto_one(source_p, form_str(i), me.name, source_p->name, name);
- sendto_one_numeric(source_p, ERR_LINKCHANNEL, form_str(ERR_LINKCHANNEL), name, chptr->chname);
+ continue;
}
+ else if(chptr != chptr2)
+ sendto_one_numeric(source_p, ERR_LINKCHANNEL, form_str(ERR_LINKCHANNEL), name, chptr2->chname);
+
+ chptr = chptr2;
if(flags == 0 &&
!IsOper(source_p) && !IsExemptSpambot(source_p))
len = rb_sprintf(pbuf, "%d:%d ", mode->join_num, mode->join_time);
pbuf += len;
}
- if(mode->forward[0] && strcmp(oldmode->forward, mode->forward) && ConfigChannel.use_forward)
+ if(mode->forward[0] && strcmp(oldmode->forward, mode->forward))
{
if(dir != MODE_ADD)
{
static char parabuf[BUFSIZE];
struct Channel *chptr;
rb_dlink_list *banlist;
- const char *s;
+ char *s, *forward;
char *t;
char *mbuf;
char *pbuf;
if(tlen > MODEBUFLEN)
break;
- if(add_id(fakesource_p, chptr, s, banlist, mode_type))
+ if((forward = strchr(s+1, '$')) != NULL)
+ {
+ *forward++ = '\0';
+ if(*forward == '\0')
+ forward = NULL;
+ }
+
+ if(add_id(fakesource_p, chptr, s, forward, banlist, mode_type))
{
/* this new one wont fit.. */
if(mlen + MAXMODEPARAMS + plen + tlen > BUFSIZE - 5 ||
&ConfigChannel.use_invex,
"Enable chanmode +I (invite exceptions)",
},
- {
- "use_forward",
- OUTPUT_BOOLEAN_YN,
- &ConfigChannel.use_forward,
- "Enable chanmode +f (channel forwarding)",
- },
{
"use_knock",
OUTPUT_BOOLEAN_YN,
if(MyClient(source_p))
{
/* don't allow a knock if the user is banned */
- if(is_banned(chptr, source_p, NULL, NULL, NULL) == CHFL_BAN ||
- is_quieted(chptr, source_p, NULL, NULL, NULL) == CHFL_BAN)
+ if(is_banned(chptr, source_p, NULL, NULL, NULL, NULL) == CHFL_BAN ||
+ is_quieted(chptr, source_p, NULL, NULL, NULL) == CHFL_BAN)
{
sendto_one_numeric(source_p, ERR_CANNOTSENDTOCHAN,
form_str(ERR_CANNOTSENDTOCHAN), name);
}
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)
{
*mbuf++ = 'f';
static int mode_limit;
static int mode_limit_simple;
static int mask_pos;
+static int removed_mask_pos;
char cflagsbuf[256];
char cflagsmyinfo[256];
switch (chmode_flags[i])
{
- case MODE_EXLIMIT:
- case MODE_DISFORWARD:
- if(ConfigChannel.use_forward)
- {
- *ptr++ = (char) i;
- }
-
- break;
case MODE_REGONLY:
if(rb_dlink_list_length(&service_list))
{
/* add_id()
*
- * inputs - client, channel, id to add, type
+ * inputs - client, channel, id to add, type, forward
* outputs - 0 on failure, 1 on success
* side effects - given id is added to the appropriate list
*/
int
-add_id(struct Client *source_p, struct Channel *chptr, const char *banid,
+add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const char *forward,
rb_dlink_list * list, long mode_type)
{
struct Ban *actualBan;
else
rb_strlcpy(who, source_p->name, sizeof(who));
- actualBan = allocate_ban(realban, who);
+ actualBan = allocate_ban(realban, who, forward);
actualBan->when = rb_current_time();
rb_dlinkAdd(actualBan, &actualBan->node, list);
/* del_id()
*
* inputs - channel, id to remove, type
- * outputs - 0 on failure, 1 on success
- * side effects - given id is removed from the appropriate list
+ * outputs - pointer to ban that was removed, if any
+ * side effects - given id is removed from the appropriate list and returned
*/
-int
+struct Ban *
del_id(struct Channel *chptr, const char *banid, rb_dlink_list * list, long mode_type)
{
rb_dlink_node *ptr;
struct Ban *banptr;
if(EmptyString(banid))
- return 0;
+ return NULL;
RB_DLINK_FOREACH(ptr, list->head)
{
if(mode_type == CHFL_BAN || mode_type == CHFL_QUIET || mode_type == CHFL_EXCEPTION)
chptr->bants++;
- return 1;
+ return banptr;
}
}
- return 0;
+ return NULL;
}
/* check_string()
{
static char mask_buf[BUFSIZE];
int old_mask_pos;
- char *nick, *user, *host;
+ char *nick, *user, *host, *forward = NULL;
char splat[] = "*";
- char *t, *at, *ex;
- char ne = 0, ue = 0, he = 0; /* save values at nick[NICKLEN], et all */
+ char *t, *at, *ex, *ex2;
+ char ne = 0, ue = 0, he = 0, fe = 0; /* save values at nick[NICKLEN], et all */
+ char e2 = 0; /* save value that delimits forward channel */
char *mask;
mask = LOCAL_COPY(idmask);
return mask_buf + old_mask_pos;
}
- at = ex = NULL;
+ at = ex = ex2 = NULL;
if((t = strchr(mask, '@')) != NULL)
{
at = t;
if(*mask != '\0')
user = mask;
}
+
+ if((t = strchr(host, '!')) != NULL || (t = strchr(host, '$')) != NULL)
+ {
+ ex2 = t;
+ e2 = *t;
+ *t++= '\0';
+ if (*t != '\0')
+ forward = t;
+ }
}
else if((t = strchr(mask, '!')) != NULL)
{
if(*t != '\0')
user = t;
}
- else if(strchr(mask, '.') != NULL || strchr(mask, ':') != NULL || strchr(mask, '/') != NULL)
+ else if(strchr(mask, '.') != NULL || strchr(mask, ':') != NULL)
{
if(*mask != '\0')
host = mask;
he = host[HOSTLEN];
host[HOSTLEN] = '\0';
}
+ if(forward && strlen(forward) > CHANNELLEN)
+ {
+ fe = forward[CHANNELLEN];
+ forward[CHANNELLEN] = '\0';
+ }
- mask_pos += rb_sprintf(mask_buf + mask_pos, "%s!%s@%s", nick, user, host) + 1;
+ if (forward)
+ mask_pos += rb_sprintf(mask_buf + mask_pos, "%s!%s@%s$%s", nick, user, host, forward) + 1;
+ else
+ mask_pos += rb_sprintf(mask_buf + mask_pos, "%s!%s@%s", nick, user, host) + 1;
/* restore mask, since we may need to use it again later */
if(at)
*at = '@';
if(ex)
*ex = '!';
+ if(ex2)
+ *ex2 = e2;
if(ne)
nick[NICKLEN - 1] = ne;
if(ue)
user[USERLEN] = ue;
if(he)
host[HOSTLEN] = he;
+ if(fe)
+ forward[CHANNELLEN] = fe;
return mask_buf + old_mask_pos;
}
/* setting + */
if((dir == MODE_ADD) && !(chptr->mode.mode & mode_type))
{
- /* if +f is disabled, ignore an attempt to set +QF locally */
- if(!ConfigChannel.use_forward && MyClient(source_p) &&
- (c == 'Q' || c == 'F'))
- return;
-
chptr->mode.mode |= mode_type;
mode_changes[mode_count].letter = c;
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type)
{
- const char *mask;
- const char *raw_mask;
+ char *mask, *raw_mask, *forward;
rb_dlink_list *list;
rb_dlink_node *ptr;
struct Ban *banptr;
RB_DLINK_FOREACH(ptr, list->head)
{
+ char buf[BANLEN];
banptr = ptr->data;
+ if(banptr->forward)
+ rb_snprintf(buf, sizeof(buf), "%s$%s", banptr->banstr, banptr->forward);
+ else
+ rb_strlcpy(buf, banptr->banstr, sizeof(buf));
+
sendto_one(source_p, form_str(rpl_list),
me.name, source_p->name, chptr->chname,
- banptr->banstr, banptr->who, banptr->when);
+ buf, banptr->who, banptr->when);
}
sendto_one(source_p, form_str(rpl_endlist), me.name, source_p->name, chptr->chname);
return;
else
mask = pretty_mask(raw_mask);
+ /* Look for a $ after the first character.
+ * As the first character, it marks an extban; afterwards
+ * it delimits a forward channel.
+ */
+ if ((forward = strchr(mask+1, '$')) != NULL)
+ {
+ *forward++ = '\0';
+ if (*forward == '\0')
+ forward = NULL;
+ }
+
/* we'd have problems parsing this, hyb6 does it too
* also make sure it will always fit on a line with channel
* name etc.
/* dont allow local clients to overflow the banlist, dont
* let remote servers set duplicate bans
*/
- if(!add_id(source_p, chptr, mask, list, mode_type))
+ if(!add_id(source_p, chptr, mask, forward, list, mode_type))
return;
+ if(forward)
+ forward[-1]= '$';
+
mode_changes[mode_count].letter = c;
mode_changes[mode_count].dir = MODE_ADD;
mode_changes[mode_count].caps = caps;
}
else if(dir == MODE_DEL)
{
- if(del_id(chptr, mask, list, mode_type) == 0)
+ struct Ban *removed;
+ static char buf[BANLEN * MAXMODEPARAMS];
+ int old_removed_mask_pos = removed_mask_pos;
+ if((removed = del_id(chptr, mask, list, mode_type)) == NULL)
{
/* mask isn't a valid ban, check raw_mask */
- if(del_id(chptr, raw_mask, list, mode_type))
+ if((removed = del_id(chptr, raw_mask, list, mode_type)) != NULL)
mask = raw_mask;
}
+ if(removed && removed->forward)
+ removed_mask_pos += rb_snprintf(buf, sizeof(buf), "%s$%s", removed->banstr, removed->forward);
+ else
+ removed_mask_pos += rb_strlcpy(buf, mask, sizeof(buf));
+ if(removed)
+ {
+ free_ban(removed);
+ removed = NULL;
+ }
+
mode_changes[mode_count].letter = c;
mode_changes[mode_count].dir = MODE_DEL;
mode_changes[mode_count].caps = caps;
mode_changes[mode_count].nocaps = 0;
mode_changes[mode_count].mems = mems;
mode_changes[mode_count].id = NULL;
- mode_changes[mode_count++].arg = mask;
+ mode_changes[mode_count++].arg = buf + old_removed_mask_pos;
}
}
struct membership *msptr;
const char *forward;
- /* if +f is disabled, ignore local attempts to set it */
- if(!ConfigChannel.use_forward && MyClient(source_p) &&
- (dir == MODE_ADD) && (parc > *parn))
- return;
-
if(dir == MODE_QUERY || (dir == MODE_ADD && parc <= *parn))
{
if (!(*errors & SM_ERR_RPL_F))
mode_changes[mode_count].dir = MODE_ADD;
mode_changes[mode_count].caps = 0;
mode_changes[mode_count].nocaps = 0;
- mode_changes[mode_count].mems = ConfigChannel.use_forward ? ALL_MEMBERS : ONLY_SERVERS;
+ mode_changes[mode_count].mems = ALL_MEMBERS;
mode_changes[mode_count].id = NULL;
mode_changes[mode_count++].arg = forward;
}
struct Client *fakesource_p;
mask_pos = 0;
+ removed_mask_pos = 0;
mode_count = 0;
mode_limit = 0;
mode_limit_simple = 0;
/* ! */ PRINT_C | KWILD_C | CHAN_C | NONEOS_C,
/* " */ PRINT_C | CHAN_C | NONEOS_C,
/* # */ PRINT_C | MWILD_C | CHANPFX_C | CHAN_C | NONEOS_C,
-/* $ */ PRINT_C | CHAN_C | NONEOS_C | USER_C,
+/* $ */ PRINT_C | NONEOS_C | USER_C,
/* % */ PRINT_C | CHAN_C | NONEOS_C,
/* & */ PRINT_C | CHANPFX_C | CHAN_C | NONEOS_C,
/* ' */ PRINT_C | CHAN_C | NONEOS_C,
{ "use_except", CF_YESNO, NULL, 0, &ConfigChannel.use_except },
{ "use_invex", CF_YESNO, NULL, 0, &ConfigChannel.use_invex },
{ "use_knock", CF_YESNO, NULL, 0, &ConfigChannel.use_knock },
- { "use_forward", CF_YESNO, NULL, 0, &ConfigChannel.use_forward },
{ "resv_forcepart", CF_YESNO, NULL, 0, &ConfigChannel.resv_forcepart },
{ "channel_target_change", CF_YESNO, NULL, 0, &ConfigChannel.channel_target_change },
{ "disable_local_channels", CF_YESNO, NULL, 0, &ConfigChannel.disable_local_channels },
ConfigChannel.use_except = YES;
ConfigChannel.use_invex = YES;
ConfigChannel.use_knock = YES;
- ConfigChannel.use_forward = YES;
ConfigChannel.knock_delay = 300;
ConfigChannel.knock_delay_channel = 60;
ConfigChannel.max_chans_per_user = 15;
}
/* FALLTHROUGH */
default:
- if (MyConnect(source_p) && *pm == 'Q' && !ConfigChannel.use_forward) {
- badflag = YES;
- break;
- }
-
if((flag = user_modes[(unsigned char) *pm]))
{
if(MyConnect(source_p)
{
static char result[80];
- rb_snprintf(result, sizeof result, "%s%sbq,k,%slj,%s",
+ rb_snprintf(result, sizeof result, "%s%sbq,k,flj,%s",
ConfigChannel.use_except ? "e" : "",
ConfigChannel.use_invex ? "I" : "",
- ConfigChannel.use_forward ? "f" : "",
cflagsbuf);
return result;
}