added internet connection detection
This commit is contained in:
parent
97469e3e43
commit
004ca7c62c
155
.idea/workspace.xml
generated
155
.idea/workspace.xml
generated
@ -14,9 +14,7 @@
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="59c80f39-2468-4db0-9afd-14b8acdbffed" name="Default Changelist" comment="deleted cmake files">
|
||||
<change afterPath="$PROJECT_DIR$/src/Logger.cpp" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/Logger.h" afterDir="false" />
|
||||
<list default="true" id="59c80f39-2468-4db0-9afd-14b8acdbffed" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/CMakeLists.txt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/API.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/src/API.cpp" afterDir="false" />
|
||||
@ -36,14 +34,20 @@
|
||||
<component name="ExecutionTargetManager" SELECTED_TARGET="CMakeBuildProfile:Debug" />
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="90">
|
||||
<caret line="6" column="40" lean-forward="true" selection-start-line="6" selection-start-column="40" selection-end-line="6" selection-end-column="40" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/API.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="210">
|
||||
<state relative-caret-position="195">
|
||||
<caret line="14" column="124" selection-start-line="14" selection-start-column="124" selection-end-line="14" selection-end-column="124" />
|
||||
<folding>
|
||||
<element signature="e#95#112#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -51,8 +55,11 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/API.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="281">
|
||||
<caret line="44" column="17" selection-start-line="44" selection-start-column="17" selection-end-line="44" selection-end-column="17" />
|
||||
<state relative-caret-position="45">
|
||||
<caret line="3" selection-start-line="3" selection-end-line="3" />
|
||||
<folding>
|
||||
<element signature="e#40#56#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -65,8 +72,8 @@
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/main.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="289">
|
||||
<caret line="29" column="41" lean-forward="true" selection-start-line="29" selection-start-column="41" selection-end-line="29" selection-end-column="41" />
|
||||
<state relative-caret-position="240">
|
||||
<caret line="16" column="69" selection-start-line="16" selection-start-column="69" selection-end-line="16" selection-end-column="69" />
|
||||
<folding>
|
||||
<element signature="e#0#19#0" expanded="true" />
|
||||
</folding>
|
||||
@ -83,7 +90,7 @@
|
||||
<entry file="file://$PROJECT_DIR$/src/Logger.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="555">
|
||||
<caret line="37" column="38" lean-forward="true" selection-start-line="37" selection-start-column="38" selection-end-line="37" selection-end-column="38" />
|
||||
<caret line="37" column="38" selection-start-line="37" selection-start-column="38" selection-end-line="37" selection-end-column="38" />
|
||||
<folding>
|
||||
<element signature="e#40#58#0" expanded="true" />
|
||||
</folding>
|
||||
@ -96,11 +103,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/cmake-build-debug/dynurefresher.log">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/Logger.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
@ -130,12 +132,12 @@
|
||||
<option value="$PROJECT_DIR$/API.h" />
|
||||
<option value="$PROJECT_DIR$/main.cpp" />
|
||||
<option value="$PROJECT_DIR$/API.cpp" />
|
||||
<option value="$PROJECT_DIR$/CMakeLists.txt" />
|
||||
<option value="$PROJECT_DIR$/.gitignore" />
|
||||
<option value="$PROJECT_DIR$/src/API.cpp" />
|
||||
<option value="$PROJECT_DIR$/src/Logger.h" />
|
||||
<option value="$PROJECT_DIR$/src/main.cpp" />
|
||||
<option value="$PROJECT_DIR$/src/Logger.cpp" />
|
||||
<option value="$PROJECT_DIR$/src/API.cpp" />
|
||||
<option value="$PROJECT_DIR$/CMakeLists.txt" />
|
||||
<option value="$PROJECT_DIR$/src/main.cpp" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@ -160,12 +162,16 @@
|
||||
<path>
|
||||
<item name="iprefresher" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="DynuIPRefresher" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="cmake-build-debug" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="iprefresher" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="DynuIPRefresher" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="iprefresher" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
|
||||
<item name="Header Search Paths" type="70bed36:NamedLibraryElementNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
@ -180,6 +186,7 @@
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
|
||||
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
|
||||
<property name="settings.editor.selected.configurable" value="CLionExternalConfigurable" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
@ -222,7 +229,7 @@
|
||||
<workItem from="1556646880233" duration="656000" />
|
||||
<workItem from="1556710548728" duration="6200000" />
|
||||
<workItem from="1557047487321" duration="761000" />
|
||||
<workItem from="1557061811880" duration="5098000" />
|
||||
<workItem from="1557061811880" duration="10758000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="edited api class and made it to work">
|
||||
<created>1557063528491</created>
|
||||
@ -245,11 +252,25 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1557063931807</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="4" />
|
||||
<task id="LOCAL-00004" summary="added loggin methods">
|
||||
<created>1557066938057</created>
|
||||
<option name="number" value="00004" />
|
||||
<option name="presentableId" value="LOCAL-00004" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1557066938057</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00005" summary="log on error">
|
||||
<created>1557067359327</created>
|
||||
<option name="number" value="00005" />
|
||||
<option name="presentableId" value="LOCAL-00005" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1557067359327</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="6" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="17949000" />
|
||||
<option name="totallyTimeSpent" value="23609000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="1919" y="0" width="1922" height="1081" extended-state="6" />
|
||||
@ -270,7 +291,7 @@
|
||||
<window_info anchor="bottom" id="Terminal" order="9" />
|
||||
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Version Control" order="11" />
|
||||
<window_info anchor="bottom" id="CMake" order="12" weight="0.32834226" />
|
||||
<window_info anchor="bottom" id="CMake" order="12" weight="0.328125" />
|
||||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
@ -283,30 +304,15 @@
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="edited api class and made it to work" />
|
||||
<MESSAGE value="deleted cmake files" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="deleted cmake files" />
|
||||
<MESSAGE value="added loggin methods" />
|
||||
<MESSAGE value="log on error" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="log on error" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/test.cpp" />
|
||||
<entry file="file://$PROJECT_DIR$/test.h" />
|
||||
<entry file="file://$PROJECT_DIR$/cmake_install.cmake" />
|
||||
<entry file="file://$PROJECT_DIR$/iprefresher.cbp" />
|
||||
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="135">
|
||||
<caret line="9" column="19" selection-start-line="9" selection-start-column="19" selection-end-line="9" selection-end-column="19" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/API.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="210">
|
||||
<caret line="14" column="124" selection-start-line="14" selection-start-column="124" selection-end-line="14" selection-end-column="124" />
|
||||
<folding>
|
||||
<element signature="e#95#112#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/Hashmap.h">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
@ -317,13 +323,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/API.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="281">
|
||||
<caret line="44" column="17" selection-start-line="44" selection-start-column="17" selection-end-line="44" selection-end-column="17" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cmake-build-debug/out.myfile">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="15">
|
||||
@ -338,29 +337,57 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cmake-build-debug/CMakeCache.txt">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cmake-build-debug/ip.txt">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cmake-build-debug/dynurefresher.log">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/Logger.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="555">
|
||||
<caret line="37" column="38" lean-forward="true" selection-start-line="37" selection-start-column="38" selection-end-line="37" selection-end-column="38" />
|
||||
<caret line="37" column="38" selection-start-line="37" selection-start-column="38" selection-end-line="37" selection-end-column="38" />
|
||||
<folding>
|
||||
<element signature="e#40#58#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cmake-build-debug/dynurefresher.log">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="195">
|
||||
<caret line="13" column="31" selection-start-line="13" selection-start-column="31" selection-end-line="13" selection-end-column="31" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cmake-build-debug/ip.txt">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/API.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="195">
|
||||
<caret line="14" column="124" selection-start-line="14" selection-start-column="124" selection-end-line="14" selection-end-column="124" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/API.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="45">
|
||||
<caret line="3" selection-start-line="3" selection-end-line="3" />
|
||||
<folding>
|
||||
<element signature="e#40#56#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cmake-build-debug/CMakeCache.txt">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="90">
|
||||
<caret line="6" column="40" lean-forward="true" selection-start-line="6" selection-start-column="40" selection-end-line="6" selection-end-column="40" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="289">
|
||||
<caret line="29" column="41" lean-forward="true" selection-start-line="29" selection-start-column="41" selection-end-line="29" selection-end-column="41" />
|
||||
<state relative-caret-position="240">
|
||||
<caret line="16" column="69" selection-start-line="16" selection-start-column="69" selection-end-line="16" selection-end-column="69" />
|
||||
<folding>
|
||||
<element signature="e#0#19#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(iprefresher)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
find_package(CURL REQUIRED)
|
||||
include_directories(${CURL_INCLUDE_DIR})
|
||||
|
@ -7,8 +7,7 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
#include "curl/curl.h"
|
||||
#include <sstream>
|
||||
|
||||
#include "Hashmap.h"
|
||||
|
51
src/main.cpp
51
src/main.cpp
@ -11,39 +11,44 @@ int main() {
|
||||
|
||||
std::string ip = api.request("https://api.ipify.org");
|
||||
|
||||
std::string oldip = logger.readip();
|
||||
if(ip == ""){
|
||||
//no internet connection
|
||||
logger.logToLogfile("[WARNING] no internet connection");
|
||||
std::cout << "[WARNING] no internet connection" << std::endl;
|
||||
|
||||
if(oldip == ip){
|
||||
std::cout << "no change -- ip: " << ip << std::endl;
|
||||
logger.logToLogfile("no change -- ip: "+ip);
|
||||
} else{
|
||||
logger.logToLogfile("ip changed! -- from :" + oldip + "to: "+ip);
|
||||
std::cout << "ip changed! -- from :" << oldip << "to: " << ip << std::endl;
|
||||
}else{
|
||||
std::string oldip = logger.readip();
|
||||
|
||||
//api key: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg
|
||||
if(oldip == ip){
|
||||
std::cout << "no change -- ip: " << ip << std::endl;
|
||||
logger.logToLogfile("no change -- ip: "+ip);
|
||||
} else{
|
||||
logger.logToLogfile("ip changed! -- from :" + oldip + "to: "+ip);
|
||||
std::cout << "ip changed! -- from :" << oldip << "to: " << ip << std::endl;
|
||||
|
||||
Hashmap<std::string, std::string> args;
|
||||
//api key: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg
|
||||
|
||||
args.add("name","luki.dynu.net");
|
||||
args.add("ipv4Address",ip);
|
||||
Hashmap<std::string, std::string> args;
|
||||
|
||||
std::vector<std::string> headers;
|
||||
headers.push_back("accept: application/json");
|
||||
headers.push_back("User-Agent: Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)");
|
||||
headers.push_back("API-Key: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg");
|
||||
args.add("name","luki.dynu.net");
|
||||
args.add("ipv4Address",ip);
|
||||
|
||||
std::string dynurepl = api.request("https://api.dynu.com/v2/dns/8506047",true, args,headers);
|
||||
std::vector<std::string> headers;
|
||||
headers.push_back("accept: application/json");
|
||||
headers.push_back("User-Agent: Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)");
|
||||
headers.push_back("API-Key: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg");
|
||||
|
||||
std::cout << "---" << dynurepl << std::endl;
|
||||
std::string dynurepl = api.request("https://api.dynu.com/v2/dns/8506047",true, args,headers);
|
||||
|
||||
if (dynurepl != "{\"statusCode\":200}"){
|
||||
logger.logToLogfile(" [ERROR] failed to write ip to dynu api!");
|
||||
std::cout << "---" << dynurepl << std::endl;
|
||||
|
||||
if (dynurepl != "{\"statusCode\":200}"){
|
||||
logger.logToLogfile(" [ERROR] failed to write ip to dynu api!");
|
||||
}
|
||||
|
||||
logger.safeip(ip);
|
||||
}
|
||||
|
||||
logger.safeip(ip);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user