From eaf8df25c2acacbd950aea885ddec60fd8e90d70 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 19 Feb 2018 14:03:05 -0800 Subject: [PATCH] ircd::info: Add name string / agency strings. --- include/ircd/info.h | 4 ++++ ircd/http.cc | 5 ++++- ircd/info.cc | 24 ++++++++++++++++++++++++ ircd/m/request.cc | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/include/ircd/info.h b/include/ircd/info.h index 92bca0672..427a01915 100644 --- a/include/ircd/info.h +++ b/include/ircd/info.h @@ -13,6 +13,7 @@ #define HAVE_IRCD_INFO_H // legacy +extern "C" const char *const ircd_name; extern "C" const char *const ircd_version; /// Information & metadata about the library. @@ -22,7 +23,10 @@ namespace ircd::info 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 time_t configured_time; diff --git a/ircd/http.cc b/ircd/http.cc index ae0691843..81b775412 100644 --- a/ircd/http.cc +++ b/ircd/http.cc @@ -339,7 +339,10 @@ ircd::http::response::response(window_buffer &out, if(code >= 200 && code < 300) writeline(out, [&code](const mutable_buffer &out) -> size_t { - return copy(out, "Server: " BRANDING_NAME " (IRCd " BRANDING_VERSION ")"_sv); + size_t ret{0}; + ret += copy(out, "Server: "_sv); + ret += copy(out + ret, ircd::info::server_agent); + return ret; }); if(code < 400) diff --git a/ircd/info.cc b/ircd/info.cc index 57b74fccf..2fc267989 100644 --- a/ircd/info.cc +++ b/ircd/info.cc @@ -67,18 +67,42 @@ ircd::info::init() }; } +extern "C" const char *const +ircd_name +{ + PACKAGE_NAME +}; + extern "C" const char *const ircd_version { RB_VERSION }; +decltype(ircd::info::name) +ircd::info::name +{ + PACKAGE_NAME +}; + decltype(ircd::info::version) ircd::info::version { RB_VERSION }; +decltype(ircd::info::user_agent) +ircd::info::user_agent +{ + BRANDING_NAME " (IRCd " BRANDING_VERSION ")" +}; + +decltype(ircd::info::server_agent) +ircd::info::server_agent +{ + BRANDING_NAME " (IRCd " BRANDING_VERSION ")" +}; + // // IRCd / build information // diff --git a/ircd/m/request.cc b/ircd/m/request.cc index 2f69287b6..609ca88ce 100644 --- a/ircd/m/request.cc +++ b/ircd/m/request.cc @@ -79,7 +79,7 @@ const size_t headers{1}; http::header header[headers + addl_headers_size] { - { "User-Agent", BRANDING_NAME " (IRCd " BRANDING_VERSION ")" }, + { "User-Agent", info::user_agent } }; for(size_t i(0); i < addl_headers_size; ++i)