46 Commits
v1.0 ... v1.2

Author SHA1 Message Date
cc8c2b0497 added package dependency of libcurl 2019-10-26 11:49:10 +02:00
8eae88edfe removed install check of systemd 2019-10-26 11:38:24 +02:00
0d00ab10cf added package build info in readme 2019-10-26 11:03:11 +02:00
8e7c01c5ed edited readme 2019-10-26 11:00:57 +02:00
eadbfe90fd improved cmake file output dirs and package install dirs 2019-10-26 10:57:32 +02:00
6a3f1dc7a5 included windows build 2019-10-25 12:24:19 +02:00
eecbc755ce temp commit 2019-10-24 22:00:58 +02:00
133b21e1bd updated build targets 2019-10-24 16:11:35 +02:00
eeaf67906f cleanup cmakelist 2019-10-23 22:05:10 +02:00
5012cc517e check for deb build tools
improved check of rpm
2019-10-23 21:55:45 +02:00
314795d70d right install service with package
check if rpm build is possible
2019-10-23 21:47:54 +02:00
d91a52c6ba created systemd service 2019-10-23 13:18:43 +02:00
436051d641 updated version info to 1.2 2019-10-23 09:32:33 +02:00
b68982345d * option to force a refresh
* option to run in loop every 5 minutes
* pack into deb, rpm ant targz archive
2019-10-23 09:24:35 +02:00
f325c3a371 outsourced main method of ip refresh and added some doc 2019-08-02 22:44:42 +02:00
700d7912df manual build type set 2019-08-01 22:31:58 +02:00
52cc5f204b added c++ doc and replaced ifndef with pragma once 2019-08-01 21:19:02 +02:00
904cd2e96a cleanup in cmake file (added libraries)
code reformats
2019-08-01 20:18:39 +02:00
c5b5029cb1 added const variables in class headers 2019-06-18 11:42:26 +02:00
07ce161155 added seperate class for ip request and dynu request 2019-06-18 11:23:24 +02:00
0e8783d354 Update README.md 2019-05-11 12:23:57 +02:00
4012d00695 Update README.md 2019-05-11 12:22:31 +02:00
f7991631a5 Update README.md 2019-05-11 12:18:24 +02:00
16f7a5f77d Update README.md 2019-05-11 11:28:12 +02:00
7198737089 readme removed linux title 2019-05-11 11:17:59 +02:00
fee0160e64 edited readme file 2019-05-11 11:16:59 +02:00
b40b674c5c some code improvements 2019-05-11 11:09:48 +02:00
a3bf259fee Update README.md 2019-05-10 23:15:05 +02:00
97925d060a Update README.md 2019-05-10 23:14:25 +02:00
a78a719e8c Update README.md 2019-05-10 23:12:08 +02:00
cdd764bb61 Update README.md 2019-05-10 23:11:01 +02:00
8242a9c742 Create README.md 2019-05-10 23:09:30 +02:00
1375c3a258 added make install function to cmake file 2019-05-10 21:37:08 +02:00
b599626bbf used Hashmap for telegram api request 2019-05-10 08:30:08 +02:00
a890cf687e readded intellij workspace files 2019-05-08 19:56:43 +02:00
b5c4b9628f removed idea folder 2019-05-08 19:37:46 +02:00
44380b31f3 update of gitignore file 2019-05-08 19:36:36 +02:00
c738a01ce4 code reformat 2019-05-08 19:31:49 +02:00
31819abcaf moved Hashmap also in api package 2019-05-08 19:28:16 +02:00
846a32ee7e added telegram api support to send message on ip update 2019-05-08 19:19:42 +02:00
3b7e78193a some structure updates 2019-05-06 21:43:17 +02:00
3971a8ab24 reformated output of main 2019-05-06 18:49:38 +02:00
1c752847d9 added command line arguments 2019-05-06 12:55:01 +02:00
1754dd8385 syntax update and sperate variable for dynu domain id 2019-05-06 09:39:28 +02:00
acd33bbbad edited some pointer references 2019-05-05 20:23:31 +02:00
004ca7c62c added internet connection detection 2019-05-05 18:50:10 +02:00
26 changed files with 539 additions and 570 deletions

68
.gitignore vendored
View File

