diff --git a/modules/server/servermodule.cpp b/modules/server/servermodule.cpp index 1788c594dc..9451c6861d 100644 --- a/modules/server/servermodule.cpp +++ b/modules/server/servermodule.cpp @@ -72,37 +72,30 @@ ServerInterface* ServerModule::serverInterfaceByIdentifier(const std::string& id } void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) { - using namespace ghoul::io; + global::callback::preSync.emplace_back([this]() { preSync(); }); - if (configuration.hasValue(KeyInterfaces)) { - ghoul::Dictionary interfaces = - configuration.value(KeyInterfaces); + if (!configuration.hasValue(KeyInterfaces)) { + return; + } + ghoul::Dictionary interfaces = configuration.value(KeyInterfaces); - for (std::string& key : interfaces.keys()) { - if (!interfaces.hasValue(key)) { - continue; - } - ghoul::Dictionary interfaceDictionary = - interfaces.value(key); + for (const std::string& key : interfaces.keys()) { + ghoul::Dictionary interfaceDictionary = interfaces.value(key); - std::unique_ptr serverInterface = - ServerInterface::createFromDictionary(interfaceDictionary); + std::unique_ptr serverInterface = + ServerInterface::createFromDictionary(interfaceDictionary); - if (global::windowDelegate.isMaster()) { - serverInterface->initialize(); - } - - _interfaceOwner.addPropertySubOwner(serverInterface.get()); - - if (serverInterface) { - _interfaces.push_back(std::move(serverInterface)); - } + if (global::windowDelegate.isMaster()) { + serverInterface->initialize(); } - } + _interfaceOwner.addPropertySubOwner(serverInterface.get()); - global::callback::preSync.emplace_back([this]() { preSync(); }); + if (serverInterface) { + _interfaces.push_back(std::move(serverInterface)); + } + } } void ServerModule::preSync() { diff --git a/modules/server/src/serverinterface.cpp b/modules/server/src/serverinterface.cpp index 886b246246..81e4498fa4 100644 --- a/modules/server/src/serverinterface.cpp +++ b/modules/server/src/serverinterface.cpp @@ -117,6 +117,19 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& config) _defaultAccess.addOption(static_cast(Access::RequirePassword), RequirePassword); _defaultAccess.addOption(static_cast(Access::Allow), AllowAccess); + if (config.hasKey(DefaultAccessInfo.identifier)) { + std::string access = config.value(DefaultAccessInfo.identifier); + if (access == DenyAccess) { + _defaultAccess.setValue(static_cast(Access::Deny)); + } + else if (access == RequirePassword) { + _defaultAccess.setValue(static_cast(Access::RequirePassword)); + } + else if (access == AllowAccess) { + _defaultAccess.setValue(static_cast(Access::Allow)); + } + } + const std::string identifier = config.value(KeyIdentifier); auto readList = @@ -153,7 +166,7 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& config) _port = static_cast(config.value(PortInfo.identifier)); _enabled = config.value(EnabledInfo.identifier); - std::function reinitialize = [this]() { + auto reinitialize = [this]() { deinitialize(); initialize(); };