Merge branch 'dev' into ikev2_fix_window_api_signal
This commit is contained in:
commit
1b1a5be607
344 changed files with 182435 additions and 13254 deletions
|
@ -58,7 +58,7 @@ AndroidVpnProtocol* AndroidVpnProtocol::instance() {
|
|||
return s_instance;
|
||||
}
|
||||
|
||||
void AndroidVpnProtocol::initialize()
|
||||
bool AndroidVpnProtocol::initialize()
|
||||
{
|
||||
qDebug() << "Initializing";
|
||||
|
||||
|
@ -81,55 +81,63 @@ void AndroidVpnProtocol::initialize()
|
|||
"(Landroid/content/Context;)V", appContext.object());
|
||||
|
||||
// Start the VPN Service (if not yet) and Bind to it
|
||||
QtAndroid::bindService(
|
||||
const bool bindResult = QtAndroid::bindService(
|
||||
QAndroidIntent(appContext.object(), "org.amnezia.vpn.VPNService"),
|
||||
*this, QtAndroid::BindFlag::AutoCreate);
|
||||
qDebug() << "Binding to the service..." << bindResult;
|
||||
|
||||
return bindResult;
|
||||
}
|
||||
|
||||
ErrorCode AndroidVpnProtocol::start()
|
||||
{
|
||||
|
||||
//qDebug().noquote() << "AndroidVpnProtocol::start" << QJsonDocument(m_rawConfig).toJson();
|
||||
qDebug() << "Prompting for VPN permission";
|
||||
auto appContext = QtAndroid::androidActivity().callObjectMethod(
|
||||
"getApplicationContext", "()Landroid/content/Context;");
|
||||
"getApplicationContext", "()Landroid/content/Context;");
|
||||
QAndroidJniObject::callStaticMethod<void>(
|
||||
PERMISSIONHELPER_CLASS, "startService", "(Landroid/content/Context;)V",
|
||||
appContext.object());
|
||||
PERMISSIONHELPER_CLASS, "startService", "(Landroid/content/Context;)V",
|
||||
appContext.object());
|
||||
|
||||
|
||||
// QJsonObject jServer;
|
||||
// jServer["ipv4AddrIn"] = server.ipv4AddrIn();
|
||||
// jServer["ipv4Gateway"] = server.ipv4Gateway();
|
||||
// jServer["ipv6AddrIn"] = server.ipv6AddrIn();
|
||||
// jServer["ipv6Gateway"] = server.ipv6Gateway();
|
||||
// jServer["publicKey"] = server.publicKey();
|
||||
// jServer["port"] = (int)server.choosePort();
|
||||
// QJsonObject jServer;
|
||||
// jServer["ipv4AddrIn"] = server.ipv4AddrIn();
|
||||
// jServer["ipv4Gateway"] = server.ipv4Gateway();
|
||||
// jServer["ipv6AddrIn"] = server.ipv6AddrIn();
|
||||
// jServer["ipv6Gateway"] = server.ipv6Gateway();
|
||||
// jServer["publicKey"] = server.publicKey();
|
||||
// jServer["port"] = (int)server.choosePort();
|
||||
|
||||
// QJsonArray allowedIPs;
|
||||
// foreach (auto item, allowedIPAddressRanges) {
|
||||
// QJsonValue val;
|
||||
// val = item.toString();
|
||||
// allowedIPs.append(val);
|
||||
// }
|
||||
// QJsonArray allowedIPs;
|
||||
// foreach (auto item, allowedIPAddressRanges) {
|
||||
// QJsonValue val;
|
||||
// val = item.toString();
|
||||
// allowedIPs.append(val);
|
||||
// }
|
||||
|
||||
// QJsonArray excludedApps;
|
||||
// foreach (auto appID, vpnDisabledApps) {
|
||||
// excludedApps.append(QJsonValue(appID));
|
||||
// }
|
||||
// QJsonArray excludedApps;
|
||||
// foreach (auto appID, vpnDisabledApps) {
|
||||
// excludedApps.append(QJsonValue(appID));
|
||||
// }
|
||||
|
||||
// QJsonObject args;
|
||||
// args["device"] = jDevice;
|
||||
// args["keys"] = jKeys;
|
||||
// args["server"] = jServer;
|
||||
// args["reason"] = (int)reason;
|
||||
// args["allowedIPs"] = allowedIPs;
|
||||
// args["excludedApps"] = excludedApps;
|
||||
// args["dns"] = dns.toString();
|
||||
// QJsonObject args;
|
||||
// args["device"] = jDevice;
|
||||
// args["keys"] = jKeys;
|
||||
// args["server"] = jServer;
|
||||
// args["reason"] = (int)reason;
|
||||
// args["allowedIPs"] = allowedIPs;
|
||||
// args["excludedApps"] = excludedApps;
|
||||
// args["dns"] = dns.toString();
|
||||
|
||||
QAndroidParcel sendData;
|
||||
sendData.writeData(QJsonDocument(m_rawConfig).toJson());
|
||||
m_serviceBinder.transact(ACTION_ACTIVATE, sendData, nullptr);
|
||||
return NoError;
|
||||
bool activateResult = false;
|
||||
while (!activateResult){
|
||||
activateResult = m_serviceBinder.transact(ACTION_ACTIVATE, sendData, nullptr);
|
||||
}
|
||||
|
||||
return activateResult ? NoError : UnknownError;
|
||||
}
|
||||
|
||||
// Activates the tunnel that is currently set
|
||||
|
@ -212,7 +220,7 @@ void AndroidVpnProtocol::cleanupBackendLogs() {
|
|||
|
||||
void AndroidVpnProtocol::onServiceConnected(
|
||||
const QString& name, const QAndroidBinder& serviceBinder) {
|
||||
qDebug() << "Server connected";
|
||||
qDebug() << "Server " + name + " connected";
|
||||
|
||||
Q_UNUSED(name);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
|
||||
virtual ~AndroidVpnProtocol() override = default;
|
||||
|
||||
void initialize();
|
||||
bool initialize();
|
||||
|
||||
virtual ErrorCode start() override;
|
||||
virtual void stop() override;
|
||||
|
|
|
@ -34,6 +34,13 @@ constexpr char hash[] = "hash";
|
|||
constexpr char ncp_disable[] = "ncp_disable";
|
||||
constexpr char tls_auth[] = "tls_auth";
|
||||
|
||||
constexpr char client_priv_key[] = "client_priv_key";
|
||||
constexpr char client_pub_key[] = "client_pub_key";
|
||||
constexpr char server_priv_key[] = "server_priv_key";
|
||||
constexpr char server_pub_key[] = "server_pub_key";
|
||||
constexpr char psk_key[] = "psk_key";
|
||||
|
||||
|
||||
constexpr char site[] = "site";
|
||||
constexpr char block_outside_dns[] = "block_outside_dns";
|
||||
|
||||
|
|
|
@ -4,11 +4,13 @@
|
|||
#include "vpnprotocol.h"
|
||||
#include "core/errorstrings.h"
|
||||
|
||||
#if defined(Q_OS_WINDOWS) || defined(Q_OS_MACX) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
#include "openvpnprotocol.h"
|
||||
#include "shadowsocksvpnprotocol.h"
|
||||
#include "openvpnovercloakprotocol.h"
|
||||
#include "wireguardprotocol.h"
|
||||
#include "ikev2_vpn_protocol.h"
|
||||
#endif
|
||||
|
||||
|
||||
VpnProtocol::VpnProtocol(const QJsonObject &configuration, QObject* parent)
|
||||
|
@ -98,12 +100,13 @@ QString VpnProtocol::vpnGateway() const
|
|||
VpnProtocol *VpnProtocol::factory(DockerContainer container, const QJsonObject& configuration)
|
||||
{
|
||||
switch (container) {
|
||||
#if defined(Q_OS_WINDOWS) || defined(Q_OS_MACX) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
case DockerContainer::OpenVpn: return new OpenVpnProtocol(configuration);
|
||||
case DockerContainer::Cloak: return new OpenVpnOverCloakProtocol(configuration);
|
||||
case DockerContainer::ShadowSocks: return new ShadowSocksVpnProtocol(configuration);
|
||||
case DockerContainer::WireGuard: return new WireguardProtocol(configuration);
|
||||
case DockerContainer::Ipsec: return new Ikev2Protocol(configuration);
|
||||
|
||||
#endif
|
||||
default: return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue