improved check of incorrect config
This commit is contained in:
parent
04e64ad79c
commit
7cf8e965b0
@ -134,7 +134,6 @@ IF (UNIX)
|
|||||||
ENDIF (UNIX)
|
ENDIF (UNIX)
|
||||||
|
|
||||||
# check if Doxygen is installed
|
# check if Doxygen is installed
|
||||||
|
|
||||||
if (BUILD_DOC)
|
if (BUILD_DOC)
|
||||||
message(STATUS "config of DOxygen build")
|
message(STATUS "config of DOxygen build")
|
||||||
find_package(Doxygen)
|
find_package(Doxygen)
|
||||||
|
@ -23,7 +23,7 @@ void IPRefresher::checkIPAdress(bool force) {
|
|||||||
std::string ip = ipapi.getGlobalIp();
|
std::string ip = ipapi.getGlobalIp();
|
||||||
|
|
||||||
if (ip.empty()) {
|
if (ip.empty()) {
|
||||||
//no internet connection
|
//no internet connection (or other error)
|
||||||
logger.logToLogfile("[WARNING] no internet connection");
|
logger.logToLogfile("[WARNING] no internet connection");
|
||||||
Logger::warning("no internet connection");
|
Logger::warning("no internet connection");
|
||||||
} else {
|
} else {
|
||||||
@ -37,7 +37,7 @@ void IPRefresher::checkIPAdress(bool force) {
|
|||||||
Logger::message("ip changed! -- from :" + oldip + "to: " + ip);
|
Logger::message("ip changed! -- from :" + oldip + "to: " + ip);
|
||||||
|
|
||||||
DynuAPI dynu;
|
DynuAPI dynu;
|
||||||
dynu.init(Credentials::dynuapikey,Credentials::domainid,Credentials::domainname);
|
dynu.init(Credentials::dynuapikey, Credentials::domainid, Credentials::domainname);
|
||||||
|
|
||||||
if (dynu.refreshIp(ip)) {
|
if (dynu.refreshIp(ip)) {
|
||||||
TelegramAPI tele;
|
TelegramAPI tele;
|
||||||
@ -55,14 +55,18 @@ void IPRefresher::checkIPAdress(bool force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IPRefresher::IPRefresher() {
|
IPRefresher::IPRefresher() {
|
||||||
|
// default constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
IPRefresher::IPRefresher(bool loop) {
|
IPRefresher::IPRefresher(bool loop) {
|
||||||
|
if (Credentials::readCredentials()) {
|
||||||
Logger::message("startup of service");
|
Logger::message("startup of service");
|
||||||
while (loop) {
|
while (loop) {
|
||||||
Logger::message("starting check");
|
Logger::message("starting check");
|
||||||
checkIPAdress(false);
|
checkIPAdress(false);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(300000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(300000));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
std::cout << "incorrect credentials!" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
14
src/main.cpp
14
src/main.cpp
@ -5,10 +5,6 @@
|
|||||||
#include <Credentials.h>
|
#include <Credentials.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (!Credentials::readCredentials()) {
|
|
||||||
std::cout << "incorrect credentials!" << std::endl;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
std::string firstarg(argv[1]);
|
std::string firstarg(argv[1]);
|
||||||
if (firstarg == "-h" || firstarg == "--help") {
|
if (firstarg == "-h" || firstarg == "--help") {
|
||||||
@ -21,7 +17,12 @@ int main(int argc, char *argv[]) {
|
|||||||
std::cout << "Version " << Version::VERSION << std::endl;
|
std::cout << "Version " << Version::VERSION << std::endl;
|
||||||
} else if (firstarg == "-f" || firstarg == "--force") {
|
} else if (firstarg == "-f" || firstarg == "--force") {
|
||||||
IPRefresher ipr;
|
IPRefresher ipr;
|
||||||
|
if (Credentials::readCredentials()) {
|
||||||
ipr.checkIPAdress(true);
|
ipr.checkIPAdress(true);
|
||||||
|
} else {
|
||||||
|
std::cout << "incorrect credentials!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (firstarg == "-l" || firstarg == "--loop") {
|
} else if (firstarg == "-l" || firstarg == "--loop") {
|
||||||
IPRefresher(true);
|
IPRefresher(true);
|
||||||
} else {
|
} else {
|
||||||
@ -30,7 +31,12 @@ int main(int argc, char *argv[]) {
|
|||||||
} else {
|
} else {
|
||||||
IPRefresher ipr;
|
IPRefresher ipr;
|
||||||
Logger::message("starting check");
|
Logger::message("starting check");
|
||||||
|
if (Credentials::readCredentials()) {
|
||||||
ipr.checkIPAdress(false);
|
ipr.checkIPAdress(false);
|
||||||
|
} else {
|
||||||
|
std::cout << "incorrect credentials!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user