aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/servers/httpsys.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-11-09 20:50:46 +0100
committerGitHub <[email protected]>2023-11-09 20:50:46 +0100
commitc289d408765fe47d54987bd49fcf277f2419104a (patch)
treed76ac1fae0a2413f080c4ecfb0e7f281ed50f271 /src/zenhttp/servers/httpsys.cpp
parent0.2.31-pre1 (diff)
downloadzen-c289d408765fe47d54987bd49fcf277f2419104a.tar.xz
zen-c289d408765fe47d54987bd49fcf277f2419104a.zip
option for zenserver - `--http-forceloopback` (#516)
* New option for zenserver - `--http-forceloopback` which forces opening of the server http server using loopback (local) connection (UE-199776) * add fallback to local connection for asio if we get access denied on public port
Diffstat (limited to 'src/zenhttp/servers/httpsys.cpp')
-rw-r--r--src/zenhttp/servers/httpsys.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/zenhttp/servers/httpsys.cpp b/src/zenhttp/servers/httpsys.cpp
index 4eeab6662..0b11d396b 100644
--- a/src/zenhttp/servers/httpsys.cpp
+++ b/src/zenhttp/servers/httpsys.cpp
@@ -1003,18 +1003,27 @@ HttpSysServer::InitializeServer(int BasePort)
int EffectivePort = BasePort;
- Result = HttpAddUrlToUrlGroup(m_HttpUrlGroupId, WildcardUrlPath.c_str(), HTTP_URL_CONTEXT(0), 0);
-
- if ((Result == ERROR_SHARING_VIOLATION) && AllowPortProbing)
+ if (m_InitialConfig.ForceLoopback)
+ {
+ // Force trigger of opening using local port
+ ZEN_ASSERT(AllowLocalOnly);
+ Result = ERROR_ACCESS_DENIED;
+ }
+ else
{
- // Sharing violation implies the port is being used by another process
- for (int PortOffset = 1; (Result == ERROR_SHARING_VIOLATION) && (PortOffset < 10); ++PortOffset)
+ Result = HttpAddUrlToUrlGroup(m_HttpUrlGroupId, WildcardUrlPath.c_str(), HTTP_URL_CONTEXT(0), 0);
+
+ if ((Result == ERROR_SHARING_VIOLATION) && AllowPortProbing)
{
- EffectivePort = BasePort + (PortOffset * 100);
- WildcardUrlPath.Reset();
- WildcardUrlPath << u8"http://*:"sv << int64_t(EffectivePort) << u8"/"sv;
+ // Sharing violation implies the port is being used by another process
+ for (int PortOffset = 1; (Result == ERROR_SHARING_VIOLATION) && (PortOffset < 10); ++PortOffset)
+ {
+ EffectivePort = BasePort + (PortOffset * 100);
+ WildcardUrlPath.Reset();
+ WildcardUrlPath << u8"http://*:"sv << int64_t(EffectivePort) << u8"/"sv;
- Result = HttpAddUrlToUrlGroup(m_HttpUrlGroupId, WildcardUrlPath.c_str(), HTTP_URL_CONTEXT(0), 0);
+ Result = HttpAddUrlToUrlGroup(m_HttpUrlGroupId, WildcardUrlPath.c_str(), HTTP_URL_CONTEXT(0), 0);
+ }
}
}