summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-10-02 03:08:29 -0400
committerAdam <Adam@anope.org>2010-10-02 03:08:29 -0400
commit0a8bb8808549e0f93a690fa887f46af03768c9db (patch)
tree5d082157c884fa2eaf0f3e072a17ae40f33e6f70 /src
parenta62d824cb4266cdfbfbc81e142b22f1a2e7ed7be (diff)
Made OperServ and Global optional
Diffstat (limited to 'src')
-rw-r--r--src/config.cpp52
-rw-r--r--src/logger.cpp13
-rw-r--r--src/modulemanager.cpp2
-rw-r--r--src/operserv.cpp28
-rw-r--r--src/servers.cpp2
5 files changed, 63 insertions, 34 deletions
diff --git a/src/config.cpp b/src/config.cpp
index a3374c0be..849d943c2 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -583,11 +583,8 @@ bool ValidateHostServ(ServerConfig *config, const Anope::string &tag, const Anop
{
if (!config->s_HostServ.empty())
{
- if (value.equals_ci("description"))
- {
- if (data.GetValue().empty())
- throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when HostServ is enabled!");
- }
+ if (value.equals_ci("description") && data.GetValue().empty())
+ throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when HostServ is enabled!");
}
return true;
}
@@ -605,6 +602,27 @@ bool ValidateLimitSessions(ServerConfig *config, const Anope::string &tag, const
return true;
}
+bool ValidateOperServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data)
+{
+ if (!config->s_OperServ.empty())
+ {
+ if ((value.equals_ci("description") || value.equals_ci("globalnick") || value.equals_ci("globaldescription")) && data.GetValue().empty())
+ throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when OperServ is enabled!");
+ else if (value.equals_ci("autokillexpiry") || value.equals_ci("chankillexpiry") || value.equals_ci("snlineexpiry") || value.equals_ci("szlineexpiry") || value.equals_ci("sqlineexpiry"))
+ return ValidateNotZero(config, tag, value, data);
+ else if (value.equals_ci("maxsessionlimit") || value.equals_ci("exceptionexpiry"))
+ return ValidateLimitSessions(config, tag, value, data);
+ }
+ return true;
+}
+
+bool ValidateGlobal(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data)
+{
+ if (!config->s_GlobalNoticer.empty() && config->desc_GlobalNoticer.empty())
+ throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when Global is enabled!");
+ return true;
+}
+
bool ValidateDefCon(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data)
{
if (value.equals_ci("defaultlevel"))
@@ -951,7 +969,7 @@ void ServerConfig::Read()
{
errstr.clear();
// These tags MUST occur and must ONLY occur once in the config file
- static const Anope::string Once[] = {"serverinfo", "networkinfo", "options", "nickserv", "chanserv", "memoserv", "operserv", ""};
+ static const Anope::string Once[] = {"serverinfo", "networkinfo", "options", "nickserv", "chanserv", ""};
// These tags can occur ONCE or not at all
InitialConfig Values[] = {
/* The following comments are from CyberBotX to w00t as examples to use:
@@ -1122,31 +1140,31 @@ void ServerConfig::Read()
{"hostserv", "nick", "", new ValueContainerString(&this->s_HostServ), DT_STRING | DT_NORELOAD, NoValidation},
{"hostserv", "description", "vHost Service", new ValueContainerString(&this->desc_HostServ), DT_STRING | DT_NORELOAD, ValidateHostServ},
{"hostserv", "modules", "", new ValueContainerString(&HostCoreModules), DT_STRING, NoValidation},
- {"operserv", "nick", "OperServ", new ValueContainerString(&this->s_OperServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty},
- {"operserv", "description", "Operator Service", new ValueContainerString(&this->desc_OperServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty},
- {"operserv", "globalnick", "Global", new ValueContainerString(&this->s_GlobalNoticer), DT_STRING | DT_NORELOAD, ValidateNotEmpty},
- {"operserv", "globaldescription", "Global Noticer", new ValueContainerString(&this->desc_GlobalNoticer), DT_STRING | DT_NORELOAD, ValidateNotEmpty},
+ {"operserv", "nick", "", new ValueContainerString(&this->s_OperServ), DT_STRING | DT_NORELOAD, ValidateOperServ},
+ {"operserv", "description", "Operator Service", new ValueContainerString(&this->desc_OperServ), DT_STRING | DT_NORELOAD, ValidateOperServ},
{"operserv", "modules", "", new ValueContainerString(&OperCoreModules), DT_STRING, NoValidation},
{"operserv", "superadmin", "no", new ValueContainerBool(&this->SuperAdmin), DT_BOOLEAN, NoValidation},
- {"operserv", "autokillexpiry", "0", new ValueContainerTime(&this->AutokillExpiry), DT_TIME, ValidateNotZero},
- {"operserv", "chankillexpiry", "0", new ValueContainerTime(&this->ChankillExpiry), DT_TIME, ValidateNotZero},
- {"operserv", "snlineexpiry", "0", new ValueContainerTime(&this->SNLineExpiry), DT_TIME, ValidateNotZero},
- {"operserv", "sqlineexpiry", "0", new ValueContainerTime(&this->SQLineExpiry), DT_TIME, ValidateNotZero},
- {"operserv", "szlineexpiry", "0", new ValueContainerTime(&this->SZLineExpiry), DT_TIME, ValidateNotZero},
+ {"operserv", "autokillexpiry", "0", new ValueContainerTime(&this->AutokillExpiry), DT_TIME, ValidateOperServ},
+ {"operserv", "chankillexpiry", "0", new ValueContainerTime(&this->ChankillExpiry), DT_TIME, ValidateOperServ},
+ {"operserv", "snlineexpiry", "0", new ValueContainerTime(&this->SNLineExpiry), DT_TIME, ValidateOperServ},
+ {"operserv", "sqlineexpiry", "0", new ValueContainerTime(&this->SQLineExpiry), DT_TIME, ValidateOperServ},
+ {"operserv", "szlineexpiry", "0", new ValueContainerTime(&this->SZLineExpiry), DT_TIME, ValidateOperServ},
{"operserv", "akillonadd", "no", new ValueContainerBool(&this->AkillOnAdd), DT_BOOLEAN, NoValidation},
{"operserv", "killonsnline", "no", new ValueContainerBool(&this->KillonSNline), DT_BOOLEAN, NoValidation},
{"operserv", "killonsqline", "no", new ValueContainerBool(&this->KillonSQline), DT_BOOLEAN, NoValidation},
{"operserv", "notifications", "", new ValueContainerString(&OSNotifications), DT_STRING, NoValidation},
{"operserv", "limitsessions", "no", new ValueContainerBool(&this->LimitSessions), DT_BOOLEAN, NoValidation},
{"operserv", "defaultsessionlimit", "0", new ValueContainerUInt(&this->DefSessionLimit), DT_UINTEGER, NoValidation},
- {"operserv", "maxsessionlimit", "0", new ValueContainerUInt(&this->MaxSessionLimit), DT_UINTEGER, ValidateLimitSessions},
- {"operserv", "exceptionexpiry", "0", new ValueContainerTime(&this->ExceptionExpiry), DT_TIME, ValidateLimitSessions},
+ {"operserv", "maxsessionlimit", "0", new ValueContainerUInt(&this->MaxSessionLimit), DT_UINTEGER, ValidateOperServ},
+ {"operserv", "exceptionexpiry", "0", new ValueContainerTime(&this->ExceptionExpiry), DT_TIME, ValidateOperServ},
{"operserv", "sessionlimitexceeded", "", new ValueContainerString(&this->SessionLimitExceeded), DT_STRING, NoValidation},
{"operserv", "sessionlimitdetailsloc", "", new ValueContainerString(&this->SessionLimitDetailsLoc), DT_STRING, NoValidation},
{"operserv", "maxsessionkill", "0", new ValueContainerInt(&this->MaxSessionKill), DT_INTEGER, NoValidation},
{"operserv", "sessionautokillexpiry", "0", new ValueContainerTime(&this->SessionAutoKillExpiry), DT_TIME, NoValidation},
{"operserv", "addakiller", "no", new ValueContainerBool(&this->AddAkiller), DT_BOOLEAN, NoValidation},
{"operserv", "opersonly", "no", new ValueContainerBool(&this->OSOpersOnly), DT_BOOLEAN, NoValidation},
+ {"global", "globalnick", "", new ValueContainerString(&this->s_GlobalNoticer), DT_STRING | DT_NORELOAD, ValidateGlobal},
+ {"global", "globaldescription", "Global Noticer", new ValueContainerString(&this->desc_GlobalNoticer), DT_STRING | DT_NORELOAD, ValidateGlobal},
{"defcon", "defaultlevel", "0", new ValueContainerInt(&DefConLevel), DT_INTEGER, ValidateDefCon},
{"defcon", "level4", "", new ValueContainerString(&DefCon4), DT_STRING, ValidateDefCon},
{"defcon", "level3", "", new ValueContainerString(&DefCon3), DT_STRING, ValidateDefCon},
diff --git a/src/logger.cpp b/src/logger.cpp
index 61e8915b8..d5982c3c7 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -104,6 +104,8 @@ Anope::string LogFile::GetName() const
Log::Log(LogType type, const Anope::string &category, BotInfo *b) : bi(b), Type(type), Category(category)
{
+ if (!b)
+ b = Global;
if (b)
this->Sources.push_back(b->nick);
}
@@ -118,7 +120,8 @@ Log::Log(LogType type, User *u, Command *c, ChannelInfo *ci) : Type(type)
this->bi = c->service ? c->service : Global;
this->Category = (c->service ? c->service->nick + "/" : "") + c->name;
- this->Sources.push_back(this->bi->nick);
+ if (this->bi)
+ this->Sources.push_back(this->bi->nick);
this->Sources.push_back(u->nick);
this->Sources.push_back(c->name);
if (ci)
@@ -172,6 +175,8 @@ Log::Log(Server *s, const Anope::string &category) : bi(OperServ), Type(LOG_SERV
if (!s)
throw CoreException("Invalid pointer passed to Log::Log");
+ if (!this->bi)
+ this->bi = Global;
if (this->bi)
this->Sources.push_back(this->bi->nick);
this->Sources.push_back(s->GetName());
@@ -182,9 +187,9 @@ Log::Log(Server *s, const Anope::string &category) : bi(OperServ), Type(LOG_SERV
Log::Log(BotInfo *b, const Anope::string &category) : bi(b), Type(LOG_USER), Category(category)
{
if (!b)
- throw CoreException("Invalid opinter passed to Log::Log");
-
- this->Sources.push_back(bi->nick);
+ b = Global;
+ if (this->bi)
+ this->Sources.push_back(bi->nick);
}
Log::~Log()
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index d2dd6cd53..e637d32c6 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -260,7 +260,7 @@ void ModuleManager::DeleteModule(Module *m)
const char *err = ano_moderr();
if (!destroy_func && err && *err)
{
- Log() << "No destroy function found, chancing delete...";
+ Log() << "No destroy function found for " << m->name << ", chancing delete...";
delete m; /* we just have to chance they haven't overwrote the delete operator then... */
}
else
diff --git a/src/operserv.cpp b/src/operserv.cpp
index c99b78238..ef561a03d 100644
--- a/src/operserv.cpp
+++ b/src/operserv.cpp
@@ -23,17 +23,20 @@ Flags<ChannelModeName, CMODE_END * 2> DefConModesOff;
/* Map of Modesa and Params for DefCon */
std::map<ChannelModeName, Anope::string> DefConModesOnParams;
-XLineManager *SGLine, *SZLine, *SQLine, *SNLine;
+XLineManager *SGLine = NULL, *SZLine = NULL, *SQLine = NULL, *SNLine = NULL;
void os_init()
{
- ModuleManager::LoadModuleList(Config->OperServCoreModules);
+ if (!Config->s_OperServ.empty())
+ {
+ ModuleManager::LoadModuleList(Config->OperServCoreModules);
- /* Yes, these are in this order for a reason. Most violent->least violent. */
- XLineManager::RegisterXLineManager(SGLine = new SGLineManager());
- XLineManager::RegisterXLineManager(SZLine = new SZLineManager());
- XLineManager::RegisterXLineManager(SQLine = new SQLineManager());
- XLineManager::RegisterXLineManager(SNLine = new SNLineManager());
+ /* Yes, these are in this order for a reason. Most violent->least violent. */
+ XLineManager::RegisterXLineManager(SGLine = new SGLineManager());
+ XLineManager::RegisterXLineManager(SZLine = new SZLineManager());
+ XLineManager::RegisterXLineManager(SQLine = new SQLineManager());
+ XLineManager::RegisterXLineManager(SNLine = new SNLineManager());
+ }
}
bool SetDefConParam(ChannelModeName Name, const Anope::string &buf)
@@ -105,6 +108,9 @@ void DelDefCon(int level, DefconLevel Level)
void server_global(const Server *s, const Anope::string &message)
{
+ if (Config->s_GlobalNoticer.empty())
+ return;
+
/* Do not send the notice to ourselves our juped servers */
if (s != Me && !s->HasFlag(SERVER_JUPED))
notice_server(Config->s_GlobalNoticer, s, "%s", message.c_str());
@@ -490,7 +496,7 @@ XLine *SGLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_
if (u && Config->AddAkiller)
realreason = "[" + u->nick + "]" + reason;
- XLine *x = new XLine(mask, u ? u->nick : OperServ->nick, expires, realreason);
+ XLine *x = new XLine(mask, u ? u->nick : (OperServ ? OperServ->nick : "OperServ"), expires, realreason);
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnAddAkill, OnAddAkill(u, x));
@@ -549,7 +555,7 @@ XLine *SNLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_
return NULL;
}
- XLine *x = new XLine(mask, u ? u->nick : OperServ->nick, expires, reason);
+ XLine *x = new XLine(mask, u ? u->nick : (OperServ ? OperServ->nick : "OperServ"), expires, reason);
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnAddXLine, OnAddXLine(u, x, X_SNLINE));
@@ -629,7 +635,7 @@ XLine *SQLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_
return NULL;
}
- XLine *x = new XLine(mask, u ? u->nick : OperServ->nick, expires, reason);
+ XLine *x = new XLine(mask, u ? u->nick : (OperServ ? OperServ->nick : "OperServ"), expires, reason);
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnAddXLine, OnAddXLine(u, x, X_SQLINE));
@@ -747,7 +753,7 @@ XLine *SZLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_
return NULL;
}
- XLine *x = new XLine(mask, u ? u->nick : OperServ->nick, expires, reason);
+ XLine *x = new XLine(mask, u ? u->nick : (OperServ ? OperServ->nick : "OperServ"), expires, reason);
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnAddXLine, OnAddXLine(u, x, X_SZLINE));
diff --git a/src/servers.cpp b/src/servers.cpp
index d8752d90b..d7517405a 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -342,7 +342,7 @@ void do_server(const Anope::string &source, const Anope::string &servername, uns
Server *newserver = new Server(s, servername, hops, descript, numeric);
/* Announce services being online. */
- if (Config->GlobalOnCycle && !Config->GlobalOnCycleUP.empty())
+ if (Config->GlobalOnCycle && !Config->GlobalOnCycleUP.empty() && !Config->s_GlobalNoticer.empty())
notice_server(Config->s_GlobalNoticer, newserver, "%s", Config->GlobalOnCycleUP.c_str());
/* Let modules know about the connection */