working commit

This commit is contained in:
2026-05-15 15:30:29 +02:00
parent 879481feab
commit 886684e224
28 changed files with 629 additions and 81 deletions
+27 -5
View File
@@ -5,17 +5,39 @@
#include <tservice.hpp>
#include <uxlogger.hpp>
#include <srvconfig.hpp>
int main(int argc, char** argv) {
TCPService service(1025);
std::expected<void, std::string> Run() {
ServConfig config;
auto readRes = config.Read("helmetsrv.conf");
if (!readRes) {
return std::unexpected("Read config error: " + readRes.error());
}
auto validateRes = config.Validate();
if (!validateRes) {
return std::unexpected("Validate config error: " + validateRes.error());
}
auto listport = config.Listenport();
auto localnets = config.Localnets();
auto tunnelnet = config.Tunnelnet();
TunService service(listport, tunnelnet, localnets);
auto bindRes = service.Bind();
if (!bindRes) {
uxlogger.Log("Bind error: " + bindRes.error());
return 1;
return std::unexpected("Bind error: " + bindRes.error());
}
uxlogger.Info(std::format("Listening on port {}", listport));
auto listenRes = service.Listen();
if (!listenRes) {
uxlogger.Log("Listen error: " + listenRes.error());
return std::unexpected("Listen error: " + listenRes.error());
}
return {};
}
int main(int argc, char** argv) {
auto runRes = Run();
if (!runRes) {
uxlogger.Log(runRes.error());
return 1;
}
return 0;