working commit
This commit is contained in:
+27
-5
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user