improved check of incorrect config

This commit is contained in:
Lukas Heiligenbrunner 2020-04-30 11:30:41 +02:00
parent 04e64ad79c
commit 7cf8e965b0
3 changed files with 25 additions and 16 deletions

View File

@ -134,7 +134,6 @@ IF (UNIX)
ENDIF (UNIX)
# check if Doxygen is installed
if (BUILD_DOC)
message(STATUS "config of DOxygen build")
find_package(Doxygen)

View File

@ -23,7 +23,7 @@ void IPRefresher::checkIPAdress(bool force) {
std::string ip = ipapi.getGlobalIp();
if (ip.empty()) {
//no internet connection
//no internet connection (or other error)
logger.logToLogfile("[WARNING] no internet connection");
Logger::warning("no internet connection");
} else {
@ -55,14 +55,18 @@ void IPRefresher::checkIPAdress(bool force) {
}
IPRefresher::IPRefresher() {
// default constructor
}
IPRefresher::IPRefresher(bool loop) {
if (Credentials::readCredentials()) {
Logger::message("startup of service");
while (loop) {
Logger::message("starting check");
checkIPAdress(false);
std::this_thread::sleep_for(std::chrono::milliseconds(300000));
}
} else {
std::cout << "incorrect credentials!" << std::endl;
}
}

View File

@ -5,10 +5,6 @@
#include <Credentials.h>
int main(int argc, char *argv[]) {
if (!Credentials::readCredentials()) {
std::cout << "incorrect credentials!" << std::endl;
return -1;
}
if (argc > 1) {
std::string firstarg(argv[1]);
if (firstarg == "-h" || firstarg == "--help") {
@ -21,7 +17,12 @@ int main(int argc, char *argv[]) {
std::cout << "Version " << Version::VERSION << std::endl;
} else if (firstarg == "-f" || firstarg == "--force") {
IPRefresher ipr;
if (Credentials::readCredentials()) {
ipr.checkIPAdress(true);
} else {
std::cout << "incorrect credentials!" << std::endl;
}
} else if (firstarg == "-l" || firstarg == "--loop") {
IPRefresher(true);
} else {
@ -30,7 +31,12 @@ int main(int argc, char *argv[]) {
} else {
IPRefresher ipr;
Logger::message("starting check");
if (Credentials::readCredentials()) {
ipr.checkIPAdress(false);
} else {
std::cout << "incorrect credentials!" << std::endl;
}
}
return 0;