working commit
This commit is contained in:
@@ -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());
|
||||||
|
|||||||
@@ -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
@@ -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 {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user