improved check of incorrect config
This commit is contained in:
parent
04e64ad79c
commit
7cf8e965b0
@ -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)
|
||||
|
@ -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 {
|
||||
@ -37,7 +37,7 @@ void IPRefresher::checkIPAdress(bool force) {
|
||||
Logger::message("ip changed! -- from :" + oldip + "to: " + ip);
|
||||
|
||||
DynuAPI dynu;
|
||||
dynu.init(Credentials::dynuapikey,Credentials::domainid,Credentials::domainname);
|
||||
dynu.init(Credentials::dynuapikey, Credentials::domainid, Credentials::domainname);
|
||||
|
||||
if (dynu.refreshIp(ip)) {
|
||||
TelegramAPI tele;
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
14
src/main.cpp
14
src/main.cpp
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user