@ -1,67 +1 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
cmake-build-debug/

2
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
# Default ignored files
/workspace.xml

2
.idea/iprefresher.iml generated
View File

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />
<module classpath="CMake" type="CPP_MODULE" version="4" />

2
.idea/misc.xml generated
View File

@ -4,4 +4,4 @@
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
</project>

2
.idea/modules.xml generated
View File

@ -5,4 +5,4 @@
<module fileurl="file://$PROJECT_DIR$/.idea/iprefresher.iml" filepath="$PROJECT_DIR$/.idea/iprefresher.iml" />
</modules>
</component>
</project>
</project>

2
.idea/vcs.xml generated
View File

@ -3,4 +3,4 @@
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
</project>

371
.idea/workspace.xml generated
View File

@ -1,371 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BookmarkManager">
<bookmark url="file://$PROJECT_DIR$/src/Logger.cpp" line="41" mnemonic="2" />
</component>
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true">
<generated>
<config projectName="iprefresher" targetName="iprefresher" />
</generated>
</component>
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</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" />
<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" />
<change beforePath="$PROJECT_DIR$/src/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.cpp" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/cmake-build-debug/" />
<ignored path="$PROJECT_DIR$/CMakeFiles/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ClangdSettings">
<option name="formatViaClangd" value="false" />
</component>
<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$/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>
</file>
<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>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Hashmap.h">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
<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" />
<folding>
<element signature="e#0#19#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/cmake-build-debug/CMakeCache.txt">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
<file pinned="false" current-in-tab="false">
<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" />
<folding>
<element signature="e#40#58#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/cmake-build-debug/ip.txt">
<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">
<state relative-caret-position="150">
<caret line="10" column="38" selection-start-line="10" selection-start-column="22" selection-end-line="10" selection-end-column="38" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="424">
<caret line="38" column="23" selection-start-line="38" selection-start-column="23" selection-end-line="38" selection-end-column="23" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<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" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="1020" />
<option name="y" value="236" />
<option name="width" value="1914" />
<option name="height" value="1051" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="iprefresher" type="b2602c69:ProjectViewProjectNode" />
<item name="DynuIPRefresher" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="iprefresher" type="b2602c69:ProjectViewProjectNode" />
<item name="DynuIPRefresher" type="462c0819:PsiDirectoryNode" />
<item name="cmake-build-debug" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="iprefresher" type="b2602c69:ProjectViewProjectNode" />
<item name="DynuIPRefresher" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<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" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="iprefresher" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="iprefresher" TARGET_NAME="iprefresher" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="iprefresher" RUN_TARGET_NAME="iprefresher">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="59c80f39-2468-4db0-9afd-14b8acdbffed" name="Default Changelist" comment="" />
<created>1556620677257</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1556620677257</updated>
<workItem from="1556620678990" duration="5234000" />
<workItem from="1556646880233" duration="656000" />
<workItem from="1556710548728" duration="6200000" />
<workItem from="1557047487321" duration="761000" />
<workItem from="1557061811880" duration="5098000" />
</task>
<task id="LOCAL-00001" summary="edited api class and made it to work">
<created>1557063528491</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1557063528491</updated>
</task>
<task id="LOCAL-00002" summary="edited api class and made it to work">
<created>1557063846200</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1557063846200</updated>
</task>
<task id="LOCAL-00003" summary="deleted cmake files">
<created>1557063931807</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1557063931807</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="17949000" />
</component>
<component name="ToolWindowManager">
<frame x="1919" y="0" width="1922" height="1081" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.26040554" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.31875" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Database Changes" order="7" />
<window_info anchor="bottom" id="Messages" order="8" weight="0.32708332" />
<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="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" />
<window_info anchor="right" id="Database" order="3" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<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" />
</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>
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="424">
<caret line="38" column="23" selection-start-line="38" selection-start-column="23" selection-end-line="38" selection-end-column="23" />
</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">
<caret line="1" column="6" selection-start-line="1" selection-start-column="6" selection-end-line="1" selection-end-column="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Logger.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="10" column="38" selection-start-line="10" selection-start-column="22" selection-end-line="10" selection-end-column="38" />
</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" />
<folding>
<element signature="e#40#58#0" expanded="true" />
</folding>
</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" />
<folding>
<element signature="e#0#19#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

