diff options
author | Naram Qashat cyberbotx@cyberbotx.com <Naram Qashat cyberbotx@cyberbotx.com@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-10-26 20:01:48 +0000 |
---|---|---|
committer | Naram Qashat cyberbotx@cyberbotx.com <Naram Qashat cyberbotx@cyberbotx.com@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-10-26 20:01:48 +0000 |
commit | 474f30a8bf5d0ab2665f4c87442956f78586a384 (patch) | |
tree | c997695a083ea7780b2f58549f1fa94f8b832178 | |
parent | 4e99df540826b6270100eea12f01d0dd6af65fbd (diff) |
Added maxsessionlimit directive to operserv block in new config.
Added ValidateLimitSessions function to validate certain session limiting directives only when session limiting is enabled.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1483 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | data/example_new.conf | 6 | ||||
-rw-r--r-- | src/config.c | 13 |
2 files changed, 17 insertions, 2 deletions
diff --git a/data/example_new.conf b/data/example_new.conf index 05ac2cc16..5dfb155eb 100644 --- a/data/example_new.conf +++ b/data/example_new.conf @@ -807,4 +807,10 @@ operserv * If not given and session limiting is enabled, it will default to no limit. */ defaultsessionlimit = 3 + + /* + * The maximum session limit that may be set for a host in an exception. This directive is only + * required if session limiting is enabled. + */ + maxsessionlimit = 100 } diff --git a/src/config.c b/src/config.c index 146a6a58e..d4a312bcc 100644 --- a/src/config.c +++ b/src/config.c @@ -503,6 +503,16 @@ bool ValidateHostServ(ServerConfig *, const char *tag, const char *value, ValueI return true; } +bool ValidateLimitSessions(ServerConfig *, const char *tag, const char *value, ValueItem &data) +{ + if (LimitSessions) { + if (static_cast<std::string>(value) == "maxsessionlimit") { + if (!data.GetInteger()) throw ConfigException(static_cast<std::string>("The value for <") + tag + ":" + value + "> must be non-zero when session limiting is enabled!"); + } + } + return true; +} + void ServerConfig::ReportConfigError(const std::string &errormessage, bool bail) { alog("There were errors in your configuration file: %s", errormessage.c_str()); @@ -660,6 +670,7 @@ int ServerConfig::Read(bool bail) {"operserv", "notifications", "", new ValueContainerString(&OSNotifications), DT_STRING, NoValidation}, {"operserv", "limitsessions", "no", new ValueContainerBool(&LimitSessions), DT_BOOLEAN, NoValidation}, {"operserv", "defaultsessionlimit", "0", new ValueContainerInt(&DefSessionLimit), DT_INTEGER, NoValidation}, + {"operserv", "maxsessionlimit", "0", new ValueContainerInt(&MaxSessionLimit), DT_INTEGER, ValidateLimitSessions}, {NULL, NULL, NULL, NULL, DT_NOTHING, NoValidation} }; /* These tags can occur multiple times, and therefore they have special code to read them @@ -1271,7 +1282,6 @@ Directive directives[] = { {"LogUsers", {{PARAM_SET, PARAM_RELOAD, &LogUsers}}}, {"MailDelay", {{PARAM_TIME, PARAM_RELOAD, &MailDelay}}}, {"MaxSessionKill", {{PARAM_INT, PARAM_RELOAD, &MaxSessionKill}}}, - {"MaxSessionLimit", {{PARAM_POSINT, PARAM_RELOAD, &MaxSessionLimit}}}, {"MemoCoreModules", {{PARAM_STRING, PARAM_RELOAD, &MemoCoreModules}}}, {"MysqlHost", {{PARAM_STRING, PARAM_RELOAD, &MysqlHost}}}, {"MysqlUser", {{PARAM_STRING, PARAM_RELOAD, &MysqlUser}}}, @@ -1881,7 +1891,6 @@ int read_config(int reload) if (LimitSessions) { - CHECK(MaxSessionLimit); CHECK(ExceptionExpiry); if (MaxSessionKill && !SessionAutoKillExpiry) |