Compare commits
5 Commits
conansuppo
...
master
Author | SHA1 | Date | |
---|---|---|---|
891330825a | |||
ad452feca2 | |||
05ca1ff60b | |||
94964d69be | |||
2d1e99260d |
@ -1,95 +1,68 @@
|
|||||||
stages:
|
stages:
|
||||||
- cmake
|
|
||||||
- build
|
- build
|
||||||
- post
|
- post
|
||||||
|
|
||||||
# Unix Build
|
# Unix Build
|
||||||
cmake:
|
|
||||||
stage: cmake
|
|
||||||
image: luki42/dynuiprefresher_build:latest
|
|
||||||
script:
|
|
||||||
- cmake -S . -B build -D WinBuild=OFF -D GUI=OFF
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- build/
|
|
||||||
- inc/
|
|
||||||
- postinst
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
image: luki42/dynuiprefresher_build:latest
|
image: luki42/dynuiprefresher_build:latest
|
||||||
script:
|
script:
|
||||||
|
- cmake -S . -B build -D WinBuild=OFF -D GUI=OFF
|
||||||
- cd build
|
- cd build
|
||||||
- make dynuiprefresher
|
- make dynuiprefresher
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- build/
|
- build/bin/
|
||||||
- inc/
|
|
||||||
- postinst
|
|
||||||
dependencies:
|
|
||||||
- cmake
|
|
||||||
|
|
||||||
|
|
||||||
build_package:
|
build_package:
|
||||||
stage: post
|
stage: post
|
||||||
image: luki42/dynuiprefresher_build:latest
|
image: luki42/dynuiprefresher_build:latest
|
||||||
script:
|
script:
|
||||||
|
- cmake -S . -B build -D WinBuild=OFF -D GUI=OFF
|
||||||
- cd build
|
- cd build
|
||||||
- make package
|
- make package
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- build/
|
- build/packages/
|
||||||
- inc/
|
needs:
|
||||||
- postinst
|
|
||||||
dependencies:
|
|
||||||
- build
|
- build
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: post
|
stage: post
|
||||||
image: luki42/dynuiprefresher_build:latest
|
image: luki42/dynuiprefresher_build:latest
|
||||||
script:
|
script:
|
||||||
|
- cmake -S . -B build -D WinBuild=OFF -D GUI=OFF
|
||||||
- cd build
|
- cd build
|
||||||
- make build-test
|
- make build-test
|
||||||
artifacts:
|
artifacts:
|
||||||
reports:
|
reports:
|
||||||
junit: build/*.xml
|
junit: build/*.xml
|
||||||
dependencies:
|
needs:
|
||||||
- build
|
- build
|
||||||
|
|
||||||
# Windows Build
|
# Windows Build
|
||||||
cmake_win64:
|
|
||||||
stage: cmake
|
|
||||||
image: luki42/dynuiprefresher_build:windows
|
|
||||||
script:
|
|
||||||
- cmake -S . -B build -D WinBuild=ON
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- build/
|
|
||||||
- inc/
|
|
||||||
|
|
||||||
build_win64:
|
build_win64:
|
||||||
stage: build
|
stage: build
|
||||||
image: luki42/dynuiprefresher_build:windows
|
image: luki42/dynuiprefresher_build:windows
|
||||||
script:
|
script:
|
||||||
|
- cmake -S . -B build -D WinBuild=ON
|
||||||
- cd build
|
- cd build
|
||||||
- make dynuiprefresher
|
- make dynuiprefresher
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- build/
|
- build/bin/
|
||||||
- inc/
|
|
||||||
dependencies:
|
|
||||||
- cmake_win64
|
|
||||||
|
|
||||||
|
|
||||||
build_package_win64:
|
build_package_win64:
|
||||||
stage: post
|
stage: post
|
||||||
image: luki42/dynuiprefresher_build:windows
|
image: luki42/dynuiprefresher_build:windows
|
||||||
script:
|
script:
|
||||||
|
- cmake -S . -B build -D WinBuild=ON
|
||||||
- cd build
|
- cd build
|
||||||
- make package
|
- make package
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- build/
|
- build/packages/
|
||||||
- inc/
|
needs:
|
||||||
dependencies:
|
|
||||||
- build_win64
|
- build_win64
|
@ -341,7 +341,7 @@ ${SAMPLECONFIG}EOM
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
systemctl enable ${Application_Name}.service
|
systemctl enable ${Application_Name}.service
|
||||||
systemctl start ${Application_Name}.service")
|
systemctl restart ${Application_Name}.service")
|
||||||
|
|
||||||
|
|
||||||
SET(CPACK_DEB_COMPONENT_INSTALL 1)
|
SET(CPACK_DEB_COMPONENT_INSTALL 1)
|
||||||
@ -487,7 +487,7 @@ if (TESTS)
|
|||||||
# create an exectuable in which the tests will be stored
|
# create an exectuable in which the tests will be stored
|
||||||
add_executable(${TESTNAME} ${ARGN})
|
add_executable(${TESTNAME} ${ARGN})
|
||||||
# link the Google test infrastructure, mocking library, and a default main fuction to
|
# link the Google test infrastructure, mocking library, and a default main fuction to
|
||||||
target_link_libraries(${TESTNAME} gtest gtest_main -lpthread -lm libdynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
|
target_link_libraries(${TESTNAME} gtest gtest_main -lpthread -lm api libdynuiprefresher ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
|
||||||
# see https://cmake.org/cmake/help/v3.10/module/GoogleTest.html for more options to pass to it
|
# see https://cmake.org/cmake/help/v3.10/module/GoogleTest.html for more options to pass to it
|
||||||
gtest_discover_tests(${TESTNAME})
|
gtest_discover_tests(${TESTNAME})
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public:
|
|||||||
* @param ip ip address to test
|
* @param ip ip address to test
|
||||||
* @return validity
|
* @return validity
|
||||||
*/
|
*/
|
||||||
static bool isIpValid(std::string ip);
|
static bool isIpValid(const std::string& ip);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Description=IP Refresher
|
Description=IP Refresher
|
||||||
After=network.target
|
After=network.target
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=iprefresher -l
|
ExecStart=dynuiprefresher -l
|
||||||
WorkingDirectory=/root
|
WorkingDirectory=/root
|
||||||
StandardOutput=inherit
|
StandardOutput=inherit
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
@ -23,8 +23,5 @@ std::string FileLogger::readip() {
|
|||||||
in >> ip;
|
in >> ip;
|
||||||
|
|
||||||
// when received ip has no . return 0.0.0.0
|
// when received ip has no . return 0.0.0.0
|
||||||
if (!IpHelper::isIpValid(ip))
|
return (IpHelper::isIpValid(ip) ? ip : "0.0.0.0");
|
||||||
return "0.0.0.0";
|
|
||||||
else
|
|
||||||
return ip;
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
#include <regex>
|
||||||
#include "IpHelper.h"
|
#include "IpHelper.h"
|
||||||
|
|
||||||
bool IpHelper::isIpValid(std::string ip) {
|
bool IpHelper::isIpValid(const std::string& ip) {
|
||||||
return (ip.find('.') != SIZE_MAX);
|
const std::regex rgx(R"(^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$)");
|
||||||
|
return (std::regex_match(ip, rgx));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
|
#include <IpHelper.h>
|
||||||
|
#include <Logger.h>
|
||||||
#include "api/IPAPI.h"
|
#include "api/IPAPI.h"
|
||||||
|
|
||||||
std::string IPAPI::getGlobalIp() {
|
std::string IPAPI::getGlobalIp() {
|
||||||
return request("https://api.ipify.org");
|
const std::string ip = request("https://api.ipify.org");
|
||||||
|
if(!IpHelper::isIpValid(ip))
|
||||||
|
Logger::warning("no valid ip returned from ipapi");
|
||||||
|
|
||||||
|
return ip;
|
||||||
}
|
}
|
@ -28,7 +28,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (firstarg == "-l" || firstarg == "--loop") {
|
} else if (firstarg == "-l" || firstarg == "--loop") {
|
||||||
IPRefresher::startUpService(true);
|
IPRefresher::startUpService(600);
|
||||||
} else if (firstarg == "-c" || firstarg == "--checkconfig") {
|
} else if (firstarg == "-c" || firstarg == "--checkconfig") {
|
||||||
if (Config::validateConfig()) {
|
if (Config::validateConfig()) {
|
||||||
Logger::message("Config file is OK");
|
Logger::message("Config file is OK");
|
||||||
|
Loading…
Reference in New Issue
Block a user