2018-02-03 18:22:01 -08:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
2018-01-13 18:03:04 -08:00
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
2018-02-03 18:22:01 -08:00
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
2018-01-13 18:03:04 -08:00
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
2018-02-03 18:22:01 -08:00
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
2018-01-13 18:03:04 -08:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_SERVER_H
|
|
|
|
|
2018-04-03 02:10:48 -07:00
|
|
|
/// The interface for when IRCd plays the role of client to other servers
|
2018-01-13 18:03:04 -08:00
|
|
|
///
|
|
|
|
namespace ircd::server
|
|
|
|
{
|
|
|
|
struct init;
|
|
|
|
struct link;
|
2018-03-05 06:59:10 -08:00
|
|
|
struct peer;
|
2018-01-15 00:11:32 -08:00
|
|
|
struct request;
|
|
|
|
struct tag;
|
2018-01-13 18:03:04 -08:00
|
|
|
|
|
|
|
IRCD_EXCEPTION(ircd::error, error);
|
2018-01-16 00:45:51 -08:00
|
|
|
IRCD_EXCEPTION(error, buffer_overrun);
|
2018-01-16 04:01:26 -08:00
|
|
|
IRCD_EXCEPTION(error, unavailable);
|
|
|
|
IRCD_EXCEPTION(error, canceled);
|
2020-11-02 12:22:21 -08:00
|
|
|
|
|
|
|
extern conf::item<bool> enable;
|
2018-04-03 02:10:48 -07:00
|
|
|
}
|
2018-01-13 18:03:04 -08:00
|
|
|
|
2018-04-03 02:10:48 -07:00
|
|
|
#include "tag.h"
|
|
|
|
#include "request.h"
|
|
|
|
#include "link.h"
|
|
|
|
#include "peer.h"
|
|
|
|
|
|
|
|
namespace ircd::server
|
|
|
|
{
|
2019-04-11 21:40:59 -07:00
|
|
|
// const utils
|
2018-01-15 20:04:45 -08:00
|
|
|
size_t tag_count();
|
|
|
|
size_t link_count();
|
2018-03-05 06:59:10 -08:00
|
|
|
size_t peer_count();
|
2018-03-10 07:50:19 -08:00
|
|
|
size_t peer_unfinished();
|
2018-01-15 18:04:23 -08:00
|
|
|
|
2019-04-11 21:40:59 -07:00
|
|
|
// iteration of all requests.
|
|
|
|
bool for_each(const link &, const request::each_closure &);
|
|
|
|
bool for_each(const peer &, const request::each_closure &);
|
|
|
|
bool for_each(const request::each_closure &);
|
|
|
|
|
|
|
|
// const utils
|
2019-09-10 16:49:56 -07:00
|
|
|
string_view errmsg(const net::hostport &) noexcept;
|
2020-04-07 13:15:47 -07:00
|
|
|
bool errant(const net::hostport &) noexcept;
|
2019-09-10 16:49:56 -07:00
|
|
|
bool exists(const net::hostport &) noexcept;
|
2020-04-25 19:30:21 -07:00
|
|
|
bool linked(const net::hostport &) noexcept;
|
2020-04-21 21:05:33 -07:00
|
|
|
bool avail(const net::hostport &) noexcept; // exists() && !errant()
|
2018-03-05 06:59:10 -08:00
|
|
|
peer &find(const net::hostport &);
|
2018-09-17 16:47:36 -07:00
|
|
|
|
2019-04-11 21:40:59 -07:00
|
|
|
// mutable utils
|
2020-10-16 00:33:23 -07:00
|
|
|
peer &get(const net::hostport &); // creates the peer if not found.
|
|
|
|
bool prelink(const net::hostport &); // creates and links if not errant.
|
|
|
|
bool errclear(const net::hostport &); // clear cached error.
|
2018-01-13 18:03:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Subsystem initialization / destruction from ircd::main
|
|
|
|
///
|
|
|
|
struct ircd::server::init
|
|
|
|
{
|
2019-10-05 16:21:06 -07:00
|
|
|
// manual control panel
|
2020-02-27 15:28:53 -08:00
|
|
|
static void interrupt();
|
|
|
|
static void close();
|
|
|
|
static void wait();
|
2019-10-05 16:21:06 -07:00
|
|
|
|
2020-02-01 13:35:11 -08:00
|
|
|
init() noexcept;
|
2018-01-13 18:03:04 -08:00
|
|
|
~init() noexcept;
|
|
|
|
};
|