View File

@ -1,16 +1,140 @@
cmake_minimum_required(VERSION 3.14)
project(iprefresher)
cmake_minimum_required(VERSION 3.13)
project(iprefresher VERSION 1.2.0 DESCRIPTION "Dynu ip refresher")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE Release) # manually set build type (Release / Debug)
set(libmethod STATIC) #SHARED / STATIC
set(WinBuild false)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
#set up toolchain
if (${WinBuild})
set(LIBSUFFIX .dll)
set(SUFFIX .exe)
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
#set(TOOLCHAIN_PREFIX i686-w64-mingw32)
# cross compilers to use for C and C++
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
# target environment on the build host system
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}/sys-root/mingw /usr/lib/gcc/${TOOLCHAIN_PREFIX}/8.3.0)
# modify default behavior of FIND_XXX() commands to
# search for headers/libs in the target environment and
# search for programs in the build host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# set(CMAKE_CXX_STANDARD_LIBRARIES -lcurl -lpthread -static-libgcc -static-libstdc++ -lcrypto -lssl -lws2_32 -std=c++11 -static -DCURL_STATICLIB)
set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ -lcurl -lpthread -lstdc++ -lwsock32 -lws2_32 ${CMAKE_CSS_STANDARD_LIBRARIES}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -Wl,-Bstatic,--whole-archive -Wl,--no-whole-archive")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
# set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
add_definitions(-DCURL_STATICLIB)
else ()
set(LIBSUFFIX .so)
set(SUFFIX "")
endif ()
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIR})
if (CURL_FOUND)
message(STATUS "Found CURL version: ${CURL_VERSION_STRING}")
message(STATUS "Using CURL include dir(s): ${CURL_INCLUDE_DIRS}")
message(STATUS "Using CURL lib(s): ${CURL_LIBRARIES}")
# include_directories(${CURL_INCLUDE_DIRS})
else ()
message(FATAL_ERROR "Could not find CURLLL")
endif ()
include_directories(${CURL_INCLUDE_DIR} inc)
add_library(api ${libmethod}
src/api/API.cpp
src/api/TelegramAPI.cpp
src/api/DynuAPI.cpp
src/api/IPAPI.cpp
)
add_library(logger ${libmethod}
src/Logger.cpp
)
set(SOURCE src/main.cpp src/API.h src/API.cpp src/Hashmap.h src/Logger.cpp src/Logger.h)
set(SOURCE
src/main.cpp
src/IPRefresher.cpp inc/IPRefresher.h)
add_executable(iprefresher ${SOURCE})
add_executable(iprefresher ${SOURCE})
# LINK generated LIBS #
target_link_libraries(iprefresher api logger ${CURL_LIBRARIES})
# INSTALL to SYSTEM #
install(TARGETS iprefresher DESTINATION bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/iprefresher.service DESTINATION /lib/systemd/system)
IF (UNIX)
SET(CPACK_DEB_COMPONENT_INSTALL 1)
SET(CPACK_OUTPUT_FILE_PREFIX packages)
target_link_libraries(iprefresher ${CURL_LIBRARIES})
FIND_PROGRAM(RPMBUILD_EXECUTABLE rpmbuild)
FIND_PROGRAM(DEB_EXECUTABLE dpkg)
SET(CPACK_GENERATOR "TGZ;TBZ2")
#check if rpm build is possible
if (NOT ${RPMBUILD_EXECUTABLE} STREQUAL "RPMBUILD_EXECUTABLE-NOTFOUND")
message(STATUS "found rpm build executeable --> able to build rpm")
set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/lib/systemd/system" "/usr/lib/systemd") # --> needed to not override existing folders
else (NOT ${RPMBUILD_EXECUTABLE} STREQUAL "RPMBUILD_EXECUTABLE-NOTFOUND")
message(STATUS "not found rpm build tools --> not building rpm")
endif (NOT ${RPMBUILD_EXECUTABLE} STREQUAL "RPMBUILD_EXECUTABLE-NOTFOUND")
#check if deb build is possible
if (NOT ${DEB_EXECUTABLE} STREQUAL "DEB_EXECUTABLE-NOTFOUND")
message(STATUS "found deb build tools --> able to build deb")
set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
else (NOT ${DEB_EXECUTABLE} STREQUAL "DEB_EXECUTABLE-NOTFOUND")
message(STATUS "not found deb build tools --> not building deb")
endif (NOT ${DEB_EXECUTABLE} STREQUAL "DEB_EXECUTABLE-NOTFOUND")
SET(CPACK_CMAKE_GENERATOR "Unix Makefiles")
SET(CPACK_SOURCE_GENERATOR "TGZ;TBZ2")
SET(CPACK_PACKAGE_DESCRIPTION "IPrefresher to refresh Dynu ip address and notify user via Telegram")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "IPrefresher to refresh Dynu ip address and notify user via Telegram")
SET(CPACK_PACKAGE_VENDOR "Lukas Heilgienbrunner")
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "2")
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
SET(CPACK_PACKAGE_CONTACT "Lukas Heiligenbrunner <ultimategameingcookie@gmail.com>")
SET(CPACK_PACKAGE_SECTION "games")
set(CPACK_PACKAGE_DEPENDS "libcurl (>= 7.0.0-1)")
INCLUDE(CPack)
add_custom_target(build-linux-packages
"${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target package
DEPENDS ${PROJECT_NAME}
COMMENT "Installing ${PROJECT_NAME}")
ENDIF (UNIX)

