You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

44 lines
1.0 KiB

// utun_node.h — C++ wrapper for embedded uTun node (runs in dedicated thread)
#ifndef UTUN_NODE_H
#define UTUN_NODE_H
#include <QObject>
#include <QByteArray>
#include <QString>
#include <atomic>
#include <thread>
struct UTUN_INSTANCE;
class UtunNode : public QObject {
Q_OBJECT
public:
explicit UtunNode(QObject* parent = nullptr);
~UtunNode();
bool start(const QString& configPath);
void stop();
bool isRunning() const { return m_running; }
void send(uint64_t dstNodeId, const QByteArray& data);
QString nodeIdHex() const;
QString pubKeyHex() const;
signals:
void started();
void stopped();
void error(const QString& msg);
void messageReceived(uint64_t src, const QByteArray& data);
private:
void runLoop();
static void recvCallback(struct ETCP_CONN* conn, struct ll_entry* entry);
UTUN_INSTANCE* m_instance = nullptr;
std::thread m_thread;
std::atomic<bool> m_running{false};
std::atomic<bool> m_stop{false};
QString m_configPath;
};
#endif // UTUN_NODE_H