summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes.conf1
-rw-r--r--data/example.conf7
-rw-r--r--docs/IRCD37
-rw-r--r--include/configreader.h2
-rw-r--r--include/extern.h5
-rw-r--r--include/services.h1
-rw-r--r--src/config.c3
-rw-r--r--src/modes.cpp57
-rw-r--r--src/protocol/bahamut.c5
-rw-r--r--src/protocol/inspircd11.c5
-rw-r--r--src/protocol/inspircd12.cpp5
-rw-r--r--src/protocol/ratbox.c4
-rw-r--r--src/protocol/unreal32.c5
-rw-r--r--src/regchannel.cpp6
14 files changed, 96 insertions, 47 deletions
diff --git a/Changes.conf b/Changes.conf
index 7900350c3..a80701f35 100644
--- a/Changes.conf
+++ b/Changes.conf
@@ -2,6 +2,7 @@ Anope Version 1.9.2
--------------------
** ADDED CONFIGURATION DIRECTIVES **
options:enablelogchannel added to auto turn on the logchannel on startup
+options:mlock added to configure the default mlock modes on new channels
** MODIFIED CONFIGURATION DIRECTIVES **
diff --git a/data/example.conf b/data/example.conf
index f4b0460ab..76f15720b 100644
--- a/data/example.conf
+++ b/data/example.conf
@@ -499,7 +499,12 @@ options
* If set, Services will start logging to the log channel immediatly on startup.
* This directive is optional, and has no effect if logchannel is not defined.
*/
- #enablelogchannel = yes
+ #enablelogchannel = yes
+
+ /*
+ * Default modes for mode lock, these are set on newly registered channels.
+ */
+ mlock = "+nrt"
}
diff --git a/docs/IRCD b/docs/IRCD
index f9dd888e5..2a721727d 100644
--- a/docs/IRCD
+++ b/docs/IRCD
@@ -150,50 +150,47 @@ How To Add IRCd Support
27) Change Realname: Change real name. Use 1 for yes, 0 for no.
- 28) Default MLock: Default channelmodes for MLOCK. This is really set later,
- use 0 for now
-
- 29) Check Nick ID: Should we check if a user should remain identified when
+ 28) Check Nick ID: Should we check if a user should remain identified when
changing their nick? This is for IRCd's that remove
their registered-user mode when someone changes their
nick (like Bahamut does).
Use 1 for yes, 0 for no.
- 30) No Knock Requires +i: Does the No Knock channel mode require invite
+ 29) No Knock Requires +i: Does the No Knock channel mode require invite
only channels? Use 1 for yes, 0 for no.
- 31) Chan Modes: If sent in CAPAB/PROTOCOL, we store it in here. This is
+ 30) Chan Modes: If sent in CAPAB/PROTOCOL, we store it in here. This is
NULL by default.
- 32) Tokens: Can we use tokens to talk to the IRCd? Use 1 for yes,
+ 31) Tokens: Can we use tokens to talk to the IRCd? Use 1 for yes,
0 for no.
- 33) base64 SJOIN TS: Are the timestamps sent with a SJOIN in base64? Use
+ 32) base64 SJOIN TS: Are the timestamps sent with a SJOIN in base64? Use
1 for yes, 0 for no.
- 34) SJOIN Ban Char: Character used to identify bans. Use ''.
+ 33) SJOIN Ban Char: Character used to identify bans. Use ''.
- 35) SJOIN Except Char: Character used to identify exceptions. Use ''.
+ 34) SJOIN Except Char: Character used to identify exceptions. Use ''.
- 36) SJOIN Invite char: Character used to idenfity invexs. Use ''.
+ 35) SJOIN Invite char: Character used to idenfity invexs. Use ''.
- 37) SVSMODE UCMODE: Can we clear user channel modes with SVSMODE? Use
+ 36) SVSMODE UCMODE: Can we clear user channel modes with SVSMODE? Use
1 for yes, 0 for no.
- 38) SGline Enforce: Does the IRCd enforce SGLINES for us or do we need to
+ 37) SGline Enforce: Does the IRCd enforce SGLINES for us or do we need to
do so? Use 1 for yes, 0 for no.
- 39) Vhost Character: The character used to represent the vHost mode, if
+ 38) Vhost Character: The character used to represent the vHost mode, if
this is supported by the IRCd.
- 40) TS6: Does the IRCd support TS6? Use 1 for yes, 0 for no.
+ 39) TS6: Does the IRCd support TS6? Use 1 for yes, 0 for no.
- 41) P10: Is this IRCd a P10-style IRCd? Use 1 for yes, 0 for no.
+ 40) P10: Is this IRCd a P10-style IRCd? Use 1 for yes, 0 for no.
- 42) Character Set: Unreal passes the character set during PROTOCTL,
+ 41) Character Set: Unreal passes the character set during PROTOCTL,
the value is stored here. Set this NULL to start.
- 43) Channel CIDR: Set to 1 if channel bans, excepts and invites
+ 42) Channel CIDR: Set to 1 if channel bans, excepts and invites
support CIDR masks. Expected syntax: *!*@ip/mask.
When set to 1, anope will only parse strict CIDR masks.
IRCd's that try to correct invalid CIDR's (like nefarious)
@@ -201,10 +198,10 @@ How To Add IRCd Support
Contact the anope Dev Team if this is the case.
Set to 0 if CIDR's are not supported by your IRCd.
- 44) Global TLD Prefix: Prefix used to send global messages, should probably
+ 43) Global TLD Prefix: Prefix used to send global messages, should probably
be "$"
- 45) Delayed AUTH: Does the ircd send if a user is identified for their nick
+ 44) Delayed AUTH: Does the ircd send if a user is identified for their nick
AFTER the initial NICK/UID? Set this to 0 for no.
So we've had this long list. Now there's a second struct to fill. This
diff --git a/include/configreader.h b/include/configreader.h
index b5b124777..97403b5fa 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -493,6 +493,8 @@ class ServerConfig
unsigned NickRegDelay;
/* Max number if news items allowed in the list */
unsigned NewsCount;
+ /* Default mlock modes */
+ std::string MLock;
/* Services can use email */
bool UseMail;
diff --git a/include/extern.h b/include/extern.h
index 348489a40..c02ef22e2 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -392,6 +392,11 @@ E int str_is_pure_wildcard(const char *str);
E uint32 str_is_ip(char *str);
E int str_is_cidr(char *str, uint32 * ip, uint32 * mask, char **host);
+/**** modes.cpp ****/
+E std::bitset<128> DefMLockOn;
+E std::bitset<128> DefMLockOff;
+E std::map<ChannelModeName, std::string> DefMLockParams;
+E void SetDefaultMLock();
/**** modules.c ****/
E void modules_unload_all(bool unload_proto); /* Read warnings near function source */
diff --git a/include/services.h b/include/services.h
index 2278d21d4..30bd0e34b 100644
--- a/include/services.h
+++ b/include/services.h
@@ -559,7 +559,6 @@ struct ircdvars_ {
int umode; /* change user modes */
int nickvhost; /* Users vhost sent during NICK */
int chgreal; /* Change RealName */
- std::bitset<128> DefMLock; /* Default mlock modes */
int check_nick_id; /* On nick change check if they could be identified */
int knock_needs_i; /* Check if we needed +i when setting NOKNOCK */
char *chanmodes; /* If the ircd sends CHANMODE in CAPAB this is where we store it */
diff --git a/src/config.c b/src/config.c
index 549e19594..aa7577cbf 100644
--- a/src/config.c
+++ b/src/config.c
@@ -642,6 +642,7 @@ int ServerConfig::Read(bool bail)
{"options", "newscount", "3", new ValueContainerUInt(&Config.NewsCount), DT_UINTEGER, NoValidation},
{"options", "ulineservers", "", new ValueContainerChar(&UlineServers), DT_CHARPTR, NoValidation},
{"options", "enablelogchannel", "no", new ValueContainerBool(&LogChan), DT_BOOLEAN, NoValidation},
+ {"options", "mlock", "+nrt", new ValueContainerString(&Config.MLock), DT_STRING, NoValidation},
{"nickserv", "nick", "NickServ", new ValueContainerChar(&Config.s_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty},
{"nickserv", "description", "Nickname Registration Service", new ValueContainerChar(&Config.desc_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty},
{"nickserv", "database", "nick.db", new ValueContainerChar(&Config.NickDBName), DT_CHARPTR, ValidateNotEmpty},
@@ -1786,6 +1787,8 @@ int read_config(int reload)
Config.NSRExpire = 0;
}
+ SetDefaultMLock();
+
if (!retval) {
printf
("\n*** Support resources: Read through the services.conf self-contained \n*** documentation. Read the documentation files found in the 'docs' \n*** folder. Visit our portal located at http://www.anope.org/. Join \n*** our support channel on /server irc.anope.org channel #anope.\n\n");
diff --git a/src/modes.cpp b/src/modes.cpp
index 7094b79b1..e43596620 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -22,6 +22,60 @@ std::map<ChannelModeName, ChannelMode *> ModeManager::ChannelModesByName;
* efficiency.
*/
+/* Default mlocked modes on */
+std::bitset<128> DefMLockOn;
+/* Default mlocked modes off */
+std::bitset<128> DefMLockOff;
+/* Map for default mlocked mode parameters */
+std::map<ChannelModeName, std::string> DefMLockParams;
+
+/** Parse the mode string from the config file and set the default mlocked modes
+ */
+void SetDefaultMLock()
+{
+ DefMLockOn.reset();
+ DefMLockOff.reset();
+ DefMLockParams.clear();
+ std::bitset<128> *ptr = NULL;
+
+ std::string modes, param;
+ spacesepstream sep(Config.MLock);
+ sep.GetToken(modes);
+
+ for (unsigned i = 0; i < modes.size(); ++i)
+ {
+ if (modes[i] == '+')
+ ptr = &DefMLockOn;
+ else if (modes[i] == '-')
+ ptr = &DefMLockOff;
+ else
+ {
+ if (!ptr)
+ continue;
+
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]);
+
+ if (cm && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM))
+ {
+ ptr->set(cm->Name);
+
+ if (*ptr == DefMLockOn && cm->Type == MODE_PARAM)
+ {
+ if (sep.GetToken(param))
+ {
+ DefMLockParams.insert(std::make_pair(cm->Name, param));
+ }
+ else
+ {
+ alog("Warning: Got default mlock mode %c with no param?", cm->ModeChar);
+ ptr->set(cm->Name, false);
+ }
+ }
+ }
+ }
+ }
+}
+
/** Add a user mode to Anope
* @param Mode The mode
* @param um A UserMode or UserMode derived class
@@ -56,6 +110,9 @@ bool ModeManager::AddChannelMode(char Mode, ChannelMode *cm)
if (ret)
{
+ /* Apply this mode to the new default mlock if its used */
+ SetDefaultMLock();
+
FOREACH_MOD(I_OnChannelModeAdd, OnChannelModeAdd(cm));
}
diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c
index c14eb945f..c3ff0747c 100644
--- a/src/protocol/bahamut.c
+++ b/src/protocol/bahamut.c
@@ -44,7 +44,6 @@ IRCDVar myIrcd[] = {
1, /* UMODE */
0, /* VHOST ON NICK */
0, /* Change RealName */
- 0,
1,
1, /* No Knock requires +i */
NULL, /* CAPAB Chan Modes */
@@ -765,10 +764,6 @@ class ProtoBahamut : public Module
moduleAddModes();
- ircd->DefMLock[CMODE_NOEXTERNAL] = true;
- ircd->DefMLock[CMODE_TOPIC] = true;
- ircd->DefMLock[CMODE_REGISTERED] = true;
-
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c
index 722d8668d..6c2b22c2b 100644
--- a/src/protocol/inspircd11.c
+++ b/src/protocol/inspircd11.c
@@ -62,7 +62,6 @@ IRCDVar myIrcd[] = {
1, /* VHOST ON NICK */
0, /* Change RealName */
0,
- 0,
1, /* No Knock requires +i */
NULL, /* CAPAB Chan Modes */
0, /* We support inspircd TOKENS */
@@ -1108,10 +1107,6 @@ class ProtoInspIRCd : public Module
moduleAddModes();
- ircd->DefMLock[CMODE_NOEXTERNAL] = true;
- ircd->DefMLock[CMODE_TOPIC] = true;
- ircd->DefMLock[CMODE_REGISTERED] = true;
-
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp
index 78216d1c8..da04bddb4 100644
--- a/src/protocol/inspircd12.cpp
+++ b/src/protocol/inspircd12.cpp
@@ -62,7 +62,6 @@ IRCDVar myIrcd[] = {
1, /* VHOST ON NICK */
0, /* Change RealName */
0,
- 0,
1, /* No Knock requires +i */
NULL, /* CAPAB Chan Modes */
0, /* We support inspircd TOKENS */
@@ -1296,10 +1295,6 @@ class ProtoInspIRCd : public Module
moduleAddModes();
- ircd->DefMLock[CMODE_NOEXTERNAL] = true;
- ircd->DefMLock[CMODE_TOPIC] = true;
- ircd->DefMLock[CMODE_REGISTERED] = true;
-
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
}
diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c
index 1af8e3a4a..73820de7e 100644
--- a/src/protocol/ratbox.c
+++ b/src/protocol/ratbox.c
@@ -42,7 +42,6 @@ IRCDVar myIrcd[] = {
0, /* O:LINE */
0, /* VHOST ON NICK */
0, /* Change RealName */
- 0,
0, /* On nick change check if they could be identified */
0, /* No Knock requires +i */
NULL, /* CAPAB Chan Modes */
@@ -899,9 +898,6 @@ class ProtoRatbox : public Module
moduleAddModes();
- ircd->DefMLock[CMODE_NOEXTERNAL] = true;
- ircd->DefMLock[CMODE_TOPIC] = true;
-
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c
index b4a86525c..bf619d27d 100644
--- a/src/protocol/unreal32.c
+++ b/src/protocol/unreal32.c
@@ -44,7 +44,6 @@ IRCDVar myIrcd[] = {
1, /* UMODE */
1, /* VHOST ON NICK */
1, /* Change RealName */
- 0,
0, /* On nick change check if they could be identified */
1, /* No Knock requires +i */
NULL, /* CAPAB Chan Modes */
@@ -1235,10 +1234,6 @@ class ProtoUnreal : public Module
moduleAddModes();
- ircd->DefMLock[CMODE_NOEXTERNAL] = true;
- ircd->DefMLock[CMODE_TOPIC] = true;
- ircd->DefMLock[CMODE_REGISTERED] = true;
-
pmodule_ircd_proto(&ircd_proto);
moduleAddIRCDMsgs();
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 993000b38..07bdc1c15 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -39,7 +39,11 @@ ChannelInfo::ChannelInfo(const std::string &chname)
/* If ircd doesn't exist, this is from DB load and mlock is set later */
if (ircd)
- mlock_on = ircd->DefMLock;
+ {
+ mlock_on = DefMLockOn;
+ mlock_off = DefMLockOff;
+ Params = DefMLockParams;
+ }
size_t t;
/* Set default channel flags */