From 0eceaff17a0fd935caa086ee43b328b0ea9282a5 Mon Sep 17 00:00:00 2001 From: "B.Greenham" Date: Sun, 28 Feb 2010 22:42:59 -0500 Subject: [PATCH] Borrow some ircd-seven code to create channel::use_local_channels. --- doc/example.conf | 1 + doc/reference.conf | 6 ++++++ include/s_conf.h | 1 + modules/m_info.c | 6 ++++++ src/channel.c | 3 ++- src/newconf.c | 1 + src/s_conf.c | 1 + src/supported.c | 12 ++++++++++-- 8 files changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/example.conf b/doc/example.conf index c6be4ce..f736d17 100755 --- a/doc/example.conf +++ b/doc/example.conf @@ -339,6 +339,7 @@ channel { use_except = yes; use_knock = yes; use_forward = yes; + use_local_channels = yes; knock_delay = 5 minutes; knock_delay_channel = 1 minute; max_chans_per_user = 15; diff --git a/doc/reference.conf b/doc/reference.conf index 8764ddb..cf7d45a 100755 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -738,6 +738,12 @@ channel { */ use_knock = yes; + /* local channels: &Channel - a channel that exists only on one server + * people on other servers will not be able to see or join local channels + * from another server. + */ + use_local_channels = yes; + /* knock delay: The amount of time a user must wait between issuing * the knock command. */ diff --git a/include/s_conf.h b/include/s_conf.h index 8a3d3f8..c07896c 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -228,6 +228,7 @@ struct config_channel_entry int use_invex; int use_knock; int use_forward; + int use_local_channels; int knock_delay; int knock_delay_channel; int max_bans; diff --git a/modules/m_info.c b/modules/m_info.c index 160fae5..a8ce27f 100644 --- a/modules/m_info.c +++ b/modules/m_info.c @@ -608,6 +608,12 @@ static struct InfoStruct info_table[] = { &ConfigChannel.use_knock, "Enable /KNOCK", }, + { + "use_local_channels", + OUTPUT_BOOLEAN_YN, + &ConfigChannel.use_local_channels, + "Enable local channels (&channels)" + }, { "resv_forcepart", OUTPUT_BOOLEAN_YN, diff --git a/src/channel.c b/src/channel.c index d45e87f..fab6c92 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1668,7 +1668,8 @@ void user_join(struct Client * client_p, struct Client * source_p, const char * } /* check it begins with # or &, and local chans are disabled */ - else if(!IsChannelName(name)) + else if(!IsChannelName(name) || + ( !ConfigChannel.use_local_channels && name[0] == '&')) { sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name); diff --git a/src/newconf.c b/src/newconf.c index b849033..31969a5 100644 --- a/src/newconf.c +++ b/src/newconf.c @@ -2227,6 +2227,7 @@ static struct ConfEntry conf_channel_table[] = { "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 }, + { "use_local_channels", CF_YESNO, NULL, 0, &ConfigChannel.use_local_channels }, { "resv_forcepart", CF_YESNO, NULL, 0, &ConfigChannel.resv_forcepart }, { "kick_no_rejoin_time", CF_INT, NULL, 0, &ConfigChannel.kick_no_rejoin_time }, { "\0", 0, NULL, 0, NULL } diff --git a/src/s_conf.c b/src/s_conf.c index a90b1c6..5eb07d5 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -753,6 +753,7 @@ set_default_conf(void) ConfigChannel.use_invex = YES; ConfigChannel.use_knock = YES; ConfigChannel.use_forward = YES; + ConfigChannel.use_local_channels = YES; ConfigChannel.knock_delay = 300; ConfigChannel.knock_delay_channel = 60; ConfigChannel.max_chans_per_user = 15; diff --git a/src/supported.c b/src/supported.c index d0d51f1..14cee91 100644 --- a/src/supported.c +++ b/src/supported.c @@ -244,12 +244,20 @@ isupport_chanmodes(const void *ptr) return result; } +static const char * +isupport_chantypes(const void *ptr) +{ + return ConfigChannel.use_local_channels ? "&#" : "#"; +} + static const char * isupport_chanlimit(const void *ptr) { static char result[30]; - rb_snprintf(result, sizeof result, "&#:%i", ConfigChannel.max_chans_per_user); + rb_snprintf(result, sizeof result, "%s:%i", + ConfigChannel.use_local_channels ? "&#" : "#", + ConfigChannel.max_chans_per_user); return result; } @@ -310,7 +318,7 @@ init_isupport(void) static int channellen = LOC_CHANNELLEN; static int topiclen = TOPICLEN; - add_isupport("CHANTYPES", isupport_string, "&#"); + add_isupport("CHANTYPES", isupport_chantypes, NULL); add_isupport("EXCEPTS", isupport_boolean, &ConfigChannel.use_except); add_isupport("INVEX", isupport_boolean, &ConfigChannel.use_invex); add_isupport("CHANMODES", isupport_chanmodes, NULL);