From 2da6f6ebd718badce9d51369cf450767e9f67ba2 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 25 Sep 2011 16:22:29 +0200 Subject: [PATCH] Put back use_forward. --- doc/example.conf | 1 + doc/reference.conf | 6 ++++++ include/s_conf.h | 1 + modules/core/m_join.c | 3 ++- modules/m_info.c | 6 ++++++ src/channel.c | 3 ++- src/chmode.c | 22 +++++++++++++++++++--- src/newconf.c | 1 + src/s_conf.c | 1 + src/s_user.c | 6 ++++++ src/supported.c | 3 ++- 11 files changed, 47 insertions(+), 6 deletions(-) diff --git a/doc/example.conf b/doc/example.conf index bfce3277a..a36511146 100755 --- a/doc/example.conf +++ b/doc/example.conf @@ -325,6 +325,7 @@ exempt { channel { use_invex = yes; use_except = yes; + use_forward = yes; use_knock = yes; knock_delay = 5 minutes; knock_delay_channel = 1 minute; diff --git a/doc/reference.conf b/doc/reference.conf index 32e5bfa76..70b555002 100755 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -679,6 +679,12 @@ channel { */ use_except = yes; + /* forward: Enable/disable channel mode +f, a channel to forward + * users to if they can't join because of +i etc. Also enables ban + * forwarding, $. + */ + 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. diff --git a/include/s_conf.h b/include/s_conf.h index 7c732e073..aa049a708 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -237,6 +237,7 @@ struct config_channel_entry { int use_except; int use_invex; + int use_forward; int use_knock; int knock_delay; int knock_delay_channel; diff --git a/modules/core/m_join.c b/modules/core/m_join.c index 1cdf43426..bdd2df1d3 100644 --- a/modules/core/m_join.c +++ b/modules/core/m_join.c @@ -1125,7 +1125,8 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode) len = rb_sprintf(pbuf, "%d:%d ", mode->join_num, mode->join_time); pbuf += len; } - if(mode->forward[0] && strcmp(oldmode->forward, mode->forward)) + if(mode->forward[0] && strcmp(oldmode->forward, mode->forward) && + ConfigChannel.use_forward) { if(dir != MODE_ADD) { diff --git a/modules/m_info.c b/modules/m_info.c index 456b846e5..08e2f4709 100644 --- a/modules/m_info.c +++ b/modules/m_info.c @@ -602,6 +602,12 @@ static struct InfoStruct info_table[] = { &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, diff --git a/src/channel.c b/src/channel.c index 4d4d25601..1641a0e2b 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1236,7 +1236,8 @@ channel_modes(struct Channel *chptr, struct Client *client_p) chptr->mode.join_time); } - if(*chptr->mode.forward) + if(*chptr->mode.forward && + (ConfigChannel.use_forward || !IsClient(client_p))) { *mbuf++ = 'f'; diff --git a/src/chmode.c b/src/chmode.c index 375deabb6..2ba95c596 100644 --- a/src/chmode.c +++ b/src/chmode.c @@ -106,8 +106,9 @@ construct_cflags_strings(void) { case MODE_EXLIMIT: case MODE_DISFORWARD: - /* TODO FIXME: make use_forward work again */ - *ptr++ = (char) i; + if(ConfigChannel.use_forward) + *ptr++ = (char) i; + break; case MODE_REGONLY: if(rb_dlink_list_length(&service_list)) { @@ -552,6 +553,11 @@ chm_simple(struct Client *source_p, struct Channel *chptr, /* 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; @@ -829,6 +835,10 @@ chm_ban(struct Client *source_p, struct Channel *chptr, return; } + if(forward != NULL && !ConfigChannel.use_forward && + MyClient(source_p)) + forward = NULL; + /* dont allow local clients to overflow the banlist, dont * let remote servers set duplicate bans */ @@ -1176,6 +1186,11 @@ chm_forward(struct Client *source_p, struct Channel *chptr, 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)) @@ -1254,7 +1269,8 @@ chm_forward(struct Client *source_p, struct Channel *chptr, mode_changes[mode_count].dir = MODE_ADD; mode_changes[mode_count].caps = 0; mode_changes[mode_count].nocaps = 0; - mode_changes[mode_count].mems = ALL_MEMBERS; + mode_changes[mode_count].mems = + ConfigChannel.use_forward ? ALL_MEMBERS : ONLY_SERVERS; mode_changes[mode_count].id = NULL; mode_changes[mode_count++].arg = forward; } diff --git a/src/newconf.c b/src/newconf.c index 0063bf76b..ae57965dc 100644 --- a/src/newconf.c +++ b/src/newconf.c @@ -2275,6 +2275,7 @@ static struct ConfEntry conf_channel_table[] = { "only_ascii_channels", CF_YESNO, NULL, 0, &ConfigChannel.only_ascii_channels }, { "use_except", CF_YESNO, NULL, 0, &ConfigChannel.use_except }, { "use_invex", CF_YESNO, NULL, 0, &ConfigChannel.use_invex }, + { "use_forward", CF_YESNO, NULL, 0, &ConfigChannel.use_forward }, { "use_knock", CF_YESNO, NULL, 0, &ConfigChannel.use_knock }, { "resv_forcepart", CF_YESNO, NULL, 0, &ConfigChannel.resv_forcepart }, { "channel_target_change", CF_YESNO, NULL, 0, &ConfigChannel.channel_target_change }, diff --git a/src/s_conf.c b/src/s_conf.c index 42c274c5d..8b963e13c 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -756,6 +756,7 @@ set_default_conf(void) ConfigChannel.use_except = YES; ConfigChannel.use_invex = YES; + ConfigChannel.use_forward = YES; ConfigChannel.use_knock = YES; ConfigChannel.knock_delay = 300; ConfigChannel.knock_delay_channel = 60; diff --git a/src/s_user.c b/src/s_user.c index 8e2c48172..9a1115f66 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -1073,6 +1073,12 @@ user_mode(struct Client *client_p, struct Client *source_p, int parc, const char } /* 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) diff --git a/src/supported.c b/src/supported.c index 8610e1ee4..ff59396d2 100644 --- a/src/supported.c +++ b/src/supported.c @@ -228,9 +228,10 @@ isupport_chanmodes(const void *ptr) { static char result[80]; - rb_snprintf(result, sizeof result, "%s%sbq,k,flj,%s", + rb_snprintf(result, sizeof result, "%s%sbq,k,%slj,%s", ConfigChannel.use_except ? "e" : "", ConfigChannel.use_invex ? "I" : "", + ConfigChannel.use_forward ? "f" : "", cflagsbuf); return result; }