Merge conflicts in .gitmodules resolved
3
.gitmodules
vendored
|
@ -16,3 +16,6 @@
|
||||||
[submodule "client/3rd/outline-go-tun2socks"]
|
[submodule "client/3rd/outline-go-tun2socks"]
|
||||||
path = client/3rd/outline-go-tun2socks
|
path = client/3rd/outline-go-tun2socks
|
||||||
url = https://github.com/Jigsaw-Code/outline-go-tun2socks.git
|
url = https://github.com/Jigsaw-Code/outline-go-tun2socks.git
|
||||||
|
[submodule "client/3rd/qzxing"]
|
||||||
|
path = client/3rd/qzxing
|
||||||
|
url = https://github.com/ftylitak/qzxing.git
|
||||||
|
|
|
@ -1,129 +0,0 @@
|
||||||
|
|
||||||
#if !defined(AFX_QR_ENCODE_H__AC886DF7_C0AE_4C9F_AC7A_FCDA8CB1DD37__INCLUDED_)
|
|
||||||
#define AFX_QR_ENCODE_H__AC886DF7_C0AE_4C9F_AC7A_FCDA8CB1DD37__INCLUDED_
|
|
||||||
|
|
||||||
#if _MSC_VER > 1000
|
|
||||||
#pragma once
|
|
||||||
#endif // _MSC_VER > 1000
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//
|
|
||||||
#define QR_LEVEL_L 0
|
|
||||||
#define QR_LEVEL_M 1
|
|
||||||
#define QR_LEVEL_Q 2
|
|
||||||
#define QR_LEVEL_H 3
|
|
||||||
|
|
||||||
//
|
|
||||||
#define QR_MODE_NUMERAL 0
|
|
||||||
#define QR_MODE_ALPHABET 1
|
|
||||||
#define QR_MODE_8BIT 2
|
|
||||||
#define QR_MODE_KANJI 3
|
|
||||||
|
|
||||||
//
|
|
||||||
#define QR_VRESION_S 0
|
|
||||||
#define QR_VRESION_M 1
|
|
||||||
#define QR_VRESION_L 2
|
|
||||||
|
|
||||||
#define MAX_ALLCODEWORD 3706
|
|
||||||
#define MAX_DATACODEWORD 2956
|
|
||||||
#define MAX_CODEBLOCK 153
|
|
||||||
#define MAX_MODULESIZE 177
|
|
||||||
|
|
||||||
#define QR_MARGIN 0
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
typedef struct tagRS_BLOCKINFO
|
|
||||||
{
|
|
||||||
int ncRSBlock;
|
|
||||||
int ncAllCodeWord;
|
|
||||||
int ncDataCodeWord;
|
|
||||||
|
|
||||||
} RS_BLOCKINFO, *LPRS_BLOCKINFO;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
typedef struct tagQR_VERSIONINFO
|
|
||||||
{
|
|
||||||
int nVersionNo;
|
|
||||||
int ncAllCodeWord;
|
|
||||||
|
|
||||||
int ncDataCodeWord[4];
|
|
||||||
|
|
||||||
int ncAlignPoint;
|
|
||||||
int nAlignPoint[6];
|
|
||||||
|
|
||||||
RS_BLOCKINFO RS_BlockInfo1[4];
|
|
||||||
RS_BLOCKINFO RS_BlockInfo2[4];
|
|
||||||
|
|
||||||
} QR_VERSIONINFO, *LPQR_VERSIONINFO;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class CQR_Encode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CQR_Encode();
|
|
||||||
~CQR_Encode();
|
|
||||||
|
|
||||||
public:
|
|
||||||
int m_nLevel;
|
|
||||||
int m_nVersion;
|
|
||||||
bool m_bAutoExtent;
|
|
||||||
int m_nMaskingNo;
|
|
||||||
|
|
||||||
public:
|
|
||||||
int m_nSymbleSize;
|
|
||||||
unsigned char m_byModuleData[MAX_MODULESIZE][MAX_MODULESIZE]; // [x][y]
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_ncDataCodeWordBit;
|
|
||||||
unsigned char m_byDataCodeWord[MAX_DATACODEWORD];
|
|
||||||
|
|
||||||
int m_ncDataBlock;
|
|
||||||
unsigned char m_byBlockMode[MAX_DATACODEWORD];
|
|
||||||
int m_nBlockLength[MAX_DATACODEWORD];
|
|
||||||
|
|
||||||
int m_ncAllCodeWord;
|
|
||||||
unsigned char m_byAllCodeWord[MAX_ALLCODEWORD];
|
|
||||||
unsigned char m_byRSWork[MAX_CODEBLOCK];
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool EncodeData(int nLevel, int nVersion, bool bAutoExtent, int nMaskingNo, const char* lpsSource, int ncSource = 0);
|
|
||||||
|
|
||||||
private:
|
|
||||||
int GetEncodeVersion(int nVersion, const char* lpsSource, int ncLength);
|
|
||||||
bool EncodeSourceData(const char* lpsSource, int ncLength, int nVerGroup);
|
|
||||||
|
|
||||||
int GetBitLength(unsigned char nMode, int ncData, int nVerGroup);
|
|
||||||
|
|
||||||
int SetBitStream(int nIndex, unsigned short wData, int ncData);
|
|
||||||
|
|
||||||
bool IsNumeralData(unsigned char c);
|
|
||||||
bool IsAlphabetData(unsigned char c);
|
|
||||||
bool IsKanjiData(unsigned char c1, unsigned char c2);
|
|
||||||
|
|
||||||
unsigned char AlphabetToBinaly(unsigned char c);
|
|
||||||
unsigned short KanjiToBinaly(unsigned short wc);
|
|
||||||
|
|
||||||
void GetRSCodeWord(unsigned char * lpbyRSWork, int ncDataCodeWord, int ncRSCodeWord);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void FormatModule();
|
|
||||||
|
|
||||||
void SetFunctionModule();
|
|
||||||
void SetFinderPattern(int x, int y);
|
|
||||||
void SetAlignmentPattern(int x, int y);
|
|
||||||
void SetVersionPattern();
|
|
||||||
void SetCodeWordPattern();
|
|
||||||
void SetMaskingPattern(int nPatternNo);
|
|
||||||
void SetFormatInfoPattern(int nPatternNo);
|
|
||||||
int CountPenalty();
|
|
||||||
};
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#endif // !defined(AFX_QR_ENCODE_H__AC886DF7_C0AE_4C9F_AC7A_FCDA8CB1DD37__INCLUDED_)
|
|
|
@ -1,5 +0,0 @@
|
||||||
HEADERS += \
|
|
||||||
3rd/QRCodeGenerator/QRCodeGenerator.h \
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
3rd/QRCodeGenerator/QRCodeGenerator.cpp \
|
|
|
@ -11,7 +11,7 @@ win32 {
|
||||||
-lcrypt32 \
|
-lcrypt32 \
|
||||||
|
|
||||||
!contains(QMAKE_TARGET.arch, x86_64) {
|
!contains(QMAKE_TARGET.arch, x86_64) {
|
||||||
INCLUDEPATH += $$PWD/windows/x86_64
|
INCLUDEPATH += $$PWD/windows/x86
|
||||||
HEADERS += $$PWD/windows/x86/botan_all.h
|
HEADERS += $$PWD/windows/x86/botan_all.h
|
||||||
SOURCES += $$PWD/windows/x86/botan_all.cpp
|
SOURCES += $$PWD/windows/x86/botan_all.cpp
|
||||||
}
|
}
|
||||||
|
|
1
client/3rd/qzxing
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 2fd4dd60c04a29c6d1271fdd9ae25378b8f61ec8
|
|
@ -2,12 +2,13 @@
|
||||||
<manifest package="org.amnezia.vpn" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto">
|
<manifest package="org.amnezia.vpn" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
|
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/>
|
||||||
|
|
||||||
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
||||||
Remove the comment if you do not require these default features. -->
|
Remove the comment if you do not require these default features. -->
|
||||||
|
|
|
@ -38,13 +38,9 @@ apply plugin: 'kotlinx-serialization'
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||||
implementation 'androidx.core:core-ktx:1.1.0'
|
implementation 'androidx.core:core-ktx:1.1.0'
|
||||||
implementation 'com.android.installreferrer:installreferrer:2.2'
|
|
||||||
implementation 'com.android.billingclient:billing-ktx:4.0.0'
|
|
||||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0-alpha02"
|
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0-alpha02"
|
||||||
implementation "androidx.security:security-crypto:1.1.0-alpha03"
|
implementation "androidx.security:security-crypto:1.1.0-alpha03"
|
||||||
implementation "androidx.security:security-identity-credential:1.0.0-alpha02"
|
implementation "androidx.security:security-identity-credential:1.0.0-alpha02"
|
||||||
implementation 'com.adjust.sdk:adjust-android:4.28.2'
|
|
||||||
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
|
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2"
|
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2"
|
||||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.0.10"
|
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.0.10"
|
||||||
}
|
}
|
||||||
|
@ -106,8 +102,8 @@ android {
|
||||||
resConfig "en"
|
resConfig "en"
|
||||||
minSdkVersion = 24
|
minSdkVersion = 24
|
||||||
targetSdkVersion = 30
|
targetSdkVersion = 30
|
||||||
versionCode 2 // Change to a higher number
|
versionCode 6 // Change to a higher number
|
||||||
versionName "2.0.1" // Change to a higher number
|
versionName "2.0.6" // Change to a higher number
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package org.ftylitak.qzxing;
|
||||||
|
|
||||||
|
public class NativeFunctions {
|
||||||
|
public static native void onPermissionsGranted();
|
||||||
|
public static native void onPermissionsDenied();
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package org.ftylitak.qzxing;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import org.qtproject.qt5.android.bindings.QtActivity;
|
||||||
|
import static org.ftylitak.qzxing.Utilities.REQUEST_CAMERA;
|
||||||
|
|
||||||
|
public class QZXingLiveActivity extends QtActivity {
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode,
|
||||||
|
String permissions[], int[] grantResults) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case REQUEST_CAMERA: {
|
||||||
|
// If request is cancelled, the result arrays are empty.
|
||||||
|
if (grantResults.length > 0
|
||||||
|
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
NativeFunctions.onPermissionsGranted();
|
||||||
|
} else {
|
||||||
|
NativeFunctions.onPermissionsDenied();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
client/android/src/org/ftylitak/qzxing/Utilities.java
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
package org.ftylitak.qzxing;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Utilities {
|
||||||
|
|
||||||
|
public static final int REQUEST_CAMERA = 0;
|
||||||
|
|
||||||
|
public static final String[] requiredPermissionsModifyPhoneState = {
|
||||||
|
Manifest.permission.CAMERA,
|
||||||
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
|
};
|
||||||
|
|
||||||
|
public static void checkAndRequestPermissionList(Activity activity, String[] permissions) {
|
||||||
|
ArrayList<String> permissionsToRequest = new ArrayList<>();
|
||||||
|
for (int i = 0; i < permissions.length; i++) {
|
||||||
|
if (ContextCompat.checkSelfPermission(activity, permissions[i])
|
||||||
|
!= PackageManager.PERMISSION_GRANTED)
|
||||||
|
permissionsToRequest.add(permissions[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (permissionsToRequest.size() != 0)
|
||||||
|
ActivityCompat.requestPermissions(activity,
|
||||||
|
permissionsToRequest.toArray(new String[0]),
|
||||||
|
REQUEST_CAMERA);
|
||||||
|
else
|
||||||
|
NativeFunctions.onPermissionsGranted();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void requestQZXingPermissions(Activity activity) {
|
||||||
|
checkAndRequestPermissionList(activity, requiredPermissionsModifyPhoneState);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -5,14 +5,17 @@ TEMPLATE = app
|
||||||
#CONFIG += console
|
#CONFIG += console
|
||||||
|
|
||||||
CONFIG += qtquickcompiler
|
CONFIG += qtquickcompiler
|
||||||
|
CONFIG += qzxing_multimedia \
|
||||||
|
enable_decoder_qr_code \
|
||||||
|
enable_encoder_qr_code
|
||||||
|
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
include("3rd/QtSsh/src/ssh/qssh.pri")
|
include("3rd/QtSsh/src/ssh/qssh.pri")
|
||||||
include("3rd/QtSsh/src/botan/botan.pri")
|
include("3rd/QtSsh/src/botan/botan.pri")
|
||||||
!android:!ios:include("3rd/SingleApplication/singleapplication.pri")
|
!android:!ios:include("3rd/SingleApplication/singleapplication.pri")
|
||||||
include("3rd/QRCodeGenerator/QRCodeGenerator.pri")
|
|
||||||
include ("3rd/SortFilterProxyModel/SortFilterProxyModel.pri")
|
include ("3rd/SortFilterProxyModel/SortFilterProxyModel.pri")
|
||||||
|
include("3rd/QZXing/src/QZXing-components.pri")
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/3rd/OpenSSL/include
|
INCLUDEPATH += $$PWD/3rd/OpenSSL/include
|
||||||
DEPENDPATH += $$PWD/3rd/OpenSSL/include
|
DEPENDPATH += $$PWD/3rd/OpenSSL/include
|
||||||
|
@ -48,6 +51,7 @@ HEADERS += \
|
||||||
ui/pages_logic/NetworkSettingsLogic.h \
|
ui/pages_logic/NetworkSettingsLogic.h \
|
||||||
ui/pages_logic/NewServerProtocolsLogic.h \
|
ui/pages_logic/NewServerProtocolsLogic.h \
|
||||||
ui/pages_logic/PageLogicBase.h \
|
ui/pages_logic/PageLogicBase.h \
|
||||||
|
ui/pages_logic/QrDecoderLogic.h \
|
||||||
ui/pages_logic/ServerConfiguringProgressLogic.h \
|
ui/pages_logic/ServerConfiguringProgressLogic.h \
|
||||||
ui/pages_logic/ServerContainersLogic.h \
|
ui/pages_logic/ServerContainersLogic.h \
|
||||||
ui/pages_logic/ServerListLogic.h \
|
ui/pages_logic/ServerListLogic.h \
|
||||||
|
@ -103,6 +107,7 @@ SOURCES += \
|
||||||
ui/pages_logic/NetworkSettingsLogic.cpp \
|
ui/pages_logic/NetworkSettingsLogic.cpp \
|
||||||
ui/pages_logic/NewServerProtocolsLogic.cpp \
|
ui/pages_logic/NewServerProtocolsLogic.cpp \
|
||||||
ui/pages_logic/PageLogicBase.cpp \
|
ui/pages_logic/PageLogicBase.cpp \
|
||||||
|
ui/pages_logic/QrDecoderLogic.cpp \
|
||||||
ui/pages_logic/ServerConfiguringProgressLogic.cpp \
|
ui/pages_logic/ServerConfiguringProgressLogic.cpp \
|
||||||
ui/pages_logic/ServerContainersLogic.cpp \
|
ui/pages_logic/ServerContainersLogic.cpp \
|
||||||
ui/pages_logic/ServerListLogic.cpp \
|
ui/pages_logic/ServerListLogic.cpp \
|
||||||
|
@ -141,12 +146,14 @@ win32 {
|
||||||
RC_FILE = platform_win/vpnclient.rc
|
RC_FILE = platform_win/vpnclient.rc
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
ui/framelesswindow.h \
|
protocols/ikev2_vpn_protocol_windows.h \
|
||||||
|
ui/framelesswindow.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
protocols/ikev2_vpn_protocol_windows.cpp \
|
||||||
ui/framelesswindow.cpp
|
ui/framelesswindow.cpp
|
||||||
|
|
||||||
VERSION = 1.0.0.0
|
VERSION = 2.0.0.0
|
||||||
QMAKE_TARGET_COMPANY = "AmneziaVPN"
|
QMAKE_TARGET_COMPANY = "AmneziaVPN"
|
||||||
QMAKE_TARGET_PRODUCT = "AmneziaVPN"
|
QMAKE_TARGET_PRODUCT = "AmneziaVPN"
|
||||||
|
|
||||||
|
@ -197,7 +204,6 @@ win32|macx|linux:!android {
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
ui/systemtray_notificationhandler.h \
|
ui/systemtray_notificationhandler.h \
|
||||||
protocols/openvpnprotocol.h \
|
protocols/openvpnprotocol.h \
|
||||||
protocols/ikev2_vpn_protocol.h \
|
|
||||||
protocols/openvpnovercloakprotocol.h \
|
protocols/openvpnovercloakprotocol.h \
|
||||||
protocols/shadowsocksvpnprotocol.h \
|
protocols/shadowsocksvpnprotocol.h \
|
||||||
protocols/wireguardprotocol.h \
|
protocols/wireguardprotocol.h \
|
||||||
|
@ -205,7 +211,6 @@ win32|macx|linux:!android {
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
ui/systemtray_notificationhandler.cpp \
|
ui/systemtray_notificationhandler.cpp \
|
||||||
protocols/openvpnprotocol.cpp \
|
protocols/openvpnprotocol.cpp \
|
||||||
protocols/ikev2_vpn_protocol.cpp \
|
|
||||||
protocols/openvpnovercloakprotocol.cpp \
|
protocols/openvpnovercloakprotocol.cpp \
|
||||||
protocols/shadowsocksvpnprotocol.cpp \
|
protocols/shadowsocksvpnprotocol.cpp \
|
||||||
protocols/wireguardprotocol.cpp \
|
protocols/wireguardprotocol.cpp \
|
||||||
|
@ -218,11 +223,13 @@ android {
|
||||||
INCLUDEPATH += platforms/android
|
INCLUDEPATH += platforms/android
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
platforms/android/native.h \
|
||||||
platforms/android/android_controller.h \
|
platforms/android/android_controller.h \
|
||||||
platforms/android/android_notificationhandler.h \
|
platforms/android/android_notificationhandler.h \
|
||||||
protocols/android_vpnprotocol.h
|
protocols/android_vpnprotocol.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
platforms/android/native.cpp \
|
||||||
platforms/android/android_controller.cpp \
|
platforms/android/android_controller.cpp \
|
||||||
platforms/android/android_notificationhandler.cpp \
|
platforms/android/android_notificationhandler.cpp \
|
||||||
protocols/android_vpnprotocol.cpp
|
protocols/android_vpnprotocol.cpp
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
namespace amnezia {
|
namespace amnezia {
|
||||||
|
|
||||||
|
constexpr const qint16 qrMagicCode = 1984;
|
||||||
|
|
||||||
struct ServerCredentials
|
struct ServerCredentials
|
||||||
{
|
{
|
||||||
QString hostName;
|
QString hostName;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#define APPLICATION_NAME "AmneziaVPN"
|
#define APPLICATION_NAME "AmneziaVPN"
|
||||||
#define SERVICE_NAME "AmneziaVPN-service"
|
#define SERVICE_NAME "AmneziaVPN-service"
|
||||||
#define ORGANIZATION_NAME "AmneziaVPN.ORG"
|
#define ORGANIZATION_NAME "AmneziaVPN.ORG"
|
||||||
#define APP_MAJOR_VERSION "2.0.1"
|
#define APP_MAJOR_VERSION "2.0.6"
|
||||||
#define APP_VERSION "2.0.1.0"
|
#define APP_VERSION "2.0.6.0"
|
||||||
|
|
||||||
#endif // DEFINES_H
|
#endif // DEFINES_H
|
||||||
|
|
BIN
client/images/ios/icon_1024x1024.png
Normal file
After Width: | Height: | Size: 499 KiB |
BIN
client/images/ios/icon_120x120.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/images/ios/icon_180x180.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
client/images/ios/icon_40x40.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
client/images/ios/icon_58x58.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
client/images/ios/icon_60x60.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
client/images/ios/icon_80x80.png
Normal file
After Width: | Height: | Size: 9 KiB |
BIN
client/images/ios/icon_87x87.png
Normal file
After Width: | Height: | Size: 10 KiB |
62
client/ios/Media.xcassets/AppIcon.appiconset/Contents.json
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "icon_40x40.png",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"scale" : "2x",
|
||||||
|
"size" : "20x20"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "icon_60x60.png",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"scale" : "3x",
|
||||||
|
"size" : "20x20"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "icon_58x58.png",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"scale" : "2x",
|
||||||
|
"size" : "29x29"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "icon_87x87.png",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"scale" : "3x",
|
||||||
|
"size" : "29x29"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "icon_80x80.png",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"scale" : "2x",
|
||||||
|
"size" : "40x40"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "icon_120x120.png",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"scale" : "3x",
|
||||||
|
"size" : "40x40"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "icon_120x120-1.png",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"scale" : "2x",
|
||||||
|
"size" : "60x60"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "icon_180x180.png",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"scale" : "3x",
|
||||||
|
"size" : "60x60"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "icon_1024x1024.png",
|
||||||
|
"idiom" : "ios-marketing",
|
||||||
|
"scale" : "1x",
|
||||||
|
"size" : "1024x1024"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
BIN
client/ios/Media.xcassets/AppIcon.appiconset/icon_1024x1024.png
Normal file
After Width: | Height: | Size: 499 KiB |
BIN
client/ios/Media.xcassets/AppIcon.appiconset/icon_120x120-1.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/ios/Media.xcassets/AppIcon.appiconset/icon_120x120.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
client/ios/Media.xcassets/AppIcon.appiconset/icon_180x180.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
client/ios/Media.xcassets/AppIcon.appiconset/icon_40x40.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
client/ios/Media.xcassets/AppIcon.appiconset/icon_58x58.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
client/ios/Media.xcassets/AppIcon.appiconset/icon_60x60.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
client/ios/Media.xcassets/AppIcon.appiconset/icon_80x80.png
Normal file
After Width: | Height: | Size: 9 KiB |
BIN
client/ios/Media.xcassets/AppIcon.appiconset/icon_87x87.png
Normal file
After Width: | Height: | Size: 10 KiB |
6
client/ios/Media.xcassets/Contents.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,8 +16,9 @@
|
||||||
#include "ui/pages_logic/AppSettingsLogic.h"
|
#include "ui/pages_logic/AppSettingsLogic.h"
|
||||||
#include "ui/pages_logic/GeneralSettingsLogic.h"
|
#include "ui/pages_logic/GeneralSettingsLogic.h"
|
||||||
#include "ui/pages_logic/NetworkSettingsLogic.h"
|
#include "ui/pages_logic/NetworkSettingsLogic.h"
|
||||||
#include "ui/pages_logic/ServerConfiguringProgressLogic.h"
|
|
||||||
#include "ui/pages_logic/NewServerProtocolsLogic.h"
|
#include "ui/pages_logic/NewServerProtocolsLogic.h"
|
||||||
|
#include "ui/pages_logic/QrDecoderLogic.h"
|
||||||
|
#include "ui/pages_logic/ServerConfiguringProgressLogic.h"
|
||||||
#include "ui/pages_logic/ServerContainersLogic.h"
|
#include "ui/pages_logic/ServerContainersLogic.h"
|
||||||
#include "ui/pages_logic/ServerListLogic.h"
|
#include "ui/pages_logic/ServerListLogic.h"
|
||||||
#include "ui/pages_logic/ServerSettingsLogic.h"
|
#include "ui/pages_logic/ServerSettingsLogic.h"
|
||||||
|
@ -34,6 +35,8 @@
|
||||||
|
|
||||||
#include "ui/uilogic.h"
|
#include "ui/uilogic.h"
|
||||||
|
|
||||||
|
#include "QZXing.h"
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
|
@ -48,6 +51,10 @@
|
||||||
#include "Windows.h"
|
#include "Windows.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
#include "native.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static void loadTranslator()
|
static void loadTranslator()
|
||||||
{
|
{
|
||||||
QTranslator* translator = new QTranslator;
|
QTranslator* translator = new QTranslator;
|
||||||
|
@ -79,6 +86,11 @@ int main(int argc, char *argv[])
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
NativeHelpers::registerApplicationInstance(&app);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
AllowSetForegroundWindow(0);
|
AllowSetForegroundWindow(0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -116,6 +128,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
app.setQuitOnLastWindowClosed(false);
|
app.setQuitOnLastWindowClosed(false);
|
||||||
|
|
||||||
|
QZXing::registerQMLTypes();
|
||||||
|
|
||||||
qRegisterMetaType<VpnProtocol::VpnConnectionState>("VpnProtocol::VpnConnectionState");
|
qRegisterMetaType<VpnProtocol::VpnConnectionState>("VpnProtocol::VpnConnectionState");
|
||||||
qRegisterMetaType<ServerCredentials>("ServerCredentials");
|
qRegisterMetaType<ServerCredentials>("ServerCredentials");
|
||||||
|
|
||||||
|
@ -156,8 +170,9 @@ int main(int argc, char *argv[])
|
||||||
engine->rootContext()->setContextProperty("AppSettingsLogic", uiLogic->appSettingsLogic());
|
engine->rootContext()->setContextProperty("AppSettingsLogic", uiLogic->appSettingsLogic());
|
||||||
engine->rootContext()->setContextProperty("GeneralSettingsLogic", uiLogic->generalSettingsLogic());
|
engine->rootContext()->setContextProperty("GeneralSettingsLogic", uiLogic->generalSettingsLogic());
|
||||||
engine->rootContext()->setContextProperty("NetworkSettingsLogic", uiLogic->networkSettingsLogic());
|
engine->rootContext()->setContextProperty("NetworkSettingsLogic", uiLogic->networkSettingsLogic());
|
||||||
engine->rootContext()->setContextProperty("ServerConfiguringProgressLogic", uiLogic->serverConfiguringProgressLogic());
|
|
||||||
engine->rootContext()->setContextProperty("NewServerProtocolsLogic", uiLogic->newServerProtocolsLogic());
|
engine->rootContext()->setContextProperty("NewServerProtocolsLogic", uiLogic->newServerProtocolsLogic());
|
||||||
|
engine->rootContext()->setContextProperty("QrDecoderLogic", uiLogic->qrDecoderLogic());
|
||||||
|
engine->rootContext()->setContextProperty("ServerConfiguringProgressLogic", uiLogic->serverConfiguringProgressLogic());
|
||||||
engine->rootContext()->setContextProperty("ServerListLogic", uiLogic->serverListLogic());
|
engine->rootContext()->setContextProperty("ServerListLogic", uiLogic->serverListLogic());
|
||||||
engine->rootContext()->setContextProperty("ServerSettingsLogic", uiLogic->serverSettingsLogic());
|
engine->rootContext()->setContextProperty("ServerSettingsLogic", uiLogic->serverSettingsLogic());
|
||||||
engine->rootContext()->setContextProperty("ServerContainersLogic", uiLogic->serverprotocolsLogic());
|
engine->rootContext()->setContextProperty("ServerContainersLogic", uiLogic->serverprotocolsLogic());
|
||||||
|
|
54
client/platforms/android/native.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#include "native.h"
|
||||||
|
#include <QMetaObject>
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
#include <jni.h>
|
||||||
|
#endif // Q_OS_ANDROID
|
||||||
|
|
||||||
|
|
||||||
|
QObject *NativeHelpers::application_p_ = 0;
|
||||||
|
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
|
||||||
|
// define our native static functions
|
||||||
|
// these are the functions that Java part will call directly from Android UI thread
|
||||||
|
static void onPermissionsGranted(JNIEnv * /*env*/, jobject /*obj*/)
|
||||||
|
{
|
||||||
|
QMetaObject::invokeMethod(NativeHelpers::getApplicationInstance(), "onPermissionsGranted"
|
||||||
|
, Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onPermissionsDenied(JNIEnv * /*env*/, jobject /*obj*/)
|
||||||
|
{
|
||||||
|
QMetaObject::invokeMethod(NativeHelpers::getApplicationInstance(), "onPermissionsDenied"
|
||||||
|
, Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
//create a vector with all our JNINativeMethod(s)
|
||||||
|
static JNINativeMethod methods[] = {
|
||||||
|
{"onPermissionsGranted", "()V", (void *)onPermissionsGranted},
|
||||||
|
{"onPermissionsDenied", "()V", (void *)onPermissionsDenied},
|
||||||
|
};
|
||||||
|
|
||||||
|
// this method is called automatically by Java after the .so file is loaded
|
||||||
|
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
|
||||||
|
{
|
||||||
|
JNIEnv* env;
|
||||||
|
// get the JNIEnv pointer.
|
||||||
|
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK)
|
||||||
|
return JNI_ERR;
|
||||||
|
|
||||||
|
// search for Java class which declares the native methods
|
||||||
|
jclass javaClass = env->FindClass("org/ftylitak/qzxing/NativeFunctions");
|
||||||
|
if (!javaClass)
|
||||||
|
return JNI_ERR;
|
||||||
|
|
||||||
|
// register our native methods
|
||||||
|
if (env->RegisterNatives(javaClass, methods,
|
||||||
|
sizeof(methods) / sizeof(methods[0])) < 0) {
|
||||||
|
return JNI_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return JNI_VERSION_1_6;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Q_OS_ANDROID
|
20
client/platforms/android/native.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef NATIVE_H
|
||||||
|
#define NATIVE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class NativeHelpers {
|
||||||
|
public:
|
||||||
|
static void registerApplicationInstance(QObject *app_p) {
|
||||||
|
application_p_ = app_p;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QObject* getApplicationInstance() {
|
||||||
|
return application_p_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QObject *application_p_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NATIVE_H
|
|
@ -1,14 +1,13 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
//#include <QRegularExpression>
|
|
||||||
//#include <QTcpSocket>
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "ikev2_vpn_protocol.h"
|
#include "ikev2_vpn_protocol_windows.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
static Ikev2Protocol* self = nullptr;
|
static Ikev2Protocol* self = nullptr;
|
||||||
|
@ -24,23 +23,19 @@ Ikev2Protocol::Ikev2Protocol(const QJsonObject &configuration, QObject* parent)
|
||||||
VpnProtocol(configuration, parent)
|
VpnProtocol(configuration, parent)
|
||||||
{
|
{
|
||||||
self = this;
|
self = this;
|
||||||
//m_configFile.setFileTemplate(QDir::tempPath() + QDir::separator() + serviceName() + ".conf");
|
|
||||||
readIkev2Configuration(configuration);
|
readIkev2Configuration(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ikev2Protocol::~Ikev2Protocol()
|
Ikev2Protocol::~Ikev2Protocol()
|
||||||
{
|
{
|
||||||
qDebug() << "IpsecProtocol::~IpsecProtocol()";
|
qDebug() << "IpsecProtocol::~IpsecProtocol()";
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
disconnect_vpn();
|
disconnect_vpn();
|
||||||
#endif
|
|
||||||
Ikev2Protocol::stop();
|
Ikev2Protocol::stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ikev2Protocol::stop()
|
void Ikev2Protocol::stop()
|
||||||
{
|
{
|
||||||
setConnectionState(VpnProtocol::Disconnecting);
|
setConnectionState(VpnProtocol::Disconnecting);
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
{
|
{
|
||||||
if (! disconnect_vpn() ){
|
if (! disconnect_vpn() ){
|
||||||
qDebug()<<"We don't disconnect";
|
qDebug()<<"We don't disconnect";
|
||||||
|
@ -50,7 +45,6 @@ void Ikev2Protocol::stop()
|
||||||
setConnectionState(VpnProtocol::Disconnected);
|
setConnectionState(VpnProtocol::Disconnected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ikev2Protocol::newConnectionStateEventReceived(UINT unMsg, tagRASCONNSTATE rasconnstate, DWORD dwError)
|
void Ikev2Protocol::newConnectionStateEventReceived(UINT unMsg, tagRASCONNSTATE rasconnstate, DWORD dwError)
|
||||||
|
@ -60,181 +54,117 @@ void Ikev2Protocol::newConnectionStateEventReceived(UINT unMsg, tagRASCONNSTATE
|
||||||
switch (rasconnstate)
|
switch (rasconnstate)
|
||||||
{
|
{
|
||||||
case RASCS_OpenPort:
|
case RASCS_OpenPort:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_OpenPort = %d\n", _connection_state);
|
|
||||||
//printf ("Opening port...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_PortOpened:
|
case RASCS_PortOpened:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_PortOpened = %d\n", _connection_state);
|
|
||||||
//printf ("Port opened.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_ConnectDevice:
|
case RASCS_ConnectDevice:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_ConnectDevice = %d\n", _connection_state);
|
|
||||||
//printf ("Connecting device...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_DeviceConnected:
|
case RASCS_DeviceConnected:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_DeviceConnected = %d\n", _connection_state);
|
|
||||||
//printf ("Device connected.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AllDevicesConnected:
|
case RASCS_AllDevicesConnected:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_AllDevicesConnected = %d\n", _connection_state);
|
|
||||||
//printf ("All devices connected.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_Authenticate:
|
case RASCS_Authenticate:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_Authenticate = %d\n", _connection_state);
|
|
||||||
// printf ("Authenticating...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthNotify:
|
case RASCS_AuthNotify:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
if (dwError != 0) {
|
if (dwError != 0) {
|
||||||
qDebug() << "have error" << dwError;
|
//qDebug() << "have error" << dwError;
|
||||||
setConnectionState(Disconnected);
|
setConnectionState(Disconnected);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "RASCS_AuthNotify but no error" << dwError;
|
//qDebug() << "RASCS_AuthNotify but no error" << dwError;
|
||||||
}
|
}
|
||||||
//printf ("RASCS_AuthNotify = %d\n", _connection_state);
|
|
||||||
// printf ("Authentication notify.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthRetry:
|
case RASCS_AuthRetry:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_AuthRetry = %d\n", _connection_state);
|
|
||||||
//printf ("Retrying authentication...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthCallback:
|
case RASCS_AuthCallback:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_AuthCallback = %d\n", _connection_state);
|
|
||||||
//printf ("Authentication callback...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthChangePassword:
|
case RASCS_AuthChangePassword:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
// printf ("RASCS_AuthChangePassword = %d\n", _connection_state);
|
|
||||||
//printf ("Change password...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthProject:
|
case RASCS_AuthProject:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_AuthProject = %d\n", _connection_state);
|
|
||||||
//printf ("Projection phase started...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthLinkSpeed:
|
case RASCS_AuthLinkSpeed:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_AuthLinkSpeed = %d\n", _connection_state);
|
|
||||||
//printf ("Negoting speed...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthAck:
|
case RASCS_AuthAck:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_AuthAck = %d\n", _connection_state);
|
|
||||||
//printf ("Authentication acknowledge...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_ReAuthenticate:
|
case RASCS_ReAuthenticate:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_ReAuthenticate = %d\n", _connection_state);
|
|
||||||
//printf ("Retrying Authentication...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_Authenticated:
|
case RASCS_Authenticated:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_Authenticated = %d\n", _connection_state);
|
|
||||||
//printf ("Authentication complete.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_PrepareForCallback:
|
case RASCS_PrepareForCallback:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_PrepareForCallback = %d\n", _connection_state);
|
|
||||||
//printf ("Preparing for callback...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_WaitForModemReset:
|
case RASCS_WaitForModemReset:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_WaitForModemReset = %d\n", _connection_state);
|
|
||||||
// printf ("Waiting for modem reset...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_WaitForCallback:
|
case RASCS_WaitForCallback:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_WaitForCallback = %d\n", _connection_state);
|
|
||||||
//printf ("Waiting for callback...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_Projected:
|
case RASCS_Projected:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_Projected = %d\n", _connection_state);
|
|
||||||
//printf ("Projection completed.\n");
|
|
||||||
break;
|
break;
|
||||||
#if (WINVER >= 0x400)
|
#if (WINVER >= 0x400)
|
||||||
case RASCS_StartAuthentication: // Windows 95 only
|
case RASCS_StartAuthentication: // Windows 95 only
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_StartAuthentication = %d\n", _connection_state);
|
|
||||||
//printf ("Starting authentication...\n");
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case RASCS_CallbackComplete: // Windows 95 only
|
case RASCS_CallbackComplete: // Windows 95 only
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_CallbackComplete = %d\n", rasconnstate);
|
|
||||||
//printf ("Callback complete.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_LogonNetwork: // Windows 95 only
|
case RASCS_LogonNetwork: // Windows 95 only
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_LogonNetwork = %d\n", _connection_state);
|
|
||||||
//printf ("Login to the network.\n");
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case RASCS_SubEntryConnected:
|
case RASCS_SubEntryConnected:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_SubEntryConnected = %d\n", _connection_state);
|
|
||||||
//printf ("Subentry connected.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_SubEntryDisconnected:
|
case RASCS_SubEntryDisconnected:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_SubEntryDisconnected = %d\n", _connection_state);
|
|
||||||
//printf ("Subentry disconnected.\n");
|
|
||||||
break;
|
break;
|
||||||
//PAUSED STATES:
|
//PAUSED STATES:
|
||||||
case RASCS_Interactive:
|
case RASCS_Interactive:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_Interactive = %d\n", _connection_state);
|
|
||||||
//printf ("In Paused state: Interactive mode.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_RetryAuthentication:
|
case RASCS_RetryAuthentication:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_RetryAuthentication = %d\n", _connection_state);
|
|
||||||
//printf ("In Paused state: Retry Authentication...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_CallbackSetByCaller:
|
case RASCS_CallbackSetByCaller:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_CallbackSetByCaller = %d\n", _connection_state);
|
|
||||||
//printf ("In Paused state: Callback set by Caller.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_PasswordExpired:
|
case RASCS_PasswordExpired:
|
||||||
setConnectionState(Error);
|
setConnectionState(Error);
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_PasswordExpired = %d\n", _connection_state);
|
|
||||||
//printf ("In Paused state: Password has expired...\n");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RASCS_Connected: // = RASCS_DONE:
|
case RASCS_Connected: // = RASCS_DONE:
|
||||||
setConnectionState(Connected);
|
setConnectionState(Connected);
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_Connected = %d\n", _connection_state);
|
|
||||||
//printf ("Connection completed.\n");
|
|
||||||
//SetEvent(gEvent_handle);
|
|
||||||
break;
|
break;
|
||||||
case RASCS_Disconnected:
|
case RASCS_Disconnected:
|
||||||
setConnectionState(Disconnected);
|
setConnectionState(Disconnected);
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_Disconnected = %d\n", _connection_state);
|
|
||||||
//printf ("Disconnecting...\n");
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("Unknown Status = %d\n", _connection_state);
|
|
||||||
//printf ("What are you going to do about it?\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,7 +176,6 @@ void Ikev2Protocol::readIkev2Configuration(const QJsonObject &configuration)
|
||||||
|
|
||||||
ErrorCode Ikev2Protocol::start()
|
ErrorCode Ikev2Protocol::start()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
QByteArray cert = QByteArray::fromBase64(m_config[config_key::cert].toString().toUtf8());
|
QByteArray cert = QByteArray::fromBase64(m_config[config_key::cert].toString().toUtf8());
|
||||||
setConnectionState(Connecting);
|
setConnectionState(Connecting);
|
||||||
|
|
||||||
|
@ -277,34 +206,10 @@ ErrorCode Ikev2Protocol::start()
|
||||||
});
|
});
|
||||||
certInstallProcess->setArguments(arguments);
|
certInstallProcess->setArguments(arguments);
|
||||||
|
|
||||||
// qDebug() << arguments.join(" ");
|
|
||||||
// connect(certInstallProcess.data(), &PrivilegedProcess::errorOccurred, [certInstallProcess](QProcess::ProcessError error) {
|
|
||||||
// qDebug() << "PrivilegedProcess errorOccurred" << error;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// connect(certInstallProcess.data(), &PrivilegedProcess::stateChanged, [certInstallProcess](QProcess::ProcessState newState) {
|
|
||||||
// qDebug() << "PrivilegedProcess stateChanged" << newState;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// connect(certInstallProcess.data(), &PrivilegedProcess::readyRead, [certInstallProcess]() {
|
|
||||||
// auto req = certInstallProcess->readAll();
|
|
||||||
// req.waitForFinished();
|
|
||||||
// qDebug() << "PrivilegedProcess readyRead" << req.returnValue();
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
certInstallProcess->start();
|
certInstallProcess->start();
|
||||||
}
|
}
|
||||||
// /*
|
// /*
|
||||||
{
|
{
|
||||||
// auto adapterRemoveProcess = new QProcess;
|
|
||||||
|
|
||||||
// adapterRemoveProcess->setProgram("powershell");
|
|
||||||
// QString arguments = QString("-command \"Remove-VpnConnection -Name '%1' -Force\"").arg(tunnelName());
|
|
||||||
// adapterRemoveProcess->setNativeArguments(arguments);
|
|
||||||
|
|
||||||
// adapterRemoveProcess->start();
|
|
||||||
// adapterRemoveProcess->waitForFinished(5000);
|
|
||||||
if ( disconnect_vpn()){
|
if ( disconnect_vpn()){
|
||||||
qDebug()<<"VPN was disconnected";
|
qDebug()<<"VPN was disconnected";
|
||||||
}
|
}
|
||||||
|
@ -319,21 +224,6 @@ ErrorCode Ikev2Protocol::start()
|
||||||
qDebug() <<"Can't create the VPN connect";
|
qDebug() <<"Can't create the VPN connect";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// auto adapterInstallProcess = new QProcess;
|
|
||||||
|
|
||||||
// adapterInstallProcess->setProgram("powershell");
|
|
||||||
// QString arguments = QString("-command \"Add-VpnConnection "
|
|
||||||
// "-ServerAddress '%1' "
|
|
||||||
// "-Name '%2' "
|
|
||||||
// "-TunnelType IKEv2 "
|
|
||||||
// "-AuthenticationMethod MachineCertificate "
|
|
||||||
// "-EncryptionLevel Required "
|
|
||||||
// "-PassThru\"")
|
|
||||||
// .arg(m_config[config_key::hostName].toString())
|
|
||||||
// .arg(tunnelName());
|
|
||||||
// adapterInstallProcess->setNativeArguments(arguments);
|
|
||||||
// adapterInstallProcess->start();
|
|
||||||
// adapterInstallProcess->waitForFinished(5000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -352,10 +242,6 @@ ErrorCode Ikev2Protocol::start()
|
||||||
.arg(tunnelName());
|
.arg(tunnelName());
|
||||||
adapterConfigProcess->setNativeArguments(arguments);
|
adapterConfigProcess->setNativeArguments(arguments);
|
||||||
|
|
||||||
// connect(adapterConfigProcess, &QProcess::readyRead, [adapterConfigProcess]() {
|
|
||||||
// qDebug().noquote() << "adapterConfigProcess readyRead" << adapterConfigProcess->readAll();
|
|
||||||
// });
|
|
||||||
|
|
||||||
adapterConfigProcess->start();
|
adapterConfigProcess->start();
|
||||||
adapterConfigProcess->waitForFinished(5000);
|
adapterConfigProcess->waitForFinished(5000);
|
||||||
}
|
}
|
||||||
|
@ -367,13 +253,8 @@ ErrorCode Ikev2Protocol::start()
|
||||||
}
|
}
|
||||||
//setConnectionState(Connecting);
|
//setConnectionState(Connecting);
|
||||||
return ErrorCode::NoError;
|
return ErrorCode::NoError;
|
||||||
#else
|
|
||||||
return ErrorCode::NoError;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
bool Ikev2Protocol::create_new_vpn(const QString & vpn_name,
|
bool Ikev2Protocol::create_new_vpn(const QString & vpn_name,
|
||||||
const QString & serv_addr){
|
const QString & serv_addr){
|
||||||
|
|
||||||
|
@ -442,5 +323,3 @@ void WINAPI RasDialFuncCallback(UINT unMsg,
|
||||||
self->newConnectionStateEventReceived(unMsg, rasconnstate, dwError);
|
self->newConnectionStateEventReceived(unMsg, rasconnstate, dwError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef IPSEC_PROTOCOL_H
|
#ifndef IKEV2_VPN_PROTOCOL_WINDOWS_H
|
||||||
#define IPSEC_PROTOCOL_H
|
#define IKEV2_VPN_PROTOCOL_WINDOWS_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
@ -10,7 +10,6 @@
|
||||||
#include "vpnprotocol.h"
|
#include "vpnprotocol.h"
|
||||||
#include "core/ipcclient.h"
|
#include "core/ipcclient.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
@ -31,8 +30,6 @@
|
||||||
#pragma comment(lib, "rasapi32.lib")
|
#pragma comment(lib, "rasapi32.lib")
|
||||||
#pragma comment(lib, "Crypt32.lib")
|
#pragma comment(lib, "Crypt32.lib")
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class Ikev2Protocol : public VpnProtocol
|
class Ikev2Protocol : public VpnProtocol
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -54,14 +51,9 @@ public:
|
||||||
private:
|
private:
|
||||||
void readIkev2Configuration(const QJsonObject &configuration);
|
void readIkev2Configuration(const QJsonObject &configuration);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
//certificates variables
|
|
||||||
|
|
||||||
#endif
|
|
||||||
private:
|
private:
|
||||||
QJsonObject m_config;
|
QJsonObject m_config;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
//RAS functions and parametrs
|
//RAS functions and parametrs
|
||||||
HRASCONN hRasConn{nullptr};
|
HRASCONN hRasConn{nullptr};
|
||||||
bool create_new_vpn(const QString & vpn_name,
|
bool create_new_vpn(const QString & vpn_name,
|
||||||
|
@ -70,12 +62,8 @@ private:
|
||||||
|
|
||||||
bool connect_to_vpn(const QString & vpn_name);
|
bool connect_to_vpn(const QString & vpn_name);
|
||||||
bool disconnect_vpn();
|
bool disconnect_vpn();
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
DWORD CALLBACK rasCallback(UINT msg, RASCONNSTATE rascs, DWORD err);
|
DWORD CALLBACK rasCallback(UINT msg, RASCONNSTATE rascs, DWORD err);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // IPSEC_PROTOCOL_H
|
#endif // IKEV2_VPN_PROTOCOL_WINDOWS_H
|
|
@ -9,7 +9,10 @@
|
||||||
#include "shadowsocksvpnprotocol.h"
|
#include "shadowsocksvpnprotocol.h"
|
||||||
#include "openvpnovercloakprotocol.h"
|
#include "openvpnovercloakprotocol.h"
|
||||||
#include "wireguardprotocol.h"
|
#include "wireguardprotocol.h"
|
||||||
#include "ikev2_vpn_protocol.h"
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
#include "ikev2_vpn_protocol_windows.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -141,5 +141,6 @@
|
||||||
<file>images/animation.gif</file>
|
<file>images/animation.gif</file>
|
||||||
<file>images/connected.png</file>
|
<file>images/connected.png</file>
|
||||||
<file>images/disconnected.png</file>
|
<file>images/disconnected.png</file>
|
||||||
|
<file>ui/qml/Pages/PageQrDecoder.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -17,9 +17,9 @@ iptables -A FORWARD -i wg0 -j ACCEPT
|
||||||
iptables -A OUTPUT -o wg0 -j ACCEPT
|
iptables -A OUTPUT -o wg0 -j ACCEPT
|
||||||
|
|
||||||
# Allow forwarding traffic only from the VPN.
|
# Allow forwarding traffic only from the VPN.
|
||||||
iptables -A FORWARD -i wg0 -o eth0 -s $WIREGUARD_SUBNET_IP/$WIREGUARD_SUBNET_MASK_CIDR -j ACCEPT
|
iptables -A FORWARD -i wg0 -o eth0 -s $WIREGUARD_SUBNET_IP/$WIREGUARD_SUBNET_CIDR -j ACCEPT
|
||||||
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
|
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
|
||||||
|
|
||||||
iptables -t nat -A POSTROUTING -s $WIREGUARD_SUBNET_IP/$OPENVPN_SUBNET_CIDR -o eth0 -j MASQUERADE
|
iptables -t nat -A POSTROUTING -s $WIREGUARD_SUBNET_IP/$WIREGUARD_SUBNET_CIDR -o eth0 -j MASQUERADE
|
||||||
|
|
||||||
tail -f /dev/null
|
tail -f /dev/null
|
||||||
|
|
|
@ -24,7 +24,7 @@ enum class Page {Start = 0, NewServer, NewServerProtocols, Vpn,
|
||||||
Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguringProgress,
|
Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguringProgress,
|
||||||
GeneralSettings, AppSettings, NetworkSettings, ServerSettings,
|
GeneralSettings, AppSettings, NetworkSettings, ServerSettings,
|
||||||
ServerContainers, ServersList, ShareConnection, Sites,
|
ServerContainers, ServersList, ShareConnection, Sites,
|
||||||
ProtocolSettings, ProtocolShare};
|
ProtocolSettings, ProtocolShare, QrDecoder};
|
||||||
Q_ENUM_NS(Page)
|
Q_ENUM_NS(Page)
|
||||||
|
|
||||||
static void declareQmlPageEnum() {
|
static void declareQmlPageEnum() {
|
||||||
|
|
82
client/ui/pages_logic/QrDecoderLogic.cpp
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
#include "QrDecoderLogic.h"
|
||||||
|
|
||||||
|
#include "ui/uilogic.h"
|
||||||
|
#include "ui/pages_logic/StartPageLogic.h"
|
||||||
|
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
#include "android_controller.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
|
QrDecoderLogic::QrDecoderLogic(UiLogic *logic, QObject *parent):
|
||||||
|
PageLogicBase(logic, parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void QrDecoderLogic::onUpdatePage()
|
||||||
|
{
|
||||||
|
m_chunks.clear();
|
||||||
|
set_detectingEnabled(true);
|
||||||
|
set_totalChunksCount(0);
|
||||||
|
set_receivedChunksCount(0);
|
||||||
|
emit startDecode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QrDecoderLogic::onDetectedQrCode(const QString &code)
|
||||||
|
{
|
||||||
|
//qDebug() << code;
|
||||||
|
|
||||||
|
if (!detectingEnabled()) return;
|
||||||
|
|
||||||
|
// check if chunk received
|
||||||
|
QByteArray ba = QByteArray::fromBase64(code.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||||
|
QDataStream s(&ba, QIODevice::ReadOnly);
|
||||||
|
qint16 magic; s >> magic;
|
||||||
|
|
||||||
|
|
||||||
|
if (magic == amnezia::qrMagicCode) {
|
||||||
|
qDebug() << "QrDecoderLogic::onDetectedQrCode magic code detected" << magic << ba.size();
|
||||||
|
|
||||||
|
quint8 chunksCount; s >> chunksCount;
|
||||||
|
if (totalChunksCount() != chunksCount) {
|
||||||
|
m_chunks.clear();
|
||||||
|
}
|
||||||
|
set_totalChunksCount(chunksCount);
|
||||||
|
|
||||||
|
quint8 chunkId; s >> chunkId;
|
||||||
|
s >> m_chunks[chunkId];
|
||||||
|
set_receivedChunksCount(m_chunks.size());
|
||||||
|
|
||||||
|
qDebug() << "Received chunks:" << receivedChunksCount() << "/" << chunksCount << "cur" << chunkId << m_chunks[chunkId].size();
|
||||||
|
qDebug() << chunkId << m_chunks[chunkId];
|
||||||
|
|
||||||
|
if (m_chunks.size() == totalChunksCount()) {
|
||||||
|
QByteArray data;
|
||||||
|
for (int i = 0; i < totalChunksCount(); ++i) {
|
||||||
|
data.append(m_chunks.value(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ok = uiLogic()->startPageLogic()->importConnectionFromQr(data);
|
||||||
|
if (ok) {
|
||||||
|
set_detectingEnabled(false);
|
||||||
|
emit stopDecode();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_chunks.clear();
|
||||||
|
set_totalChunksCount(0);
|
||||||
|
set_receivedChunksCount(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bool ok = uiLogic()->startPageLogic()->importConnectionFromQr(ba);
|
||||||
|
if (ok) {
|
||||||
|
set_detectingEnabled(false);
|
||||||
|
emit stopDecode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
30
client/ui/pages_logic/QrDecoderLogic.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef QR_DECODER_LOGIC_H
|
||||||
|
#define QR_DECODER_LOGIC_H
|
||||||
|
|
||||||
|
#include "PageLogicBase.h"
|
||||||
|
|
||||||
|
class UiLogic;
|
||||||
|
|
||||||
|
class QrDecoderLogic : public PageLogicBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
AUTO_PROPERTY(bool, detectingEnabled)
|
||||||
|
AUTO_PROPERTY(int, totalChunksCount)
|
||||||
|
AUTO_PROPERTY(int, receivedChunksCount)
|
||||||
|
|
||||||
|
public:
|
||||||
|
Q_INVOKABLE void onUpdatePage() override;
|
||||||
|
Q_INVOKABLE void onDetectedQrCode(const QString &code);
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit QrDecoderLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
~QrDecoderLogic() = default;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void startDecode();
|
||||||
|
void stopDecode();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMap<int, QByteArray> m_chunks;
|
||||||
|
};
|
||||||
|
#endif // QR_DECODER_LOGIC_H
|
|
@ -1,11 +1,7 @@
|
||||||
#include <QApplication>
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QClipboard>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QSaveFile>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QZXing>
|
||||||
|
|
||||||
#include "ShareConnectionLogic.h"
|
#include "ShareConnectionLogic.h"
|
||||||
|
|
||||||
|
@ -18,6 +14,7 @@
|
||||||
#include "configurators/ssh_configurator.h"
|
#include "configurators/ssh_configurator.h"
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
#include "core/defs.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "../uilogic.h"
|
#include "../uilogic.h"
|
||||||
|
@ -35,7 +32,8 @@ ShareConnectionLogic::ShareConnectionLogic(UiLogic *logic, QObject *parent):
|
||||||
void ShareConnectionLogic::onUpdatePage()
|
void ShareConnectionLogic::onUpdatePage()
|
||||||
{
|
{
|
||||||
set_textEditShareAmneziaCodeText(tr(""));
|
set_textEditShareAmneziaCodeText(tr(""));
|
||||||
set_shareAmneziaQrCodeText("");
|
set_shareAmneziaQrCodeTextSeries({});
|
||||||
|
set_shareAmneziaQrCodeTextSeriesLength(0);
|
||||||
|
|
||||||
set_textEditShareOpenVpnCodeText("");
|
set_textEditShareOpenVpnCodeText("");
|
||||||
|
|
||||||
|
@ -56,7 +54,8 @@ void ShareConnectionLogic::onUpdatePage()
|
||||||
void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
||||||
{
|
{
|
||||||
set_textEditShareAmneziaCodeText("");
|
set_textEditShareAmneziaCodeText("");
|
||||||
set_shareAmneziaQrCodeText("");
|
set_shareAmneziaQrCodeTextSeries({});
|
||||||
|
set_shareAmneziaQrCodeTextSeriesLength(0);
|
||||||
|
|
||||||
QJsonObject serverConfig;
|
QJsonObject serverConfig;
|
||||||
// Full access
|
// Full access
|
||||||
|
@ -97,15 +96,15 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray ba = QJsonDocument(serverConfig).toBinaryData();
|
QByteArray ba = QJsonDocument(serverConfig).toJson();
|
||||||
ba = qCompress(ba, 8);
|
ba = qCompress(ba, 8);
|
||||||
QString code = QString("vpn://%1").arg(QString(ba.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)));
|
QString code = QString("vpn://%1").arg(QString(ba.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)));
|
||||||
set_textEditShareAmneziaCodeText(code);
|
set_textEditShareAmneziaCodeText(code);
|
||||||
|
|
||||||
if (ba.size() < 2900) {
|
|
||||||
QImage qr = updateQRCodeImage(ba.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals));
|
QList<QString> qrChunks = genQrCodeImageSeries(ba);
|
||||||
set_shareAmneziaQrCodeText(imageToBase64(qr));
|
set_shareAmneziaQrCodeTextSeries(qrChunks);
|
||||||
}
|
set_shareAmneziaQrCodeTextSeriesLength(qrChunks.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShareConnectionLogic::onPushButtonShareOpenVpnGenerateClicked()
|
void ShareConnectionLogic::onPushButtonShareOpenVpnGenerateClicked()
|
||||||
|
@ -147,7 +146,7 @@ void ShareConnectionLogic::onPushButtonShareShadowSocksGenerateClicked()
|
||||||
ssString = "ss://" + ssString.toUtf8().toBase64();
|
ssString = "ss://" + ssString.toUtf8().toBase64();
|
||||||
set_lineEditShareShadowSocksStringText(ssString);
|
set_lineEditShareShadowSocksStringText(ssString);
|
||||||
|
|
||||||
QImage qr = updateQRCodeImage(ssString.toUtf8());
|
QImage qr = QZXing::encodeData(ssString.toUtf8(), QZXing::EncoderFormat_QR_CODE, QSize(512,512), QZXing::EncodeErrorCorrectionLevel_L);
|
||||||
set_shareShadowSocksQrCodeText(imageToBase64(qr));
|
set_shareShadowSocksQrCodeText(imageToBase64(qr));
|
||||||
|
|
||||||
QString humanString = QString("Server: %3\n"
|
QString humanString = QString("Server: %3\n"
|
||||||
|
@ -200,7 +199,8 @@ void ShareConnectionLogic::onPushButtonShareWireGuardGenerateClicked()
|
||||||
|
|
||||||
set_textEditShareWireGuardCodeText(cfg);
|
set_textEditShareWireGuardCodeText(cfg);
|
||||||
|
|
||||||
QImage qr = updateQRCodeImage(cfg.toUtf8());
|
QImage qr = QZXing::encodeData(cfg.toUtf8(), QZXing::EncoderFormat_QR_CODE, QSize(512,512), QZXing::EncodeErrorCorrectionLevel_L);
|
||||||
|
|
||||||
set_shareWireGuardQrCodeText(imageToBase64(qr));
|
set_shareWireGuardQrCodeText(imageToBase64(qr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,30 +234,29 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, DockerContainer co
|
||||||
uiLogic()->selectedDockerContainer = container;
|
uiLogic()->selectedDockerContainer = container;
|
||||||
uiLogic()->selectedServerIndex = serverIndex;
|
uiLogic()->selectedServerIndex = serverIndex;
|
||||||
set_shareFullAccess(container == DockerContainer::None);
|
set_shareFullAccess(container == DockerContainer::None);
|
||||||
|
|
||||||
|
m_shareAmneziaQrCodeTextSeries.clear();
|
||||||
|
set_shareAmneziaQrCodeTextSeriesLength(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage ShareConnectionLogic::updateQRCodeImage(const QByteArray &data)
|
QList<QString> ShareConnectionLogic::genQrCodeImageSeries(const QByteArray &data)
|
||||||
{
|
{
|
||||||
int levelIndex = 1;
|
double k = 1500;
|
||||||
int versionIndex = 0;
|
|
||||||
bool bExtent = true;
|
|
||||||
int maskIndex = -1;
|
|
||||||
|
|
||||||
m_qrEncode.EncodeData( levelIndex, versionIndex, bExtent, maskIndex, data.data() );
|
quint8 chunksCount = std::ceil(data.size() / k);
|
||||||
|
QList<QString> chunks;
|
||||||
|
for (int i = 0; i < data.size(); i = i + k) {
|
||||||
|
QByteArray chunk;
|
||||||
|
QDataStream s(&chunk, QIODevice::WriteOnly);
|
||||||
|
s << amnezia::qrMagicCode << chunksCount << (quint8)std::round(i/k) << data.mid(i, k);
|
||||||
|
|
||||||
int qrImageSize = m_qrEncode.m_nSymbleSize;
|
QByteArray ba = chunk.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||||
|
|
||||||
int encodeImageSize = qrImageSize + ( QR_MARGIN * 2 );
|
QImage qr = QZXing::encodeData(ba, QZXing::EncoderFormat_QR_CODE, QSize(512,512), QZXing::EncodeErrorCorrectionLevel_L);
|
||||||
QImage encodeImage( encodeImageSize, encodeImageSize, QImage::Format_Mono );
|
chunks.append(imageToBase64(qr));
|
||||||
|
}
|
||||||
|
|
||||||
encodeImage.fill( 1 );
|
return chunks;
|
||||||
|
|
||||||
for ( int i = 0; i < qrImageSize; i++ )
|
|
||||||
for ( int j = 0; j < qrImageSize; j++ )
|
|
||||||
if ( m_qrEncode.m_byModuleData[i][j] )
|
|
||||||
encodeImage.setPixel( i + QR_MARGIN, j + QR_MARGIN, 0 );
|
|
||||||
|
|
||||||
return encodeImage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ShareConnectionLogic::imageToBase64(const QImage &image)
|
QString ShareConnectionLogic::imageToBase64(const QImage &image)
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define SHARE_CONNECTION_LOGIC_H
|
#define SHARE_CONNECTION_LOGIC_H
|
||||||
|
|
||||||
#include "PageLogicBase.h"
|
#include "PageLogicBase.h"
|
||||||
#include "3rd/QRCodeGenerator/QRCodeGenerator.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
|
@ -14,7 +13,8 @@ public:
|
||||||
AUTO_PROPERTY(bool, shareFullAccess)
|
AUTO_PROPERTY(bool, shareFullAccess)
|
||||||
|
|
||||||
AUTO_PROPERTY(QString, textEditShareAmneziaCodeText)
|
AUTO_PROPERTY(QString, textEditShareAmneziaCodeText)
|
||||||
AUTO_PROPERTY(QString, shareAmneziaQrCodeText)
|
AUTO_PROPERTY(QStringList, shareAmneziaQrCodeTextSeries)
|
||||||
|
AUTO_PROPERTY(int, shareAmneziaQrCodeTextSeriesLength)
|
||||||
|
|
||||||
AUTO_PROPERTY(QString, textEditShareOpenVpnCodeText)
|
AUTO_PROPERTY(QString, textEditShareOpenVpnCodeText)
|
||||||
|
|
||||||
|
@ -46,11 +46,10 @@ public:
|
||||||
~ShareConnectionLogic() = default;
|
~ShareConnectionLogic() = default;
|
||||||
|
|
||||||
void updateSharingPage(int serverIndex, DockerContainer container);
|
void updateSharingPage(int serverIndex, DockerContainer container);
|
||||||
QImage updateQRCodeImage(const QByteArray &data);
|
QList<QString> genQrCodeImageSeries(const QByteArray &data);
|
||||||
|
|
||||||
QString imageToBase64(const QImage &image);
|
QString imageToBase64(const QImage &image);
|
||||||
|
|
||||||
private:
|
|
||||||
CQR_Encode m_qrEncode;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // SHARE_CONNECTION_LOGIC_H
|
#endif // SHARE_CONNECTION_LOGIC_H
|
||||||
|
|
|
@ -3,6 +3,13 @@
|
||||||
#include "configurators/ssh_configurator.h"
|
#include "configurators/ssh_configurator.h"
|
||||||
#include "../uilogic.h"
|
#include "../uilogic.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
#ifdef Q_OS_ANDROID
|
||||||
|
#include "platforms/android/android_controller.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
StartPageLogic::StartPageLogic(UiLogic *logic, QObject *parent):
|
StartPageLogic::StartPageLogic(UiLogic *logic, QObject *parent):
|
||||||
PageLogicBase(logic, parent),
|
PageLogicBase(logic, parent),
|
||||||
m_pushButtonConnectEnabled{true},
|
m_pushButtonConnectEnabled{true},
|
||||||
|
@ -119,67 +126,97 @@ void StartPageLogic::onPushButtonConnect()
|
||||||
|
|
||||||
void StartPageLogic::onPushButtonImport()
|
void StartPageLogic::onPushButtonImport()
|
||||||
{
|
{
|
||||||
QString s = lineEditStartExistingCodeText();
|
importConnectionFromCode(lineEditStartExistingCodeText());
|
||||||
s.replace("vpn://", "");
|
}
|
||||||
QByteArray ba = QByteArray::fromBase64(s.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
|
||||||
QByteArray ba_uncompressed = qUncompress(ba);
|
|
||||||
|
|
||||||
QJsonObject o;
|
void StartPageLogic::onPushButtonImportOpenFile()
|
||||||
if (!ba_uncompressed.isEmpty()) {
|
{
|
||||||
o = QJsonDocument::fromBinaryData(ba_uncompressed).object();
|
QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open profile"),
|
||||||
}
|
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.vpn");
|
||||||
else {
|
|
||||||
o = QJsonDocument::fromJson(ba).object();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (fileName.isEmpty()) return;
|
||||||
|
|
||||||
|
QFile file(fileName);
|
||||||
|
file.open(QIODevice::ReadOnly);
|
||||||
|
QByteArray data = file.readAll();
|
||||||
|
|
||||||
|
importConnectionFromCode(QString(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StartPageLogic::importConnection(const QJsonObject &profile)
|
||||||
|
{
|
||||||
ServerCredentials credentials;
|
ServerCredentials credentials;
|
||||||
credentials.hostName = o.value("h").toString();
|
credentials.hostName = profile.value(config_key::hostName).toString();
|
||||||
if (credentials.hostName.isEmpty()) credentials.hostName = o.value(config_key::hostName).toString();
|
credentials.port = profile.value(config_key::port).toInt();
|
||||||
|
credentials.userName = profile.value(config_key::userName).toString();
|
||||||
|
credentials.password = profile.value(config_key::password).toString();
|
||||||
|
|
||||||
credentials.port = o.value("p").toInt();
|
// qDebug() << QString("Added server %3@%1:%2").
|
||||||
if (credentials.port == 0) credentials.port = o.value(config_key::port).toInt();
|
// arg(credentials.hostName).
|
||||||
|
// arg(credentials.port).
|
||||||
credentials.userName = o.value("u").toString();
|
// arg(credentials.userName);
|
||||||
if (credentials.userName.isEmpty()) credentials.userName = o.value(config_key::userName).toString();
|
|
||||||
|
|
||||||
credentials.password = o.value("w").toString();
|
|
||||||
if (credentials.password.isEmpty()) credentials.password = o.value(config_key::password).toString();
|
|
||||||
|
|
||||||
if (credentials.isValid()) {
|
|
||||||
o.insert(config_key::hostName, credentials.hostName);
|
|
||||||
o.insert(config_key::port, credentials.port);
|
|
||||||
o.insert(config_key::userName, credentials.userName);
|
|
||||||
o.insert(config_key::password, credentials.password);
|
|
||||||
|
|
||||||
o.remove("h");
|
|
||||||
o.remove("p");
|
|
||||||
o.remove("u");
|
|
||||||
o.remove("w");
|
|
||||||
}
|
|
||||||
qDebug() << QString("Added server %3@%1:%2").
|
|
||||||
arg(credentials.hostName).
|
|
||||||
arg(credentials.port).
|
|
||||||
arg(credentials.userName);
|
|
||||||
|
|
||||||
//qDebug() << QString("Password") << credentials.password;
|
//qDebug() << QString("Password") << credentials.password;
|
||||||
|
|
||||||
if (credentials.isValid() || o.contains(config_key::containers)) {
|
if (credentials.isValid() || profile.contains(config_key::containers)) {
|
||||||
m_settings.addServer(o);
|
m_settings.addServer(profile);
|
||||||
m_settings.setDefaultServer(m_settings.serversCount() - 1);
|
m_settings.setDefaultServer(m_settings.serversCount() - 1);
|
||||||
|
|
||||||
|
emit uiLogic()->goToPage(Page::Vpn);
|
||||||
emit uiLogic()->setStartPage(Page::Vpn);
|
emit uiLogic()->setStartPage(Page::Vpn);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug() << "Failed to import profile";
|
qDebug() << "Failed to import profile";
|
||||||
qDebug().noquote() << QJsonDocument(o).toJson();
|
qDebug().noquote() << QJsonDocument(profile).toJson();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!o.contains(config_key::containers)) {
|
if (!profile.contains(config_key::containers)) {
|
||||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||||
uiLogic()->onUpdateAllPages();
|
uiLogic()->onUpdateAllPages();
|
||||||
|
|
||||||
emit uiLogic()->goToPage(Page::ServerContainers);
|
emit uiLogic()->goToPage(Page::ServerContainers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StartPageLogic::importConnectionFromCode(QString code)
|
||||||
|
{
|
||||||
|
code.replace("vpn://", "");
|
||||||
|
QByteArray ba = QByteArray::fromBase64(code.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||||
|
|
||||||
|
QByteArray ba_uncompressed = qUncompress(ba);
|
||||||
|
if (!ba_uncompressed.isEmpty()) {
|
||||||
|
ba = ba_uncompressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject o;
|
||||||
|
o = QJsonDocument::fromJson(ba).object();
|
||||||
|
if (!o.isEmpty()) {
|
||||||
|
return importConnection(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
o = QJsonDocument::fromBinaryData(ba).object();
|
||||||
|
if (!o.isEmpty()) {
|
||||||
|
return importConnection(o);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StartPageLogic::importConnectionFromQr(const QByteArray &data)
|
||||||
|
{
|
||||||
|
qDebug() << "StartPageLogic::importConnectionFromQr" << data;
|
||||||
|
QJsonObject dataObj = QJsonDocument::fromJson(data).object();
|
||||||
|
if (!dataObj.isEmpty()) {
|
||||||
|
return importConnection(dataObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray ba_uncompressed = qUncompress(data);
|
||||||
|
if (!ba_uncompressed.isEmpty()) {
|
||||||
|
return importConnection(QJsonDocument::fromJson(ba_uncompressed).object());
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,11 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void onPushButtonConnect();
|
Q_INVOKABLE void onPushButtonConnect();
|
||||||
Q_INVOKABLE void onPushButtonImport();
|
Q_INVOKABLE void onPushButtonImport();
|
||||||
|
Q_INVOKABLE void onPushButtonImportOpenFile();
|
||||||
|
|
||||||
|
bool importConnection(const QJsonObject &profile);
|
||||||
|
bool importConnectionFromCode(QString code);
|
||||||
|
bool importConnectionFromQr(const QByteArray &data);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StartPageLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
explicit StartPageLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "vpnconnection.h"
|
#include "vpnconnection.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "../uilogic.h"
|
#include "../uilogic.h"
|
||||||
|
#include "defines.h"
|
||||||
|
|
||||||
|
|
||||||
VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
|
VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
|
||||||
|
@ -13,7 +14,6 @@ VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
|
||||||
m_radioButtonVpnModeAllSitesChecked{true},
|
m_radioButtonVpnModeAllSitesChecked{true},
|
||||||
m_radioButtonVpnModeForwardSitesChecked{false},
|
m_radioButtonVpnModeForwardSitesChecked{false},
|
||||||
m_radioButtonVpnModeExceptSitesChecked{false},
|
m_radioButtonVpnModeExceptSitesChecked{false},
|
||||||
m_pushButtonVpnAddSiteEnabled{true},
|
|
||||||
|
|
||||||
m_labelSpeedReceivedText{tr("0 Mbps")},
|
m_labelSpeedReceivedText{tr("0 Mbps")},
|
||||||
m_labelSpeedSentText{tr("0 Mbps")},
|
m_labelSpeedSentText{tr("0 Mbps")},
|
||||||
|
@ -42,7 +42,6 @@ void VpnLogic::onUpdatePage()
|
||||||
set_radioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites);
|
set_radioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites);
|
||||||
set_radioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites);
|
set_radioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites);
|
||||||
set_radioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites);
|
set_radioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites);
|
||||||
set_pushButtonVpnAddSiteEnabled(mode != Settings::VpnAllSites);
|
|
||||||
|
|
||||||
const QJsonObject &server = uiLogic()->m_settings.defaultServer();
|
const QJsonObject &server = uiLogic()->m_settings.defaultServer();
|
||||||
QString serverString = QString("%2 (%3)")
|
QString serverString = QString("%2 (%3)")
|
||||||
|
@ -53,22 +52,35 @@ void VpnLogic::onUpdatePage()
|
||||||
DockerContainer selectedContainer = m_settings.defaultContainer(m_settings.defaultServerIndex());
|
DockerContainer selectedContainer = m_settings.defaultContainer(m_settings.defaultServerIndex());
|
||||||
QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer);
|
QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer);
|
||||||
set_labelCurrentService(selectedContainerName);
|
set_labelCurrentService(selectedContainerName);
|
||||||
|
|
||||||
|
set_isContainerWorkingOnPlatform(ContainerProps::isWorkingOnPlatform(selectedContainer));
|
||||||
|
if (!isContainerWorkingOnPlatform()) {
|
||||||
|
set_labelErrorText(tr("AmneziaVPN not supporting selected protocol on this device. Select another protocol."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
set_labelErrorText("");
|
||||||
|
}
|
||||||
|
QString ver = QString("v. %2").arg(QString(APP_MAJOR_VERSION));
|
||||||
|
set_labelVersionText(ver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VpnLogic::onRadioButtonVpnModeAllSitesClicked()
|
void VpnLogic::onRadioButtonVpnModeAllSitesClicked()
|
||||||
{
|
{
|
||||||
m_settings.setRouteMode(Settings::VpnAllSites);
|
m_settings.setRouteMode(Settings::VpnAllSites);
|
||||||
|
onUpdatePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VpnLogic::onRadioButtonVpnModeForwardSitesClicked()
|
void VpnLogic::onRadioButtonVpnModeForwardSitesClicked()
|
||||||
{
|
{
|
||||||
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
||||||
|
onUpdatePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VpnLogic::onRadioButtonVpnModeExceptSitesClicked()
|
void VpnLogic::onRadioButtonVpnModeExceptSitesClicked()
|
||||||
{
|
{
|
||||||
m_settings.setRouteMode(Settings::VpnAllExceptSites);
|
m_settings.setRouteMode(Settings::VpnAllExceptSites);
|
||||||
|
onUpdatePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VpnLogic::onBytesChanged(quint64 receivedData, quint64 sentData)
|
void VpnLogic::onBytesChanged(quint64 receivedData, quint64 sentData)
|
||||||
|
|
|
@ -19,8 +19,10 @@ class VpnLogic : public PageLogicBase
|
||||||
AUTO_PROPERTY(bool, pushButtonConnectEnabled)
|
AUTO_PROPERTY(bool, pushButtonConnectEnabled)
|
||||||
AUTO_PROPERTY(bool, pushButtonConnectVisible)
|
AUTO_PROPERTY(bool, pushButtonConnectVisible)
|
||||||
AUTO_PROPERTY(bool, widgetVpnModeEnabled)
|
AUTO_PROPERTY(bool, widgetVpnModeEnabled)
|
||||||
|
AUTO_PROPERTY(bool, isContainerWorkingOnPlatform)
|
||||||
|
|
||||||
AUTO_PROPERTY(QString, labelErrorText)
|
AUTO_PROPERTY(QString, labelErrorText)
|
||||||
AUTO_PROPERTY(bool, pushButtonVpnAddSiteEnabled)
|
AUTO_PROPERTY(QString, labelVersionText)
|
||||||
|
|
||||||
AUTO_PROPERTY(bool, radioButtonVpnModeAllSitesChecked)
|
AUTO_PROPERTY(bool, radioButtonVpnModeAllSitesChecked)
|
||||||
AUTO_PROPERTY(bool, radioButtonVpnModeForwardSitesChecked)
|
AUTO_PROPERTY(bool, radioButtonVpnModeForwardSitesChecked)
|
||||||
|
|
|
@ -10,7 +10,13 @@ Item {
|
||||||
property var page: PageEnum.Start
|
property var page: PageEnum.Start
|
||||||
property var logic: UiLogic
|
property var logic: UiLogic
|
||||||
|
|
||||||
|
property bool pageActive: false
|
||||||
|
|
||||||
signal activated(bool reset)
|
signal activated(bool reset)
|
||||||
|
signal deactivated()
|
||||||
|
|
||||||
|
onActivated: pageActive = true
|
||||||
|
onDeactivated: pageActive = false
|
||||||
|
|
||||||
// width: GC.screenWidth
|
// width: GC.screenWidth
|
||||||
// height: GC.screenHeight
|
// height: GC.screenHeight
|
||||||
|
|
163
client/ui/qml/Pages/PageQrDecoder.qml
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.12
|
||||||
|
import PageEnum 1.0
|
||||||
|
import QtMultimedia 5.5
|
||||||
|
import QZXing 3.2
|
||||||
|
|
||||||
|
import "./"
|
||||||
|
import "../Controls"
|
||||||
|
import "../Config"
|
||||||
|
|
||||||
|
PageBase {
|
||||||
|
id: root
|
||||||
|
page: PageEnum.QrDecoder
|
||||||
|
logic: QrDecoderLogic
|
||||||
|
|
||||||
|
onDeactivated: {
|
||||||
|
console.debug("Stopping QR decoder")
|
||||||
|
loader.sourceComponent = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
BackButton {
|
||||||
|
}
|
||||||
|
Caption {
|
||||||
|
id: caption
|
||||||
|
text: qsTr("Import configuration")
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: QrDecoderLogic
|
||||||
|
function onStartDecode() {
|
||||||
|
console.debug("Starting QR decoder")
|
||||||
|
loader.sourceComponent = component
|
||||||
|
}
|
||||||
|
function onStopDecode() {
|
||||||
|
console.debug("Stopping QR decoder")
|
||||||
|
loader.sourceComponent = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: loader
|
||||||
|
|
||||||
|
anchors.top: caption.bottom
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: component
|
||||||
|
|
||||||
|
Item {
|
||||||
|
anchors.fill: parent
|
||||||
|
Camera
|
||||||
|
{
|
||||||
|
id:camera
|
||||||
|
focus {
|
||||||
|
focusMode: CameraFocus.FocusContinuous
|
||||||
|
focusPointMode: CameraFocus.FocusPointAuto
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoOutput
|
||||||
|
{
|
||||||
|
id: videoOutput
|
||||||
|
source: camera
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
autoOrientation: true
|
||||||
|
fillMode: VideoOutput.PreserveAspectFit
|
||||||
|
filters: [ zxingFilter ]
|
||||||
|
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
color: "black"
|
||||||
|
opacity: 0.5
|
||||||
|
width: videoOutput.contentRect.width *0.15
|
||||||
|
height: videoOutput.contentRect.height
|
||||||
|
x: (videoOutput.width - videoOutput.contentRect.width)/2
|
||||||
|
anchors.verticalCenter: videoOutput.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
color: "black"
|
||||||
|
opacity: 0.5
|
||||||
|
width: videoOutput.contentRect.width *0.15
|
||||||
|
height: videoOutput.contentRect.height
|
||||||
|
x: videoOutput.width/2 + videoOutput.contentRect.width/2 - videoOutput.contentRect.width *0.15
|
||||||
|
anchors.verticalCenter: videoOutput.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
color: "black"
|
||||||
|
opacity: 0.5
|
||||||
|
width: videoOutput.contentRect.width *0.7
|
||||||
|
height: videoOutput.contentRect.height *0.15
|
||||||
|
x: (videoOutput.width - videoOutput.contentRect.width)/2 + videoOutput.contentRect.width *0.15
|
||||||
|
y: (videoOutput.height - videoOutput.contentRect.height)/2
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
color: "black"
|
||||||
|
opacity: 0.5
|
||||||
|
width: videoOutput.contentRect.width *0.7
|
||||||
|
height: videoOutput.contentRect.height *0.15
|
||||||
|
x: (videoOutput.width - videoOutput.contentRect.width)/2 + videoOutput.contentRect.width *0.15
|
||||||
|
y: videoOutput.height/2 + videoOutput.contentRect.height/2 - videoOutput.contentRect.height *0.15
|
||||||
|
}
|
||||||
|
|
||||||
|
LabelType {
|
||||||
|
width: parent.width
|
||||||
|
text: qsTr("Decoded QR chunks " + QrDecoderLogic.receivedChunksCount + "/" + QrDecoderLogic.totalChunksCount)
|
||||||
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
visible: QrDecoderLogic.totalChunksCount > 0
|
||||||
|
anchors.horizontalCenter: videoOutput.horizontalCenter
|
||||||
|
y: videoOutput.height/2 + videoOutput.contentRect.height/2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QZXingFilter
|
||||||
|
{
|
||||||
|
id: zxingFilter
|
||||||
|
orientation: videoOutput.orientation
|
||||||
|
captureRect: {
|
||||||
|
// setup bindings
|
||||||
|
videoOutput.contentRect;
|
||||||
|
videoOutput.sourceRect;
|
||||||
|
return videoOutput.mapRectToSource(videoOutput.mapNormalizedRectToItem(Qt.rect(
|
||||||
|
0.15, 0.15, 0.7, 0.7 //0, 0, 1.0, 1.0
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
decoder {
|
||||||
|
enabledDecoders: QZXing.DecoderFormat_QR_CODE
|
||||||
|
|
||||||
|
onTagFound: {
|
||||||
|
QrDecoderLogic.onDetectedQrCode(tag)
|
||||||
|
}
|
||||||
|
|
||||||
|
tryHarder: true
|
||||||
|
}
|
||||||
|
|
||||||
|
property int framesDecoded: 0
|
||||||
|
property real timePerFrameDecode: 0
|
||||||
|
|
||||||
|
onDecodingFinished:
|
||||||
|
{
|
||||||
|
timePerFrameDecode = (decodeTime + framesDecoded * timePerFrameDecode) / (framesDecoded + 1);
|
||||||
|
framesDecoded++;
|
||||||
|
if(succeeded)
|
||||||
|
console.log("frame finished: " + succeeded, decodeTime, timePerFrameDecode, framesDecoded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ PageBase {
|
||||||
|
|
||||||
BackButton {
|
BackButton {
|
||||||
id: back_from_start
|
id: back_from_start
|
||||||
|
visible: pageLoader.depth > 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Caption {
|
Caption {
|
||||||
|
@ -103,12 +104,43 @@ PageBase {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
y: 210
|
y: 210
|
||||||
anchors.top: lineEdit_start_existing_code.bottom
|
anchors.top: lineEdit_start_existing_code.bottom
|
||||||
anchors.topMargin: 40
|
anchors.topMargin: 10
|
||||||
text: qsTr("Connect")
|
text: qsTr("Connect")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
StartPageLogic.onPushButtonImport()
|
StartPageLogic.onPushButtonImport()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BlueButtonType {
|
||||||
|
id: qr_code_import_open
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.top: new_sever_import.bottom
|
||||||
|
anchors.topMargin: 40
|
||||||
|
|
||||||
|
text: qsTr("Open file")
|
||||||
|
visible: StartPageLogic.pushButtonConnectVisible
|
||||||
|
onClicked: {
|
||||||
|
StartPageLogic.onPushButtonImportOpenFile()
|
||||||
|
}
|
||||||
|
enabled: StartPageLogic.pushButtonConnectEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
BlueButtonType {
|
||||||
|
id: qr_code_import
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.top: qr_code_import_open.bottom
|
||||||
|
anchors.topMargin: 10
|
||||||
|
|
||||||
|
text: qsTr("Scan QR code")
|
||||||
|
visible: StartPageLogic.pushButtonConnectVisible
|
||||||
|
onClicked: {
|
||||||
|
UiLogic.goToPage(PageEnum.QrDecoder)
|
||||||
|
}
|
||||||
|
enabled: StartPageLogic.pushButtonConnectEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,8 +256,6 @@ PageBase {
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BlueButtonType {
|
BlueButtonType {
|
||||||
id: new_sever_connect
|
id: new_sever_connect
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
|
@ -20,6 +20,16 @@ PageBase {
|
||||||
source: "qrc:/images/background_connected.png"
|
source: "qrc:/images/background_connected.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LabelType {
|
||||||
|
x: 10
|
||||||
|
y: 5
|
||||||
|
width: 100
|
||||||
|
height: 21
|
||||||
|
text: VpnLogic.labelVersionText
|
||||||
|
color: "#dddddd"
|
||||||
|
font.pixelSize: 12
|
||||||
|
}
|
||||||
|
|
||||||
ImageButtonType {
|
ImageButtonType {
|
||||||
x: parent.width - 40
|
x: parent.width - 40
|
||||||
y: 10
|
y: 10
|
||||||
|
@ -41,7 +51,7 @@ PageBase {
|
||||||
height: width
|
height: width
|
||||||
|
|
||||||
visible: !VpnLogic.pushButtonConnectVisible
|
visible: !VpnLogic.pushButtonConnectVisible
|
||||||
paused: VpnLogic.pushButtonConnectVisible
|
paused: VpnLogic.pushButtonConnectVisible && !root.pageActive
|
||||||
//VisibleBehavior on visible { }
|
//VisibleBehavior on visible { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +71,7 @@ PageBase {
|
||||||
}
|
}
|
||||||
contentItem: Item {}
|
contentItem: Item {}
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
enabled: VpnLogic.pushButtonConnectEnabled
|
enabled: VpnLogic.pushButtonConnectEnabled && VpnLogic.isContainerWorkingOnPlatform
|
||||||
opacity: VpnLogic.pushButtonConnectVisible ? 1 : 0
|
opacity: VpnLogic.pushButtonConnectVisible ? 1 : 0
|
||||||
|
|
||||||
// transitions: Transition {
|
// transitions: Transition {
|
||||||
|
@ -141,11 +151,14 @@ PageBase {
|
||||||
id: error_text
|
id: error_text
|
||||||
anchors.top: layout2.bottom
|
anchors.top: layout2.bottom
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
width: parent.width
|
anchors.topMargin: 20
|
||||||
|
width: parent.width - 20
|
||||||
|
|
||||||
height: 21
|
height: 21
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
text: VpnLogic.labelErrorText
|
text: VpnLogic.labelErrorText
|
||||||
|
color: "red"
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
@ -273,7 +286,7 @@ PageBase {
|
||||||
width: parent.width - 40
|
width: parent.width - 40
|
||||||
height: GC.isMobile() ? 0: 40
|
height: GC.isMobile() ? 0: 40
|
||||||
text: qsTr("+ Add site")
|
text: qsTr("+ Add site")
|
||||||
enabled: VpnLogic.pushButtonVpnAddSiteEnabled
|
enabled: ! VpnLogic.radioButtonVpnModeAllSitesChecked
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: 4
|
radius: 4
|
||||||
|
|
|
@ -33,6 +33,13 @@ PageShareProtocolBase {
|
||||||
contentHeight: content.height + 20
|
contentHeight: content.height + 20
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
|
Behavior on contentY{
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 300
|
||||||
|
easing.type: Easing.InOutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: content
|
id: content
|
||||||
enabled: logic.pageEnabled
|
enabled: logic.pageEnabled
|
||||||
|
@ -73,6 +80,7 @@ New encryption keys pair will be generated.")
|
||||||
ShareConnectionLogic.onPushButtonShareAmneziaGenerateClicked()
|
ShareConnectionLogic.onPushButtonShareAmneziaGenerateClicked()
|
||||||
enabled = true
|
enabled = true
|
||||||
genConfigProcess = false
|
genConfigProcess = false
|
||||||
|
fl.contentY = tfShareCode.mapToItem(fl.contentItem, 0, 0).y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,19 +122,32 @@ New encryption keys pair will be generated.")
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: label_share_code
|
id: image_share_code
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: width
|
Layout.preferredHeight: width
|
||||||
smooth: false
|
smooth: false
|
||||||
source: ShareConnectionLogic.shareAmneziaQrCodeText
|
|
||||||
visible: ShareConnectionLogic.shareAmneziaQrCodeText.length > 0
|
Timer {
|
||||||
|
property int idx: 0
|
||||||
|
interval: 1000
|
||||||
|
running: root.pageActive && ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength > 0
|
||||||
|
repeat: true
|
||||||
|
onTriggered: {
|
||||||
|
idx++
|
||||||
|
if (idx >= ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength) {
|
||||||
|
idx = 0
|
||||||
|
}
|
||||||
|
image_share_code.source = ShareConnectionLogic.shareAmneziaQrCodeTextSeries[idx]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
visible: ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
LabelType {
|
LabelType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: qsTr("Config too long to be displayed as QR code")
|
text: qsTr("Scan QR code using AmneziaVPN mobile")
|
||||||
visible: ShareConnectionLogic.shareAmneziaQrCodeText.length == 0 && tfShareCode.textArea.length > 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ PageShareProtocolBase {
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: content
|
id: content
|
||||||
enabled: logic.pageEnabled
|
enabled: logic.pageEnabled
|
||||||
anchors.top: parent.bottom
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ Window {
|
||||||
UiLogic.onCloseWindow()
|
UiLogic.onCloseWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
//flags: Qt.FramelessWindowHint
|
|
||||||
title: "AmneziaVPN"
|
title: "AmneziaVPN"
|
||||||
|
|
||||||
function gotoPage(type, page, reset, slide) {
|
function gotoPage(type, page, reset, slide) {
|
||||||
|
@ -41,6 +40,9 @@ Window {
|
||||||
|
|
||||||
console.debug("QML gotoPage " + type + " " + page + " " + p_obj)
|
console.debug("QML gotoPage " + type + " " + page + " " + p_obj)
|
||||||
|
|
||||||
|
if (pageLoader.depth > 0) {
|
||||||
|
pageLoader.currentItem.deactivated()
|
||||||
|
}
|
||||||
|
|
||||||
if (slide) {
|
if (slide) {
|
||||||
pageLoader.push(p_obj, {}, StackView.PushTransition)
|
pageLoader.push(p_obj, {}, StackView.PushTransition)
|
||||||
|
@ -59,10 +61,15 @@ Window {
|
||||||
if (pageLoader.depth <= 1) {
|
if (pageLoader.depth <= 1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
pageLoader.currentItem.deactivated()
|
||||||
pageLoader.pop()
|
pageLoader.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_start_page(page, slide) {
|
function set_start_page(page, slide) {
|
||||||
|
if (pageLoader.depth > 0) {
|
||||||
|
pageLoader.currentItem.deactivated()
|
||||||
|
}
|
||||||
|
|
||||||
pageLoader.clear()
|
pageLoader.clear()
|
||||||
if (slide) {
|
if (slide) {
|
||||||
pageLoader.push(pages[page], {}, StackView.PushTransition)
|
pageLoader.push(pages[page], {}, StackView.PushTransition)
|
||||||
|
@ -104,8 +111,6 @@ Window {
|
||||||
color: "white"
|
color: "white"
|
||||||
}
|
}
|
||||||
|
|
||||||
//PageShareProtoAmnezia {}
|
|
||||||
|
|
||||||
StackView {
|
StackView {
|
||||||
id: pageLoader
|
id: pageLoader
|
||||||
y: GC.isDesktop() ? titleBar.height : 0
|
y: GC.isDesktop() ? titleBar.height : 0
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QFile>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
|
@ -16,7 +17,6 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QSaveFile>
|
|
||||||
|
|
||||||
#include "configurators/cloak_configurator.h"
|
#include "configurators/cloak_configurator.h"
|
||||||
#include "configurators/vpn_configurator.h"
|
#include "configurators/vpn_configurator.h"
|
||||||
|
@ -51,8 +51,9 @@
|
||||||
#include "pages_logic/AppSettingsLogic.h"
|
#include "pages_logic/AppSettingsLogic.h"
|
||||||
#include "pages_logic/GeneralSettingsLogic.h"
|
#include "pages_logic/GeneralSettingsLogic.h"
|
||||||
#include "pages_logic/NetworkSettingsLogic.h"
|
#include "pages_logic/NetworkSettingsLogic.h"
|
||||||
#include "pages_logic/ServerConfiguringProgressLogic.h"
|
|
||||||
#include "pages_logic/NewServerProtocolsLogic.h"
|
#include "pages_logic/NewServerProtocolsLogic.h"
|
||||||
|
#include "pages_logic/QrDecoderLogic.h"
|
||||||
|
#include "pages_logic/ServerConfiguringProgressLogic.h"
|
||||||
#include "pages_logic/ServerListLogic.h"
|
#include "pages_logic/ServerListLogic.h"
|
||||||
#include "pages_logic/ServerSettingsLogic.h"
|
#include "pages_logic/ServerSettingsLogic.h"
|
||||||
#include "pages_logic/ServerContainersLogic.h"
|
#include "pages_logic/ServerContainersLogic.h"
|
||||||
|
@ -84,8 +85,9 @@ UiLogic::UiLogic(QObject *parent) :
|
||||||
m_appSettingsLogic = new AppSettingsLogic(this);
|
m_appSettingsLogic = new AppSettingsLogic(this);
|
||||||
m_generalSettingsLogic = new GeneralSettingsLogic(this);
|
m_generalSettingsLogic = new GeneralSettingsLogic(this);
|
||||||
m_networkSettingsLogic = new NetworkSettingsLogic(this);
|
m_networkSettingsLogic = new NetworkSettingsLogic(this);
|
||||||
m_serverConfiguringProgressLogic = new ServerConfiguringProgressLogic(this);
|
|
||||||
m_newServerProtocolsLogic = new NewServerProtocolsLogic(this);
|
m_newServerProtocolsLogic = new NewServerProtocolsLogic(this);
|
||||||
|
m_qrDecoderLogic = new QrDecoderLogic(this);
|
||||||
|
m_serverConfiguringProgressLogic = new ServerConfiguringProgressLogic(this);
|
||||||
m_serverListLogic = new ServerListLogic(this);
|
m_serverListLogic = new ServerListLogic(this);
|
||||||
m_serverSettingsLogic = new ServerSettingsLogic(this);
|
m_serverSettingsLogic = new ServerSettingsLogic(this);
|
||||||
m_serverprotocolsLogic = new ServerContainersLogic(this);
|
m_serverprotocolsLogic = new ServerContainersLogic(this);
|
||||||
|
@ -121,9 +123,9 @@ UiLogic::~UiLogic()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_vpnConnection->deleteLater();
|
||||||
m_vpnConnectionThread.quit();
|
m_vpnConnectionThread.quit();
|
||||||
m_vpnConnectionThread.wait(3000);
|
m_vpnConnectionThread.wait(3000);
|
||||||
delete m_vpnConnection;
|
|
||||||
|
|
||||||
qDebug() << "Application closed";
|
qDebug() << "Application closed";
|
||||||
}
|
}
|
||||||
|
@ -263,9 +265,6 @@ void UiLogic::keyPressEvent(Qt::Key key)
|
||||||
case Qt::Key_Q:
|
case Qt::Key_Q:
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
break;
|
break;
|
||||||
// case Qt::Key_0:
|
|
||||||
// *((char*)-1) = 'x';
|
|
||||||
// break;
|
|
||||||
case Qt::Key_H:
|
case Qt::Key_H:
|
||||||
selectedServerIndex = m_settings.defaultServerIndex();
|
selectedServerIndex = m_settings.defaultServerIndex();
|
||||||
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
|
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
|
||||||
|
@ -645,38 +644,36 @@ PageEnumNS::Page UiLogic::currentPage()
|
||||||
return static_cast<PageEnumNS::Page>(currentPageValue());
|
return static_cast<PageEnumNS::Page>(currentPageValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UiLogic::saveTextFile(const QString& desc, const QString& ext, const QString& data)
|
void UiLogic::saveTextFile(const QString& desc, const QString& ext, const QString& data)
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(nullptr, desc,
|
QString fileName = QFileDialog::getSaveFileName(nullptr, desc,
|
||||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), ext);
|
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), ext);
|
||||||
|
|
||||||
if (fileName.isEmpty()) return false;
|
if (fileName.isEmpty()) return;
|
||||||
|
|
||||||
QSaveFile save(fileName);
|
QFile save(fileName);
|
||||||
save.open(QIODevice::WriteOnly);
|
save.open(QIODevice::WriteOnly);
|
||||||
save.write(data.toUtf8());
|
save.write(data.toUtf8());
|
||||||
|
save.close();
|
||||||
|
|
||||||
QFileInfo fi(fileName);
|
QFileInfo fi(fileName);
|
||||||
QDesktopServices::openUrl(fi.absoluteDir().absolutePath());
|
QDesktopServices::openUrl(fi.absoluteDir().absolutePath());
|
||||||
|
|
||||||
return save.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UiLogic::saveBinaryFile(const QString &desc, const QString &ext, const QString &data)
|
void UiLogic::saveBinaryFile(const QString &desc, const QString &ext, const QString &data)
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(nullptr, desc,
|
QString fileName = QFileDialog::getSaveFileName(nullptr, desc,
|
||||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), ext);
|
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), ext);
|
||||||
|
|
||||||
if (fileName.isEmpty()) return false;
|
if (fileName.isEmpty()) return;
|
||||||
|
|
||||||
QSaveFile save(fileName);
|
QFile save(fileName);
|
||||||
save.open(QIODevice::WriteOnly);
|
save.open(QIODevice::WriteOnly);
|
||||||
save.write(QByteArray::fromBase64(data.toUtf8()));
|
save.write(QByteArray::fromBase64(data.toUtf8()));
|
||||||
|
save.close();
|
||||||
|
|
||||||
QFileInfo fi(fileName);
|
QFileInfo fi(fileName);
|
||||||
QDesktopServices::openUrl(fi.absoluteDir().absolutePath());
|
QDesktopServices::openUrl(fi.absoluteDir().absolutePath());
|
||||||
|
|
||||||
return save.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiLogic::copyToClipboard(const QString &text)
|
void UiLogic::copyToClipboard(const QString &text)
|
||||||
|
|
|
@ -22,6 +22,7 @@ class AppSettingsLogic;
|
||||||
class GeneralSettingsLogic;
|
class GeneralSettingsLogic;
|
||||||
class NetworkSettingsLogic;
|
class NetworkSettingsLogic;
|
||||||
class NewServerProtocolsLogic;
|
class NewServerProtocolsLogic;
|
||||||
|
class QrDecoderLogic;
|
||||||
class ServerConfiguringProgressLogic;
|
class ServerConfiguringProgressLogic;
|
||||||
class ServerListLogic;
|
class ServerListLogic;
|
||||||
class ServerSettingsLogic;
|
class ServerSettingsLogic;
|
||||||
|
@ -99,8 +100,8 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void keyPressEvent(Qt::Key key);
|
Q_INVOKABLE void keyPressEvent(Qt::Key key);
|
||||||
|
|
||||||
Q_INVOKABLE bool saveTextFile(const QString& desc, const QString& ext, const QString& data);
|
Q_INVOKABLE void saveTextFile(const QString& desc, const QString& ext, const QString& data);
|
||||||
Q_INVOKABLE bool saveBinaryFile(const QString& desc, const QString& ext, const QString& data);
|
Q_INVOKABLE void saveBinaryFile(const QString& desc, const QString& ext, const QString& data);
|
||||||
Q_INVOKABLE void copyToClipboard(const QString& text);
|
Q_INVOKABLE void copyToClipboard(const QString& text);
|
||||||
|
|
||||||
QString getDialogConnectErrorText() const;
|
QString getDialogConnectErrorText() const;
|
||||||
|
@ -167,8 +168,9 @@ public:
|
||||||
AppSettingsLogic *appSettingsLogic() { return m_appSettingsLogic; }
|
AppSettingsLogic *appSettingsLogic() { return m_appSettingsLogic; }
|
||||||
GeneralSettingsLogic *generalSettingsLogic() { return m_generalSettingsLogic; }
|
GeneralSettingsLogic *generalSettingsLogic() { return m_generalSettingsLogic; }
|
||||||
NetworkSettingsLogic *networkSettingsLogic() { return m_networkSettingsLogic; }
|
NetworkSettingsLogic *networkSettingsLogic() { return m_networkSettingsLogic; }
|
||||||
ServerConfiguringProgressLogic *serverConfiguringProgressLogic() { return m_serverConfiguringProgressLogic; }
|
|
||||||
NewServerProtocolsLogic *newServerProtocolsLogic() { return m_newServerProtocolsLogic; }
|
NewServerProtocolsLogic *newServerProtocolsLogic() { return m_newServerProtocolsLogic; }
|
||||||
|
QrDecoderLogic *qrDecoderLogic() { return m_qrDecoderLogic; }
|
||||||
|
ServerConfiguringProgressLogic *serverConfiguringProgressLogic() { return m_serverConfiguringProgressLogic; }
|
||||||
ServerListLogic *serverListLogic() { return m_serverListLogic; }
|
ServerListLogic *serverListLogic() { return m_serverListLogic; }
|
||||||
ServerSettingsLogic *serverSettingsLogic() { return m_serverSettingsLogic; }
|
ServerSettingsLogic *serverSettingsLogic() { return m_serverSettingsLogic; }
|
||||||
ServerContainersLogic *serverprotocolsLogic() { return m_serverprotocolsLogic; }
|
ServerContainersLogic *serverprotocolsLogic() { return m_serverprotocolsLogic; }
|
||||||
|
@ -191,8 +193,9 @@ private:
|
||||||
AppSettingsLogic *m_appSettingsLogic;
|
AppSettingsLogic *m_appSettingsLogic;
|
||||||
GeneralSettingsLogic *m_generalSettingsLogic;
|
GeneralSettingsLogic *m_generalSettingsLogic;
|
||||||
NetworkSettingsLogic *m_networkSettingsLogic;
|
NetworkSettingsLogic *m_networkSettingsLogic;
|
||||||
ServerConfiguringProgressLogic *m_serverConfiguringProgressLogic;
|
|
||||||
NewServerProtocolsLogic *m_newServerProtocolsLogic;
|
NewServerProtocolsLogic *m_newServerProtocolsLogic;
|
||||||
|
QrDecoderLogic *m_qrDecoderLogic;
|
||||||
|
ServerConfiguringProgressLogic *m_serverConfiguringProgressLogic;
|
||||||
ServerListLogic *m_serverListLogic;
|
ServerListLogic *m_serverListLogic;
|
||||||
ServerSettingsLogic *m_serverSettingsLogic;
|
ServerSettingsLogic *m_serverSettingsLogic;
|
||||||
ServerContainersLogic *m_serverprotocolsLogic;
|
ServerContainersLogic *m_serverprotocolsLogic;
|
||||||
|
|
|
@ -26,16 +26,16 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "vpnconnection.h"
|
#include "vpnconnection.h"
|
||||||
|
|
||||||
VpnConnection::VpnConnection(QObject* parent) : QObject(parent)
|
VpnConnection::VpnConnection(QObject* parent) : QObject(parent),
|
||||||
{
|
m_settings(this)
|
||||||
|
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VpnConnection::~VpnConnection()
|
VpnConnection::~VpnConnection()
|
||||||
{
|
{
|
||||||
//qDebug() << "VpnConnection::~VpnConnection() 1";
|
m_vpnProtocol->deleteLater();
|
||||||
m_vpnProtocol.clear();
|
m_vpnProtocol.clear();
|
||||||
//qDebug() << "VpnConnection::~VpnConnection() 2";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VpnConnection::onBytesChanged(quint64 receivedBytes, quint64 sentBytes)
|
void VpnConnection::onBytesChanged(quint64 receivedBytes, quint64 sentBytes)
|
||||||
|
@ -47,6 +47,7 @@ void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState sta
|
||||||
{
|
{
|
||||||
if (IpcClient::Interface()) {
|
if (IpcClient::Interface()) {
|
||||||
if (state == VpnProtocol::Connected){
|
if (state == VpnProtocol::Connected){
|
||||||
|
IpcClient::Interface()->resetIpStack();
|
||||||
IpcClient::Interface()->flushDns();
|
IpcClient::Interface()->flushDns();
|
||||||
|
|
||||||
if (m_settings.routeMode() != Settings::VpnAllSites) {
|
if (m_settings.routeMode() != Settings::VpnAllSites) {
|
||||||
|
@ -219,7 +220,7 @@ void VpnConnection::connectToVpn(int serverIndex,
|
||||||
|
|
||||||
#if !defined (Q_OS_ANDROID) && !defined (Q_OS_IOS)
|
#if !defined (Q_OS_ANDROID) && !defined (Q_OS_IOS)
|
||||||
if (!m_IpcClient) {
|
if (!m_IpcClient) {
|
||||||
m_IpcClient = new IpcClient;
|
m_IpcClient = new IpcClient(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_IpcClient->isSocketConnected()) {
|
if (!m_IpcClient->isSocketConnected()) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ class IpcInterface
|
||||||
SLOT( bool clearSavedRoutes() );
|
SLOT( bool clearSavedRoutes() );
|
||||||
SLOT( bool routeDeleteList(const QString &gw, const QStringList &ip) );
|
SLOT( bool routeDeleteList(const QString &gw, const QStringList &ip) );
|
||||||
SLOT( void flushDns() );
|
SLOT( void flushDns() );
|
||||||
|
SLOT( void resetIpStack() );
|
||||||
|
|
||||||
SLOT( bool checkAndInstallDriver() );
|
SLOT( bool checkAndInstallDriver() );
|
||||||
SLOT( QStringList getTapList() );
|
SLOT( QStringList getTapList() );
|
||||||
|
|
|
@ -83,6 +83,11 @@ void IpcServer::flushDns()
|
||||||
return Router::flushDns();
|
return Router::flushDns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IpcServer::resetIpStack()
|
||||||
|
{
|
||||||
|
Router::resetIpStack();
|
||||||
|
}
|
||||||
|
|
||||||
bool IpcServer::checkAndInstallDriver()
|
bool IpcServer::checkAndInstallDriver()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
|
@ -20,6 +20,7 @@ public:
|
||||||
virtual bool clearSavedRoutes() override;
|
virtual bool clearSavedRoutes() override;
|
||||||
virtual bool routeDeleteList(const QString &gw, const QStringList &ips) override;
|
virtual bool routeDeleteList(const QString &gw, const QStringList &ips) override;
|
||||||
virtual void flushDns() override;
|
virtual void flushDns() override;
|
||||||
|
virtual void resetIpStack() override;
|
||||||
virtual bool checkAndInstallDriver() override;
|
virtual bool checkAndInstallDriver() override;
|
||||||
virtual QStringList getTapList() override;
|
virtual QStringList getTapList() override;
|
||||||
|
|
||||||
|
|
|
@ -53,3 +53,14 @@ void Router::flushDns()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Router::resetIpStack()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
RouterWin::Instance().resetIpStack();
|
||||||
|
#elif defined (Q_OS_MAC)
|
||||||
|
// todo fixme
|
||||||
|
#elif defined Q_OS_LINUX
|
||||||
|
// todo fixme
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
static bool clearSavedRoutes();
|
static bool clearSavedRoutes();
|
||||||
static int routeDeleteList(const QString &gw, const QStringList &ips);
|
static int routeDeleteList(const QString &gw, const QStringList &ips);
|
||||||
static void flushDns();
|
static void flushDns();
|
||||||
|
static void resetIpStack();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ROUTER_H
|
#endif // ROUTER_H
|
||||||
|
|
|
@ -289,6 +289,27 @@ void RouterWin::flushDns()
|
||||||
//qDebug().noquote() << "OUTPUT ipconfig /flushdns: " + p.readAll();
|
//qDebug().noquote() << "OUTPUT ipconfig /flushdns: " + p.readAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RouterWin::resetIpStack()
|
||||||
|
{
|
||||||
|
// {
|
||||||
|
// QProcess p;
|
||||||
|
// QString command = QString("ipconfig /release");
|
||||||
|
// p.start(command);
|
||||||
|
// }
|
||||||
|
{
|
||||||
|
QProcess p;
|
||||||
|
QString command = QString("netsh int ip reset");
|
||||||
|
p.start(command);
|
||||||
|
p.waitForFinished();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QProcess p;
|
||||||
|
QString command = QString("netsh winsock reset");
|
||||||
|
p.start(command);
|
||||||
|
p.waitForFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RouterWin::suspendWcmSvc(bool suspend)
|
void RouterWin::suspendWcmSvc(bool suspend)
|
||||||
{
|
{
|
||||||
if (suspend == m_suspended) return;
|
if (suspend == m_suspended) return;
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
bool clearSavedRoutes();
|
bool clearSavedRoutes();
|
||||||
int routeDeleteList(const QString &gw, const QStringList &ips);
|
int routeDeleteList(const QString &gw, const QStringList &ips);
|
||||||
void flushDns();
|
void flushDns();
|
||||||
|
void resetIpStack();
|
||||||
|
|
||||||
void suspendWcmSvc(bool suspend);
|
void suspendWcmSvc(bool suspend);
|
||||||
|
|
||||||
|
|