1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 17:26:38 +02:00

Added os_config and support for including additional configuration files.

This commit is contained in:
Adam
2011-03-11 00:47:28 -05:00
parent 97c2e0957d
commit 1ee3d3d810
22 changed files with 891 additions and 668 deletions
+20 -2
View File
@@ -724,7 +724,7 @@ log
* operserv/global operserv/news operserv/stats operserv/kick
* operserv/mode operserv/session operserv/modlist operserv/ignore
* operserv/chankill operserv/akill operserv/sqline operserv/snline
* operserv/szline operserv/staff operserv/defcon
* operserv/szline operserv/staff operserv/defcon operserv/config
* operserv/modload operserv/jupe operserv/set operserv/noop
* operserv/quit operserv/update operserv/reload operserv/restart
* operserv/shutdown operserv/svsnick operserv/oline
@@ -1493,7 +1493,7 @@ operserv
*
* This directive is optional, but highly recommended.
*/
modules = "os_help os_global os_stats os_staff os_mode os_kick os_akill os_snline os_sqline os_szline os_chanlist os_userlist os_news os_session os_noop os_jupe os_ignore os_set os_reload os_update os_restart os_quit os_shutdown os_defcon os_chankill os_svsnick os_oline os_modload os_modunload os_modreload os_modlist os_modinfo"
modules = "os_help os_global os_stats os_staff os_mode os_kick os_akill os_snline os_sqline os_szline os_chanlist os_userlist os_news os_session os_noop os_jupe os_ignore os_set os_reload os_update os_restart os_quit os_shutdown os_defcon os_chankill os_svsnick os_oline os_modload os_modunload os_modreload os_modlist os_modinfo os_config"
/*
* If set, Services Admins will be able to use SUPERADMIN [ON|OFF] which will temporarily grant
@@ -1772,6 +1772,24 @@ defcon
#akillreason = "This network is currently not accepting connections, please try again later"
}
/*
* [OPTIONAL] Additional includes
*
* You can include additional configuration files here.
* You may also include executable files, which will be executed and
* the output from it will be included into your configuration.
*/
include
{
#type = "file"
#name = "some_other.conf"
}
include
{
#type = "executable"
#name = "/usr/bin/wget -q -O - http://some.miconfigured.network.com/services.conf"
}
/*
* [OPTIONAL] Non-Core Modules
*
+1
View File
@@ -13,6 +13,7 @@ A Added support for learning tracking/storing/locking all modes at runtime
A Added m_alias
A Added support for XMLRPC queries
A Added /botserv set msg
A Added /operserv config
F Changed the GHOST command to not allow ghosting unidentified users if the RECOVER command exists
F Some failed logic in /operserv exception that prevents proper exceptions from being added
F Fixed the anope_os_sxlines MySQL table and code to work after restarting
+1
View File
@@ -10,6 +10,7 @@ nickserv:modules added ns_ajoin
options:nomlock added
log:target added globops
nickserv:confirmemailchanges added
operserv:modules added os_config
** MODIFIED CONFIGURATION DIRECTIVES **
operserv:notifications removed osglobal, osmode, oskick, osakill, ossnline, ossqline, osszline, osnoop, osjupe, getpass, setpass, forbid, drop
+83 -135
View File
@@ -34,8 +34,6 @@ enum ConfigDataType
DT_UINTEGER, // Unsigned Integer
DT_LUINTEGER, // Long Unsigned Integer
DT_CHARPTR, // Char pointer
DT_CSSTRING, // std::string
DT_CISTRING, // ci::string
DT_STRING, // Anope::string
DT_BOOLEAN, // Boolean
DT_HOSTNAME, // Hostname syntax
@@ -89,11 +87,7 @@ class ValueItem
int GetInteger() const;
/** Get value as a string */
const char *GetString() const;
/** Get value as an std::string */
inline const std::string GetCSValue() const { return v.str(); }
/** Get value as a ci::string */
inline const ci::string GetCIValue() const { return v.ci_str(); }
/** Get value as a ci::string */
/** Get value as an Anope::string */
inline const Anope::string &GetValue() const { return v; }
/** Get value as a bool */
bool GetBool() const;
@@ -177,78 +171,6 @@ template<> class ValueContainer<char **> : public ValueContainerBase
}
};
/** This a specific version of ValueContainer to handle std::string specially
*/
template<> class ValueContainer<std::string *> : public ValueContainerBase
{
private:
/** Contained item */
std::string *val;
public:
/** Initialize with nothing */
ValueContainer() : ValueContainerBase(), val(NULL) { }
/** Initialize with an std::string */
ValueContainer(std::string *Val) : ValueContainerBase(), val(Val) { }
/** Initialize with a copy */
ValueContainer(const ValueContainer &Val) : ValueContainerBase(), val(Val.val) { }
ValueContainer &operator=(const ValueContainer &Val)
{
val = Val.val;
return *this;
}
/** Change value to given std::string */
void Set(const std::string &newval)
{
*val = newval;
}
/** Change value to given ci::string */
void Set(const ci::string &newval)
{
*val = newval.c_str();
}
/** Change value to given char pointer */
void Set(const char *newval)
{
*val = newval;
}
};
/** This a specific version of ValueContainer to handle ci::string specially
*/
template<> class ValueContainer<ci::string *> : public ValueContainerBase
{
private:
/** Contained item */
ci::string *val;
public:
/** Initialize with nothing */
ValueContainer() : ValueContainerBase(), val(NULL) { }
/** Initialize with an std::string */
ValueContainer(ci::string *Val) : ValueContainerBase(), val(Val) { }
/** Initialize with a copy */
ValueContainer(const ValueContainer &Val) : ValueContainerBase(), val(Val.val) { }
ValueContainer &operator=(const ValueContainer &Val)
{
val = Val.val;
return *this;
}
/** Change value to given std::string */
void Set(const std::string &newval)
{
*val = newval.c_str();
}
/** Change value to given ci::string */
void Set(const ci::string &newval)
{
*val = newval;
}
/** Change value to given char pointer */
void Set(const char *newval)
{
*val = newval;
}
};
/** This a specific version of ValueContainer to handle Anope::string specially
*/
template<> class ValueContainer<Anope::string *> : public ValueContainerBase
@@ -268,16 +190,7 @@ template<> class ValueContainer<Anope::string *> : public ValueContainerBase
val = Val.val;
return *this;
}
/** Change value to given std::string */
void Set(const std::string &newval)
{
*val = newval;
}
/** Change value to given ci::string */
void Set(const ci::string &newval)
{
*val = newval;
}
/** Change value to given Anope::string */
void Set(const Anope::string &newval)
{
@@ -319,16 +232,6 @@ typedef ValueContainer<int *> ValueContainerInt;
*/
typedef ValueContainer<time_t *> ValueContainerTime;
/** A specialization of ValueContainer to hold a pointer to
* an std::string
*/
typedef ValueContainer<std::string *> ValueContainerCSString;
/** A specialization of ValueContainer to hold a pointer to
* an ci::string
*/
typedef ValueContainer<ci::string *> ValueContainerCIString;
/** A specialization of ValueContainer to hold a pointer to
* an Anope::string
*/
@@ -348,43 +251,89 @@ typedef bool (*MultiValidator)(ServerConfig *, const Anope::string &, const Anop
*/
typedef bool (*MultiNotify)(ServerConfig *, const Anope::string &);
/** Holds a core configuration item and its callbacks
bool ValidateNotEmpty(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateNotZero(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateEmailReg(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidatePort(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateGuestPrefix(ServerConfig *conf, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateBantype(ServerConfig *, const Anope::string &, const Anope::string &, ValueItem &data);
bool ValidateChanServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateMemoServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateBotServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateHostServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateLimitSessions(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateOperServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateGlobal(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateDefCon(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateNickLen(ServerConfig *, const Anope::string &, const Anope::string &, ValueItem &data);
bool ValidateMail(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateGlobalOnCycle(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
/** Represents a configuration file
*/
struct InitialConfig
class ConfigurationFile
{
/** Tag name */
const Anope::string tag;
/** Value name */
const Anope::string value;
/** Default, if not defined */
const Anope::string default_value;
/** Value containers */
ValueContainerBase *val;
/** Data types */
int datatype;
/** Validation function */
Validator validation_function;
Anope::string name;
bool executable;
FILE *fp;
public:
ConfigurationFile(const Anope::string &, bool);
~ConfigurationFile();
const Anope::string &GetName() const;
bool IsOpen() const;
bool Open();
void Close();
bool End() const;
Anope::string Read();
};
/** Holds a core configuration item and its callbacks
* where there may be more than one item
/** Holds all of the core configuration items
*/
struct MultiConfig
class ConfigItems
{
/** Tag name */
const Anope::string tag;
/** One or more items within tag */
const Anope::string items[17];
/** One or more defaults for items within tags */
const Anope::string items_default[17];
/** One or more data types */
int datatype[17];
/** Initialization function */
MultiNotify init_function;
/** Validation function */
MultiValidator validation_function;
/** Completion function */
MultiNotify finish_function;
public:
/** Holds a core configuration item and its callbacks
*/
struct Item
{
/** Tag name */
Anope::string tag;
/** Value name */
Anope::string value;
/** Default, if not defined */
Anope::string default_value;
/** Value containers */
ValueContainerBase *val;
/** Data types */
int datatype;
/** Validation function */
Validator validation_function;
} *Values;
/** Holds a core configuration item and its callbacks
* where there may be more than one item
*/
struct MultiItem
{
/** Tag name */
Anope::string tag;
/** One or more items within tag */
Anope::string items[17];
/** One or more defaults for items within tags */
Anope::string items_default[17];
/** One or more data types */
int datatype[17];
/** Initialization function */
MultiNotify init_function;
/** Validation function */
MultiValidator validation_function;
/** Completion function */
MultiNotify finish_function;
} *MultiValues;
ConfigItems(ServerConfig *conf);
~ConfigItems();
};
/** This class holds the bulk of the runtime configuration for Anope.
@@ -398,8 +347,6 @@ class CoreExport ServerConfig
*/
bool CheckOnce(const Anope::string &);
public:
/* Error from the config */
std::ostringstream errstr;
/** This holds all the information in the config file,
* it's indexed by tag name to a vector of key/values.
*/
@@ -407,15 +354,16 @@ class CoreExport ServerConfig
/** Construct a new ServerConfig
*/
ServerConfig();
/** Read the entire configuration into memory
* and initialize this class. All other methods
* should be used only by the core.
*/
void Read();
/** Load 'filename' into 'target', with the new config parser everything is parsed into
/** Load the configuration file into 'this'. With the new config parser everything is parsed into
* tag/key/value at load-time rather than at read-value time.
*/
bool LoadConf(ConfigDataHash &, const Anope::string &);
void LoadConf(ConfigurationFile &file);
// Both these return true if the value existed or false otherwise
/** Writes 'length' chars into 'result' as a string
*/
@@ -857,7 +805,7 @@ class CoreExport ConfigReader
long error;
public:
/** Default constructor.
* This constructor initialises the ConfigReader class to read services.conf.
* This constructor initialises the ConfigReader class to read the configuration file(s).
*/
ConfigReader();
/** Overloaded constructor.
+2 -2
View File
@@ -108,7 +108,7 @@ E Anope::string get_mlock_modes(ChannelInfo *ci, int complete);
/**** config.c ****/
E Anope::string services_conf;
E ConfigurationFile services_conf;
E ServerConfig *Config;
/* hostserv.c */
@@ -234,7 +234,7 @@ E size_t strlcat(char *, const char *, size_t);
#endif
E time_t dotime(const Anope::string &s);
E Anope::string duration(NickCore *nc, time_t seconds);
E Anope::string duration(time_t seconds);
E Anope::string expire_left(NickCore *nc, time_t expires);
E Anope::string do_strftime(const time_t &t);
E bool doValidHost(const Anope::string &host, int type);
+1 -1
View File
@@ -10,7 +10,7 @@
#define BAD_USERHOST_MASK "Mask must be in the form \037user\037@\037host\037."
#define BAD_EXPIRY_TIME "Invalid expiry time."
#define USERHOST_MASK_TOO_WIDE "%s coverage is too wide; Please use a more specific mask."
#define READ_ONLY_MODE "\002Notice:\002 Services is in read-only mode; changes will not be saved!"
#define READ_ONLY_MODE "Services are in read-only mode!"
#define PASSWORD_INCORRECT "Password incorrect."
#define ACCESS_DENIED "Access denied."
#define MORE_OBSCURE_PASSWORD "Please try again with a more obscure password. Passwords should be at least five characters long, should not be something easily guessed (e.g. your real name or your nick), and cannot contain the space or tab characters."
+1
View File
@@ -942,6 +942,7 @@ class IRCDProto;
class IRCdMessage;
struct Uplink;
class ServerConfig;
class ConfigurationFile;
#include "extern.h"
#include "language.h"
+1 -1
View File
@@ -95,7 +95,7 @@ class CommandNSIdentify : public Command
source.Reply(_("Your email address is not confirmed. To confirm it, follow the instructions that were emailed to you when you registered."));
time_t time_registered = Anope::CurTime - na->time_registered;
if (Config->NSUnconfirmedExpire > time_registered)
source.Reply(_("Your account will expire, if not confirmed, in %s"), duration(u->Account(), Config->NSUnconfirmedExpire - time_registered).c_str());
source.Reply(_("Your account will expire, if not confirmed, in %s"), duration(Config->NSUnconfirmedExpire - time_registered).c_str());
}
check_memos(u);
+3 -3
View File
@@ -51,7 +51,7 @@ class CommandNSRecover : public Command
u2->Collide(na);
/* Convert Config->NSReleaseTimeout seconds to string format */
Anope::string relstr = duration(na->nc, Config->NSReleaseTimeout);
Anope::string relstr = duration(Config->NSReleaseTimeout);
source.Reply(_(NICK_RECOVERED), Config->s_NickServ.c_str(), nick.c_str(), relstr.c_str());
}
@@ -74,7 +74,7 @@ class CommandNSRecover : public Command
u2->Collide(na);
/* Convert Config->NSReleaseTimeout seconds to string format */
Anope::string relstr = duration(na->nc, Config->NSReleaseTimeout);
Anope::string relstr = duration(Config->NSReleaseTimeout);
source.Reply(_(NICK_RECOVERED), Config->s_NickServ.c_str(), nick.c_str(), relstr.c_str());
}
@@ -87,7 +87,7 @@ class CommandNSRecover : public Command
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
/* Convert Config->NSReleaseTimeout seconds to string format */
Anope::string relstr = duration(source.u->Account(), Config->NSReleaseTimeout);
Anope::string relstr = duration(Config->NSReleaseTimeout);
source.Reply(_("Syntax: \002RECOVER \037nickname\037 [\037password\037]\002\n"
" \n"
+1 -1
View File
@@ -200,7 +200,7 @@ class CommandNSRegister : public Command
if (SendRegmail(u, na))
{
source.Reply(_("A passcode has been sent to %s, please type %R%s confirm <passcode> to confirm your email address."), email.c_str(), NickServ->nick.c_str());
source.Reply(_("If you do not confirm your email address within %s your account will expire."), duration(na->nc, Config->NSUnconfirmedExpire).c_str());
source.Reply(_("If you do not confirm your email address within %s your account will expire."), duration(Config->NSUnconfirmedExpire).c_str());
}
}
+1 -2
View File
@@ -72,8 +72,7 @@ class CommandNSRelease : public Command
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
/* Convert Config->NSReleaseTimeout seconds to string format */
User *u = source.u;
Anope::string relstr = duration(u->Account(), Config->NSReleaseTimeout);
Anope::string relstr = duration(Config->NSReleaseTimeout);
source.Reply(_("Syntax: \002RELEASE \037nickname\037 [\037password\037]\002\n"
" \n"
+1 -1
View File
@@ -195,7 +195,7 @@ class CommandOSAKill : public Command
source.Reply(_("\002%s\002 added to the AKILL list."), mask.c_str());
Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << duration(NULL, expires - Anope::CurTime) << " [affects " << affected << " user(s) (" << percent << "%)]";
Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << duration(expires - Anope::CurTime) << " [affects " << affected << " user(s) (" << percent << "%)]";
if (readonly)
source.Reply(_(READ_ONLY_MODE));
+231
View File
@@ -0,0 +1,231 @@
/* OperServ core functions
*
* (C) 2003-2011 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
/*************************************************************************/
#include "module.h"
class CommandOSConfig : public Command
{
void ChangeHash(ConfigDataHash &hash, const Anope::string &block, const Anope::string &iname, const Anope::string &value)
{
ConfigDataHash::iterator it = hash.find(block);
KeyValList &list = it->second;
for (unsigned i = 0; i < list.size(); ++i)
{
const Anope::string &item = list[i].first;
if (item == iname)
{
list[i] = std::make_pair(item, value);
break;
}
}
}
public:
CommandOSConfig() : Command("CONFIG", 1, 4, "operserv/config")
{
this->SetDesc("View and change configuration file settings");
}
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
const Anope::string &what = params[0];
if (what.equals_ci("MODIFY") && params.size() > 3)
{
ConfigItems configitems(Config);
for (unsigned i = 0; !configitems.Values[i].tag.empty(); ++i)
{
ConfigItems::Item *v = &configitems.Values[i];
if (v->tag.equals_cs(params[1]) && v->value.equals_cs(params[2]))
{
try
{
ValueItem vi(params[3]);
if (!v->validation_function(Config, v->tag, v->value, vi))
throw ConfigException("Parameter failed to validate.");
int dt = v->datatype;
if (dt & DT_NORELOAD)
throw ConfigException("This item can not be changed while Anope is running.");
bool allow_wild = dt & DT_ALLOW_WILD;
dt &= ~(DT_ALLOW_NEWLINE | DT_ALLOW_WILD);
/* Yay for *massive* copypaste from config.cpp */
switch (dt)
{
case DT_NOSPACES:
{
ValueContainerString *vcs = debug_cast<ValueContainerString *>(v->val);
Config->ValidateNoSpaces(vi.GetValue(), v->tag, v->value);
vcs->Set(vi.GetValue());
break;
}
case DT_HOSTNAME:
{
ValueContainerString *vcs = debug_cast<ValueContainerString *>(v->val);
Config->ValidateHostname(vi.GetValue(), v->tag, v->value);
vcs->Set(vi.GetValue());
break;
}
case DT_IPADDRESS:
{
ValueContainerString *vcs = debug_cast<ValueContainerString *>(v->val);
Config->ValidateIP(vi.GetValue(), v->tag, v->value, allow_wild);
vcs->Set(vi.GetValue());
break;
}
case DT_CHARPTR:
{
ValueContainerChar *vcc = debug_cast<ValueContainerChar *>(v->val);
// Make sure we also copy the null terminator
vcc->Set(vi.GetString(), strlen(vi.GetString()) + 1);
break;
}
case DT_STRING:
{
ValueContainerString *vcs = debug_cast<ValueContainerString *>(v->val);
vcs->Set(vi.GetValue());
break;
}
case DT_INTEGER:
{
int val = vi.GetInteger();
ValueContainerInt *vci = debug_cast<ValueContainerInt *>(v->val);
vci->Set(&val, sizeof(int));
break;
}
case DT_UINTEGER:
{
unsigned val = vi.GetInteger();
ValueContainerUInt *vci = debug_cast<ValueContainerUInt *>(v->val);
vci->Set(&val, sizeof(unsigned));
break;
}
case DT_LUINTEGER:
{
unsigned long val = vi.GetInteger();
ValueContainerLUInt *vci = debug_cast<ValueContainerLUInt *>(v->val);
vci->Set(&val, sizeof(unsigned long));
break;
}
case DT_TIME:
{
time_t time = dotime(vi.GetValue());
ValueContainerTime *vci = debug_cast<ValueContainerTime *>(v->val);
vci->Set(&time, sizeof(time_t));
break;
}
case DT_BOOLEAN:
{
bool val = vi.GetBool();
ValueContainerBool *vcb = debug_cast<ValueContainerBool *>(v->val);
vcb->Set(&val, sizeof(bool));
break;
}
default:
break;
}
}
catch (const ConfigException &ex)
{
source.Reply(_("Error changing configuration value: ") + ex.GetReason());
return MOD_CONT;
}
ChangeHash(Config->config_data, params[1], params[2], params[3]);
Log(LOG_ADMIN, source.u, this) << "to change the configuration value of " << params[1] << ":" << params[2] << " to " << params[3];
source.Reply(_("Value of %s:%s changed to %s"), params[1].c_str(), params[2].c_str(), params[3].c_str());
return MOD_CONT;
}
}
source.Reply("There is no configuration value named %s:%s", params[1].c_str(), params[2].c_str());
}
else if (what.equals_ci("VIEW"))
{
/* Blocks we should show */
const Anope::string show_blocks[] = { "botserv", "chanserv", "defcon", "global", "memoserv", "nickserv", "networkinfo", "operserv", "options", "" };
Log(LOG_ADMIN, source.u, this);
for (ConfigDataHash::const_iterator it = Config->config_data.begin(), it_end = Config->config_data.end(); it != it_end; ++it)
{
const Anope::string &bname = it->first;
const KeyValList &list = it->second;
bool ok = false;
for (unsigned i = 0; !show_blocks[i].empty(); ++i)
if (bname == show_blocks[i])
ok = true;
if (ok == false)
continue;
source.Reply(_("%s settings:"), bname.c_str());
for (unsigned i = 0; i < list.size(); ++i)
{
const Anope::string &first = list[i].first, second = list[i].second;
if (first == "modules")
continue; // Modules list isn't important
source.Reply(_(" Name: %-15s Value: %s"), first.c_str(), second.c_str());
}
}
source.Reply(_("End of configuration."));
}
else
this->OnSyntaxError(source, what);
return MOD_CONT;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
source.Reply(_("Syntax: \002CONFIG {\037MODIFY\037|\037VIEW\037} [\037block name\037 \037item name\037 \037item value\037]\002\n"
"\n"
"\002CONFIG\002 allows you to change and view configuration settings.\n"
"Settings changed by this command are temporary and will not be reflected\n"
"back into the configuration file, and will be lost if Anope is shut down,\n"
"restarted, or the RELOAD command is used.\n"
" \n"
"Example:\n"
" \002CONFIG MODIFY nickserv forcemail no\002"));
return true;
}
void OnSyntaxError(CommandSource &source, const Anope::string &subcommand)
{
SyntaxError(source, "CONFIG", _("CONFIG {\037MODIFY\037|\037VIEW\037} [\037block name\037 \037item name\037 \037item value\037]"));
}
};
class OSConfig : public Module
{
CommandOSConfig commandosconfig;
public:
OSConfig(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(OperServ, &commandosconfig);
}
};
MODULE_INIT(OSConfig)
+2 -1
View File
@@ -29,13 +29,14 @@ class CommandOSReload : public Command
delete Config;
Config = newconfig;
FOREACH_MOD(I_OnReload, OnReload(false));
source.Reply(_("Services' configuration file has been reloaded."));
}
catch (const ConfigException &ex)
{
Log() << "Error reloading configuration file: " << ex.GetReason();
source.Reply(_("Error reloading confguration file: ") + ex.GetReason());
}
source.Reply(_("Services' configuration file has been reloaded."));
return MOD_CONT;
}
+1 -1
View File
@@ -208,7 +208,7 @@ class CommandOSSNLine : public Command
return MOD_CONT;
source.Reply(_("\002%s\002 added to the SNLINE list."), mask.c_str());
Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << duration(NULL, expires - Anope::CurTime) << " [affects " << affected << " user(s) (" << percent << "%)]";
Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << duration(expires - Anope::CurTime) << " [affects " << affected << " user(s) (" << percent << "%)]";
if (readonly)
source.Reply(_(READ_ONLY_MODE));
+1 -1
View File
@@ -188,7 +188,7 @@ class CommandOSSQLine : public Command
return MOD_CONT;
source.Reply(_("\002%s\002 added to the SQLINE list."), mask.c_str());
Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << duration(NULL, expires - Anope::CurTime) << " [affects " << affected << " user(s) (" << percent << "%)]";
Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << duration(expires - Anope::CurTime) << " [affects " << affected << " user(s) (" << percent << "%)]";
if (readonly)
source.Reply(_(READ_ONLY_MODE));
+1 -39
View File
@@ -130,47 +130,9 @@ class CommandOSStats : public Command
CommandReturn DoStatsUptime(CommandSource &source)
{
time_t uptime = Anope::CurTime - start_time;
int days = uptime / 86400, hours = (uptime / 3600) % 24, mins = (uptime / 60) % 60, secs = uptime % 60;
source.Reply(_("Current users: \002%d\002 (\002%d\002 ops)"), usercnt, opcnt);
source.Reply(_("Maximum users: \002%d\002 (%s)"), maxusercnt, do_strftime(maxusertime).c_str());
if (days > 1)
source.Reply(_("Services up \002%d\002 days, \002%02d:%02d\002"), days, hours, mins, secs);
else if (days == 1)
source.Reply(_("Services up OPER_STATS_UPTIME_1\002%dOPER_STATS_UPTIME_1\002 day, OPER_STATS_UPTIME_1\002%02d:%02dOPER_STATS_UPTIME_1\002"), days, hours, mins, secs);
else
{
if (hours > 1)
{
if (mins != 1)
source.Reply(_("Services up \002%d\002 hours, \002%d\002 minutes"), hours, mins);
else
source.Reply(_("Services up OPER_STATS_UPTIME_H1\002%dOPER_STATS_UPTIME_H1\002 hours, OPER_STATS_UPTIME_H1\002%dOPER_STATS_UPTIME_H1\002 minute"), hours, mins, secs);
}
else if (hours == 1)
{
if (mins != 1)
source.Reply(_("Services up OPER_STATS_UPTIME_1\002%dOPER_STATS_UPTIME_1\002 hour, OPER_STATS_UPTIME_1\002%dOPER_STATS_UPTIME_1\002 minutes"), hours, mins, secs);
else
source.Reply(_("Services up OPER_STATS_UPTIME_1H1\002%dOPER_STATS_UPTIME_1H1\002 hour, OPER_STATS_UPTIME_1H1\002%dOPER_STATS_UPTIME_1H1\002 minute"), hours, mins, secs);
}
else
{
if (mins != 1)
{
if (secs != 1)
source.Reply(_("Services up \002%d\002 minutes, \002%d\002 seconds"), mins, secs);
else
source.Reply(_("Services up OPER_STATS_UPTIME_M1\002%dOPER_STATS_UPTIME_M1\002 minutes, OPER_STATS_UPTIME_M1\002%dOPER_STATS_UPTIME_M1\002 second"), mins, secs);
}
else
{
if (secs != 1)
source.Reply(_("Services up OPER_STATS_UPTIME_1\002%dOPER_STATS_UPTIME_1\002 minute, OPER_STATS_UPTIME_1\002%dOPER_STATS_UPTIME_1\002 seconds"), mins, secs);
else
source.Reply(_("Services up OPER_STATS_UPTIME_1M1\002%dOPER_STATS_UPTIME_1M1\002 minute, OPER_STATS_UPTIME_1M1\002%dOPER_STATS_UPTIME_1M1\002 second"), mins, secs);
}
}
}
source.Reply(_("Services up %s"), duration(uptime).c_str());
return MOD_CONT;
}
+1 -1
View File
@@ -192,7 +192,7 @@ class CommandOSSZLine : public Command
return MOD_CONT;
source.Reply(_("\002%s\002 added to the SZLINE list."), mask.c_str());
Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << duration(NULL, expires - Anope::CurTime) << " [affects " << affected << " user(s) (" << percent << "%)]";
Log(LOG_ADMIN, u, this) << "on " << mask << " (" << reason << ") expires in " << duration(expires - Anope::CurTime) << " [affects " << affected << " user(s) (" << percent << "%)]";
if (readonly)
source.Reply(_(READ_ONLY_MODE));
+1 -1
View File
@@ -147,7 +147,7 @@ void BotInfo::Assign(User *u, ChannelInfo *ci)
ci->bi = this;
if (ci->c && ci->c->users.size() >= Config->BSMinUsers)
this->Join(ci->c);
this->Join(ci->c, &Config->BotModeList);
}
void BotInfo::UnAssign(User *u, ChannelInfo *ci)
+531 -469
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -295,7 +295,7 @@ void Init(int ac, char **av)
{
if (Arg.empty())
throw FatalException("The --config option requires a file name");
services_conf = Arg;
services_conf = ConfigurationFile(Arg, false);
}
if (GetCommandLineArgument("dir", 0, Arg))
@@ -315,9 +315,9 @@ void Init(int ac, char **av)
Log(LOG_TERMINAL) << "Anope " << Anope::Version() << ", " << Anope::Build();
#ifdef _WIN32
Log(LOG_TERMINAL) << "Using configuration file " << services_dir << "\\" << services_conf;
Log(LOG_TERMINAL) << "Using configuration file " << services_dir << "\\" << services_conf.GetName();
#else
Log(LOG_TERMINAL) << "Using configuration file " << services_dir << "/" << services_conf;
Log(LOG_TERMINAL) << "Using configuration file " << services_dir << "/" << services_conf.GetName();
#endif
/* Read configuration file; exit if there are problems. */
+3 -4
View File
@@ -201,11 +201,10 @@ time_t dotime(const Anope::string &s)
/**
* Expresses in a string the period of time represented by a given amount
* of seconds (with days/hours/minutes).
* @param na Nick Alias
* @param seconds time in seconds
* @return buffer
*/
Anope::string duration(NickCore *nc, time_t seconds)
Anope::string duration(time_t seconds)
{
/* We first calculate everything */
time_t days = seconds / 86400;
@@ -248,9 +247,9 @@ Anope::string do_strftime(const time_t &t)
char buf[BUFSIZE];
strftime(buf, sizeof(buf), "%b %d %H:%M:%S %Y %Z", &tm);
if (t < Anope::CurTime)
return Anope::string(buf) + " (" + duration(NULL, Anope::CurTime - t) + " ago)";
return Anope::string(buf) + " (" + duration(Anope::CurTime - t) + " ago)";
else
return Anope::string(buf) + " (" + duration(NULL, t - Anope::CurTime) + " from now)";
return Anope::string(buf) + " (" + duration(t - Anope::CurTime) + " from now)";
}
/*************************************************************************/