diff --git a/helmetsrv.cpp b/helmetsrv.cpp index 857ff37..5d28e68 100644 --- a/helmetsrv.cpp +++ b/helmetsrv.cpp @@ -23,6 +23,10 @@ std::expected Run() { auto localnets = config.Localnets(); auto tunnelnet = config.Tunnelnet(); TunService service(listport, tunnelnet, localnets); + auto initRes = service.Init(); + if (!initRes) { + return std::unexpected("Init error: " + initRes.error()); + } auto bindRes = service.Bind(); if (!bindRes) { return std::unexpected("Bind error: " + bindRes.error()); diff --git a/networkaux.hpp b/networkaux.hpp index 3d9f2ca..8946a7b 100644 --- a/networkaux.hpp +++ b/networkaux.hpp @@ -8,4 +8,8 @@ std::expected nethost(std::string network, uint prefix std::expected netprefix(const std::string network); std::expected network(const std::string network); +uint64_t netcapa6(const uint prefix); +uint64_t netcapa4(const uint prefix); +std::expected netcapa(std::string network, uint prefix); + #endif diff --git a/tservice.cpp b/tservice.cpp index 5f1e629..bf8ff84 100644 --- a/tservice.cpp +++ b/tservice.cpp @@ -29,7 +29,14 @@ std::expected TunService::Init(void) { if (!netprefixRes) { return std::unexpected(networkRes.error()); }; - + auto prefix = netprefixRes.value(); + auto netaddr = networkRes.value(); + auto totalHostsRes = netcapa(netaddr, prefix); + if (!totalHostsRes) { + return std::unexpected(totalHostsRes.error()); + }; + auto totalNets = totalHostsRes.value() / 4; + uxlogger.Debug(std::format("Total networks: {}", totalNets)); return {}; }