45
README.md Normal file
View File

@ -0,0 +1,45 @@
# DynuIPRefresher
## Build
## Basic Build
### Download source files
`git clone https://github.com/Lukas-Heiligenbrunner/DynuIPRefresher.git`
### install build dependencies
`libcurl`
`libcurl-devel`
Debian:
`apt install libcurl4-openssl-dev`
Fedora:
`dnf install libcurl-devel`
#### dependencies for package build
`dpkg` --> debian/ubuntu package
`rpmbuild` --> Fedora/RedHat/CentOS package
### cmake project
cd into downloaded files and Generate makefiles:
`cmake -S . -B build`
### compile project
`make`
[root] install it to the system
`make install`
[root] or create Linux packages
`make package`
### Windows cross build
TODO!

17
inc/IPRefresher.h Normal file
View File

@ -0,0 +1,17 @@
//
// Created by lukas on 02.08.19.
//
#pragma once
class IPRefresher {
public:
/**
* refresh ip address on Dynu server
*/
void checkIPAdress(bool force);
IPRefresher();
IPRefresher(bool loop);
};

27
inc/Logger.h Normal file
View File

@ -0,0 +1,27 @@
//
// Created by lukas on 05.05.19.
//
#pragma once
#include <string>
class Logger {
public:
/**
* log messages to logfile
* @param text message
*/
void logToLogfile(std::string text);
/**
* safe ip to temp file
* @param ip ip address to save
*/
void safeip(std::string ip);
/**
* read ip from file
* @return read ip
*/
std::string readip();
};

32
inc/api/API.h Normal file
View File

@ -0,0 +1,32 @@
//
// Created by lukas on 06.04.19.
//
#pragma once
#include <string>
#include "Hashmap.h"
class API {
public:
/**
* Simple API get request
* @param myurl api url
* @return return string of server
*/
std::string request(std::string myurl);
/**
* complex request with post/get and header information support
* @param myurl base request url
* @param post boolean (false=get)
* @param map post/get fields
* @param headers header fields
* @return return string of server
*/
std::string request(std::string myurl, bool post, Hashmap<std::string, std::string> &map, std::vector<std::string> &headers);
private:
static size_t write_data(void *buffer, size_t size, size_t buffersize, FILE *stream);
};

23
inc/api/DynuAPI.h Normal file
View File

@ -0,0 +1,23 @@
//
// Created by lukas on 18.06.19.
//
#pragma once
#include "API.h"
class DynuAPI : API{
public:
/**
* refresh the ip of domain on Dynu server
* @param ip new ip
* @return request status
*/
int refreshIp(std::string ip);
private:
const std::string dynuapikey = "88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg";
const std::string domainid = "8506047"; //id of the dynu domain
const std::string domainname = "luki.dynu.net";
};

View File

