0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00

ircd::info: Reorganize info.

This commit is contained in:
Jason Volk 2018-12-19 12:23:38 -08:00
parent ddfafd45e2
commit 0017a942e2
2 changed files with 245 additions and 363 deletions

View file

@ -22,12 +22,6 @@ namespace ircd::info
struct line; struct line;
struct tc_version; struct tc_version;
// Primary information
extern const string_view name;
extern const string_view version;
extern const string_view user_agent;
extern const string_view server_agent;
// Build information // Build information
extern const string_view tag; extern const string_view tag;
extern const string_view branch; extern const string_view branch;
@ -38,40 +32,40 @@ namespace ircd::info
extern const string_view compiled; extern const string_view compiled;
extern const string_view startup; extern const string_view startup;
// System / platform information // System information
extern const size_t max_align; extern const size_t max_align;
extern const size_t hardware_concurrency; extern const size_t hardware_concurrency;
extern const size_t destructive_interference; extern const size_t destructive_interference;
extern const size_t constructive_interference; extern const size_t constructive_interference;
extern const size_t page_size;
extern const size_t iov_max;
extern const size_t aio_max;
extern const size_t aio_reqprio_max;
extern const size_t rlimit_as; extern const size_t rlimit_as;
extern const size_t rlimit_data; extern const size_t rlimit_data;
extern const size_t rlimit_rss; extern const size_t rlimit_rss;
extern const size_t rlimit_nofile; extern const size_t rlimit_nofile;
extern const size_t rlimit_rttime; extern const size_t rlimit_rttime;
extern const int glibc_version[3]; // Host information
extern const string_view glibc_version_str;
extern const size_t page_size;
extern const size_t iov_max;
extern const size_t aio_max;
extern const size_t aio_reqprio_max;
extern const size_t clk_tck;
#ifdef HAVE_SYS_UTSNAME_H #ifdef HAVE_SYS_UTSNAME_H
extern const ::utsname utsname; extern const ::utsname utsname;
#endif #endif
// Extended information // Third-party information
extern const std::vector<info::line> myinfo; extern const int glibc_version[3];
extern const std::vector<string_view> credits; extern const string_view glibc_version_str;
// Primary information
extern const string_view name;
extern const string_view version;
extern const string_view user_agent;
extern const string_view server_agent;
// Extended information
extern const string_view credits[];
// Util
void dump(); void dump();
void init(); void init();
} }
struct ircd::info::line
{
std::string key;
std::string valstr;
uint64_t valnum;
std::string desc;
};

View file

