Added a basic TUN, testing the implementation.

This commit is contained in:
2025-11-13 08:31:46 +01:00
parent aebca5cd7e
commit 5c8409b312
15 changed files with 310 additions and 52 deletions

View File

@@ -13,6 +13,8 @@
#include <array>
#include <algorithm>
#include <vector>
#include <columnlynx/common/net/protocol_structs.hpp>
#include <columnlynx/common/net/virtual_interface.hpp>
using asio::ip::tcp;
@@ -25,7 +27,8 @@ namespace ColumnLynx::Net::TCP {
Utils::LibSodiumWrapper* sodiumWrapper,
std::array<uint8_t, 32>* aesKey,
uint64_t* sessionIDRef,
bool* insecureMode)
bool* insecureMode,
VirtualInterface* tun = nullptr)
:
mResolver(ioContext),
mSocket(ioContext),
@@ -70,5 +73,7 @@ namespace ColumnLynx::Net::TCP {
std::chrono::steady_clock::time_point mLastHeartbeatSent;
int mMissedHeartbeats = 0;
bool mIsHostDomain;
Protocol::TunConfig mTunConfig;
VirtualInterface* mTun = nullptr;
};
}

View File

@@ -9,6 +9,7 @@
#include <columnlynx/common/utils.hpp>
#include <columnlynx/common/libsodium_wrapper.hpp>
#include <array>
#include <columnlynx/common/net/virtual_interface.hpp>
namespace ColumnLynx::Net::UDP {
class UDPClient {
@@ -17,8 +18,9 @@ namespace ColumnLynx::Net::UDP {
const std::string& host,
const std::string& port,
std::array<uint8_t, 32>* aesKeyRef,
uint64_t* sessionIDRef)
: mSocket(ioContext), mResolver(ioContext), mHost(host), mPort(port), mAesKeyRef(aesKeyRef), mSessionIDRef(sessionIDRef) { mStartReceive(); }
uint64_t* sessionIDRef,
VirtualInterface* tunRef = nullptr)
: mSocket(ioContext), mResolver(ioContext), mHost(host), mPort(port), mAesKeyRef(aesKeyRef), mSessionIDRef(sessionIDRef), mTunRef(tunRef) { mStartReceive(); }
void start();
void sendMessage(const std::string& data = "");
@@ -35,6 +37,7 @@ namespace ColumnLynx::Net::UDP {
std::string mPort;
std::array<uint8_t, 32>* mAesKeyRef;
uint64_t* mSessionIDRef;
VirtualInterface* mTunRef;
std::array<uint8_t, 2048> mRecvBuffer; // Adjust size as needed
};
}