mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 23:44:01 +01:00
Checkpoint reorganization.
This commit is contained in:
parent
b2a6d4ebab
commit
1a1a50f5f3
15 changed files with 101 additions and 97 deletions
23
README.md
23
README.md
|
@ -31,8 +31,8 @@ This is the first implementation of a Matrix homeserver written in C++. The road
|
||||||
for service is as follows:
|
for service is as follows:
|
||||||
|
|
||||||
- [✓] Phase One: Matrix clients using HTTP.
|
- [✓] Phase One: Matrix clients using HTTP.
|
||||||
- [ ] Phase Two: Legacy IRC networks using TS6 protocol (Atheme Federation).
|
- Phase Two: Legacy IRC networks using TS6 protocol (Atheme Federation).
|
||||||
- [ ] Phase Three: Legacy IRC clients using RFC1459/RFC2812 legacy grammars.
|
- Phase Three: Legacy IRC clients using RFC1459/RFC2812 legacy grammars.
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
@ -126,8 +126,7 @@ which may introduce the actual application features (or the "business logic")
|
||||||
of the server. These additional modules are found in the `modules/` directory;
|
of the server. These additional modules are found in the `modules/` directory;
|
||||||
|
|
||||||
This library can be embedded by developers creating their own server or those
|
This library can be embedded by developers creating their own server or those
|
||||||
who simply want to use the library of routines it provides. See the section for
|
who simply want to use the library of routines it provides.
|
||||||
`Using libircd`.
|
|
||||||
|
|
||||||
##### libircd can be embedded in your application with very minimal overhead.
|
##### libircd can be embedded in your application with very minimal overhead.
|
||||||
|
|
||||||
|
@ -157,15 +156,15 @@ on multiple threads by the embedder's application, libircd will use a single
|
||||||
`io_service::strand`.
|
`io_service::strand`.
|
||||||
|
|
||||||
This methodology ensures there is an uninterrupted execution working through
|
This methodology ensures there is an uninterrupted execution working through
|
||||||
a single event queue providing service which is not otherwise computationally
|
a single event queue providing service. Even if there are periods of execution
|
||||||
bound. Even if there are periods of execution which are computationally intense
|
which are computationally intense like parsing, hashing, cryptography etc -- this
|
||||||
like parsing, hashing, signature verification etc -- this is insignificant
|
is absorbed in lieu of thread synchronization and bus contention. Scaling this
|
||||||
compared to the amortized cost of thread synchronization and bus contention
|
system is done through running multiple instances which synchronize at the
|
||||||
for a network application.
|
application level.
|
||||||
|
|
||||||
✝ However, don't start assuming a truly threadless execution. If there is
|
✝ However, don't start assuming a truly threadless execution for the entire
|
||||||
ever a truly long-running background computation or a call to a 3rd
|
address space. If there is ever a long-running background computation or a call
|
||||||
party library which will do IO and block the event loop, we may use an
|
to a 3rd party library which will do IO and block the event loop, we may use an
|
||||||
additional `std::thread` to "offload" such an operation. Thus we do have
|
additional `std::thread` to "offload" such an operation. Thus we do have
|
||||||
a threading model, but it is heterogeneous.
|
a threading model, but it is heterogeneous.
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <ircd/ircd.h>
|
#include <ircd/ircd.h>
|
||||||
#include <ircd/asio.h>
|
#include <ircd/asio.h>
|
||||||
|
#include <ircd/m/m.h>
|
||||||
#include "charybdis.h"
|
#include "charybdis.h"
|
||||||
|
|
||||||
using namespace ircd;
|
using namespace ircd;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 090fadc2ca44cd8e2d057cb90cd648cf60587c2e
|
Subproject commit e58e94fb0696e9d99b8685348f02278a4bafced7
|
|
@ -9,17 +9,24 @@ AM_CXXFLAGS = \
|
||||||
###
|
###
|
||||||
|
|
||||||
if GCC
|
if GCC
|
||||||
AM_CXXFLAGS += -fpch-deps
|
AM_CXXFLAGS += \
|
||||||
|
-fpch-deps \
|
||||||
|
###
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if DEBUG
|
if DEBUG
|
||||||
if GCC
|
if GCC
|
||||||
AM_CXXFLAGS += -fmax-errors=2
|
AM_CXXFLAGS += \
|
||||||
|
-fmax-errors=2 \
|
||||||
|
###
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if BUILD_PCH
|
if BUILD_PCH
|
||||||
BUILT_SOURCES = stdinc.h.gch stdinc.pic.h.gch
|
BUILT_SOURCES = \
|
||||||
|
stdinc.h.gch \
|
||||||
|
stdinc.pic.h.gch \
|
||||||
|
###
|
||||||
endif
|
endif
|
||||||
|
|
||||||
stdinc.h.gch:
|
stdinc.h.gch:
|
||||||
|
|
|
@ -1,25 +1,23 @@
|
||||||
/*
|
/*
|
||||||
* ircd-ratbox: A slightly useful ircd.
|
* Copyright (C) 2017 Matrix Construct Development Team
|
||||||
* ircd.h: A header for the ircd startup routines.
|
* Copyright (C) 2017 Jason Volk <jason@zemos.net>
|
||||||
*
|
*
|
||||||
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* Copyright (C) 1996-2002 Hybrid Development Team
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* Copyright (C) 2002-2004 ircd-ratbox development team
|
* copyright notice and this permission notice is present in all copies.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
* it under the terms of the GNU General Public License as published by
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* (at your option) any later version.
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* 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, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
||||||
* USA
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -38,18 +36,11 @@ namespace ircd
|
||||||
{
|
{
|
||||||
struct init;
|
struct init;
|
||||||
|
|
||||||
enum class runlevel :uint;
|
extern runlevel_handler runlevel_changed;
|
||||||
using runlevel_handler = std::function<void (const enum runlevel &)>;
|
|
||||||
|
|
||||||
extern bool debugmode; ///< Toggled by command line to indicate debug behavior
|
|
||||||
extern const enum runlevel &runlevel; ///< Reflects current running mode of library
|
|
||||||
extern runlevel_handler runlevel_changed; ///< User hook to get called on runlevel change.
|
|
||||||
|
|
||||||
string_view reflect(const enum runlevel &);
|
string_view reflect(const enum runlevel &);
|
||||||
|
|
||||||
void init(boost::asio::io_service &ios, const std::string &conf, runlevel_handler = {});
|
void init(boost::asio::io_service &ios, const std::string &conf, runlevel_handler = {});
|
||||||
void init(boost::asio::io_service &ios, runlevel_handler = {});
|
void init(boost::asio::io_service &ios, runlevel_handler = {});
|
||||||
|
|
||||||
bool quit() noexcept;
|
bool quit() noexcept;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,12 +62,19 @@ namespace ircd
|
||||||
/// mode and may require some user action to continue.
|
/// mode and may require some user action to continue.
|
||||||
///
|
///
|
||||||
enum class ircd::runlevel
|
enum class ircd::runlevel
|
||||||
:uint
|
:int
|
||||||
{
|
{
|
||||||
HALT = 0x00, ///< [inter] IRCd Powered off.
|
HALT = 0, ///< [inter] IRCd Powered off.
|
||||||
READY = 0x01, ///< [inter] Ready for user to run ios event loop.
|
READY = 1, ///< [inter] Ready for user to run ios event loop.
|
||||||
START = 0x02, ///< [trans] Starting up subsystems for service.
|
START = 2, ///< [trans] Starting up subsystems for service.
|
||||||
RUN = 0x04, ///< [inter] IRCd in service.
|
RUN = 3, ///< [inter] IRCd in service.
|
||||||
QUIT = 0x10, ///< [trans] Clean shutdown in progress
|
QUIT = 4, ///< [trans] Clean shutdown in progress
|
||||||
FAULT = 0xFF, ///< [trans] QUIT with exception (dirty shutdown)
|
FAULT = -1, ///< [trans] QUIT with exception (dirty shutdown)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
std::string
|
||||||
|
ircd::demangle()
|
||||||
|
{
|
||||||
|
return demangle(typeid(T).name());
|
||||||
|
}
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
/*
|
/*
|
||||||
* ircd-ratbox: A slightly useful ircd.
|
* Copyright (C) 2017 Matrix Construct Development Team
|
||||||
* stdinc.h: Pull in all of the necessary system headers
|
* Copyright (C) 2017 Jason Volk <jason@zemos.net>
|
||||||
*
|
*
|
||||||
* Copyright (C) 2002 Aaron Sethman <androsyn@ratbox.org>
|
* 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.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
* it under the terms of the GNU General Public License as published by
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* (at your option) any later version.
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
*
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* This program is distributed in the hope that it will be useful,
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
* GNU General Public License for more details.
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
*
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* You should have received a copy of the GNU General Public License
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
||||||
* USA
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -144,9 +143,10 @@ namespace std
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Some items imported into our namespace.
|
// libircd API
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// Some items imported into our namespace.
|
||||||
namespace ircd
|
namespace ircd
|
||||||
{
|
{
|
||||||
using std::nullptr_t;
|
using std::nullptr_t;
|
||||||
|
@ -166,21 +166,17 @@ namespace ircd
|
||||||
using uint128_t = unsigned __int128;
|
using uint128_t = unsigned __int128;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// libircd API
|
|
||||||
//
|
|
||||||
|
|
||||||
// Unsorted section
|
|
||||||
namespace ircd
|
namespace ircd
|
||||||
{
|
{
|
||||||
struct client;
|
struct client;
|
||||||
struct server;
|
struct server;
|
||||||
enum class runlevel :uint;
|
enum class runlevel :int;
|
||||||
|
using runlevel_handler = std::function<void (const enum runlevel &)>;
|
||||||
|
|
||||||
constexpr size_t BUFSIZE { 512 };
|
constexpr size_t BUFSIZE { 512 };
|
||||||
extern const std::string &conf;
|
|
||||||
extern const enum runlevel &runlevel;
|
extern const enum runlevel &runlevel;
|
||||||
|
extern const std::string &conf;
|
||||||
|
extern bool debugmode; ///< Toggle; available only ifdef RB_DEBUG
|
||||||
|
|
||||||
std::string demangle(const std::string &symbol);
|
std::string demangle(const std::string &symbol);
|
||||||
template<class T> std::string demangle();
|
template<class T> std::string demangle();
|
||||||
|
@ -224,14 +220,7 @@ namespace ircd
|
||||||
#include "js.h"
|
#include "js.h"
|
||||||
#include "mods.h"
|
#include "mods.h"
|
||||||
#include "net/net.h"
|
#include "net/net.h"
|
||||||
#include "m/m.h"
|
|
||||||
#include "resource.h"
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
#include "m/m.h"
|
||||||
template<class T>
|
#include "resource.h"
|
||||||
std::string
|
|
||||||
ircd::demangle()
|
|
||||||
{
|
|
||||||
return demangle(typeid(T).name());
|
|
||||||
}
|
|
||||||
|
|
|
@ -75,10 +75,10 @@ libircd_la_SOURCES = \
|
||||||
lexical.cc \
|
lexical.cc \
|
||||||
locale.cc \
|
locale.cc \
|
||||||
logger.cc \
|
logger.cc \
|
||||||
m_id.cc \
|
m/id.cc \
|
||||||
m_io.cc \
|
m/io.cc \
|
||||||
m_vm.cc \
|
m/vm.cc \
|
||||||
m.cc \
|
m/m.cc \
|
||||||
mods.cc \
|
mods.cc \
|
||||||
net.cc \
|
net.cc \
|
||||||
openssl.cc \
|
openssl.cc \
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ircd/asio.h>
|
#include <ircd/asio.h>
|
||||||
|
#include <ircd/m/m.h>
|
||||||
|
#include <ircd/resource.h>
|
||||||
|
|
||||||
namespace ircd {
|
namespace ircd {
|
||||||
|
|
||||||
|
@ -33,14 +35,14 @@ namespace ircd {
|
||||||
// (or idle mode) after which it is disconnected.
|
// (or idle mode) after which it is disconnected.
|
||||||
const auto async_timeout
|
const auto async_timeout
|
||||||
{
|
{
|
||||||
300s
|
40s
|
||||||
};
|
};
|
||||||
|
|
||||||
// Time limit for how long a connected client can be in "request mode." This
|
// Time limit for how long a connected client can be in "request mode." This
|
||||||
// should never be hit unless there's an error in the handling code.
|
// should never be hit unless there's an error in the handling code.
|
||||||
const auto request_timeout
|
const auto request_timeout
|
||||||
{
|
{
|
||||||
60s
|
20s
|
||||||
};
|
};
|
||||||
|
|
||||||
// The pool of request contexts. When a client makes a request it does so by acquiring
|
// The pool of request contexts. When a client makes a request it does so by acquiring
|
||||||
|
@ -48,7 +50,7 @@ const auto request_timeout
|
||||||
// in a synchronous manner as if each connection had its own thread.
|
// in a synchronous manner as if each connection had its own thread.
|
||||||
ctx::pool request
|
ctx::pool request
|
||||||
{
|
{
|
||||||
"request", 256_KiB
|
"request", 4_MiB
|
||||||
};
|
};
|
||||||
|
|
||||||
// Container for all active clients (connections) for iteration purposes.
|
// Container for all active clients (connections) for iteration purposes.
|
||||||
|
@ -67,7 +69,7 @@ template<class... args> std::shared_ptr<client> make_client(args&&...);
|
||||||
|
|
||||||
ircd::client::init::init()
|
ircd::client::init::init()
|
||||||
{
|
{
|
||||||
request.add(2);
|
request.add(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -247,8 +249,9 @@ bool
|
||||||
ircd::client::main()
|
ircd::client::main()
|
||||||
noexcept try
|
noexcept try
|
||||||
{
|
{
|
||||||
const auto header_max{8192};
|
const auto header_max{8_KiB};
|
||||||
const auto content_max{65536};
|
//const auto content_max{64_KiB};
|
||||||
|
const auto content_max{8_MiB};
|
||||||
const unique_buffer<mutable_buffer> buffer
|
const unique_buffer<mutable_buffer> buffer
|
||||||
{
|
{
|
||||||
header_max + content_max
|
header_max + content_max
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ircd/asio.h>
|
#include <ircd/asio.h>
|
||||||
|
#include <ircd/m/m.h>
|
||||||
|
|
||||||
namespace ircd
|
namespace ircd
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ircd/m/m.h>
|
||||||
|
|
||||||
namespace ircd::m::io
|
namespace ircd::m::io
|
||||||
{
|
{
|
||||||
bool acquire_local(event::fetch &);
|
bool acquire_local(event::fetch &);
|
|
@ -19,6 +19,8 @@
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ircd/m/m.h>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// m.h
|
// m.h
|
|
@ -19,6 +19,8 @@
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ircd/m/m.h>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// m/vm.h
|
// m/vm.h
|
|
@ -19,6 +19,9 @@
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ircd/m/m.h>
|
||||||
|
#include <ircd/resource.h>
|
||||||
|
|
||||||
namespace ircd {
|
namespace ircd {
|
||||||
|
|
||||||
IRCD_INIT_PRIORITY(STD_CONTAINER)
|
IRCD_INIT_PRIORITY(STD_CONTAINER)
|
||||||
|
|
|
@ -11,9 +11,6 @@ AM_CPPFLAGS = \
|
||||||
@JS_CPPFLAGS@ \
|
@JS_CPPFLAGS@ \
|
||||||
@BOOST_CPPFLAGS@ \
|
@BOOST_CPPFLAGS@ \
|
||||||
-include $(top_srcdir)/include/ircd/ircd.h \
|
-include $(top_srcdir)/include/ircd/ircd.h \
|
||||||
-include $(top_srcdir)/include/ircd/server.h \
|
|
||||||
-include $(top_srcdir)/include/ircd/m/m.h \
|
|
||||||
-include $(top_srcdir)/include/ircd/resource.h \
|
|
||||||
-include $(top_srcdir)/include/ircd/mapi.h \
|
-include $(top_srcdir)/include/ircd/mapi.h \
|
||||||
###
|
###
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue