Compare commits
5 Commits
conansuppo
...
master
Author | SHA1 | Date | |
---|---|---|---|
891330825a | |||
ad452feca2 | |||
05ca1ff60b | |||
94964d69be | |||
2d1e99260d |
@ -1,95 +1,68 @@
|
||||
stages:
|
||||
- cmake
|
||||
- build
|
||||
- post
|
||||
|
||||
# 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:
|
||||
stage: build
|
||||
image: luki42/dynuiprefresher_build:latest
|
||||
script:
|
||||
- cmake -S . -B build -D WinBuild=OFF -D GUI=OFF
|
||||
- cd build
|
||||
- make dynuiprefresher
|
||||
artifacts:
|
||||
paths:
|
||||
- build/
|
||||
- inc/
|
||||
- postinst
|
||||
dependencies:
|
||||
- cmake
|
||||
- build/bin/
|
||||
|
||||
|
||||
build_package:
|
||||
stage: post
|
||||
image: luki42/dynuiprefresher_build:latest
|
||||
script:
|
||||
- cmake -S . -B build -D WinBuild=OFF -D GUI=OFF
|
||||
- cd build
|
||||
- make package
|
||||
artifacts:
|
||||
paths:
|
||||
- build/
|
||||
- inc/
|
||||
- postinst
|
||||
dependencies:
|
||||
- build/packages/
|
||||
needs:
|
||||
- build
|
||||
|
||||
test:
|
||||
stage: post
|
||||
image: luki42/dynuiprefresher_build:latest
|
||||
script:
|
||||
- cmake -S . -B build -D WinBuild=OFF -D GUI=OFF
|
||||
- cd build
|
||||
- make build-test
|
||||
artifacts:
|
||||
reports:
|
||||
junit: build/*.xml
|
||||
dependencies:
|
||||
needs:
|
||||
- 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:
|
||||
stage: build
|
||||
image: luki42/dynuiprefresher_build:windows
|
||||
script:
|
||||
- cmake -S . -B build -D WinBuild=ON
|
||||
- cd build
|
||||
- make dynuiprefresher
|
||||
artifacts:
|
||||
paths:
|
||||
- build/
|
||||
- inc/
|
||||
dependencies:
|
||||
- cmake_win64
|
||||
- build/bin/
|
||||
|
||||
|
||||
build_package_win64:
|
||||
stage: post
|
||||
image: luki42/dynuiprefresher_build:windows
|
||||
script:
|
||||
- cmake -S . -B build -D WinBuild=ON
|
||||
- cd build
|
||||
- make package
|
||||
artifacts:
|
||||
paths:
|
||||
- build/
|
||||
- inc/
|
||||
dependencies:
|
||||
- build/packages/
|
||||
needs:
|
||||
- build_win64
|
@ -341,7 +341,7 @@ ${SAMPLECONFIG}EOM
|
||||
fi
|
||||
|
||||
systemctl enable ${Application_Name}.service
|
||||
systemctl start ${Application_Name}.service")
|
||||
systemctl restart ${Application_Name}.service")
|
||||
|
||||
|
||||
SET(CPACK_DEB_COMPONENT_INSTALL 1)
|
||||
@ -487,7 +487,7 @@ if (TESTS)
|
||||
# create an exectuable in which the tests will be stored
|
||||
add_executable(${TESTNAME} ${ARGN})
|
||||
# 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
|
||||
gtest_discover_tests(${TESTNAME})
|
||||
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
* @param ip ip address to test
|
||||
* @return validity
|
||||
*/
|
||||
static bool isIpValid(std::string ip);
|
||||
static bool isIpValid(const std::string& ip);
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
Description=IP Refresher
|
||||
After=network.target
|
||||
[Service]
|
||||
ExecStart=iprefresher -l
|
||||
ExecStart=dynuiprefresher -l
|
||||
WorkingDirectory=/root
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
|
@ -23,8 +23,5 @@ std::string FileLogger::readip() {
|
||||
in >> ip;
|
||||
|
||||
// when received ip has no . return 0.0.0.0
|
||||
if (!IpHelper::isIpValid(ip))
|
||||
return "0.0.0.0";
|
||||
else
|
||||
return ip;
|
||||
return (IpHelper::isIpValid(ip) ? ip : "0.0.0.0");
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <regex>
|
||||
#include "IpHelper.h"
|
||||
|
||||
bool IpHelper::isIpValid(std::string ip) {
|
||||
return (ip.find('.') != SIZE_MAX);
|
||||
bool IpHelper::isIpValid(const std::string& ip) {
|
||||
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"
|
||||
|
||||
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") {
|
||||
IPRefresher::startUpService(true);
|
||||
IPRefresher::startUpService(600);
|
||||
} else if (firstarg == "-c" || firstarg == "--checkconfig") {
|
||||
if (Config::validateConfig()) {
|
||||
Logger::message("Config file is OK");
|
||||
|
Loading…
Reference in New Issue
Block a user