mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-21 02:01:03 +07:00
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
#ifndef XRAYPROTOCOL_H
|
|
#define XRAYPROTOCOL_H
|
|
|
|
#include "QProcess"
|
|
#include <QtCore/qsharedpointer.h>
|
|
#include <QHostAddress>
|
|
#include <QList>
|
|
|
|
#include "core/utils/errorCodes.h"
|
|
#include "core/utils/routeModes.h"
|
|
#include "core/utils/commonStructs.h"
|
|
#include "core/utils/ipcClient.h"
|
|
#include "vpnProtocol.h"
|
|
|
|
class XrayProtocol : public VpnProtocol
|
|
{
|
|
public:
|
|
XrayProtocol(const QJsonObject &configuration, QObject *parent = nullptr);
|
|
virtual ~XrayProtocol() override;
|
|
|
|
ErrorCode start() override;
|
|
void stop() override;
|
|
void setPrimary(const QJsonObject &config) override;
|
|
|
|
private:
|
|
enum class Phase {
|
|
Inactive,
|
|
Active,
|
|
Stopping,
|
|
};
|
|
|
|
ErrorCode setupRouting();
|
|
ErrorCode startTun2Socks();
|
|
|
|
QJsonObject m_xrayConfig;
|
|
amnezia::RouteMode m_routeMode;
|
|
QList<QHostAddress> m_dnsServers;
|
|
QString m_remoteAddress;
|
|
|
|
QString m_socksUser;
|
|
QString m_socksPassword;
|
|
int m_socksPort = 10808;
|
|
|
|
QSharedPointer<IpcProcessInterfaceReplica> m_tun2socksProcess;
|
|
int m_tun2socksRetryCount = 0;
|
|
static constexpr int maxTun2SocksRetries = 5;
|
|
static constexpr int tun2socksRetryDelayMs = 400;
|
|
|
|
QString m_tunName;
|
|
Phase m_phase = Phase::Inactive;
|
|
};
|
|
|
|
#endif // XRAYPROTOCOL_H
|