Compare commits
No commits in common. "cc4506b918c8f74ef803114bdcf627aa3e9c878c" and "eb292a7d7925593830931ee2c88e6a23382010ed" have entirely different histories.
cc4506b918
...
eb292a7d79
8
Makefile
8
Makefile
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
CPPSTD=c++20
|
|
||||||
CXXFLAGS=-std=$(CPPSTD) -O0 -g -no-pie -pipe -MMD -Wall -Wextra
|
CXXFLAGS=-std=c++17 -O0 -g -no-pie -pipe -MMD -Wall -Wextra
|
||||||
RELEASE_CXXFLAGS=-std=$(CPPSTD) -O3 -pipe -MMD -Wall -Wextra
|
RELEASE_CXXFLAGS=-std=c++17 -O3 -pipe -MMD -Wall -Wextra
|
||||||
LDFLAGS=-lsqlite3 -lpthread -lcrypto -lstdc++fs
|
LDFLAGS=-lsqlite3 -lpthread -lcrypto -lstdc++fs
|
||||||
INCLUDEFLAGS=-I submodules/sqlitemoderncpp/hdr -I submodules/cpp-httplib -I submodules/qssb.h
|
INCLUDEFLAGS=-I submodules/sqlitemoderncpp/hdr -I submodules/cpp-httplib -I submodules/qssb.h
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ GTEST_DIR = /home/data/SOURCES/gtest/googletest
|
|||||||
|
|
||||||
GTESTS_TESTDIR = ./tests/
|
GTESTS_TESTDIR = ./tests/
|
||||||
|
|
||||||
GTEST_CXXFLAGS=-std=$(CPPSTD) -isystem $(GTEST_DIR)/include -I$(GTEST_DIR) -g -O0 -pipe -Wall -Wextra
|
GTEST_CXXFLAGS=-std=c++17 -isystem $(GTEST_DIR)/include -I$(GTEST_DIR) -g -O0 -pipe -Wall -Wextra
|
||||||
GTEST_LDFLAGS=-lsqlite3 -g -O0 -lpthread -lcrypto -lstdc++fs
|
GTEST_LDFLAGS=-lsqlite3 -g -O0 -lpthread -lcrypto -lstdc++fs
|
||||||
GTEST_OBJECTS=$(filter-out qswiki.o, $(WIKIOBJECTS))
|
GTEST_OBJECTS=$(filter-out qswiki.o, $(WIKIOBJECTS))
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ Authenticator::Authenticator(UserDao &userDao)
|
|||||||
// TODO: make failure counter configurable
|
// TODO: make failure counter configurable
|
||||||
bool Authenticator::isBanned(std::string ip)
|
bool Authenticator::isBanned(std::string ip)
|
||||||
{
|
{
|
||||||
if(loginFails.contains(ip))
|
if(utils::hasKey(loginFails, ip))
|
||||||
{
|
{
|
||||||
LoginFail &fl = loginFails[ip];
|
LoginFail &fl = loginFails[ip];
|
||||||
std::lock_guard<std::mutex> lock(fl.mutex);
|
std::lock_guard<std::mutex> lock(fl.mutex);
|
||||||
|
2
cache/fscache.cpp
vendored
2
cache/fscache.cpp
vendored
@ -46,7 +46,7 @@ void FsCache::removePrefix(std::string_view prefix)
|
|||||||
// TODO: lock dir
|
// TODO: lock dir
|
||||||
for(auto &entry : std::filesystem::directory_iterator(std::filesystem::path{this->path}))
|
for(auto &entry : std::filesystem::directory_iterator(std::filesystem::path{this->path}))
|
||||||
{
|
{
|
||||||
if(std::string_view(entry.path().filename().c_str()).starts_with(prefix) == 0)
|
if(static_cast<std::string>(entry.path().filename()).find(prefix) == 0)
|
||||||
{
|
{
|
||||||
std::filesystem::remove_all(entry);
|
std::filesystem::remove_all(entry);
|
||||||
}
|
}
|
||||||
|
1
cache/mapcache.h
vendored
1
cache/mapcache.h
vendored
@ -3,7 +3,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
/* Thread-Safe Key-Value store */
|
/* Thread-Safe Key-Value store */
|
||||||
template <class T> class MapCache
|
template <class T> class MapCache
|
||||||
|
19
cli.cpp
19
cli.cpp
@ -54,7 +54,7 @@ std::pair<bool, std::string> CLIHandler::user_add(const std::vector<std::string>
|
|||||||
return {true, ""};
|
return {true, ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, std::string> CLIHandler::user_change_pw([[maybe_unused]] const std::vector<std::string> &args)
|
std::pair<bool, std::string> CLIHandler::user_change_pw(const std::vector<std::string> &args)
|
||||||
{
|
{
|
||||||
std::string username = args.at(0);
|
std::string username = args.at(0);
|
||||||
std::string password = args.at(1);
|
std::string password = args.at(1);
|
||||||
@ -75,16 +75,19 @@ std::pair<bool, std::string> CLIHandler::user_change_pw([[maybe_unused]] const s
|
|||||||
|
|
||||||
userDao->save(*user);
|
userDao->save(*user);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return {false, "User not found"};
|
return {false, "User not found"};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, std::string> CLIHandler::user_rename([[maybe_unused]] const std::vector<std::string> &args)
|
std::pair<bool, std::string> CLIHandler::user_rename(const std::vector<std::string> &args)
|
||||||
{
|
{
|
||||||
|
|
||||||
return {true, ""};
|
return {true, ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, std::string> CLIHandler::user_set_perms([[maybe_unused]] const std::vector<std::string> &args)
|
std::pair<bool, std::string> CLIHandler::user_set_perms(const std::vector<std::string> &args)
|
||||||
{
|
{
|
||||||
auto userDao = this->db->createUserDao();
|
auto userDao = this->db->createUserDao();
|
||||||
std::string username = args.at(0);
|
std::string username = args.at(0);
|
||||||
@ -104,7 +107,7 @@ std::pair<bool, std::string> CLIHandler::user_set_perms([[maybe_unused]] const s
|
|||||||
return {false, "User not found"};
|
return {false, "User not found"};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, std::string> CLIHandler::user_list([[maybe_unused]] const std::vector<std::string> &args)
|
std::pair<bool, std::string> CLIHandler::user_list(const std::vector<std::string> &args)
|
||||||
{
|
{
|
||||||
auto userDao = this->db->createUserDao();
|
auto userDao = this->db->createUserDao();
|
||||||
QueryOption o;
|
QueryOption o;
|
||||||
@ -135,7 +138,7 @@ std::pair<bool, std::string> CLIHandler::user_show(const std::vector<std::string
|
|||||||
return {false, "User not found"};
|
return {false, "User not found"};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, std::string> CLIHandler::page_list([[maybe_unused]] const std::vector<std::string> &args)
|
std::pair<bool, std::string> CLIHandler::page_list(const std::vector<std::string> &args)
|
||||||
{
|
{
|
||||||
auto pageDao = this->db->createPageDao();
|
auto pageDao = this->db->createPageDao();
|
||||||
QueryOption o;
|
QueryOption o;
|
||||||
@ -160,7 +163,7 @@ std::pair<bool, std::string> CLIHandler::pageperms_set_permissions(const std::ve
|
|||||||
return {true, ""};
|
return {true, ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, std::string> CLIHandler::attach([[maybe_unused]] const std::vector<std::string> &args)
|
std::pair<bool, std::string> CLIHandler::attach(const std::vector<std::string> &args)
|
||||||
{
|
{
|
||||||
/* TODO: consider authentication */
|
/* TODO: consider authentication */
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
@ -242,12 +245,12 @@ std::pair<std::string, std::vector<std::string>> CLIHandler::splitCommand(std::s
|
|||||||
return {cmd, splitted};
|
return {cmd, splitted};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, std::string> CLIHandler::version([[maybe_unused]] const std::vector<std::string> &args)
|
std::pair<bool, std::string> CLIHandler::version(const std::vector<std::string> &args)
|
||||||
{
|
{
|
||||||
return {true, get_version_string()};
|
return {true, get_version_string()};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, std::string> CLIHandler::category_list([[maybe_unused]] const std::vector<std::string> &args)
|
std::pair<bool, std::string> CLIHandler::category_list(const std::vector<std::string> &args)
|
||||||
{
|
{
|
||||||
auto categoryDao = this->db->createCategoryDao();
|
auto categoryDao = this->db->createCategoryDao();
|
||||||
auto categories = categoryDao->fetchList(QueryOption{});
|
auto categories = categoryDao->fetchList(QueryOption{});
|
||||||
|
30
cli.h
30
cli.h
@ -22,20 +22,20 @@ class CLIHandler
|
|||||||
Config *conf;
|
Config *conf;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::pair<bool, std::string> attach([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> attach(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> cli_help([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> cli_help(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> user_add([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> user_add(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> user_change_pw([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> user_change_pw(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> user_rename([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> user_rename(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> user_set_perms([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> user_set_perms(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> user_list([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> user_list(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> user_show([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> user_show(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> page_list([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> page_list(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> pageperms_set_permissions([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> pageperms_set_permissions(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> version([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> version(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> category_list([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> category_list(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> category_delete([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> category_delete(const std::vector<std::string> &args);
|
||||||
std::pair<bool, std::string> category_show([[maybe_unused]] const std::vector<std::string> &args);
|
std::pair<bool, std::string> category_show(const std::vector<std::string> &args);
|
||||||
|
|
||||||
std::vector<struct cmd> cmds{
|
std::vector<struct cmd> cmds{
|
||||||
{{"user",
|
{{"user",
|
||||||
@ -73,7 +73,7 @@ class CLIHandler
|
|||||||
"exit cli",
|
"exit cli",
|
||||||
0,
|
0,
|
||||||
{},
|
{},
|
||||||
[](CLIHandler *, [[maybe_unused]] const std::vector<std::string> &args) -> std::pair<bool, std::string>
|
[](CLIHandler *, const std::vector<std::string> &args) -> std::pair<bool, std::string>
|
||||||
{
|
{
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
return {true, ""};
|
return {true, ""};
|
||||||
|
@ -36,7 +36,7 @@ bool CLIServer::detachServer(std::string socketpath)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto worker = [this, s]
|
auto worker = [=]
|
||||||
{
|
{
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,6 @@ std::optional<Category> CategoryDaoSqlite::find(std::string name)
|
|||||||
{
|
{
|
||||||
throwFrom(e);
|
throwFrom(e);
|
||||||
}
|
}
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CategoryDaoSqlite::save(const Category &c)
|
void CategoryDaoSqlite::save(const Category &c)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#ifndef PERMISSIONSDAO_H
|
#ifndef PERMISSIONSDAO_H
|
||||||
#define PERMISSIONSDAO_H
|
#define PERMISSIONSDAO_H
|
||||||
#include <optional>
|
|
||||||
#include "../permissions.h"
|
#include "../permissions.h"
|
||||||
#include "../user.h"
|
#include "../user.h"
|
||||||
class PermissionsDao
|
class PermissionsDao
|
||||||
|
@ -22,17 +22,18 @@ SOFTWARE.
|
|||||||
|
|
||||||
bool SqliteDao::execBool(sqlite::database_binder &binder) const
|
bool SqliteDao::execBool(sqlite::database_binder &binder) const
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
bool result;
|
||||||
binder >> result;
|
binder >> result;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
catch(sqlite::sqlite_exception &e)
|
catch(sqlite::sqlite_exception &e)
|
||||||
{
|
{
|
||||||
// TODO: well, we may want to check whether rows have found or not and thus log this here
|
// TODO: well, we may want to check whether rows have found or not and thus log this here
|
||||||
result = false;
|
return false;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SqliteDao::execInt(sqlite::database_binder &binder) const
|
int SqliteDao::execInt(sqlite::database_binder &binder) const
|
||||||
@ -51,5 +52,4 @@ int SqliteDao::execInt(sqlite::database_binder &binder) const
|
|||||||
{
|
{
|
||||||
throwFrom(e);
|
throwFrom(e);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ bool UserDaoSqlite::exists(std::string username)
|
|||||||
|
|
||||||
std::optional<User> UserDaoSqlite::find(std::string username)
|
std::optional<User> UserDaoSqlite::find(std::string username)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
User user;
|
User user;
|
||||||
@ -57,7 +58,6 @@ std::optional<User> UserDaoSqlite::find(std::string username)
|
|||||||
{
|
{
|
||||||
throwFrom(e);
|
throwFrom(e);
|
||||||
}
|
}
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<User> UserDaoSqlite::find(int id)
|
std::optional<User> UserDaoSqlite::find(int id)
|
||||||
@ -81,7 +81,6 @@ std::optional<User> UserDaoSqlite::find(int id)
|
|||||||
{
|
{
|
||||||
throwFrom(e);
|
throwFrom(e);
|
||||||
}
|
}
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<User> UserDaoSqlite::list(QueryOption o)
|
std::vector<User> UserDaoSqlite::list(QueryOption o)
|
||||||
@ -117,7 +116,7 @@ std::vector<User> UserDaoSqlite::list(QueryOption o)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserDaoSqlite::deleteUser([[maybe_unused]] std::string username)
|
void UserDaoSqlite::deleteUser(std::string username)
|
||||||
{
|
{
|
||||||
// What to do with the contributions of the user?
|
// What to do with the contributions of the user?
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,12 @@ class Handler
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual Response handle(const Request &r);
|
virtual Response handle(const Request &r);
|
||||||
virtual Response handleRequest([[maybe_unused]] const Request &r)
|
virtual Response handleRequest(const Request &r)
|
||||||
{
|
{
|
||||||
return this->errorResponse("Invalid action", "This action is not implemented yet");
|
return this->errorResponse("Invalid action", "This action is not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool canAccess([[maybe_unused]] const Permissions &perms)
|
virtual bool canAccess(const Permissions &perms)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
#include "handlerdefault.h"
|
#include "handlerdefault.h"
|
||||||
|
|
||||||
Response HandlerDefault::handleRequest([[maybe_unused]] const Request &r)
|
Response HandlerDefault::handleRequest(const Request &r)
|
||||||
{
|
{
|
||||||
return Response::redirectTemporarily(this->urlProvider->index());
|
return Response::redirectTemporarily(this->urlProvider->index());
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ HandlerDefault::~HandlerDefault()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandlerDefault::canAccess([[maybe_unused]] const Permissions &perms)
|
bool HandlerDefault::canAccess(const Permissions &perms)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,7 @@ Response HandlerHistory::handleRequest(const Request &r)
|
|||||||
std::vector<Revision> resultList;
|
std::vector<Revision> resultList;
|
||||||
auto revisionDao = this->database->createRevisionDao();
|
auto revisionDao = this->database->createRevisionDao();
|
||||||
|
|
||||||
auto makeSortedLink = [&](unsigned int limit, unsigned int offset, unsigned int order)
|
auto makeSortedLink = [&](unsigned int limit, unsigned int offset, unsigned int order) {
|
||||||
{
|
|
||||||
if(!page.empty())
|
if(!page.empty())
|
||||||
{
|
{
|
||||||
return this->urlProvider->pageHistorySort(page, limit, offset, order);
|
return this->urlProvider->pageHistorySort(page, limit, offset, order);
|
||||||
@ -123,7 +122,7 @@ Response HandlerHistory::handleRequest(const Request &r)
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandlerHistory::canAccess([[maybe_unused]] const Permissions &perms)
|
bool HandlerHistory::canAccess(const Permissions &perms)
|
||||||
{
|
{
|
||||||
return true; // This is a lie but we need to this a little more fine grained here, which we do in the handleRequest
|
return true; // This is a lie but we need to this a little more fine grained here, which we do in the handleRequest
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,12 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
#include "handlerinvalidaction.h"
|
#include "handlerinvalidaction.h"
|
||||||
|
|
||||||
Response HandlerInvalidAction::handleRequest([[maybe_unused]] const Request &r)
|
Response HandlerInvalidAction::handleRequest(const Request &r)
|
||||||
{
|
{
|
||||||
return errorResponse("Invalid action", "No action defined for this action");
|
return errorResponse("Invalid action", "No action defined for this action");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandlerInvalidAction::canAccess([[maybe_unused]] const Permissions &perms)
|
bool HandlerInvalidAction::canAccess(const Permissions &perms)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ Response HandlerLogin::handleRequest(const Request &r)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandlerLogin::canAccess([[maybe_unused]] const Permissions &perms)
|
bool HandlerLogin::canAccess(const Permissions &perms)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ SOFTWARE.
|
|||||||
#include "../request.h"
|
#include "../request.h"
|
||||||
|
|
||||||
#include "../parser.h"
|
#include "../parser.h"
|
||||||
bool HandlerPageEdit::canAccess([[maybe_unused]] std::string page)
|
bool HandlerPageEdit::canAccess(std::string page)
|
||||||
{
|
{
|
||||||
return effectivePermissions(page).canEdit();
|
return this->userSession->user.permissions.canEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandlerPageEdit::pageMustExist()
|
bool HandlerPageEdit::pageMustExist()
|
||||||
|
@ -62,7 +62,7 @@ Response HandlerUserSettings::handleRequest(const Request &r)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandlerUserSettings::canAccess([[maybe_unused]] const Permissions &perms)
|
bool HandlerUserSettings::canAccess(const Permissions &perms)
|
||||||
{
|
{
|
||||||
return this->userSession->loggedIn;
|
return this->userSession->loggedIn;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "handlerversion.h"
|
#include "handlerversion.h"
|
||||||
#include "../version.h"
|
#include "../version.h"
|
||||||
Response HandlerVersion::handleRequest([[maybe_unused]] const Request &r)
|
Response HandlerVersion::handleRequest(const Request &r)
|
||||||
{
|
{
|
||||||
Response response;
|
Response response;
|
||||||
response.setContentType("text/plain");
|
response.setContentType("text/plain");
|
||||||
|
@ -9,7 +9,7 @@ class HandlerVersion : public Handler
|
|||||||
public:
|
public:
|
||||||
Response handleRequest(const Request &r) override;
|
Response handleRequest(const Request &r) override;
|
||||||
|
|
||||||
bool canAccess([[maybe_unused]] const Permissions &perms) override
|
bool canAccess(const Permissions &perms) override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ SOFTWARE.
|
|||||||
#include "cliserver.h"
|
#include "cliserver.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
void sigterm_handler([[maybe_unused]] int arg)
|
void sigterm_handler(int arg)
|
||||||
{
|
{
|
||||||
// TODO: proper shutdown.
|
// TODO: proper shutdown.
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 4f8fcdbaf7696a17c407cdd498819a7c7200c73b
|
Subproject commit d87d0672a8e0f3695f168ff1f55028f6fbe4aedf
|
@ -1 +1 @@
|
|||||||
Subproject commit 0d7c5bd6d437ae95a4900aab6b7b6cc207acbd1b
|
Subproject commit 11d64c6fcf144f9b875a11e8a636a107eedc4f64
|
7
utils.h
7
utils.h
@ -8,7 +8,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <limits>
|
|
||||||
namespace utils
|
namespace utils
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -21,6 +20,12 @@ std::string strreplace(std::string str, const std::string &search, const std::st
|
|||||||
std::string html_xss(std::string_view str);
|
std::string html_xss(std::string_view str);
|
||||||
std::string getenv(const std::string &key);
|
std::string getenv(const std::string &key);
|
||||||
|
|
||||||
|
template <class T, class U> bool hasKey(const std::map<T, U> &map, const T &key)
|
||||||
|
{
|
||||||
|
auto k = map.find(key);
|
||||||
|
return k != map.end();
|
||||||
|
}
|
||||||
|
|
||||||
template <class T, class U> U getKeyOrEmpty(const std::map<T, U> &map, const T &key)
|
template <class T, class U> U getKeyOrEmpty(const std::map<T, U> &map, const T &key)
|
||||||
{
|
{
|
||||||
auto k = map.find(key);
|
auto k = map.find(key);
|
||||||
|
@ -60,12 +60,12 @@ std::string Varreplacer::makeReplacement(std::string_view varkeyvalue)
|
|||||||
std::string_view value;
|
std::string_view value;
|
||||||
|
|
||||||
std::tie(key, value) = extractKeyAndValue(varkeyvalue);
|
std::tie(key, value) = extractKeyAndValue(varkeyvalue);
|
||||||
if(keyValues.contains(key))
|
if(utils::hasKey(keyValues, key))
|
||||||
{
|
{
|
||||||
std::string replacementContent = keyValues[key];
|
std::string replacementContent = keyValues[key];
|
||||||
return replacementContent;
|
return replacementContent;
|
||||||
}
|
}
|
||||||
else if(resolverFunctionsMap.contains(key))
|
else if(utils::hasKey(resolverFunctionsMap, key))
|
||||||
{
|
{
|
||||||
|
|
||||||
auto resolver = this->resolverFunctionsMap[key];
|
auto resolver = this->resolverFunctionsMap[key];
|
||||||
|
Loading…
Reference in New Issue
Block a user