diff options
Diffstat (limited to 'src/zenhttp/servers')
| -rw-r--r-- | src/zenhttp/servers/httpasio.cpp | 35 | ||||
| -rw-r--r-- | src/zenhttp/servers/httpasio.h | 1 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/zenhttp/servers/httpasio.cpp b/src/zenhttp/servers/httpasio.cpp index e8b27da70..643f33618 100644 --- a/src/zenhttp/servers/httpasio.cpp +++ b/src/zenhttp/servers/httpasio.cpp @@ -2157,15 +2157,18 @@ HttpAsioServerImpl::Start(uint16_t Port, const AsioConfig& Config) ZEN_INFO("starting asio http with {} service threads", Config.ThreadCount); - m_Acceptor.reset( - new asio_http::HttpAcceptor(*this, m_IoService, Port, Config.ForceLoopback, /*AllowPortProbing */ !Config.IsDedicatedServer)); - - if (!m_Acceptor->IsValid()) + if (!Config.NoNetwork) { - return 0; - } + m_Acceptor.reset( + new asio_http::HttpAcceptor(*this, m_IoService, Port, Config.ForceLoopback, /*AllowPortProbing */ !Config.IsDedicatedServer)); + + if (!m_Acceptor->IsValid()) + { + return 0; + } - m_Acceptor->Start(); + m_Acceptor->Start(); + } #if defined(ASIO_HAS_LOCAL_SOCKETS) if (!Config.UnixSocketPath.empty()) @@ -2184,7 +2187,7 @@ HttpAsioServerImpl::Start(uint16_t Port, const AsioConfig& Config) #endif #if ZEN_USE_OPENSSL - if (!Config.CertFile.empty() && !Config.KeyFile.empty()) + if (!Config.NoNetwork && !Config.CertFile.empty() && !Config.KeyFile.empty()) { m_SslContext = std::make_unique<asio::ssl::context>(asio::ssl::context::tlsv12_server); m_SslContext->set_options(asio::ssl::context::default_workarounds | asio::ssl::context::no_sslv2 | asio::ssl::context::no_sslv3 | @@ -2243,12 +2246,18 @@ HttpAsioServerImpl::Start(uint16_t Port, const AsioConfig& Config) }); } - ZEN_INFO("asio http started in {} mode, using {} threads on port {}", - Config.IsDedicatedServer ? "DEDICATED" : "NORMAL", - Config.ThreadCount, - m_Acceptor->GetAcceptPort()); + if (m_Acceptor) + { + ZEN_INFO("asio http started in {} mode, using {} threads on port {}", + Config.IsDedicatedServer ? "DEDICATED" : "NORMAL", + Config.ThreadCount, + m_Acceptor->GetAcceptPort()); + + return m_Acceptor->GetAcceptPort(); + } - return m_Acceptor->GetAcceptPort(); + ZEN_INFO("asio http started in no-network mode, using {} threads (unix socket only)", Config.ThreadCount); + return Port; } void diff --git a/src/zenhttp/servers/httpasio.h b/src/zenhttp/servers/httpasio.h index 5adf4d5e8..21d10170e 100644 --- a/src/zenhttp/servers/httpasio.h +++ b/src/zenhttp/servers/httpasio.h @@ -11,6 +11,7 @@ struct AsioConfig unsigned int ThreadCount = 0; bool ForceLoopback = false; bool IsDedicatedServer = false; + bool NoNetwork = false; std::string UnixSocketPath; #if ZEN_USE_OPENSSL int HttpsPort = 0; // 0 = auto-assign; set CertFile/KeyFile to enable HTTPS |