use climits for MAX_ULONG
check if received ip from api has at least a :
This commit is contained in:
parent
2353e4b420
commit
a3c8fe44dd
@ -16,6 +16,7 @@
|
|||||||
#include <IPRefresher.h>
|
#include <IPRefresher.h>
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <Version.h>
|
#include <Version.h>
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
void IPRefresher::checkIPAdress(bool force) {
|
void IPRefresher::checkIPAdress(bool force) {
|
||||||
FileLogger logger;
|
FileLogger logger;
|
||||||
@ -26,6 +27,9 @@ void IPRefresher::checkIPAdress(bool force) {
|
|||||||
if (ip.empty()) {
|
if (ip.empty()) {
|
||||||
//no internet connection (or other error)
|
//no internet connection (or other error)
|
||||||
Logger::warning("no internet connection");
|
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 {
|
} else {
|
||||||
std::string oldip = logger.readip();
|
std::string oldip = logger.readip();
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "api/TelegramAPI.h"
|
#include "api/TelegramAPI.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
#include <Logger.h>
|
#include <climits>
|
||||||
|
|
||||||
int TelegramAPI::sendMessage(const std::string& text) {
|
int TelegramAPI::sendMessage(const std::string& text) {
|
||||||
Hashmap<std::string, std::string> args;
|
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);
|
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) {
|
if (reply.find("\"error_code\"") != ULONG_MAX) {
|
||||||
Logger::error("failed to refresh the ip (Dynu API)");
|
Logger::error("failed to refresh the ip (Dynu API)");
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user