working commit
This commit is contained in:
+17
-2
@@ -20,6 +20,7 @@ extern "C" {
|
||||
#include <msgheader.hpp>
|
||||
#include <uxlogger.hpp>
|
||||
#include <iprouter.hpp>
|
||||
#include <networkaux.hpp>
|
||||
|
||||
#include <uxcontrol.pb.h>
|
||||
|
||||
@@ -147,6 +148,12 @@ void UxClient::RecvMessages(void) {
|
||||
routeMessage.ParseFromString(rawMessage);
|
||||
auto network = routeMessage.address();
|
||||
auto prefix = routeMessage.prefix();
|
||||
auto networkRes = nethost(network, prefix, 0);
|
||||
if (!networkRes) {
|
||||
uxlogger.Error(networkRes.error());
|
||||
break;
|
||||
}
|
||||
network = networkRes.value();
|
||||
uxlogger.Info(std::format("Received route {}/{} gw {}", network, prefix, tunAddress));
|
||||
if (tunAddress != "") {
|
||||
Router router;
|
||||
@@ -217,14 +224,22 @@ std::expected<void, std::string> UxClient::Run(void) {
|
||||
if (!createRes) {
|
||||
return std::unexpected(createRes.error());
|
||||
}
|
||||
|
||||
/*
|
||||
auto setAddrRes = interface.SetIP4Address("10.1.1.1");
|
||||
if (!setAddrRes) {
|
||||
uxlogger.Error(setAddrRes.error());
|
||||
}
|
||||
auto setMaskRes = interface.SetIP4Netmask(24);
|
||||
if (!setMaskRes) {
|
||||
uxlogger.Error(setMaskRes.error());
|
||||
}
|
||||
Router router;
|
||||
auto addRouteRes = router.AddRoute("1.1.1.2", 32, "10.1.1.2");
|
||||
auto addRouteRes = router.AddRoute("1.1.1.0", 24, "10.1.1.1", "");
|
||||
if (!addRouteRes) {
|
||||
return std::unexpected(addRouteRes.error());
|
||||
}
|
||||
*/
|
||||
|
||||
std::thread sendThr(&UxClient::SendMessages, this);
|
||||
sendThr.detach();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user