@ -2,19 +2,40 @@
// Created by lukas on 07.04.19.
//
#ifndef QT5PROJECT_HASHMAP_H
#define QT5PROJECT_HASHMAP_H
#pragma once
#include <iostream>
#include <vector>
template <class keytype,class valuetype> class Hashmap {
template<class keytype, class valuetype>
class Hashmap {
public:
void add(keytype key,keytype value);
/**
* add key-value pair to hashmap
* @param key keyvalue
* @param value valuevalue
*/
void add(keytype key, keytype value);
/**
* get key of specific position
* @param position int position
* @return responding key object
*/
keytype getKey(int position);
/**
* get value of specific position
* @param position int position
* @return responding value object
*/
valuetype getValue(int position);
/**
* get size of Hashmap
* @return size of Hashmap
*/
int size();
private:
@ -40,8 +61,5 @@ valuetype Hashmap<keytype, valuetype>::getValue(int position) {
template<class keytype, class valuetype>
int Hashmap<keytype, valuetype>::size() {
return keys.size();
return (int) (keys.size());
}
#endif //QT5PROJECT_HASHMAP_H

17
inc/api/IPAPI.h Normal file
View File

@ -0,0 +1,17 @@
//
// Created by lukas on 18.06.19.
//
#pragma once
#include <string>
#include "API.h"
class IPAPI : API{
public:
/**
* get global ip of current internet connection
* @return global ip
*/
std::string getGlobalIp();
};

29
inc/api/TelegramAPI.h Normal file
View File

@ -0,0 +1,29 @@
//
// Created by lukas on 08.05.19.
//
#pragma once
#include <string>
#include "API.h"
class TelegramAPI : API {
public:
/**
* send telegram Message to predefined destination
* @param text message
*/
void sendMessage(std::string text);
/**
* init Telegram api with apikey and chatid
* @param apikey recieved API key
* @param chatid chatid where bot should post into
*/
void init(std::string apikey, std::string chatid);
private:
std::string apikey;
std::string chatid;
};

12
iprefresher.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=IP Refresher
After=network.target
[Service]
ExecStart=iprefresher -l
WorkingDirectory=/root
StandardOutput=inherit
StandardError=inherit
Restart=always
User=root
[Install]
WantedBy=multi-user.target

View File

@ -1,22 +0,0 @@
//
// Created by lukas on 06.04.19.
//
#ifndef IPREFRESHER_API_H
#define IPREFRESHER_API_H
#include <string>
#include "Hashmap.h"
class API {
public:
std::string request(std::string myurl);
std::string request(std::string myurl, bool post, Hashmap<std::string,std::string> &map,std::vector<std::string> headers);
private:
static size_t write_data(void *buffer, size_t size, size_t buffersize, FILE *stream);
};
#endif //IPREFRESHER_API_H

62
src/IPRefresher.cpp Normal file
View File

@ -0,0 +1,62 @@
//
// Created by lukas on 02.08.19.
//
#include <string>
#include <Logger.h>
#include <api/IPAPI.h>
#include <api/DynuAPI.h>
#include <api/TelegramAPI.h>
#include <chrono>
#include <thread>
#include "IPRefresher.h"
void IPRefresher::checkIPAdress(bool force) {
Logger logger;
IPAPI ipapi;
std::string ip = ipapi.getGlobalIp();
if (ip.empty()) {
//no internet connection
logger.logToLogfile("[WARNING] no internet connection");
std::cout << "[WARNING] no internet connection" << std::endl;
} else {
std::string oldip = logger.readip();
if (oldip == ip && !force) {
std::cout << "[INFO] no change -- ip: " << ip << std::endl;
logger.logToLogfile(" [INFO] no change -- ip: " + ip);
} else {
logger.logToLogfile(" [INFO] ip changed! -- from :" + oldip + "to: " + ip);
std::cout << "[INFO] ip changed! -- from :" << oldip << "to: " << ip << std::endl;
DynuAPI dynu;
if (dynu.refreshIp(ip)) {
TelegramAPI tele;
tele.init("717213769:AAHan1nSXhUsxLJAN1Dv8Oc0z8wqwDdYPn4","618154204");
tele.sendMessage(oldip + " moved to " + ip);
} else {
//error
logger.logToLogfile(" [ERROR] failed to write ip to dynu api!");
}
logger.safeip(ip);
}
}
}
IPRefresher::IPRefresher() {
}
IPRefresher::IPRefresher(bool loop) {
while(true){
std::this_thread::sleep_for(std::chrono::milliseconds(300000));
checkIPAdress(false);
}
}

View File

@ -11,7 +11,7 @@
void Logger::safeip(std::string ip) {
std::ofstream out;
out.open("ip.txt",std::ios::out);
out.open("ip.txt", std::ios::out);
out << ip;
@ -20,7 +20,7 @@ void Logger::safeip(std::string ip) {
std::string Logger::readip() {
std::ifstream in;
in.open("ip.txt",std::ios::in);
in.open("ip.txt", std::ios::in);
std::string ip;
@ -31,16 +31,16 @@ std::string Logger::readip() {
void Logger::logToLogfile(std::string text) {
std::ofstream out;
out.open("dynurefresher.log",std::ios::out | std::ios::app);
out.open("dynurefresher.log", std::ios::out | std::ios::app);
std::time_t t = std::time(0); // get time now
std::tm* now = std::localtime(&t);
std::tm *now = std::localtime(&t);
std::stringstream logline;
logline << "[ "<< (now->tm_year + 1900) << '-' << (now->tm_mon + 1) << '-' << now->tm_mday
<< "_" << now->tm_hour << ":" << now->tm_min << ":" << now->tm_sec << " ] " << '\t' << text << std::endl;
logline << "[ " << (now->tm_year + 1900) << '-' << (now->tm_mon + 1) << '-' << now->tm_mday
<< "_" << now->tm_hour << ":" << now->tm_min << ":" << now->tm_sec << " ] " << '\t' << text << std::endl;
out << logline.str();

View File

@ -1,18 +0,0 @@
//
// Created by lukas on 05.05.19.
//
#ifndef IPREFRESHER_LOGGER_H
#define IPREFRESHER_LOGGER_H
class Logger {
public:
void logToLogfile(std::string text);
void safeip(std::string ip);
std::string readip();
};
#endif //IPREFRESHER_LOGGER_H

View File

@ -2,39 +2,35 @@
// Created by lukas on 06.04.19.
//
#include "API.h"
#include "api/API.h"
#include "api/Hashmap.h"
#include <string>
#include <iostream>
#include <stdio.h>
#include <curl/curl.h>
#include <sstream>
#include <curl/curl.h>
#include "Hashmap.h"
std::string API::request(std::string myurl) {
Hashmap<std::string,std::string> map;
Hashmap<std::string, std::string> map;
std::vector<std::string> str;
return request(myurl,false,map,str);
return request(std::move(myurl), false, map, str);
}
std::string API::request(std::string myurl, bool post, Hashmap<std::string,std::string> &map, std::vector<std::string> headers) {
std::string
API::request(std::string myurl, bool post, Hashmap<std::string, std::string> &map, std::vector<std::string> &headers) {
CURL *curl;
CURLcode res;
curl = curl_easy_init();
struct curl_slist *list = NULL;
struct curl_slist *list = nullptr;
for (int j = 0; j < headers.size(); ++j) {
list = curl_slist_append(list, headers.at(j).c_str());
list = curl_slist_append(list, headers.at((unsigned long) (j)).c_str());
}
std::string readString;
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, myurl.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
@ -42,38 +38,40 @@ std::string API::request(std::string myurl, bool post, Hashmap<std::string,std::
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
if(post){
if (post) {
std::stringstream poststring;
poststring << "{";
poststring << "{";
for (int i = 0; i < map.size(); i++) {
poststring << "\""+map.getKey(i) << "\": \""+map.getValue(i) << "\"";
if(i < map.size()-1){
poststring << "\"" + map.getKey(i) << "\": \"" + map.getValue(i) << "\"";
if (i < map.size() - 1) {
poststring << ", ";
}
}
poststring << "}";
// std::cout << "post string: " << poststring.str() << "\n";
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, poststring.str().c_str());
}else{
std::string getstring;
for(int i =0; i< map.size();i++){
getstring+=map.getKey(i)+"="+map.getValue(i);
if(i < map.size()-1){
getstring+="&";
} else {
if (map.size() > 0) {
std::string getstring;
for (int i = 0; i < map.size(); i++) {
getstring += map.getKey(i) + "=" + map.getValue(i);
if (i < map.size() - 1) {
getstring += "&";
}
}
}
myurl+="?"+getstring;
myurl += "?" + getstring;
}
}
curl_easy_setopt(curl, CURLOPT_URL, myurl.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readString);
res = curl_easy_perform(curl);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
@ -81,6 +79,6 @@ std::string API::request(std::string myurl, bool post, Hashmap<std::string,std::
}
size_t API::write_data(void *contents, size_t size, size_t nmemb, FILE *stream) {
((std::string*)stream)->append((char*)contents, size * nmemb);
((std::string *) stream)->append((char *) contents, size * nmemb);
return size * nmemb;
}

27
src/api/DynuAPI.cpp Normal file
View File

@ -0,0 +1,27 @@
//
// Created by lukas on 18.06.19.
//
#include "api/DynuAPI.h"
int DynuAPI::refreshIp(std:: string ip) {
Hashmap<std::string, std::string> args;
args.add("name", domainname);
args.add("ipv4Address", ip);
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: " + dynuapikey);
std::string dynurepl = request("https://api.dynu.com/v2/dns/" + domainid, true, args, headers);
// std::cout << "[DEBUG] api reply:: " << dynurepl << std::endl;
if (dynurepl != "{\"statusCode\":200}") {
return -1;
} else {
return 1;
}
}

9
src/api/IPAPI.cpp Normal file
View File

@ -0,0 +1,9 @@
//
// Created by lukas on 18.06.19.
//
#include "api/IPAPI.h"
std::string IPAPI::getGlobalIp() {
return request("https://api.ipify.org");
}

21
src/api/TelegramAPI.cpp Normal file
View File

@ -0,0 +1,21 @@
//
// Created by lukas on 08.05.19.
//
#include "api/TelegramAPI.h"
void TelegramAPI::sendMessage(std::string text) {
Hashmap<std::string, std::string> args;
args.add("chat_id", chatid);
args.add("text", text);
std::vector<std::string> headers;
std::string reply = request("https://api.telegram.org/bot" + apikey + "/sendmessage", false, args, headers);
// std::cout << "[DEBUG] " << reply << std::endl;
}
void TelegramAPI::init(std::string apikey, std::string chatid) {
this->apikey = apikey;
this->chatid = chatid;
}

View File

@ -1,49 +1,32 @@
#include <iostream>
#include <ctime>
#include <IPRefresher.h>
#include "API.h"
#include "Logger.h"
int main(int argc, char *argv[]) {
int main() {
API api;
Logger logger;
std::string ip = api.request("https://api.ipify.org");
std::string oldip = logger.readip();
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;
//api key: 88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg
Hashmap<std::string, std::string> args;
args.add("name","luki.dynu.net");
args.add("ipv4Address",ip);
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::string dynurepl = api.request("https://api.dynu.com/v2/dns/8506047",true, args,headers);
std::cout << "---" << dynurepl << std::endl;
if (dynurepl != "{\"statusCode\":200}"){
logger.logToLogfile(" [ERROR] failed to write ip to dynu api!");
if (argc > 1) {
std::string firstarg(argv[1]);
if (firstarg == "-h" || firstarg == "--help") {
std::cout << "help page: " << std::endl << "[-h] [--help] print this help page" << std::endl
<< "[-v] [--version] print the software version" << std::endl
<< "[-f] [--force] force refresh of ip" << std::endl
<< "[-l] [--loop] infinite loop to refresh ip every five minutes" << std::endl
<< "[no argument] normal ip check and refresh" << std::endl;
} else if (firstarg == "-v" || firstarg == "--version") {
std::cout << "Version 1.2" << std::endl;
} else if (firstarg == "-f" || firstarg == "--force") {
IPRefresher ipr;
ipr.checkIPAdress(true);
} else if (firstarg == "-l" || firstarg == "--loop") {
IPRefresher ipr(true);
ipr.checkIPAdress(false);
} else {
std::cout << "wrong arguments! -h for help" << std::endl;
}
} else {
IPRefresher ipr;
ipr.checkIPAdress(false);
logger.safeip(ip);
}
return 0;
}