mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-10-23 03:26:59 +09:00
* fix: share double-stop guard via VpnProtocol base class * feat: add local proxy core module * feat: local proxy settings api * feat: wire local proxy into app controllers * feat: local proxy settings ui * feat: arbitrate shared xray engine ownership via ipc tokens * fix: remove connection type * chore: add qthttpserver to desktop ci qt modules * fix: local proxy port fallback and active port reporting * fix: keep text field button aligned when error is shown * fix: hide local proxy for free servers and guard device unlink * fix: show local proxy state per server * fix: anchor text field button to content * fix: adapt local proxy pages to design * fix: copy logic and port logic * refactor: move local proxy files to controllers and utils * refactor: merge local proxy into LocalProxyController * refactor: reuse gateway config request and keep local proxy state in memory --------- Co-authored-by: vkamn <vk@amnezia.org>
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#ifndef XRAY_H
|
|
#define XRAY_H
|
|
|
|
#include <QString>
|
|
|
|
class Xray
|
|
{
|
|
public:
|
|
static Xray& getInstance()
|
|
{
|
|
static Xray instance;
|
|
return instance;
|
|
}
|
|
|
|
// The engine is shared between consumers (VPN protocol, local proxy).
|
|
// start() returns an owner token; stop(token) is a no-op unless the token
|
|
// still owns the running engine, so a late teardown can't kill a newer owner.
|
|
qint64 start(const QString& cfg);
|
|
bool stop(qint64 token);
|
|
bool stopAny();
|
|
qint64 currentToken() const;
|
|
|
|
private:
|
|
bool startXray(const QString& cfg);
|
|
bool stopXray();
|
|
|
|
qint64 m_currentToken = 0;
|
|
qint64 m_lastToken = 0;
|
|
|
|
static void ctxSockCallback(uintptr_t fd, void* ctx) {
|
|
reinterpret_cast<Xray*>(ctx)->sockCallback(fd);
|
|
}
|
|
static void ctxLogHandler(char* str, void* ctx) {
|
|
reinterpret_cast<Xray*>(ctx)->logHandler(str);
|
|
}
|
|
|
|
void sockCallback(uintptr_t fd);
|
|
void logHandler(char* str);
|
|
|
|
#ifdef Q_OS_LINUX
|
|
QByteArray m_defaultIfaceName;
|
|
#else
|
|
int m_defaultIfaceIdx;
|
|
#endif
|
|
|
|
#ifdef Q_OS_MAC
|
|
QString m_uplinkIfaceName;
|
|
QString m_uplinkGateway;
|
|
#endif
|
|
};
|
|
|
|
#endif // XRAY_H
|