2018-02-04 03:22:01 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2018-06-16 00:13:18 +02:00
|
|
|
#define HAVE_IRCD_IRCD_H
|
|
|
|
|
|
|
|
// Generated by ./configure
|
|
|
|
#include "config.h"
|
2018-06-16 00:19:29 +02:00
|
|
|
#include "stdinc.h"
|
2018-06-16 00:13:18 +02:00
|
|
|
|
|
|
|
namespace ircd
|
|
|
|
{
|
|
|
|
enum class runlevel :int;
|
|
|
|
|
|
|
|
extern const enum runlevel &runlevel;
|
2018-08-16 09:20:27 +02:00
|
|
|
|
2018-06-16 00:13:18 +02:00
|
|
|
extern bool debugmode; ///< Toggle; available only ifdef RB_DEBUG
|
|
|
|
extern bool nolisten; ///< Init option to not bind listener socks.
|
|
|
|
extern bool noautomod; ///< Option to not load modules on init.
|
|
|
|
extern bool checkdb; ///< Perform checks on database opens
|
2018-07-07 01:53:10 +02:00
|
|
|
extern bool pitrecdb; ///< Allow Point-In-Time Recovery if DB corrupt.
|
2018-07-06 01:20:35 +02:00
|
|
|
extern bool nojs; ///< Option to not init js subsystem.
|
2018-09-03 16:59:05 +02:00
|
|
|
extern bool nodirect; ///< Option to not use direct IO (O_DIRECT).
|
2018-06-16 00:13:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "string_view.h"
|
|
|
|
#include "vector_view.h"
|
|
|
|
#include "byte_view.h"
|
|
|
|
#include "buffer/buffer.h"
|
|
|
|
#include "allocator.h"
|
|
|
|
#include "util/util.h"
|
|
|
|
#include "exception.h"
|
|
|
|
#include "demangle.h"
|
|
|
|
#include "localee.h"
|
|
|
|
#include "date.h"
|
|
|
|
#include "logger.h"
|
|
|
|
#include "info.h"
|
|
|
|
#include "nacl.h"
|
|
|
|
#include "rand.h"
|
|
|
|
#include "hash.h"
|
|
|
|
#include "ed25519.h"
|
|
|
|
#include "color.h"
|
|
|
|
#include "lex_cast.h"
|
|
|
|
#include "base.h"
|
|
|
|
#include "stringops.h"
|
|
|
|
#include "tokens.h"
|
|
|
|
#include "iov.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "rfc1459.h"
|
|
|
|
#include "json/json.h"
|
2018-09-02 01:57:56 +02:00
|
|
|
//#include "cbor/cbor.h"
|
2018-06-16 00:13:18 +02:00
|
|
|
#include "openssl.h"
|
|
|
|
#include "http.h"
|
|
|
|
#include "fmt.h"
|
|
|
|
#include "magics.h"
|
|
|
|
#include "conf.h"
|
|
|
|
#include "fs/fs.h"
|
|
|
|
#include "ios.h"
|
|
|
|
#include "ctx/ctx.h"
|
|
|
|
#include "db/db.h"
|
|
|
|
#include "js.h"
|
|
|
|
#include "mods/mods.h"
|
|
|
|
#include "rfc3986.h"
|
|
|
|
#include "rfc1035.h"
|
|
|
|
#include "net/net.h"
|
|
|
|
#include "server/server.h"
|
|
|
|
#include "m/m.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "client.h"
|
|
|
|
|
2017-09-12 18:37:44 +02:00
|
|
|
/// \brief Internet Relay Chat daemon. This is the principal namespace for IRCd.
|
|
|
|
///
|
2017-08-28 23:51:22 +02:00
|
|
|
namespace ircd
|
|
|
|
{
|
2017-09-26 03:43:33 +02:00
|
|
|
struct init;
|
2018-03-23 20:05:40 +01:00
|
|
|
struct runlevel_changed;
|
2016-09-06 01:05:16 +02:00
|
|
|
|
2017-09-26 03:43:33 +02:00
|
|
|
string_view reflect(const enum runlevel &);
|
2018-04-15 01:19:15 +02:00
|
|
|
|
|
|
|
seconds uptime();
|
|
|
|
|
2018-08-13 23:36:12 +02:00
|
|
|
void init(boost::asio::io_context &ios, const string_view &hostname);
|
2017-11-06 21:14:50 +01:00
|
|
|
bool quit() noexcept;
|
2017-08-28 23:51:22 +02:00
|
|
|
}
|
2017-09-26 03:43:33 +02:00
|
|
|
|
2018-03-23 20:05:40 +01:00
|
|
|
/// An instance of this class registers itself to be called back when
|
|
|
|
/// the ircd::runlevel has changed.
|
|
|
|
///
|
|
|
|
/// Note: Its destructor will access a list in libircd; after a callback
|
|
|
|
/// for a HALT do not unload libircd.so until destructing this object.
|
|
|
|
///
|
|
|
|
/// A static ctx::dock is also available for contexts to wait for a runlevel
|
|
|
|
/// change notification.
|
|
|
|
///
|
|
|
|
struct ircd::runlevel_changed
|
|
|
|
:instance_list<ircd::runlevel_changed>
|
|
|
|
,std::function<void (const enum runlevel &)>
|
|
|
|
{
|
|
|
|
using handler = std::function<void (const enum runlevel &)>;
|
|
|
|
|
|
|
|
static ctx::dock dock;
|
|
|
|
|
|
|
|
runlevel_changed(handler function);
|
|
|
|
~runlevel_changed() noexcept;
|
|
|
|
};
|
|
|
|
|
2017-11-06 21:14:50 +01:00
|
|
|
/// The runlevel allows all observers to know the coarse state of IRCd and to
|
|
|
|
/// react accordingly. This can be used by the embedder of libircd to know
|
|
|
|
/// when it's safe to use or delete libircd resources. It is also used
|
|
|
|
/// similarly by the library and its modules.
|
|
|
|
///
|
|
|
|
/// Primary modes:
|
|
|
|
///
|
|
|
|
/// * HALT is the off mode. Nothing is/will be running in libircd until
|
|
|
|
/// an invocation of ircd::init();
|
|
|
|
///
|
|
|
|
/// * RUN is the service mode. Full client and application functionality
|
|
|
|
/// exists in this mode. Leaving the RUN mode is done with ircd::quit();
|
|
|
|
///
|
|
|
|
/// - Transitional modes: Modes which are working towards the next mode.
|
|
|
|
/// - Interventional modes: Modes which are *not* working towards the next
|
|
|
|
/// mode and may require some user action to continue.
|
|
|
|
///
|
2017-09-26 03:43:33 +02:00
|
|
|
enum class ircd::runlevel
|
2017-11-30 20:44:23 +01:00
|
|
|
:int
|
2017-09-26 03:43:33 +02:00
|
|
|
{
|
2017-11-30 20:44:23 +01:00
|
|
|
HALT = 0, ///< [inter] IRCd Powered off.
|
|
|
|
READY = 1, ///< [inter] Ready for user to run ios event loop.
|
|
|
|
START = 2, ///< [trans] Starting up subsystems for service.
|
|
|
|
RUN = 3, ///< [inter] IRCd in service.
|
|
|
|
QUIT = 4, ///< [trans] Clean shutdown in progress
|
|
|
|
FAULT = -1, ///< [trans] QUIT with exception (dirty shutdown)
|
2017-09-26 03:43:33 +02:00
|
|
|
};
|