@ -77,7 +77,7 @@ ircd::info::dump()
// This message flashes posix information about the resource limits // This message flashes posix information about the resource limits
log::debug log::debug
{ {
"AS=%lu DATA=%lu RSS=%lu NOFILE=%lu; RTTIME=%lu iov_max=%zu aio_max=%zu aio_reqprio_max=%zu clk_tck=%zu", "AS=%lu DATA=%lu RSS=%lu NOFILE=%lu; RTTIME=%lu iov_max=%zu aio_max=%zu aio_reqprio_max=%zu",
rlimit_as, rlimit_as,
rlimit_data, rlimit_data,
rlimit_rss, rlimit_rss,
@ -86,18 +86,44 @@ ircd::info::dump()
iov_max, iov_max,
aio_max, aio_max,
aio_reqprio_max, aio_reqprio_max,
clk_tck
}; };
} }
extern "C" const char *const decltype(ircd::info::credits)
ircd_name ircd::info::credits
{ {
PACKAGE_NAME "Inspired by the original Internet Relay Chat daemon from Jarkko Oikarinen",
" ",
"This - is The Construct",
" ",
"Internet Relay Chat daemon: Matrix Construct",
" ",
"Copyright (C) 2016-2018 Matrix Construct Developers, Authors & Contributors",
"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.",
" ",
nullptr
}; };
extern "C" const char *const //
ircd_version // Primary information
//
decltype(ircd::info::server_agent)
ircd::info::server_agent
{
BRANDING_NAME " (IRCd " BRANDING_VERSION ")"
};
decltype(ircd::info::user_agent)
ircd::info::user_agent
{
BRANDING_NAME " (IRCd " BRANDING_VERSION ")"
};
decltype(ircd::info::version)
ircd::info::version
{ {
RB_VERSION RB_VERSION
}; };
@ -108,224 +134,16 @@ ircd::info::name
PACKAGE_NAME PACKAGE_NAME
}; };
decltype(ircd::info::version) extern "C" const char *const
ircd::info::version ircd_version
{ {
RB_VERSION RB_VERSION
}; };
decltype(ircd::info::user_agent) extern "C" const char *const
ircd::info::user_agent ircd_name
{ {
BRANDING_NAME " (IRCd " BRANDING_VERSION ")" PACKAGE_NAME
};
decltype(ircd::info::server_agent)
ircd::info::server_agent
{
BRANDING_NAME " (IRCd " BRANDING_VERSION ")"
};
//
// IRCd / build information
//
decltype(ircd::info::tag)
ircd::info::tag
{
RB_VERSION_TAG
};
decltype(ircd::info::branch)
ircd::info::branch
{
RB_VERSION_BRANCH
};
decltype(ircd::info::commit)
ircd::info::commit
{
RB_VERSION_COMMIT
};
decltype(ircd::info::configured_time)
ircd::info::configured_time
{
RB_TIME_CONFIGURED
};
decltype(ircd::info::startup_time)
ircd::info::startup_time
{
std::time(nullptr)
};
decltype(ircd::info::configured)
ircd::info::configured
{
ctime(&configured_time)
};
decltype(ircd::info::compiled)
ircd::info::compiled
{
__TIMESTAMP__
};
decltype(ircd::info::startup)
ircd::info::startup
{
ctime(&startup_time)
};
//
// System / platform information
//
decltype(ircd::info::glibc_version)
ircd::info::glibc_version
{
__GNU_LIBRARY__,
__GLIBC__,
__GLIBC_MINOR__,
};
char ircd_info_glibc_version_str_buf[32];
decltype(ircd::info::glibc_version_str)
ircd::info::glibc_version_str
(
ircd_info_glibc_version_str_buf,
::snprintf(ircd_info_glibc_version_str_buf, sizeof(ircd_info_glibc_version_str_buf),
"%d.%d.%d",
glibc_version[0],
glibc_version[1],
glibc_version[2])
);
decltype(ircd::info::page_size)
ircd::info::page_size
{
size_t(syscall(::sysconf, _SC_PAGESIZE))
};
decltype(ircd::info::iov_max)
ircd::info::iov_max
{
#ifdef _SC_IOV_MAX
size_t(syscall(::sysconf, _SC_IOV_MAX))
#endif
};
decltype(ircd::info::aio_max)
ircd::info::aio_max
{
#ifdef _SC_AIO_MAX
0 //size_t(syscall(::sysconf, _SC_AIO_MAX))
#endif
};
decltype(ircd::info::aio_reqprio_max)
ircd::info::aio_reqprio_max
{
#ifdef _SC_AIO_PRIO_DELTA_MAX
size_t(syscall(::sysconf, _SC_AIO_PRIO_DELTA_MAX))
#endif
};
decltype(ircd::info::clk_tck)
ircd::info::clk_tck
{
#ifdef _SC_CLK_TCK
size_t(syscall(::sysconf, _SC_CLK_TCK))
#endif
};
#ifdef HAVE_SYS_UTSNAME_H
decltype(ircd::info::utsname)
ircd::info::utsname{[]
{
struct ::utsname utsname;
syscall(::uname, &utsname);
return utsname;
}()};
#endif
#ifdef HAVE_SYS_RESOURCE_H
static uint64_t
_get_rlimit(const int &resource)
{
rlimit rlim;
ircd::syscall(getrlimit, resource, &rlim);
return rlim.rlim_cur;
}
#else
static uint64_t
_get_rlimit(const int &resource)
{
return 0;
}
#endif
decltype(ircd::info::rlimit_as)
ircd::info::rlimit_as
{
_get_rlimit(RLIMIT_AS)
};
decltype(ircd::info::rlimit_data)
ircd::info::rlimit_data
{
_get_rlimit(RLIMIT_DATA)
};
decltype(ircd::info::rlimit_rss)
ircd::info::rlimit_rss
{
_get_rlimit(RLIMIT_RSS)
};
decltype(ircd::info::rlimit_nofile)
ircd::info::rlimit_nofile
{
_get_rlimit(RLIMIT_NOFILE)
};
decltype(ircd::info::rlimit_rttime)
ircd::info::rlimit_rttime
{
_get_rlimit(RLIMIT_RTTIME)
};
decltype(ircd::info::max_align)
ircd::info::max_align
{
alignof(std::max_align_t)
};
decltype(ircd::info::hardware_concurrency)
ircd::info::hardware_concurrency
{
std::thread::hardware_concurrency()
};
decltype(ircd::info::destructive_interference)
ircd::info::destructive_interference
{
#ifdef __cpp_lib_hardware_interference_size
std::hardware_destructive_interference_size
#else
0
#endif
};
decltype(ircd::info::constructive_interference)
ircd::info::constructive_interference
{
#ifdef __cpp_lib_hardware_interference_size
std::hardware_constructive_interference_size
#else
0
#endif
}; };
// //
@ -348,142 +166,212 @@ ircd::tc_version::tc_version()
{} {}
*/ */
decltype(ircd::info::glibc_version)
ircd::info::glibc_version
{
__GNU_LIBRARY__,
__GLIBC__,
__GLIBC_MINOR__,
};
char ircd_info_glibc_version_str_buf[32];
decltype(ircd::info::glibc_version_str)
ircd::info::glibc_version_str
(
ircd_info_glibc_version_str_buf,
::snprintf(ircd_info_glibc_version_str_buf, sizeof(ircd_info_glibc_version_str_buf),
"%d.%d.%d",
glibc_version[0],
glibc_version[1],
glibc_version[2])
);
// //
// Extended information // Host information
// //
//TODO: XXX: integrate CREDITS text again somehow #ifdef HAVE_SYS_UTSNAME_H
decltype(ircd::info::credits) decltype(ircd::info::utsname)
ircd::info::credits ircd::info::utsname{[]
{{ {
struct ::utsname utsname;
syscall(::uname, &utsname);
return utsname;
}()};
#endif
"Inspired by the original Internet Relay Chat daemon from Jarkko Oikarinen", //
" ", // System information
"This - is The Construct", //
" ",
"Internet Relay Chat daemon: Matrix Construct",
" ",
"Copyright (C) 2016-2018 Matrix Construct Developers, Authors & Contributors",
"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.",
" ",
}};
decltype(ircd::info::myinfo) #ifdef HAVE_SYS_RESOURCE_H
ircd::info::myinfo static uint64_t
{{ _get_rlimit(const int &resource)
#ifdef CPATH {
{"CPATH", CPATH, 0, "Path to Main Configuration File"}, rlimit rlim;
ircd::syscall(getrlimit, resource, &rlim);
return rlim.rlim_cur;
}
#else
static uint64_t
_get_rlimit(const int &resource)
{
return 0;
}
#endif
decltype(ircd::info::rlimit_rttime)
ircd::info::rlimit_rttime
{
#ifdef RLIMIT_RTTIME
_get_rlimit(RLIMIT_RTTIME)
#endif
};
decltype(ircd::info::rlimit_nofile)
ircd::info::rlimit_nofile
{
#ifdef RLIMIT_NOFILE
_get_rlimit(RLIMIT_NOFILE)
#endif
};
decltype(ircd::info::rlimit_rss)
ircd::info::rlimit_rss
{
#ifdef RLIMIT_RSS
_get_rlimit(RLIMIT_RSS)
#endif
};
decltype(ircd::info::rlimit_data)
ircd::info::rlimit_data
{
#ifdef RLIMIT_DATA
_get_rlimit(RLIMIT_DATA)
#endif
};
decltype(ircd::info::rlimit_as)
ircd::info::rlimit_as
{
#ifdef RLIMIT_AS
_get_rlimit(RLIMIT_AS)
#endif
};
decltype(ircd::info::aio_reqprio_max)
ircd::info::aio_reqprio_max
{
#ifdef _SC_AIO_PRIO_DELTA_MAX
size_t(syscall(::sysconf, _SC_AIO_PRIO_DELTA_MAX))
#endif
};
decltype(ircd::info::aio_max)
ircd::info::aio_max
{
#ifdef _SC_AIO_MAX
0 //size_t(syscall(::sysconf, _SC_AIO_MAX))
#endif
};
decltype(ircd::info::iov_max)
ircd::info::iov_max
{
#ifdef _SC_IOV_MAX
size_t(syscall(::sysconf, _SC_IOV_MAX))
#endif
};
decltype(ircd::info::page_size)
ircd::info::page_size
{
#ifdef _SC_PAGESIZE
size_t(syscall(::sysconf, _SC_PAGESIZE))
#endif
};
decltype(ircd::info::constructive_interference)
ircd::info::constructive_interference
{
#ifdef __cpp_lib_hardware_interference_size
std::hardware_constructive_interference_size
#else #else
{"CPATH", "NONE", 0, "Path to Main Configuration File"}, 0
#endif #endif
};
#ifdef DPATH decltype(ircd::info::destructive_interference)
{"DPATH", DPATH, 0, "Directory Containing Configuration Files"}, ircd::info::destructive_interference
{
#ifdef __cpp_lib_hardware_interference_size
std::hardware_destructive_interference_size
#else #else
{"DPATH", "NONE", 0, "Directory Containing Configuration Files"}, 0
#endif #endif
};
#ifdef HPATH decltype(ircd::info::hardware_concurrency)
{"HPATH", HPATH, 0, "Path to Operator Help Files"}, ircd::info::hardware_concurrency
#else {
{"HPATH", "NONE", 0, "Path to Operator Help Files"}, std::thread::hardware_concurrency()
#endif };
#ifdef UHPATH decltype(ircd::info::max_align)
{"UHPATH", UHPATH, 0, "Path to User Help Files"}, ircd::info::max_align
#else {
{"UHPATH", "NONE", 0, "Path to User Help Files"}, alignof(std::max_align_t)
#endif };
#ifdef RB_IPV6 //
{"IPV6", "ON", 0, "IPv6 Support"}, // Build information
#else //
{"IPV6", "OFF", 0, "IPv6 Support"},
#endif
#ifdef JOIN_LEAVE_COUNT_EXPIRE_TIME decltype(ircd::info::startup)
{"JOIN_LEAVE_COUNT_EXPIRE_TIME", "", JOIN_LEAVE_COUNT_EXPIRE_TIME, "Anti SpamBot Parameter"}, ircd::info::startup
#endif {
ctime(&startup_time)
};
#ifdef KILLCHASETIMELIMIT decltype(ircd::info::compiled)
{"KILLCHASETIMELIMIT", "", KILLCHASETIMELIMIT, "Nick Change Tracker for KILL"}, ircd::info::compiled
#endif {
__TIMESTAMP__
};
#ifdef LPATH decltype(ircd::info::configured)
{"LPATH", LPATH, 0, "Path to Log File"}, ircd::info::configured
#else {
{"LPATH", "NONE", 0, "Path to Log File"}, ctime(&configured_time)
#endif };
#ifdef MAX_BUFFER decltype(ircd::info::startup_time)
{"MAX_BUFFER", "", MAX_BUFFER, "Maximum Buffer Connections Allowed"}, ircd::info::startup_time
#endif {
std::time(nullptr)
};
#ifdef MAX_JOIN_LEAVE_COUNT decltype(ircd::info::configured_time)
{"MAX_JOIN_LEAVE_COUNT", "", MAX_JOIN_LEAVE_COUNT, "Anti SpamBot Parameter"}, ircd::info::configured_time
#endif {
RB_TIME_CONFIGURED
};
#ifdef MAX_JOIN_LEAVE_TIME decltype(ircd::info::commit)
{"MIN_JOIN_LEAVE_TIME", "", MIN_JOIN_LEAVE_TIME, "Anti SpamBot Parameter"}, ircd::info::commit
#endif {
RB_VERSION_COMMIT
};
#ifdef MPATH decltype(ircd::info::branch)
{"MPATH", MPATH, 0, "Path to MOTD File"}, ircd::info::branch
#else {
{"MPATH", "NONE", 0, "Path to MOTD File"}, RB_VERSION_BRANCH
#endif };
#ifdef NICKNAMEHISTORYLENGTH decltype(ircd::info::tag)
{"NICKNAMEHISTORYLENGTH", "", NICKNAMEHISTORYLENGTH, "Size of WHOWAS Array"}, ircd::info::tag
#endif {
RB_VERSION_TAG
#ifdef OPATH };
{"OPATH", OPATH, 0, "Path to Operator MOTD File"},
#else
{"OPATH", "NONE", 0, "Path to Operator MOTD File"},
#endif
#ifdef OPER_SPAM_COUNTDOWN
{"OPER_SPAM_COUNTDOWN", "", OPER_SPAM_COUNTDOWN, "Anti SpamBot Parameter"},
#endif
#ifdef HAVE_LIBCRYPTO
{"HAVE_LIBCRYPTO", "ON", 0, "Enable OpenSSL CHALLENGE Support"},
#else
{"HAVE_LIBCRYPTO", "OFF", 0, "Enable OpenSSL CHALLENGE Support"},
#endif
#ifdef HAVE_LIBZ
{"HAVE_LIBZ", "YES", 0, "zlib (ziplinks) support"},
#else
{"HAVE_LIBZ", "NO", 0, "zlib (ziplinks) support"},
#endif
#ifdef PPATH
{"PPATH", PPATH, 0, "Path to Pid File"},
#else
{"PPATH", "NONE", 0, "Path to Pid File"},
#endif
#ifdef SPATH
{"SPATH", SPATH, 0, "Path to Server Executable"},
#else
{"SPATH", "NONE", 0, "Path to Server Executable"},
#endif
#ifdef TS_MAX_DELTA_DEFAULT
{"TS_MAX_DELTA_DEFAULT", "", TS_MAX_DELTA_DEFAULT, "Maximum Allowed TS Delta from another Server"},
#endif
#ifdef TS_WARN_DELTA_DEFAULT
{"TS_WARN_DELTA_DEFAULT", "", TS_WARN_DELTA_DEFAULT, "Maximum TS Delta before Sending Warning"},
#endif
#ifdef USE_IODEBUG_HOOKS
{"USE_IODEBUG_HOOKS", "YES", 0, "IO Debugging support"},
#else
{"USE_IODEBUG_HOOKS", "NO", 0, "IO Debugging support"},
#endif
}};