This commit is contained in:
2025-11-13 15:12:00 +01:00
parent 5c8409b312
commit c85f622a60
7 changed files with 19 additions and 15 deletions

View File

@@ -63,8 +63,8 @@ int main(int argc, char** argv) {
WintunInitialize();
#endif
VirtualInterface tun("utun1");
log("Using virtual interface: " + tun.getName());
std::shared_ptr<VirtualInterface> tun = std::make_shared<VirtualInterface>("utun0");
log("Using virtual interface: " + tun->getName());
LibSodiumWrapper sodiumWrapper = LibSodiumWrapper();
@@ -72,8 +72,8 @@ int main(int argc, char** argv) {
uint64_t sessionID = 0;
asio::io_context io;
auto client = std::make_shared<ColumnLynx::Net::TCP::TCPClient>(io, host, port, &sodiumWrapper, &aesKey, &sessionID, &insecureMode, &tun);
auto udpClient = std::make_shared<ColumnLynx::Net::UDP::UDPClient>(io, host, port, &aesKey, &sessionID, &tun);
auto client = std::make_shared<ColumnLynx::Net::TCP::TCPClient>(io, host, port, &sodiumWrapper, &aesKey, &sessionID, &insecureMode, tun);
auto udpClient = std::make_shared<ColumnLynx::Net::UDP::UDPClient>(io, host, port, &aesKey, &sessionID, tun);
client->start();
udpClient->start();
@@ -89,7 +89,7 @@ int main(int argc, char** argv) {
// Client is running
// TODO: SIGINT or SIGTERM seems to not kill this instantly!
while ((client->isConnected() || !client->isHandshakeComplete()) && !done) {
auto packet = tun.readPacket();
auto packet = tun->readPacket();
Nonce nonce{};
randombytes_buf(nonce.data(), nonce.size());

View File

@@ -61,8 +61,8 @@ int main(int argc, char** argv) {
WintunInitialize();
#endif
VirtualInterface tun("utun0");
log("Using virtual interface: " + tun.getName());
std::shared_ptr<VirtualInterface> tun = std::make_shared<VirtualInterface>("utun0");
log("Using virtual interface: " + tun->getName());
// Generate a temporary keypair, replace with actual CA signed keys later (Note, these are stored in memory)
LibSodiumWrapper sodiumWrapper = LibSodiumWrapper();
@@ -74,7 +74,7 @@ int main(int argc, char** argv) {
asio::io_context io;
auto server = std::make_shared<TCPServer>(io, serverPort(), &sodiumWrapper, &hostRunning, ipv4Only);
auto udpServer = std::make_shared<UDPServer>(io, serverPort(), &hostRunning, ipv4Only, &tun);
auto udpServer = std::make_shared<UDPServer>(io, serverPort(), &hostRunning, ipv4Only, tun);
asio::signal_set signals(io, SIGINT, SIGTERM);
signals.async_wait([&](const std::error_code&, int) {
@@ -84,6 +84,8 @@ int main(int argc, char** argv) {
hostRunning = false;
server->stop();
udpServer->stop();
tun.reset();
tun = nullptr;
});
});
@@ -97,7 +99,7 @@ int main(int argc, char** argv) {
log("Server started on port " + std::to_string(serverPort()));
while (!done) {
auto packet = tun.readPacket();
auto packet = tun->readPacket();
if (packet.empty()) {
continue;
}

View File

@@ -62,6 +62,7 @@ namespace ColumnLynx::Net::UDP {
// For now, just log the decrypted payload
std::string payloadStr(plaintext.begin(), plaintext.end());
Utils::log("UDP: Received packet from " + mRemoteEndpoint.address().to_string() + " - Payload: " + payloadStr);
if (mTun) {
mTun->writePacket(plaintext); // Send to virtual interface
}