Added a basic TUN, testing the implementation.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <columnlynx/common/utils.hpp>
|
||||
#include <columnlynx/common/libsodium_wrapper.hpp>
|
||||
#include <columnlynx/common/net/session_registry.hpp>
|
||||
#include <columnlynx/common/net/protocol_structs.hpp>
|
||||
|
||||
namespace ColumnLynx::Net::TCP {
|
||||
class TCPConnection : public std::enable_shared_from_this<TCPConnection> {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <columnlynx/common/utils.hpp>
|
||||
#include <columnlynx/server/net/tcp/tcp_connection.hpp>
|
||||
#include <columnlynx/common/libsodium_wrapper.hpp>
|
||||
#include <columnlynx/common/net/protocol_structs.hpp>
|
||||
|
||||
namespace ColumnLynx::Net::TCP {
|
||||
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
#include <columnlynx/common/net/udp/udp_message_type.hpp>
|
||||
#include <columnlynx/common/utils.hpp>
|
||||
#include <array>
|
||||
#include <columnlynx/common/net/virtual_interface.hpp>
|
||||
|
||||
namespace ColumnLynx::Net::UDP {
|
||||
class UDPServer {
|
||||
public:
|
||||
UDPServer(asio::io_context& ioContext, uint16_t port, bool* hostRunning, bool ipv4Only = false)
|
||||
: mSocket(ioContext), mHostRunning(hostRunning)
|
||||
UDPServer(asio::io_context& ioContext, uint16_t port, bool* hostRunning, bool ipv4Only = false, VirtualInterface* tun = nullptr)
|
||||
: mSocket(ioContext), mHostRunning(hostRunning), mTun(tun)
|
||||
{
|
||||
asio::error_code ec;
|
||||
|
||||
@@ -43,13 +44,15 @@ namespace ColumnLynx::Net::UDP {
|
||||
|
||||
void stop();
|
||||
|
||||
void sendData(const uint64_t sessionID, const std::string& data);
|
||||
|
||||
private:
|
||||
void mStartReceive();
|
||||
void mHandlePacket(std::size_t bytes);
|
||||
void mSendData(const uint64_t sessionID, const std::string& data);
|
||||
asio::ip::udp::socket mSocket;
|
||||
asio::ip::udp::endpoint mRemoteEndpoint;
|
||||
std::array<uint8_t, 2048> mRecvBuffer; // Adjust size as needed
|
||||
bool* mHostRunning;
|
||||
VirtualInterface* mTun;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user