From 7daef82218412f38f68727607f81271375de4a57 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 16 Mar 2018 18:59:28 -0700 Subject: [PATCH] construct/ircd: Add option to soft-indicate no listening sockets should be bound. --- construct/construct.cc | 1 + include/ircd/stdinc.h | 3 ++- ircd/ircd.cc | 1 + ircd/m/m.cc | 10 ++++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/construct/construct.cc b/construct/construct.cc index b691cd0d6..b4555b278 100644 --- a/construct/construct.cc +++ b/construct/construct.cc @@ -52,6 +52,7 @@ lgetopt opts[] = { "debug", &ircd::debugmode, lgetopt::BOOL, "Enable options for debugging" }, { "console", &cmdline, lgetopt::BOOL, "Drop to a command line immediately after startup" }, { "execute", &execute, lgetopt::STRING, "Execute command lines immediately after startup" }, + { "nolisten", &ircd::nolisten, lgetopt::BOOL, "Normal execution but without listening sockets" }, { nullptr, nullptr, lgetopt::STRING, nullptr }, }; diff --git a/include/ircd/stdinc.h b/include/ircd/stdinc.h index 3558e51dd..fdd7f7f9c 100644 --- a/include/ircd/stdinc.h +++ b/include/ircd/stdinc.h @@ -184,7 +184,8 @@ namespace ircd constexpr size_t BUFSIZE { 512 }; extern const enum runlevel &runlevel; extern const std::string &config; - extern bool debugmode; ///< Toggle; available only ifdef RB_DEBUG + extern bool debugmode; ///< Toggle; available only ifdef RB_DEBUG + extern bool nolisten; ///< Init option to not bind listener socks. std::string demangle(const std::string &symbol); template std::string demangle(); diff --git a/ircd/ircd.cc b/ircd/ircd.cc index 808be8110..e8e76d968 100644 --- a/ircd/ircd.cc +++ b/ircd/ircd.cc @@ -22,6 +22,7 @@ namespace ircd ctx::ctx *main_context; // Main program loop bool debugmode; // meaningful ifdef RB_DEBUG + bool nolisten; // indicates no listener binding void set_runlevel(const enum runlevel &); void at_main_exit() noexcept; diff --git a/ircd/m/m.cc b/ircd/m/m.cc index e02e954b6..6f1bce9f6 100644 --- a/ircd/m/m.cc +++ b/ircd/m/m.cc @@ -158,6 +158,16 @@ namespace ircd::m void ircd::m::init::listeners() { + if(ircd::nolisten) + { + log::warning + { + "Not listening on any addresses because nolisten flag is set." + }; + + return; + } + const json::array listeners { config["listeners"]