Merge pull request #8 from Lukas-Heiligenbrunner/DoctypeBug

Doctype bug
This commit is contained in:
Lukas-Heiligenbrunner 2020-05-05 19:15:57 +02:00 committed by GitHub
commit 8659237ece
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -4,6 +4,7 @@
#include <fstream>
#include <iostream>
#include <climits>
#include "FileLogger.h"
@ -24,5 +25,9 @@ std::string FileLogger::readip() {
in >> ip;
return ip;
// when received ip has no : return 0.0.0.0
if (ip.find(':') == ULONG_MAX)
return "0.0.0.0";
else
return ip;
}

View File

@ -16,6 +16,7 @@
#include <IPRefresher.h>
#include <Config.h>
#include <Version.h>
#include <climits>
void IPRefresher::checkIPAdress(bool force) {
FileLogger logger;
@ -26,6 +27,9 @@ void IPRefresher::checkIPAdress(bool force) {
if (ip.empty()) {
//no internet connection (or other error)
Logger::warning("no internet connection");
} else if (ip.find(':') == ULONG_MAX) {
// error when ip doesn't contain a :
Logger::warning("an error occured when getting the global ip");
} else {
std::string oldip = logger.readip();

View File

@ -3,8 +3,9 @@
//
#include "api/TelegramAPI.h"
#include "Logger.h"
#include <Logger.h>
#include <climits>
int TelegramAPI::sendMessage(const std::string& text) {
Hashmap<std::string, std::string> args;
@ -15,7 +16,6 @@ int TelegramAPI::sendMessage(const std::string& text) {
std::string reply = request("https://api.telegram.org/bot" + apikey + "/sendmessage", false, args, headers);
unsigned const long ULONG_MAX = -1;
if (reply.find("\"error_code\"") != ULONG_MAX) {
Logger::error("failed to refresh the ip (Dynu API)");
return -1;