}
if (config["uid"].IsDefined()) {
- string uid = config["uid"].as<string>();
+ auto uid = config["uid"].as<string>();
try {
configuration.uid = pdns::checked_stoi<uid_t>(uid);
}
}
int main(int argc, char** argv) {
- g_log.setLoglevel(Logger::Notice);
- g_log.toConsole(Logger::Notice);
- g_log.setPrefixed(true);
- g_log.disableSyslog(true);
- g_log.setTimestamps(false);
+ bool had_error = false;
+ std::optional<IXFRDistConfiguration> configuration{std::nullopt};
+ std::unique_ptr<FDMultiplexer> fdm{nullptr};
- auto fdm = std::unique_ptr<FDMultiplexer>(FDMultiplexer::getMultiplexerSilent());
- if (!fdm) {
- g_log<<Logger::Error<<"Could not enable a multiplexer for the listen sockets!"<<endl;
- return EXIT_FAILURE;
- }
+ try {
+ g_log.setLoglevel(Logger::Notice);
+ g_log.toConsole(Logger::Notice);
+ g_log.setPrefixed(true);
+ g_log.disableSyslog(true);
+ g_log.setTimestamps(false);
+
+ fdm = std::unique_ptr<FDMultiplexer>(FDMultiplexer::getMultiplexerSilent());
+ if (!fdm) {
+ g_log<<Logger::Error<<"Could not enable a multiplexer for the listen sockets!"<<endl;
+ return EXIT_FAILURE;
+ }
- auto configuration = parseConfiguration(argc, argv, *fdm);
+ configuration = parseConfiguration(argc, argv, *fdm);
+ if (!configuration) {
+ // We have already sent the errors to stderr, just die
+ return EXIT_FAILURE;
+ }
- if (!configuration) {
- // We have already sent the errors to stderr, just die
- return EXIT_FAILURE;
+ if (configuration->done) {
+ return EXIT_SUCCESS;
+ }
}
-
- if (configuration->done) {
- return EXIT_SUCCESS;
+ catch (const YAML::Exception& exp) {
+ had_error = true;
+ g_log<<Logger::Error<<"Got an exception while processing our configuration: "<<exp.msg<<endl;
}
- bool had_error = false;
try {
if (configuration->gid != 0) {
g_log<<Logger::Notice<<"Dropping effective group-id to "<<configuration->gid<<endl;
// It all starts here
signal(SIGTERM, handleSignal);
signal(SIGINT, handleSignal);
+ //NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
signal(SIGPIPE, SIG_IGN);
// Launch the webserver!
if (had_error) {
return EXIT_FAILURE;
}
+ }
+ catch (const YAML::Exception& exp) {
+ had_error = true;
+ g_log<<Logger::Error<<"Got an exception while applying our configuration: "<<exp.msg<<endl;
+ }
+ try {
// Init the things we need
reportAllTypes();
}
catch (const YAML::Exception& exp) {
had_error = true;
- g_log<<Logger::Error<<"Got an exception while applying our configuration: "<<exp.msg<<endl;
+ g_log<<Logger::Error<<"Got an exception: "<<exp.msg<<endl;
}
return had_error ? EXIT_FAILURE : EXIT_SUCCESS;