working commit

This commit is contained in:
Олег Бородин
2026-05-20 17:43:25 +02:00
parent ee4cee5809
commit f2c0679255
3 changed files with 16 additions and 1 deletions
+4
View File
@@ -23,6 +23,10 @@ std::expected<void, std::string> Run() {
auto localnets = config.Localnets(); auto localnets = config.Localnets();
auto tunnelnet = config.Tunnelnet(); auto tunnelnet = config.Tunnelnet();
TunService service(listport, tunnelnet, localnets); TunService service(listport, tunnelnet, localnets);
auto initRes = service.Init();
if (!initRes) {
return std::unexpected("Init error: " + initRes.error());
}
auto bindRes = service.Bind(); auto bindRes = service.Bind();
if (!bindRes) { if (!bindRes) {
return std::unexpected("Bind error: " + bindRes.error()); return std::unexpected("Bind error: " + bindRes.error());
+4
View File
@@ -8,4 +8,8 @@ std::expected<std::string, std::string> nethost(std::string network, uint prefix
std::expected<uint, std::string> netprefix(const std::string network); std::expected<uint, std::string> netprefix(const std::string network);
std::expected<std::string, std::string> network(const std::string network); std::expected<std::string, std::string> network(const std::string network);
uint64_t netcapa6(const uint prefix);
uint64_t netcapa4(const uint prefix);
std::expected<uint, std::string> netcapa(std::string network, uint prefix);
#endif #endif
+8 -1
View File
@@ -29,7 +29,14 @@ std::expected<void, std::string> TunService::Init(void) {
if (!netprefixRes) { if (!netprefixRes) {
return std::unexpected(networkRes.error()); 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 {}; return {};
} }