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 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
extern const string_view tag;
extern const string_view branch;
@ -38,40 +32,40 @@ namespace ircd::info
extern const string_view compiled;
extern const string_view startup;
// System / platform information
// System information
extern const size_t max_align;
extern const size_t hardware_concurrency;
extern const size_t destructive_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_data;
extern const size_t rlimit_rss;
extern const size_t rlimit_nofile;
extern const size_t rlimit_rttime;
extern const int glibc_version[3];
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;
// Host information
#ifdef HAVE_SYS_UTSNAME_H
extern const ::utsname utsname;
#endif
// Extended information
extern const std::vector<info::line> myinfo;
extern const std::vector<string_view> credits;
// Third-party information
extern const int glibc_version[3];
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 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
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_data,
rlimit_rss,
@ -86,18 +86,44 @@ ircd::info::dump()
iov_max,
aio_max,
aio_reqprio_max,
clk_tck
};
}
extern "C" const char *const
ircd_name
decltype(ircd::info::credits)
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
};
@ -108,224 +134,16 @@ ircd::info::name
PACKAGE_NAME
};
decltype(ircd::info::version)
ircd::info::version
extern "C" const char *const
ircd_version
{
RB_VERSION
};
decltype(ircd::info::user_agent)
ircd::info::user_agent
extern "C" const char *const
ircd_name
{
BRANDING_NAME " (IRCd " BRANDING_VERSION ")"
};
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
PACKAGE_NAME
};
//
@ -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
decltype(ircd::info::credits)
ircd::info::credits
{{
#ifdef HAVE_SYS_UTSNAME_H
decltype(ircd::info::utsname)
ircd::info::utsname{[]
{
struct ::utsname utsname;
syscall(::uname, &utsname);
return utsname;
}()};
#endif
"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.",
" ",
}};
//
// System information
//
decltype(ircd::info::myinfo)
ircd::info::myinfo
{{
#ifdef CPATH
{"CPATH", CPATH, 0, "Path to Main Configuration File"},
#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_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
{"CPATH", "NONE", 0, "Path to Main Configuration File"},
0
#endif
};
#ifdef DPATH
{"DPATH", DPATH, 0, "Directory Containing Configuration Files"},
decltype(ircd::info::destructive_interference)
ircd::info::destructive_interference
{
#ifdef __cpp_lib_hardware_interference_size
std::hardware_destructive_interference_size
#else
{"DPATH", "NONE", 0, "Directory Containing Configuration Files"},
0
#endif
};
#ifdef HPATH
{"HPATH", HPATH, 0, "Path to Operator Help Files"},
#else
{"HPATH", "NONE", 0, "Path to Operator Help Files"},
#endif
decltype(ircd::info::hardware_concurrency)
ircd::info::hardware_concurrency
{
std::thread::hardware_concurrency()
};
#ifdef UHPATH
{"UHPATH", UHPATH, 0, "Path to User Help Files"},
#else
{"UHPATH", "NONE", 0, "Path to User Help Files"},
#endif
decltype(ircd::info::max_align)
ircd::info::max_align
{
alignof(std::max_align_t)
};
#ifdef RB_IPV6
{"IPV6", "ON", 0, "IPv6 Support"},
#else
{"IPV6", "OFF", 0, "IPv6 Support"},
#endif
//
// Build information
//
#ifdef JOIN_LEAVE_COUNT_EXPIRE_TIME
{"JOIN_LEAVE_COUNT_EXPIRE_TIME", "", JOIN_LEAVE_COUNT_EXPIRE_TIME, "Anti SpamBot Parameter"},
#endif
decltype(ircd::info::startup)
ircd::info::startup
{
ctime(&startup_time)
};
#ifdef KILLCHASETIMELIMIT
{"KILLCHASETIMELIMIT", "", KILLCHASETIMELIMIT, "Nick Change Tracker for KILL"},
#endif
decltype(ircd::info::compiled)
ircd::info::compiled
{
__TIMESTAMP__
};
#ifdef LPATH
{"LPATH", LPATH, 0, "Path to Log File"},
#else
{"LPATH", "NONE", 0, "Path to Log File"},
#endif
decltype(ircd::info::configured)
ircd::info::configured
{
ctime(&configured_time)
};
#ifdef MAX_BUFFER
{"MAX_BUFFER", "", MAX_BUFFER, "Maximum Buffer Connections Allowed"},
#endif
decltype(ircd::info::startup_time)
ircd::info::startup_time
{
std::time(nullptr)
};
#ifdef MAX_JOIN_LEAVE_COUNT
{"MAX_JOIN_LEAVE_COUNT", "", MAX_JOIN_LEAVE_COUNT, "Anti SpamBot Parameter"},
#endif
decltype(ircd::info::configured_time)
ircd::info::configured_time
{
RB_TIME_CONFIGURED
};
#ifdef MAX_JOIN_LEAVE_TIME
{"MIN_JOIN_LEAVE_TIME", "", MIN_JOIN_LEAVE_TIME, "Anti SpamBot Parameter"},
#endif
decltype(ircd::info::commit)
ircd::info::commit
{
RB_VERSION_COMMIT
};
#ifdef MPATH
{"MPATH", MPATH, 0, "Path to MOTD File"},
#else
{"MPATH", "NONE", 0, "Path to MOTD File"},
#endif
decltype(ircd::info::branch)
ircd::info::branch
{
RB_VERSION_BRANCH
};
#ifdef NICKNAMEHISTORYLENGTH
{"NICKNAMEHISTORYLENGTH", "", NICKNAMEHISTORYLENGTH, "Size of WHOWAS Array"},
#endif
#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
}};
decltype(ircd::info::tag)
ircd::info::tag
{
RB_VERSION_TAG
};