2012-04-19 20:58:29 +02:00
|
|
|
/*
|
|
|
|
* InspIRCd -- Internet Relay Chat Daemon
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
2020-01-11 22:02:47 +00:00
|
|
|
* Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
|
|
|
|
* Copyright (C) 2018 Chris Novakovic <chrisnovakovic@users.noreply.github.com>
|
|
|
|
* Copyright (C) 2013-2014, 2016 Attila Molnar <attilamolnar@hush.com>
|
|
|
|
* Copyright (C) 2013 Daniel Vassdal <shutter@canternet.org>
|
2021-02-26 06:58:13 +00:00
|
|
|
* Copyright (C) 2012-2014, 2016-2021 Sadie Powell <sadie@witchery.services>
|
2020-01-11 22:02:47 +00:00
|
|
|
* Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
|
|
|
|
* Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
|
|
|
|
* Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
|
|
|
|
* Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
|
|
|
|
* Copyright (C) 2007-2008 Craig Edwards <brain@inspircd.org>
|
|
|
|
* Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This file is part of InspIRCd. InspIRCd is free software: you can
|
|
|
|
* redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
* License as published by the Free Software Foundation, version 2.
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2007-07-16 17:30:04 +00:00
|
|
|
*/
|
|
|
|
|
2012-04-19 20:58:29 +02:00
|
|
|
|
2013-04-02 20:12:15 +01:00
|
|
|
#pragma once
|
2007-07-16 17:30:04 +00:00
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include "inspircd.h"
|
|
|
|
#include "modules.h"
|
|
|
|
#include "socketengine.h"
|
|
|
|
#include "socket.h"
|
2017-08-17 18:32:19 +01:00
|
|
|
#include "token_list.h"
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2012-07-05 21:00:35 +01:00
|
|
|
/** Structure representing a single \<tag> in config */
|
2009-10-22 22:29:35 +00:00
|
|
|
class CoreExport ConfigTag : public refcountbase
|
2008-03-23 20:43:35 +00:00
|
|
|
{
|
2016-12-08 01:57:47 +00:00
|
|
|
ConfigItems items;
|
2009-10-22 22:29:35 +00:00
|
|
|
public:
|
2009-10-17 02:14:44 +00:00
|
|
|
const std::string tag;
|
2009-10-17 17:53:22 +00:00
|
|
|
const std::string src_name;
|
|
|
|
const int src_line;
|
2008-10-18 16:52:48 +00:00
|
|
|
|
2018-06-29 11:26:51 +01:00
|
|
|
/** Get the value of an option, using def if it does not exist */
|
|
|
|
std::string getString(const std::string& key, const std::string& def, const TR1NS::function<bool(const std::string&)>& validator);
|
2009-10-22 22:29:35 +00:00
|
|
|
/** Get the value of an option, using def if it does not exist */
|
2017-08-17 14:54:49 +01:00
|
|
|
std::string getString(const std::string& key, const std::string& def = "", size_t minlen = 0, size_t maxlen = UINT32_MAX);
|
2009-10-22 22:29:35 +00:00
|
|
|
/** Get the value of an option, using def if it does not exist */
|
2018-04-14 16:53:03 +01:00
|
|
|
long getInt(const std::string& key, long def, long min = LONG_MIN, long max = LONG_MAX);
|
2009-10-22 22:29:35 +00:00
|
|
|
/** Get the value of an option, using def if it does not exist */
|
2018-04-14 15:43:03 +01:00
|
|
|
unsigned long getUInt(const std::string& key, unsigned long def, unsigned long min = 0, unsigned long max = ULONG_MAX);
|
|
|
|
/** Get the value of an option, using def if it does not exist */
|
2018-04-14 16:11:57 +01:00
|
|
|
double getFloat(const std::string& key, double def, double min = DBL_MIN, double max = DBL_MAX);
|
2009-10-22 22:29:35 +00:00
|
|
|
/** Get the value of an option, using def if it does not exist */
|
2009-10-17 02:14:44 +00:00
|
|
|
bool getBool(const std::string& key, bool def = false);
|
2008-10-18 16:52:48 +00:00
|
|
|
|
2013-08-12 19:20:18 +02:00
|
|
|
/** Get the value in seconds of a duration that is in the user-friendly "1h2m3s" format,
|
|
|
|
* using a default value if it does not exist or is out of bounds.
|
|
|
|
* @param key The config key name
|
|
|
|
* @param def Default value (optional)
|
|
|
|
* @param min Minimum acceptable value (optional)
|
|
|
|
* @param max Maximum acceptable value (optional)
|
|
|
|
* @return The duration in seconds
|
|
|
|
*/
|
2018-04-14 14:59:35 +01:00
|
|
|
unsigned long getDuration(const std::string& key, unsigned long def, unsigned long min = 0, unsigned long max = ULONG_MAX);
|
2013-08-12 19:20:18 +02:00
|
|
|
|
2009-10-22 22:29:35 +00:00
|
|
|
/** Get the value of an option
|
|
|
|
* @param key The option to get
|
|
|
|
* @param value The location to store the value (unmodified if does not exist)
|
|
|
|
* @param allow_newline Allow newlines in the option (normally replaced with spaces)
|
|
|
|
* @return true if the option exists
|
|
|
|
*/
|
2009-10-17 02:14:44 +00:00
|
|
|
bool readString(const std::string& key, std::string& value, bool allow_newline = false);
|
2009-10-17 17:53:22 +00:00
|
|
|
|
|
|
|
std::string getTagLocation();
|
2009-10-22 22:29:35 +00:00
|
|
|
|
2016-12-08 01:57:47 +00:00
|
|
|
inline const ConfigItems& getItems() const { return items; }
|
2009-10-23 19:07:40 +00:00
|
|
|
|
2016-12-08 01:57:47 +00:00
|
|
|
/** Create a new ConfigTag, giving access to the private ConfigItems item list */
|
|
|
|
static ConfigTag* create(const std::string& Tag, const std::string& file, int line, ConfigItems*& Items);
|
2009-10-22 22:29:35 +00:00
|
|
|
private:
|
|
|
|
ConfigTag(const std::string& Tag, const std::string& file, int line);
|
2008-03-23 20:43:35 +00:00
|
|
|
};
|
|
|
|
|
2008-09-20 20:53:04 +00:00
|
|
|
/** Defines the server's length limits on various length-limited
|
|
|
|
* items such as topics, nicknames, channel names etc.
|
|
|
|
*/
|
2009-09-02 00:46:11 +00:00
|
|
|
class ServerLimits
|
2008-05-25 17:30:43 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-09-30 17:21:52 +01:00
|
|
|
/** Maximum line length */
|
|
|
|
size_t MaxLine;
|
2008-09-20 20:53:04 +00:00
|
|
|
/** Maximum nickname length */
|
2008-05-25 17:30:43 +00:00
|
|
|
size_t NickMax;
|
2008-09-20 20:53:04 +00:00
|
|
|
/** Maximum channel length */
|
2008-05-25 17:30:43 +00:00
|
|
|
size_t ChanMax;
|
2008-09-20 20:53:04 +00:00
|
|
|
/** Maximum number of modes per line */
|
2008-05-25 17:30:43 +00:00
|
|
|
size_t MaxModes;
|
2008-09-20 20:53:04 +00:00
|
|
|
/** Maximum length of ident, not including ~ etc */
|
2008-05-25 17:30:43 +00:00
|
|
|
size_t IdentMax;
|
2008-09-20 20:53:04 +00:00
|
|
|
/** Maximum length of a quit message */
|
2008-05-25 17:30:43 +00:00
|
|
|
size_t MaxQuit;
|
2008-09-20 20:53:04 +00:00
|
|
|
/** Maximum topic length */
|
2008-05-25 17:30:43 +00:00
|
|
|
size_t MaxTopic;
|
2008-09-20 20:53:04 +00:00
|
|
|
/** Maximum kick message length */
|
2008-05-25 17:30:43 +00:00
|
|
|
size_t MaxKick;
|
2018-07-30 18:30:11 +01:00
|
|
|
/** Maximum real name length */
|
|
|
|
size_t MaxReal;
|
2008-09-20 20:53:04 +00:00
|
|
|
/** Maximum away message length */
|
2008-05-25 17:30:43 +00:00
|
|
|
size_t MaxAway;
|
2014-03-06 21:43:36 +00:00
|
|
|
/** Maximum hostname length */
|
|
|
|
size_t MaxHost;
|
2008-05-25 17:30:43 +00:00
|
|
|
|
2014-12-09 12:35:31 +01:00
|
|
|
/** Read all limits from a config tag. Limits which aren't specified in the tag are set to a default value.
|
|
|
|
* @param tag Configuration tag to read the limits from
|
|
|
|
*/
|
|
|
|
ServerLimits(ConfigTag* tag);
|
2016-07-22 11:26:11 +01:00
|
|
|
|
2017-08-25 13:03:53 +01:00
|
|
|
/** Maximum length of a n!u\@h mask */
|
2016-07-22 11:26:11 +01:00
|
|
|
size_t GetMaxMask() const { return NickMax + 1 + IdentMax + 1 + MaxHost; }
|
2008-05-25 17:30:43 +00:00
|
|
|
};
|
|
|
|
|
2009-10-21 23:46:24 +00:00
|
|
|
struct CommandLineConf
|
|
|
|
{
|
|
|
|
/** If this value is true, the owner of the
|
|
|
|
* server specified -nofork on the command
|
|
|
|
* line, causing the daemon to stay in the
|
|
|
|
* foreground.
|
|
|
|
*/
|
|
|
|
bool nofork;
|
|
|
|
|
|
|
|
/** If this value if true then all log
|
|
|
|
* messages will be output, regardless of
|
|
|
|
* the level given in the config file.
|
|
|
|
* This is set with the -debug commandline
|
|
|
|
* option.
|
|
|
|
*/
|
|
|
|
bool forcedebug;
|
|
|
|
|
|
|
|
/** If this is true then log output will be
|
|
|
|
* written to the logfile. This is the default.
|
|
|
|
* If you put -nolog on the commandline then
|
|
|
|
* the logfile will not be written.
|
|
|
|
* This is meant to be used in conjunction with
|
|
|
|
* -debug for debugging without filling up the
|
|
|
|
* hard disk.
|
|
|
|
*/
|
|
|
|
bool writelog;
|
|
|
|
|
2018-06-04 12:40:32 +01:00
|
|
|
/** If this is true, a PID file will be written
|
|
|
|
* to the file given in the "file" variable of
|
2018-10-21 19:18:08 +01:00
|
|
|
* the \<pid> tag in the config file. This is
|
2018-06-04 12:40:32 +01:00
|
|
|
* the default.
|
|
|
|
* Passing --nopid as a command line argument
|
|
|
|
* sets this to false; in this case, a PID file
|
|
|
|
* will not be written, even the default PID
|
2018-10-21 19:18:08 +01:00
|
|
|
* file that is usually written when the \<pid>
|
2018-06-04 12:40:32 +01:00
|
|
|
* tag is not defined in the config file.
|
|
|
|
*/
|
|
|
|
bool writepid;
|
|
|
|
|
2019-12-09 01:15:31 +00:00
|
|
|
/* Whether the --runasroot option was specified at boot. */
|
|
|
|
bool runasroot;
|
|
|
|
|
|
|
|
/** Saved argc from startup. */
|
2009-10-21 23:46:24 +00:00
|
|
|
int argc;
|
|
|
|
|
2019-12-09 01:15:31 +00:00
|
|
|
/** Saved argv from startup. */
|
2009-10-21 23:46:24 +00:00
|
|
|
char** argv;
|
|
|
|
};
|
|
|
|
|
2009-10-21 23:45:44 +00:00
|
|
|
class CoreExport OperInfo : public refcountbase
|
|
|
|
{
|
|
|
|
public:
|
2017-08-17 18:32:19 +01:00
|
|
|
TokenList AllowedOperCommands;
|
|
|
|
TokenList AllowedPrivs;
|
2009-10-21 23:46:05 +00:00
|
|
|
|
|
|
|
/** Allowed user modes from oper classes. */
|
|
|
|
std::bitset<64> AllowedUserModes;
|
|
|
|
|
|
|
|
/** Allowed channel modes from oper classes. */
|
|
|
|
std::bitset<64> AllowedChanModes;
|
|
|
|
|
2020-04-11 15:09:34 +01:00
|
|
|
/** Allowed snomasks from oper classes. */
|
|
|
|
std::bitset<64> AllowedSnomasks;
|
|
|
|
|
2012-07-05 21:00:35 +01:00
|
|
|
/** \<oper> block used for this oper-up. May be NULL. */
|
2009-10-21 23:45:44 +00:00
|
|
|
reference<ConfigTag> oper_block;
|
2012-07-05 21:00:35 +01:00
|
|
|
/** \<type> block used for this oper-up. Valid for local users, may be NULL on remote */
|
2009-10-21 23:45:44 +00:00
|
|
|
reference<ConfigTag> type_block;
|
2012-07-05 21:00:35 +01:00
|
|
|
/** \<class> blocks referenced from the \<type> block. These define individual permissions */
|
2009-10-21 23:45:44 +00:00
|
|
|
std::vector<reference<ConfigTag> > class_blocks;
|
|
|
|
/** Name of the oper type; i.e. the one shown in WHOIS */
|
|
|
|
std::string name;
|
|
|
|
|
2017-10-16 02:37:57 +01:00
|
|
|
/** Creates a new OperInfo with the specified oper type name.
|
|
|
|
* @param Name The name of the oper type.
|
|
|
|
*/
|
|
|
|
OperInfo(const std::string& Name);
|
|
|
|
|
2009-10-21 23:45:44 +00:00
|
|
|
/** Get a configuration item, searching in the oper, type, and class blocks (in that order) */
|
|
|
|
std::string getConfig(const std::string& key);
|
2009-10-21 23:46:05 +00:00
|
|
|
void init();
|
2009-10-21 23:45:44 +00:00
|
|
|
};
|
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
/** This class holds the bulk of the runtime configuration for the ircd.
|
|
|
|
* It allows for reading new config values, accessing configuration files,
|
|
|
|
* and storage of the configuration data needed to run the ircd, such as
|
|
|
|
* the servername, connect classes, /ADMIN data, MOTDs and filenames etc.
|
|
|
|
*/
|
2009-10-18 16:01:33 +00:00
|
|
|
class CoreExport ServerConfig
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
private:
|
2009-08-12 18:03:52 +00:00
|
|
|
void CrossCheckOperClassType();
|
|
|
|
void CrossCheckConnectBlocks(ServerConfig* current);
|
|
|
|
|
2007-11-11 18:57:22 +00:00
|
|
|
public:
|
2018-07-10 20:32:08 +01:00
|
|
|
/** How to treat a user in a channel who is banned. */
|
|
|
|
enum BannedUserTreatment
|
|
|
|
{
|
|
|
|
/** Don't treat a banned user any different to normal. */
|
|
|
|
BUT_NORMAL,
|
|
|
|
|
|
|
|
/** Restrict the actions of a banned user. */
|
|
|
|
BUT_RESTRICT_SILENT,
|
|
|
|
|
|
|
|
/** Restrict the actions of a banned user and notify them of their treatment. */
|
|
|
|
BUT_RESTRICT_NOTIFY
|
|
|
|
};
|
|
|
|
|
2013-07-10 18:11:48 +01:00
|
|
|
class ServerPaths
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Config path */
|
|
|
|
std::string Config;
|
|
|
|
|
|
|
|
/** Data path */
|
|
|
|
std::string Data;
|
|
|
|
|
|
|
|
/** Log path */
|
|
|
|
std::string Log;
|
|
|
|
|
|
|
|
/** Module path */
|
|
|
|
std::string Module;
|
|
|
|
|
2021-01-18 06:56:18 +00:00
|
|
|
/** Runtime path */
|
|
|
|
std::string Runtime;
|
|
|
|
|
2017-08-27 12:59:02 +01:00
|
|
|
ServerPaths(ConfigTag* tag);
|
2013-07-10 18:11:48 +01:00
|
|
|
|
2013-10-05 04:55:11 +01:00
|
|
|
std::string PrependConfig(const std::string& fn) const { return FileSystem::ExpandPath(Config, fn); }
|
|
|
|
std::string PrependData(const std::string& fn) const { return FileSystem::ExpandPath(Data, fn); }
|
|
|
|
std::string PrependLog(const std::string& fn) const { return FileSystem::ExpandPath(Log, fn); }
|
|
|
|
std::string PrependModule(const std::string& fn) const { return FileSystem::ExpandPath(Module, fn); }
|
2021-01-18 06:56:18 +00:00
|
|
|
std::string PrependRuntime(const std::string& fn) const { return FileSystem::ExpandPath(Runtime, fn); }
|
2013-07-10 18:11:48 +01:00
|
|
|
};
|
2009-10-21 23:44:27 +00:00
|
|
|
|
2014-07-16 12:30:05 +02:00
|
|
|
/** Holds a complete list of all connect blocks
|
|
|
|
*/
|
|
|
|
typedef std::vector<reference<ConnectClass> > ClassVector;
|
|
|
|
|
2014-07-16 12:32:47 +02:00
|
|
|
/** Index of valid oper blocks and types
|
|
|
|
*/
|
2014-12-15 17:48:52 +01:00
|
|
|
typedef insp::flat_map<std::string, reference<OperInfo> > OperIndex;
|
2014-07-16 12:32:47 +02:00
|
|
|
|
2018-10-01 16:09:45 +01:00
|
|
|
/** Get a configuration tag by name. If one or more tags are present then the first is returned.
|
|
|
|
* @param tag The name of the tag to get.
|
|
|
|
* @returns Either a tag from the config or EmptyTag.
|
2009-10-21 23:44:27 +00:00
|
|
|
*/
|
2009-10-21 23:46:13 +00:00
|
|
|
ConfigTag* ConfValue(const std::string& tag);
|
|
|
|
|
2018-10-01 16:09:45 +01:00
|
|
|
/** Get a list of configuration tags by name.
|
|
|
|
* @param tag The name of the tags to get.
|
|
|
|
* @returns Either a list of tags from the config or an empty ConfigTagList.
|
|
|
|
*/
|
2009-10-21 23:46:13 +00:00
|
|
|
ConfigTagList ConfTags(const std::string& tag);
|
2009-10-21 23:44:27 +00:00
|
|
|
|
2014-10-08 16:34:37 +01:00
|
|
|
/** An empty configuration tag. */
|
|
|
|
ConfigTag* EmptyTag;
|
|
|
|
|
2008-09-20 20:53:04 +00:00
|
|
|
/** Error stream, contains error output from any failed configuration parsing.
|
|
|
|
*/
|
2009-07-01 22:55:54 +00:00
|
|
|
std::stringstream errstr;
|
2007-11-11 23:09:09 +00:00
|
|
|
|
2009-07-01 22:55:46 +00:00
|
|
|
/** True if this configuration is valid enough to run with */
|
|
|
|
bool valid;
|
2007-11-11 23:09:09 +00:00
|
|
|
|
2010-02-23 18:45:26 +00:00
|
|
|
/** Bind to IPv6 by default */
|
|
|
|
bool WildcardIPv6;
|
|
|
|
|
2018-03-31 13:02:57 +01:00
|
|
|
/** This holds all the information in the config file,
|
2007-07-16 17:30:04 +00:00
|
|
|
* it's indexed by tag name to a vector of key/values.
|
|
|
|
*/
|
|
|
|
ConfigDataHash config_data;
|
|
|
|
|
2010-02-02 16:47:25 +00:00
|
|
|
/** This holds all extra files that have been read in the configuration
|
|
|
|
* (for example, MOTD and RULES files are stored here)
|
|
|
|
*/
|
|
|
|
ConfigFileCache Files;
|
|
|
|
|
2008-09-20 20:53:04 +00:00
|
|
|
/** Length limits, see definition of ServerLimits class
|
|
|
|
*/
|
2008-05-25 17:30:43 +00:00
|
|
|
ServerLimits Limits;
|
|
|
|
|
2013-07-10 18:11:48 +01:00
|
|
|
/** Locations of various types of file (config, module, etc). */
|
|
|
|
ServerPaths Paths;
|
|
|
|
|
2009-10-21 23:46:24 +00:00
|
|
|
/** Configuration parsed from the command line.
|
|
|
|
*/
|
|
|
|
CommandLineConf cmdline;
|
|
|
|
|
2008-07-12 13:58:37 +00:00
|
|
|
/** Clones CIDR range for ipv4 (0-32)
|
2020-04-21 06:34:17 +00:00
|
|
|
* Defaults to 32 (checks clones on all IPs separately)
|
2008-07-12 13:58:37 +00:00
|
|
|
*/
|
2017-11-17 00:02:03 +00:00
|
|
|
unsigned char c_ipv4_range;
|
2008-07-12 13:58:37 +00:00
|
|
|
|
|
|
|
/** Clones CIDR range for ipv6 (0-128)
|
2020-04-21 06:34:17 +00:00
|
|
|
* Defaults to 128 (checks on all IPs separately)
|
2008-07-12 13:58:37 +00:00
|
|
|
*/
|
2017-11-17 00:02:03 +00:00
|
|
|
unsigned char c_ipv6_range;
|
2008-07-12 13:58:37 +00:00
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Holds the server name of the local server
|
|
|
|
* as defined by the administrator.
|
|
|
|
*/
|
2009-10-03 01:52:59 +00:00
|
|
|
std::string ServerName;
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2013-07-10 14:50:26 +01:00
|
|
|
/** Notice to give to users when they are banned by an XLine
|
2007-07-16 17:30:04 +00:00
|
|
|
*/
|
2013-07-10 14:50:26 +01:00
|
|
|
std::string XLineMessage;
|
2009-02-14 21:14:36 +00:00
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
/* Holds the network name the local server
|
2020-04-21 06:34:17 +00:00
|
|
|
* belongs to. This is an arbitrary field defined
|
2007-07-16 17:30:04 +00:00
|
|
|
* by the administrator.
|
|
|
|
*/
|
2009-10-03 01:52:59 +00:00
|
|
|
std::string Network;
|
2007-07-16 17:30:04 +00:00
|
|
|
|
|
|
|
/** Holds the description of the local server
|
|
|
|
* as defined by the administrator.
|
|
|
|
*/
|
2009-10-03 01:52:59 +00:00
|
|
|
std::string ServerDesc;
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2018-07-10 20:32:08 +01:00
|
|
|
/** How to treat a user in a channel who is banned. */
|
|
|
|
BannedUserTreatment RestrictBannedUsers;
|
2008-11-01 23:58:33 +00:00
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
/** The size of the read() buffer in the user
|
|
|
|
* handling code, used to read data into a user's
|
|
|
|
* recvQ.
|
|
|
|
*/
|
|
|
|
int NetBufferSize;
|
|
|
|
|
|
|
|
/** The value to be used for listen() backlogs
|
|
|
|
* as default.
|
|
|
|
*/
|
|
|
|
int MaxConn;
|
|
|
|
|
2013-07-01 12:31:36 -07:00
|
|
|
/** If we should check for clones during CheckClass() in AddUser()
|
|
|
|
* Setting this to false allows to not trigger on maxclones for users
|
|
|
|
* that may belong to another class after DNS-lookup is complete.
|
|
|
|
* It does, however, make the server spend more time on users we may potentially not want.
|
|
|
|
*/
|
|
|
|
bool CCOnConnect;
|
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
/** The soft limit value assigned to the irc server.
|
|
|
|
* The IRC server will not allow more than this
|
|
|
|
* number of local users.
|
|
|
|
*/
|
|
|
|
unsigned int SoftLimit;
|
|
|
|
|
|
|
|
/** Maximum number of targets for a multi target command
|
|
|
|
* such as PRIVMSG or KICK
|
|
|
|
*/
|
|
|
|
unsigned int MaxTargets;
|
|
|
|
|
2018-12-04 19:04:09 +00:00
|
|
|
/** The number of seconds that the server clock can skip by before server operators are warned. */
|
|
|
|
time_t TimeSkipWarn;
|
|
|
|
|
2019-01-08 03:03:53 -07:00
|
|
|
/** True if we're going to hide ban reasons for non-opers (e.g. G-lines,
|
|
|
|
* K-lines, Z-lines)
|
2007-07-16 17:30:04 +00:00
|
|
|
*/
|
|
|
|
bool HideBans;
|
|
|
|
|
2010-03-19 18:06:39 +00:00
|
|
|
/** True if raw I/O is being logged */
|
|
|
|
bool RawLog;
|
|
|
|
|
2017-12-15 23:26:15 +00:00
|
|
|
/** Set to a non-empty string to obfuscate server names. */
|
|
|
|
std::string HideServer;
|
2007-07-16 17:30:04 +00:00
|
|
|
|
|
|
|
/** The full pathname and filename of the PID
|
|
|
|
* file as defined in the configuration.
|
|
|
|
*/
|
2009-08-12 18:03:52 +00:00
|
|
|
std::string PID;
|
2007-07-16 17:30:04 +00:00
|
|
|
|
|
|
|
/** The connect classes in use by the IRC server.
|
|
|
|
*/
|
|
|
|
ClassVector Classes;
|
|
|
|
|
|
|
|
/** Default channel modes
|
|
|
|
*/
|
2009-10-03 01:52:59 +00:00
|
|
|
std::string DefaultModes;
|
2007-07-16 17:30:04 +00:00
|
|
|
|
|
|
|
/** Custom version string, which if defined can replace the system info in VERSION.
|
|
|
|
*/
|
2009-10-03 01:52:59 +00:00
|
|
|
std::string CustomVersion;
|
2007-07-16 17:30:04 +00:00
|
|
|
|
|
|
|
/** If set to true, provide syntax hints for unknown commands
|
|
|
|
*/
|
|
|
|
bool SyntaxHints;
|
|
|
|
|
2017-07-30 17:34:05 +01:00
|
|
|
/** The name of the casemapping method used by this server.
|
|
|
|
*/
|
|
|
|
std::string CaseMapping;
|
|
|
|
|
2012-07-05 21:00:35 +01:00
|
|
|
/** If set to true, the full nick!user\@host will be shown in the TOPIC command
|
2007-07-16 17:30:04 +00:00
|
|
|
* for who set the topic last. If false, only the nick is shown.
|
|
|
|
*/
|
|
|
|
bool FullHostInTopic;
|
|
|
|
|
2013-08-13 14:22:07 +02:00
|
|
|
/** Oper blocks keyed by their name
|
2007-07-16 17:30:04 +00:00
|
|
|
*/
|
2009-10-21 23:45:44 +00:00
|
|
|
OperIndex oper_blocks;
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2013-08-13 14:22:07 +02:00
|
|
|
/** Oper types keyed by their name
|
|
|
|
*/
|
|
|
|
OperIndex OperTypes;
|
|
|
|
|
2016-09-02 21:51:19 +02:00
|
|
|
/** Default value for <connect:maxchans>, deprecated in 3.0
|
2007-07-16 17:30:04 +00:00
|
|
|
*/
|
|
|
|
unsigned int MaxChans;
|
|
|
|
|
2016-09-02 21:51:19 +02:00
|
|
|
/** Default value for <oper:maxchans>, deprecated in 3.0
|
2007-07-16 17:30:04 +00:00
|
|
|
*/
|
|
|
|
unsigned int OperMaxChans;
|
|
|
|
|
2007-08-27 19:56:38 +00:00
|
|
|
/** TS6-like server ID.
|
|
|
|
* NOTE: 000...999 are usable for InspIRCd servers. This
|
|
|
|
* makes code simpler. 0AA, 1BB etc with letters are reserved
|
|
|
|
* for services use.
|
|
|
|
*/
|
2009-10-03 01:52:59 +00:00
|
|
|
std::string sid;
|
2007-08-27 19:56:38 +00:00
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Construct a new ServerConfig
|
|
|
|
*/
|
2009-09-26 14:13:13 +00:00
|
|
|
ServerConfig();
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2014-10-08 16:34:37 +01:00
|
|
|
~ServerConfig();
|
|
|
|
|
2007-08-28 18:02:01 +00:00
|
|
|
/** Get server ID as string with required leading zeroes
|
|
|
|
*/
|
2013-06-02 00:28:55 +02:00
|
|
|
const std::string& GetSID() const { return sid; }
|
2007-08-28 18:02:01 +00:00
|
|
|
|
2020-12-20 03:04:21 +00:00
|
|
|
/** Retrieves the server name which should be shown to users. */
|
|
|
|
const std::string& GetServerName() const { return HideServer.empty() ? ServerName : HideServer; }
|
|
|
|
|
|
|
|
/** Retrieves the server description which should be shown to users. */
|
|
|
|
const std::string& GetServerDesc() const { return HideServer.empty() ? ServerDesc : HideServer; }
|
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
/** Read the entire configuration into memory
|
|
|
|
* and initialize this class. All other methods
|
|
|
|
* should be used only by the core.
|
|
|
|
*/
|
2009-07-01 22:55:46 +00:00
|
|
|
void Read();
|
|
|
|
|
|
|
|
/** Apply configuration changes from the old configuration.
|
|
|
|
*/
|
|
|
|
void Apply(ServerConfig* old, const std::string &useruid);
|
2009-08-12 18:03:52 +00:00
|
|
|
void ApplyModules(User* user);
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2009-10-17 02:14:44 +00:00
|
|
|
void Fill();
|
|
|
|
|
2013-05-17 02:03:16 +01:00
|
|
|
/** Escapes a value for storage in a configuration key.
|
|
|
|
* @param str The string to escape.
|
|
|
|
* @param xml Are we using the XML config format?
|
|
|
|
*/
|
|
|
|
static std::string Escape(const std::string& str, bool xml = true);
|
2008-08-07 16:35:58 +00:00
|
|
|
|
2012-04-15 10:45:34 +02:00
|
|
|
/** If this value is true, snotices will not stack when repeats are sent
|
|
|
|
*/
|
|
|
|
bool NoSnoticeStack;
|
2007-07-16 17:30:04 +00:00
|
|
|
};
|
2009-10-21 23:46:13 +00:00
|
|
|
|
2009-10-25 15:21:45 +00:00
|
|
|
/** The background thread for config reading, so that reading from executable includes
|
|
|
|
* does not block.
|
|
|
|
*/
|
|
|
|
class CoreExport ConfigReaderThread : public Thread
|
|
|
|
{
|
|
|
|
ServerConfig* Config;
|
|
|
|
volatile bool done;
|
|
|
|
public:
|
|
|
|
const std::string TheUserUID;
|
|
|
|
ConfigReaderThread(const std::string &useruid)
|
|
|
|
: Config(new ServerConfig), done(false), TheUserUID(useruid)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~ConfigReaderThread()
|
|
|
|
{
|
|
|
|
delete Config;
|
|
|
|
}
|
|
|
|
|
2017-11-21 13:05:17 +00:00
|
|
|
void Run() CXX11_OVERRIDE;
|
2009-10-25 15:21:45 +00:00
|
|
|
/** Run in the main thread to apply the configuration */
|
|
|
|
void Finish();
|
|
|
|
bool IsDone() { return done; }
|
|
|
|
};
|
2013-08-16 12:10:55 +02:00
|
|
|
|
2019-09-02 15:17:30 +01:00
|
|
|
/** Represents the status of a config load. */
|
2013-08-16 12:10:55 +02:00
|
|
|
class CoreExport ConfigStatus
|
|
|
|
{
|
|
|
|
public:
|
2019-09-02 15:17:30 +01:00
|
|
|
/** Whether this is the initial config load. */
|
|
|
|
bool const initial;
|
|
|
|
|
|
|
|
/** The user who initiated the config load or NULL if not initiated by a user. */
|
2013-08-16 12:10:55 +02:00
|
|
|
User* const srcuser;
|
|
|
|
|
2019-09-02 15:17:30 +01:00
|
|
|
/** Initializes a new instance of the ConfigStatus class.
|
|
|
|
* @param user The user who initiated the config load or NULL if not initiated by a user.
|
|
|
|
* @param isinitial Whether this is the initial config load.
|
|
|
|
*/
|
|
|
|
ConfigStatus(User* user = NULL, bool isinitial = false)
|
|
|
|
: initial(isinitial)
|
|
|
|
, srcuser(user)
|
2013-08-16 12:10:55 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|