From 5abb6a2c08329839432b30f5d70b22ddac1dca1f Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Tue, 25 Jan 2022 11:38:44 +0100 Subject: Command line paths containing whitespace were getting truncated --- zenserver/config.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'zenserver/config.cpp') diff --git a/zenserver/config.cpp b/zenserver/config.cpp index 4afe012dd..3c4f6f3d8 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -91,6 +91,16 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) const char* DefaultHttp = "asio"; #endif + // Note to those adding future options; std::filesystem::path-type options + // must be read into a std::string first. As of cxxopts-3.0.0 it uses a >> + // stream operator to convert argv value into the options type. std::fs::path + // expects paths in streams to be quoted but argv paths are unquoted. By + // going into a std::string first, paths with whitespace parse correctly. + std::string DataDir; + std::string ContentDir; + std::string AbsLogFile; + std::string ConfigFile; + cxxopts::Options options("zenserver", "Zen Server"); options.add_options()("dedicated", "Enable dedicated server mode", @@ -99,10 +109,10 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) options.add_options()("help", "Show command line help"); options.add_options()("t, test", "Enable test mode", cxxopts::value(ServerOptions.IsTest)->default_value("false")); options.add_options()("log-id", "Specify id for adding context to log output", cxxopts::value(ServerOptions.LogId)); - options.add_options()("data-dir", "Specify persistence root", cxxopts::value(ServerOptions.DataDir)); - options.add_options()("content-dir", "Frontend content directory", cxxopts::value(ServerOptions.ContentDir)); - options.add_options()("abslog", "Path to log file", cxxopts::value(ServerOptions.AbsLogFile)); - options.add_options()("config", "Path to Lua config file", cxxopts::value(ServerOptions.ConfigFile)); + options.add_options()("data-dir", "Specify persistence root", cxxopts::value(DataDir)); + options.add_options()("content-dir", "Frontend content directory", cxxopts::value(ContentDir)); + options.add_options()("abslog", "Path to log file", cxxopts::value(AbsLogFile)); + options.add_options()("config", "Path to Lua config file", cxxopts::value(ConfigFile)); options.add_options()("no-sentry", "Disable Sentry crash handler", cxxopts::value(ServerOptions.NoSentry)->default_value("false")); @@ -327,6 +337,10 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) exit(0); } + ServerOptions.DataDir = DataDir; + ServerOptions.ContentDir = ContentDir; + ServerOptions.AbsLogFile = AbsLogFile; + ServerOptions.ConfigFile = ConfigFile; ServerOptions.UpstreamCacheConfig.CachePolicy = ParseUpstreamCachePolicy(UpstreamCachePolicyOptions); if (!ServerOptions.ConfigFile.empty()) -- cgit v1.2.3 From 5291894278e160b9200b6ce261c6ab5437e45ccc Mon Sep 17 00:00:00 2001 From: Per Larsson Date: Wed, 26 Jan 2022 09:00:16 +0100 Subject: Fixed issue with missing endpoint name when configuring upstream cache from Lua. --- zenserver/config.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'zenserver/config.cpp') diff --git a/zenserver/config.cpp b/zenserver/config.cpp index 3c4f6f3d8..a36ce5f33 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -337,10 +337,10 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) exit(0); } - ServerOptions.DataDir = DataDir; - ServerOptions.ContentDir = ContentDir; - ServerOptions.AbsLogFile = AbsLogFile; - ServerOptions.ConfigFile = ConfigFile; + ServerOptions.DataDir = DataDir; + ServerOptions.ContentDir = ContentDir; + ServerOptions.AbsLogFile = AbsLogFile; + ServerOptions.ConfigFile = ConfigFile; ServerOptions.UpstreamCacheConfig.CachePolicy = ParseUpstreamCachePolicy(UpstreamCachePolicyOptions); if (!ServerOptions.ConfigFile.empty()) @@ -478,6 +478,9 @@ ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptio if (auto JupiterConfig = UpstreamConfig->get>("jupiter")) { + UpdateStringValueFromConfig(JupiterConfig.value(), + std::string_view("name"), + ServerOptions.UpstreamCacheConfig.JupiterConfig.Name); UpdateStringValueFromConfig(JupiterConfig.value(), std::string_view("url"), ServerOptions.UpstreamCacheConfig.JupiterConfig.Url); @@ -507,6 +510,8 @@ ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptio if (auto ZenConfig = UpstreamConfig->get>("zen")) { + ServerOptions.UpstreamCacheConfig.ZenConfig.Name = ZenConfig.value().get_or("name", std::string("Zen")); + if (auto Url = ZenConfig.value().get>("url")) { ServerOptions.UpstreamCacheConfig.ZenConfig.Urls.push_back(Url.value()); -- cgit v1.2.3