added a template for the v2ray protocol
This commit is contained in:
parent
dc2a1467c7
commit
8032e55d7c
14 changed files with 124 additions and 10 deletions
|
|
@ -248,6 +248,7 @@ if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID))
|
|||
${CMAKE_CURRENT_LIST_DIR}/protocols/openvpnovercloakprotocol.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/protocols/shadowsocksvpnprotocol.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/protocols/wireguardprotocol.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/protocols/v2rayprotocol.h
|
||||
)
|
||||
|
||||
set(SOURCES ${SOURCES}
|
||||
|
|
@ -258,6 +259,7 @@ if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID))
|
|||
${CMAKE_CURRENT_LIST_DIR}/protocols/openvpnovercloakprotocol.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/protocols/shadowsocksvpnprotocol.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/protocols/wireguardprotocol.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/protocols/v2rayprotocol.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@
|
|||
#include "core/servercontroller.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
CloakConfigurator::CloakConfigurator(std::shared_ptr<Settings> settings, std::shared_ptr<ServerController> serverController, QObject *parent):
|
||||
ConfiguratorBase(settings, serverController, parent)
|
||||
CloakConfigurator::CloakConfigurator(std::shared_ptr<Settings> settings, std::shared_ptr<ServerController> serverController,
|
||||
QObject *parent): ConfiguratorBase(settings, serverController, parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString CloakConfigurator::genCloakConfig(const ServerCredentials &credentials,
|
||||
DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode)
|
||||
QString CloakConfigurator::genCloakConfig(const ServerCredentials &credentials, DockerContainer container,
|
||||
const QJsonObject &containerConfig, ErrorCode *errorCode)
|
||||
{
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
|
||||
|
|
|
|||
13
client/configurators/v2ray_configurator.cpp
Normal file
13
client/configurators/v2ray_configurator.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#include "v2ray_configurator.h"
|
||||
|
||||
V2RayConfigurator::V2RayConfigurator(std::shared_ptr<Settings> settings, std::shared_ptr<ServerController> serverController,
|
||||
QObject *parent) : ConfiguratorBase(settings, serverController, parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString V2RayConfigurator::genCloakConfig(const ServerCredentials &credentials, DockerContainer container,
|
||||
const QJsonObject &containerConfig, ErrorCode *errorCode)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
21
client/configurators/v2ray_configurator.h
Normal file
21
client/configurators/v2ray_configurator.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef V2RAYCONFIGURATOR_H
|
||||
#define V2RAYCONFIGURATOR_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "configurator_base.h"
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
class V2RayConfigurator : ConfiguratorBase
|
||||
{
|
||||
public:
|
||||
V2RayConfigurator(std::shared_ptr<Settings> settings,
|
||||
std::shared_ptr<ServerController> serverController, QObject *parent = nullptr);
|
||||
|
||||
QString genCloakConfig(const ServerCredentials &credentials, DockerContainer container,
|
||||
const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr);
|
||||
};
|
||||
|
||||
#endif // V2RAYCONFIGURATOR_H
|
||||
|
||||
|
|
@ -45,6 +45,9 @@ QVector<amnezia::Proto> ContainerProps::protocolsForContainer(amnezia::DockerCon
|
|||
case DockerContainer::Ipsec:
|
||||
return { Proto::Ikev2 /*, Protocol::L2tp */};
|
||||
|
||||
case DockerContainer::V2Ray:
|
||||
return { Proto::V2Ray };
|
||||
|
||||
case DockerContainer::Dns:
|
||||
return { };
|
||||
|
||||
|
|
@ -76,6 +79,7 @@ QMap<DockerContainer, QString> ContainerProps::containerHumanNames()
|
|||
{DockerContainer::Cloak, "OpenVpn over Cloak"},
|
||||
{DockerContainer::WireGuard, "WireGuard"},
|
||||
{DockerContainer::Ipsec, QObject::tr("IPsec")},
|
||||
{DockerContainer::V2Ray, "V2Ray"},
|
||||
|
||||
{DockerContainer::TorWebSite, QObject::tr("Web site in Tor network")},
|
||||
{DockerContainer::Dns, QObject::tr("DNS Service")},
|
||||
|
|
@ -93,6 +97,7 @@ QMap<DockerContainer, QString> ContainerProps::containerDescriptions()
|
|||
"configured with traffic masking by Cloak plugin")},
|
||||
{DockerContainer::WireGuard, QObject::tr("WireGuard container")},
|
||||
{DockerContainer::Ipsec, QObject::tr("IPsec container")},
|
||||
{DockerContainer::V2Ray, QObject::tr("V2Ray container")},
|
||||
|
||||
{DockerContainer::TorWebSite, QObject::tr("Web site in Tor network")},
|
||||
{DockerContainer::Dns, QObject::tr("DNS Service")},
|
||||
|
|
@ -110,6 +115,8 @@ amnezia::ServiceType ContainerProps::containerService(DockerContainer c)
|
|||
case DockerContainer::ShadowSocks : return ServiceType::Vpn;
|
||||
case DockerContainer::WireGuard : return ServiceType::Vpn;
|
||||
case DockerContainer::Ipsec : return ServiceType::Vpn;
|
||||
case DockerContainer::V2Ray : return ServiceType::Vpn;
|
||||
|
||||
case DockerContainer::TorWebSite : return ServiceType::Other;
|
||||
case DockerContainer::Dns : return ServiceType::Other;
|
||||
//case DockerContainer::FileShare : return ServiceType::Other;
|
||||
|
|
@ -127,6 +134,7 @@ Proto ContainerProps::defaultProtocol(DockerContainer c)
|
|||
case DockerContainer::ShadowSocks : return Proto::ShadowSocks;
|
||||
case DockerContainer::WireGuard : return Proto::WireGuard;
|
||||
case DockerContainer::Ipsec : return Proto::Ikev2;
|
||||
case DockerContainer::V2Ray : return Proto::V2Ray;
|
||||
|
||||
case DockerContainer::TorWebSite : return Proto::TorWebSite;
|
||||
case DockerContainer::Dns : return Proto::Dns;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ enum DockerContainer {
|
|||
Cloak,
|
||||
WireGuard,
|
||||
Ipsec,
|
||||
V2Ray,
|
||||
|
||||
//non-vpn
|
||||
TorWebSite,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ QString amnezia::scriptFolder(amnezia::DockerContainer container)
|
|||
case DockerContainer::ShadowSocks: return QLatin1String("openvpn_shadowsocks");
|
||||
case DockerContainer::WireGuard: return QLatin1String("wireguard");
|
||||
case DockerContainer::Ipsec: return QLatin1String("ipsec");
|
||||
case DockerContainer::V2Ray: return QLatin1String("openvpn_v2ray_vmess");
|
||||
|
||||
case DockerContainer::TorWebSite: return QLatin1String("website_tor");
|
||||
case DockerContainer::Dns: return QLatin1String("dns");
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ QMap<amnezia::Proto, QString> ProtocolProps::protocolHumanNames()
|
|||
{Proto::WireGuard, "WireGuard"},
|
||||
{Proto::Ikev2, "IKEv2"},
|
||||
{Proto::L2tp, "L2TP"},
|
||||
{Proto::V2Ray, "V2Ray"},
|
||||
|
||||
{Proto::TorWebSite, "Web site in Tor network"},
|
||||
{Proto::Dns, "DNS Service"},
|
||||
|
|
@ -96,6 +97,8 @@ amnezia::ServiceType ProtocolProps::protocolService(Proto p)
|
|||
case Proto::Cloak : return ServiceType::Vpn;
|
||||
case Proto::ShadowSocks : return ServiceType::Vpn;
|
||||
case Proto::WireGuard : return ServiceType::Vpn;
|
||||
case Proto::V2Ray : return ServiceType::Vpn;
|
||||
|
||||
case Proto::TorWebSite : return ServiceType::Other;
|
||||
case Proto::Dns : return ServiceType::Other;
|
||||
case Proto::FileShare : return ServiceType::Other;
|
||||
|
|
@ -113,6 +116,7 @@ int ProtocolProps::defaultPort(Proto p)
|
|||
case Proto::WireGuard : return 51820;
|
||||
case Proto::Ikev2 : return -1;
|
||||
case Proto::L2tp : return -1;
|
||||
case Proto::V2Ray : return -1;
|
||||
|
||||
case Proto::TorWebSite : return -1;
|
||||
case Proto::Dns : return 53;
|
||||
|
|
@ -132,6 +136,7 @@ bool ProtocolProps::defaultPortChangeable(Proto p)
|
|||
case Proto::WireGuard : return true;
|
||||
case Proto::Ikev2 : return false;
|
||||
case Proto::L2tp : return false;
|
||||
case Proto::V2Ray : return true;
|
||||
|
||||
|
||||
case Proto::TorWebSite : return true;
|
||||
|
|
@ -151,6 +156,7 @@ TransportProto ProtocolProps::defaultTransportProto(Proto p)
|
|||
case Proto::WireGuard : return TransportProto::Udp;
|
||||
case Proto::Ikev2 : return TransportProto::Udp;
|
||||
case Proto::L2tp : return TransportProto::Udp;
|
||||
case Proto::V2Ray : return TransportProto::Tcp;
|
||||
// non-vpn
|
||||
case Proto::TorWebSite : return TransportProto::Tcp;
|
||||
case Proto::Dns : return TransportProto::Udp;
|
||||
|
|
@ -169,6 +175,7 @@ bool ProtocolProps::defaultTransportProtoChangeable(Proto p)
|
|||
case Proto::WireGuard : return false;
|
||||
case Proto::Ikev2 : return false;
|
||||
case Proto::L2tp : return false;
|
||||
case Proto::V2Ray : return false;
|
||||
// non-vpn
|
||||
case Proto::TorWebSite : return false;
|
||||
case Proto::Dns : return false;
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ enum Proto {
|
|||
WireGuard,
|
||||
Ikev2,
|
||||
L2tp,
|
||||
V2Ray,
|
||||
|
||||
// non-vpn
|
||||
TorWebSite,
|
||||
|
|
|
|||
37
client/protocols/v2rayprotocol.cpp
Normal file
37
client/protocols/v2rayprotocol.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "v2rayprotocol.h"
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
V2RayProtocol::V2RayProtocol(const QJsonObject &configuration, QObject *parent) : VpnProtocol(configuration, parent)
|
||||
{
|
||||
writeV2RayConfiguration(configuration);
|
||||
}
|
||||
|
||||
V2RayProtocol::~V2RayProtocol()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ErrorCode V2RayProtocol::start()
|
||||
{
|
||||
return ErrorCode::NoError;
|
||||
}
|
||||
|
||||
void V2RayProtocol::stop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void V2RayProtocol::writeV2RayConfiguration(const QJsonObject &configuration)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const QString V2RayProtocol::v2rayExecPath() const
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
return Utils::executable(QString("v2ray/v2ray"), true);
|
||||
#else
|
||||
return Utils::executable(QString("/v2ray/v2ray"), true);
|
||||
#endif
|
||||
}
|
||||
22
client/protocols/v2rayprotocol.h
Normal file
22
client/protocols/v2rayprotocol.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef V2RAYPROTOCOL_H
|
||||
#define V2RAYPROTOCOL_H
|
||||
|
||||
#include "vpnprotocol.h"
|
||||
|
||||
class V2RayProtocol : public VpnProtocol
|
||||
{
|
||||
public:
|
||||
V2RayProtocol(const QJsonObject& configuration, QObject* parent = nullptr);
|
||||
virtual ~V2RayProtocol() override;
|
||||
|
||||
ErrorCode start() override;
|
||||
void stop() override;
|
||||
|
||||
private:
|
||||
QJsonObject m_shadowSocksConfig;
|
||||
void writeV2RayConfiguration(const QJsonObject &configuration);
|
||||
|
||||
const QString v2rayExecPath() const;
|
||||
};
|
||||
|
||||
#endif // V2RAYPROTOCOL_H
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
#include "shadowsocksvpnprotocol.h"
|
||||
#include "openvpnovercloakprotocol.h"
|
||||
#include "wireguardprotocol.h"
|
||||
#include "v2rayprotocol.h"
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
|
@ -114,6 +115,7 @@ VpnProtocol *VpnProtocol::factory(DockerContainer container, const QJsonObject&
|
|||
case DockerContainer::Cloak: return new OpenVpnOverCloakProtocol(configuration);
|
||||
case DockerContainer::ShadowSocks: return new ShadowSocksVpnProtocol(configuration);
|
||||
case DockerContainer::WireGuard: return new WireguardProtocol(configuration);
|
||||
case DockerContainer::V2Ray: return new V2RayProtocol(configuration);
|
||||
#endif
|
||||
default: return nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
#include "wireguardprotocol.h"
|
||||
#include "utilities.h"
|
||||
|
||||
WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject* parent) :
|
||||
VpnProtocol(configuration, parent)
|
||||
WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject* parent) : VpnProtocol(configuration, parent)
|
||||
{
|
||||
m_configFile.setFileName(QDir::tempPath() + QDir::separator() + serviceName() + ".conf");
|
||||
writeWireguardConfiguration(configuration);
|
||||
|
|
|
|||
BIN
deploy/data/windows/x64/v2ray/v2ray.exe
Normal file
BIN
deploy/data/windows/x64/v2ray/v2ray.exe
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue