aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/servers/httpasio.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-12 17:02:01 +0100
committerGitHub Enterprise <[email protected]>2026-03-12 17:02:01 +0100
commit3aa6aa83d05249d7081a8c19a28ce9b9c4566da2 (patch)
treef4f14006e82cdf0ed05083c9af90e17116614368 /src/zenhttp/servers/httpasio.cpp
parentUpdate CHANGELOG.md (diff)
downloadzen-3aa6aa83d05249d7081a8c19a28ce9b9c4566da2.tar.xz
zen-3aa6aa83d05249d7081a8c19a28ce9b9c4566da2.zip
Add --no-network option (#831)
- Add `--no-network` CLI option which disables all TCP/HTTPS listeners, restricting zenserver to Unix domain socket communication only. - Also fixes asio upgrade breakage on main
Diffstat (limited to 'src/zenhttp/servers/httpasio.cpp')
-rw-r--r--src/zenhttp/servers/httpasio.cpp35
1 files changed, 22 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