Terminate client if host is empty and no mDNS

This commit is contained in:
badaix 2020-11-02 20:29:03 +01:00
parent a7c945ad53
commit f743ae717f
2 changed files with 8 additions and 2 deletions

View file

@ -262,6 +262,12 @@ int main(int argc, char** argv)
else
throw SnapException("Invalid log sink: " + settings.logging.sink);
#if !defined(HAS_AVAHI) && !defined(HAS_BONJOUR)
if (settings.server.host.empty())
throw SnapException("Snapserver host not configured and mDNS not available, please configure with \"--host\".");
#endif
#ifdef HAS_DAEMON
std::unique_ptr<Daemon> daemon;
if (daemonOption->is_set())
@ -383,6 +389,6 @@ int main(int argc, char** argv)
exitcode = EXIT_FAILURE;
}
LOG(NOTICE, LOG_TAG) << "daemon terminated." << endl;
LOG(NOTICE, LOG_TAG) << "Snapclient terminated." << endl;
exit(exitcode);
}

View file

@ -327,6 +327,6 @@ int main(int argc, char* argv[])
exitcode = EXIT_FAILURE;
}
Config::instance().save();
LOG(NOTICE) << "daemon terminated." << endl;
LOG(NOTICE) << "Snapserver terminated." << endl;
exit(exitcode);
}