diff --git a/.gitattributes b/.gitattributes index 7dc1509d..c96e19e3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,4 @@ deploy/data/windows/x64/tap/windows_7/OemVista.inf eol=crlf deploy/data/windows/x64/tap/windows_10/OemVista.inf eol=crlf deploy/data/windows/x32/tap/windows_7/OemVista.inf eol=crlf deploy/data/windows/x32/tap/windows_10/OemVista.inf eol=crlf +client/3rd/* linguist-vendored diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ca7ac87d..e5cea7a3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest env: - QT_VERSION: 6.4.1 + QT_VERSION: 6.5.0 QIF_VERSION: 4.5 steps: @@ -63,7 +63,7 @@ jobs: runs-on: windows-latest env: - QT_VERSION: 6.4.1 + QT_VERSION: 6.5.0 QIF_VERSION: 4.5 BUILD_ARCH: 64 @@ -124,8 +124,7 @@ jobs: runs-on: macos-latest env: - QT_VERSION: 6.4.1 - QIF_VERSION: 4.4 + QT_VERSION: 6.5.0 steps: - name: 'Setup xcode' @@ -139,18 +138,18 @@ jobs: version: ${{ env.QT_VERSION }} host: 'mac' target: 'desktop' + modules: 'qtremoteobjects qt5compat qtshadertools qtmultimedia' arch: 'clang_64' - modules: 'qtremoteobjects qt5compat qtshadertools' dir: ${{ runner.temp }} set-env: 'true' - - name: 'Install ios Qt' + - name: 'Install iOS Qt' uses: jurplel/install-qt-action@v3 with: version: ${{ env.QT_VERSION }} host: 'mac' target: 'ios' - modules: 'qtremoteobjects qt5compat qtshadertools' + modules: 'qtremoteobjects qt5compat qtshadertools qtmultimedia' dir: ${{ runner.temp }} setup-python: 'true' set-env: 'true' @@ -200,7 +199,7 @@ jobs: runs-on: macos-latest env: - QT_VERSION: 6.4.1 + QT_VERSION: 6.5.0 QIF_VERSION: 4.5 steps: @@ -263,8 +262,7 @@ jobs: arch: ['android_x86_64', 'android_x86'] #, 'android_armv7', 'android_arm64_v8a'] env: - QT_VERSION: 6.4.1 - QIF_VERSION: 4.5 + QT_VERSION: 6.5.0 steps: - name: 'Install desktop Qt' @@ -293,6 +291,11 @@ jobs: set-env: 'true' extra: '--external 7z' + - name: 'Install GO' + uses: actions/setup-go@v2 + with: + go-version: 1.17 + - name: 'Get sources' uses: actions/checkout@v3 with: diff --git a/.gitignore b/.gitignore index 562b2ee7..88a3b397 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,4 @@ captures/ client/3rd/ShadowSocks/ss_ios.xcconfig # UML generated pics -out/ \ No newline at end of file +out/ diff --git a/.gitmodules b/.gitmodules index b70375ba..007eb375 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/WireGuard/wireguard-apple [submodule "client/3rd/OpenVPNAdapter"] path = client/3rd/OpenVPNAdapter - url = https://github.com/ss-abramchuk/OpenVPNAdapter.git + url = https://github.com/amnezia-vpn/OpenVPNAdapter.git [submodule "client/3rd/ShadowPath"] path = client/3rd/ShadowPath url = https://github.com/qman9501/ShadowPath @@ -28,12 +28,33 @@ [submodule "client/3rd/zlib"] path = client/3rd/zlib url = https://github.com/madler/zlib.git -[submodule "deploy/amnezia-ios-certificates"] - path = deploy/amnezia-ios-certificates - url = https://github.com/amnezia-vpn/amnezia-ios-certificates.git [submodule "client/3rd/SortFilterProxyModel"] path = client/3rd/SortFilterProxyModel url = https://github.com/mitchcurtis/SortFilterProxyModel.git +[submodule "client/android/cpp/openvpn3"] + path = client/android/cpp/openvpn3 + url = https://github.com/amnezia-vpn/openvpn3.git +[submodule "client/android/cpp/asio"] + path = client/android/cpp/asio + url = https://github.com/chriskohlhoff/asio +[submodule "client/android/cpp/lz4"] + path = client/android/cpp/lz4 + url = https://github.com/lz4/lz4.git +[submodule "client/android/cpp/mbedtls"] + path = client/android/cpp/mbedtls + url = https://github.com/ARMmbed/mbedtls.git +[submodule "client/android/cpp/openvpn"] + path = client/android/cpp/openvpn + url = https://github.com/schwabe/openvpn.git +[submodule "client/android/cpp/openssl"] + path = client/android/cpp/openssl + url = https://github.com/schwabe/platform_external_openssl.git +[submodule "client/android/cpp/cloak"] + path = client/android/cpp/cloak + url = https://github.com/amnezia-vpn/Cloak +[submodule "client/android/cpp/lzo"] + path = client/android/cpp/lzo + url = https://github.com/amnezia-vpn/lzo.git [submodule "client/3rd/mbedtls"] path = client/3rd/mbedtls url = https://github.com/Mbed-TLS/mbedtls.git diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 00000000..2defeb74 --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,47 @@ +FROM gitpod/workspace-full-vnc + +USER gitpod + +RUN sudo apt-get -q update \ + && sudo apt-get install -yq \ + build-essential \ + libgl1-mesa-dev \ + libgstreamer-gl1.0-0 \ + libpulse-dev \ + libsecret-1-dev \ + libxcb-glx0 \ + libxcb-icccm4 \ + libxcb-image0 \ + libxcb-keysyms1 \ + libxcb-randr0 \ + libxcb-render-util0 \ + libxcb-render0 \ + libxcb-shape0 \ + libxcb-shm0 \ + libxcb-sync1 \ + libxcb-util1 \ + libxcb-xfixes0 \ + libxcb-xinerama0 \ + libxcb1 \ + libxkbcommon-dev \ + libxkbcommon-x11-0 \ + libxcb-xkb-dev \ + p7zip-full \ + && sudo rm -rf /var/lib/apt/lists/* + +RUN sudo pip3 install aqtinstall + +ARG QT_VERSION=6.4.1 +ARG QT_ARCH=gcc_64 + +ARG QT_DIR=/opt/qt +RUN sudo aqt install-qt --outputdir ${QT_DIR} linux desktop ${QT_VERSION} ${QT_ARCH} --modules \ + qtremoteobjects \ + qt5compat \ + qtshadertools +ENV QT_BIN_DIR=${QT_DIR}/${QT_VERSION}/${QT_ARCH}/bin + +ARG QIF_VERSION=4.5 +ARG QIF_DIR=/opt/qif +RUN sudo aqt install-tool --outputdir ${QIF_DIR} linux desktop tools_ifw +ENV QIF_BIN_DIR=${QIF_DIR}/Tools/QtInstallerFramework/${QIF_VERSION}/bin diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 00000000..20136846 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,8 @@ +tasks: +- init: >- + deploy/build_linux.sh +image: + file: .gitpod.Dockerfile +vscode: + extensions: + - llvm-vs-code-extensions.vscode-clangd diff --git a/AmneziaVPN.pro b/AmneziaVPN.pro deleted file mode 100644 index eea6d034..00000000 --- a/AmneziaVPN.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = client - -!ios:!android { - SUBDIRS += service -} diff --git a/CMakeLists.txt b/CMakeLists.txt index f1e5d37c..c8b27351 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,13 @@ cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR) set(PROJECT AmneziaVPN) -project(${PROJECT}) + +project(${PROJECT} VERSION 3.0.7.5 + DESCRIPTION "AmneziaVPN" + HOMEPAGE_URL "https://amnezia.org/" +) +set(RELEASE_DATE "2023-05-15") +set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH}) if(ANDROID) set(QT_ANDROID_BUILD_ALL_ABIS ON) @@ -15,4 +21,6 @@ add_subdirectory(client) if(NOT IOS AND NOT ANDROID) add_subdirectory(service) + + include(${CMAKE_SOURCE_DIR}/deploy/installer/config.cmake) endif() diff --git a/README.md b/README.md index 698aba76..6e77e198 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,24 @@ # Amnezia VPN ## _The best client for self-hosted VPN_ -[![Build Status](https://github.com/amnezia-vpn/desktop-client/actions/workflows/deploy.yml/badge.svg?branch=dev)] +[![Build Status](https://github.com/amnezia-vpn/amnezia-client/actions/workflows/deploy.yml/badge.svg?branch=dev)](https://github.com/amnezia-vpn/amnezia-client/actions/workflows/deploy.yml?query=branch:dev) +[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/amnezia-vpn/amnezia-client) -Amnezia is a VPN client with the key feature of deploying your own VPN server on you virtual server. +Amnezia is an open-source VPN client, with a key feature that enables you to deploy your own VPN server on your server. ## Features -- Very easy to use - enter your ip address, ssh login and password, and Amnezia client will automatically install VPN docker containers to your server and connect to VPN. -- OpenVPN and OpenVPN over ShadowSocks protocols support. -- Custom VPN routing mode support - add any sites to client to enable VPN only for them. -- Windows and MacOS support. -- Unsecure sharing connection profile for family use. +- Very easy to use - enter your ip address, ssh login and password, and Amnezia will automatically install VPN docker containers to your server and connect to VPN. +- OpenVPN, ShadowSocks, WireGuard, IKEv2 protocols support. +- Masking VPN with OpenVPN over Cloak plugin +- Split tunneling support - add any sites to client to enable VPN only for them (only for desktops) +- Windows, MacOS, Linux, Android, iOS releases. + +## Links +[https://amnezia.org](https://amnezia.org) - project website +[https://www.reddit.com/r/AmneziaVPN](https://www.reddit.com/r/AmneziaVPN) - Reddit +[https://t.me/amnezia_vpn_en](https://t.me/amnezia_vpn_en) - Telegram support channel (English) +[https://t.me/amnezia_vpn](https://t.me/amnezia_vpn) - Telegram support channel (Russian) +[https://signal.group/...](https://signal.group/#CjQKIB2gUf8QH_IXnOJMGQWMDjYz9cNfmRQipGWLFiIgc4MwEhAKBONrSiWHvoUFbbD0xwdh) - Signal channel ## Tech @@ -20,7 +28,7 @@ AmneziaVPN uses a number of open source projects to work: - [OpenVPN](https://openvpn.net/) - [ShadowSocks](https://shadowsocks.org/) - [Qt](https://www.qt.io/) -- [QtSsh](https://github.com/jaredtao/QtSsh) - forked form Qt Creator +- [LibSsh](https://libssh.org) - forked form Qt Creator - and more... ## Checking out the source code @@ -36,39 +44,35 @@ git submodule update --init Want to contribute? Welcome! ### Building sources and deployment -Easiest way to build your own executables - is to fork project and configure [Travis CI](https://travis-ci.com/) -Or you can build sources manually using Qt Creator. Qt >= 14.2 supported. -Look to the `build_macos.sh` and `build_windows.bat` scripts in `deploy` folder for details. +Look deploy folder for build scripts. ### How to build iOS app from source code on MacOS -1. First, make sure you have [XCode](https://developer.apple.com/xcode/) installed, -at least version 12 or higher. +1. First, make sure you have [XCode](https://developer.apple.com/xcode/) installed, at least version 14 or higher. -2. We use `qmake` to generate the XCode project and then we "patch" it to add -extra components such as the wireguard, the browser bridge and so on. We patch -the XCode project using [xcodeproj](https://github.com/CocoaPods/Xcodeproj). To -install it: -```bash -gem install xcodeproj # probably you want to run this command with `sudo` -``` -3. You also need to install go >= v1.16. If you don't have it done already, +2. We use QT to generate the XCode project. we need QT version 6.4. Install QT for macos in [here](https://doc.qt.io/qt-6/macos.html) + +3. Install cmake is require. We recommend cmake version 3.25. You can install cmake in [here](https://cmake.org/download/) + +4. You also need to install go >= v1.16. If you don't have it done already, download go from the [official website](https://golang.org/dl/) or use Homebrew. -Latest version is recommended. - -4. Navigate inside client folder and generate the XCode project using our script: +Latest version is recommended. Install gomobile ```bash -cd client -./scripts/apple_compile.sh ios +export PATH=$PATH:~/go/bin +go install golang.org/x/mobile/cmd/gomobile@latest +gomobile init ``` -If you have more than one version of Qt installed, you'll most likely get -a "`qmake` cannot be found in your `$PATH`" error. In this case run this script -using QT\IOS\_BIN env to set the path for the Qt5 macos build bin folder. -For example, the path could look like this: +5. Build project ```bash -QT_IOS_BIN="/Users/username/Qt/6.4.1/ios/bin" ./scripts/apple_compile.sh ios +export QT_BIN_DIR="/Qt//ios/bin" +export QT_IOS_BIN=$QT_BIN_DIR +export PATH=$PATH:~/go/bin +mkdir build-ios +$QT_IOS_BIN/qt-cmake . -B build-ios -GXcode -DQT_HOST_PATH=$QT_BIN_DIR ``` +Replace PATH-TO-QT-FOLDER and QT-VERSION to your environment + If you get `gomobile: command not found` make sure to set PATH to the location of the bin folder where gomobile was installed. Usually, it's in `GOPATH`. @@ -76,7 +80,7 @@ of the bin folder where gomobile was installed. Usually, it's in `GOPATH`. export PATH=$(PATH):/path/to/GOPATH/bin ``` -5. Xcode should automatically open. You can then run/test/archive/ship the app. +5. Open XCode project. You can then run/test/archive/ship the app. If build fails with the following error ``` @@ -125,12 +129,6 @@ You may face compiling issues in QT Creator after you've worked in Android Studi ## License GPL v.3 -## Contacts -[https://t.me/amnezia_vpn_en](https://t.me/amnezia_vpn_en) - Telegram support channel (English) -[https://t.me/amnezia_vpn](https://t.me/amnezia_vpn) - Telegram support channel (Russian) -[https://signal.group/...](https://signal.group/#CjQKIB2gUf8QH_IXnOJMGQWMDjYz9cNfmRQipGWLFiIgc4MwEhAKBONrSiWHvoUFbbD0xwdh) - Signal channel -[https://amnezia.org](https://amnezia.org) - project website - ## Donate Bitcoin: bc1qn9rhsffuxwnhcuuu4qzrwp4upkrq94xnh8r26u XMR: 48spms39jt1L2L5vyw2RQW6CXD6odUd4jFu19GZcDyKKQV9U88wsJVjSbL4CfRys37jVMdoaWVPSvezCQPhHXUW5UKLqUp3 diff --git a/client/3rd/OpenVPNAdapter b/client/3rd/OpenVPNAdapter index 0e2db0ba..7b4046fa 160000 --- a/client/3rd/OpenVPNAdapter +++ b/client/3rd/OpenVPNAdapter @@ -1 +1 @@ -Subproject commit 0e2db0baa0d66029cbb18d74b78bc7a5c9013fba +Subproject commit 7b4046faf358206d9640a8cc01cb4ab5fe2e4a6c diff --git a/client/AmneziaVPN-Swift.h b/client/AmneziaVPN-Swift.h deleted file mode 100644 index 08981bcd..00000000 --- a/client/AmneziaVPN-Swift.h +++ /dev/null @@ -1,249 +0,0 @@ -#ifndef AmneziaVPN_Swift_h -#define AmneziaVPN_Swift_h -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgcc-compat" - -#if !defined(__has_include) -# define __has_include(x) 0 -#endif -#if !defined(__has_attribute) -# define __has_attribute(x) 0 -#endif -#if !defined(__has_feature) -# define __has_feature(x) 0 -#endif -#if !defined(__has_warning) -# define __has_warning(x) 0 -#endif - -#if __has_include() -# include -#endif - -#pragma clang diagnostic ignored "-Wauto-import" -#include -#include -#include -#include - -#if !defined(SWIFT_TYPEDEFS) -# define SWIFT_TYPEDEFS 1 -# if __has_include() -# include -# elif !defined(__cplusplus) -typedef uint_least16_t char16_t; -typedef uint_least32_t char32_t; -# endif -typedef float swift_float2 __attribute__((__ext_vector_type__(2))); -typedef float swift_float3 __attribute__((__ext_vector_type__(3))); -typedef float swift_float4 __attribute__((__ext_vector_type__(4))); -typedef double swift_double2 __attribute__((__ext_vector_type__(2))); -typedef double swift_double3 __attribute__((__ext_vector_type__(3))); -typedef double swift_double4 __attribute__((__ext_vector_type__(4))); -typedef int swift_int2 __attribute__((__ext_vector_type__(2))); -typedef int swift_int3 __attribute__((__ext_vector_type__(3))); -typedef int swift_int4 __attribute__((__ext_vector_type__(4))); -typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2))); -typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3))); -typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4))); -#endif - -#if !defined(SWIFT_PASTE) -# define SWIFT_PASTE_HELPER(x, y) x##y -# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y) -#endif -#if !defined(SWIFT_METATYPE) -# define SWIFT_METATYPE(X) Class -#endif -#if !defined(SWIFT_CLASS_PROPERTY) -# if __has_feature(objc_class_property) -# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__ -# else -# define SWIFT_CLASS_PROPERTY(...) -# endif -#endif - -#if __has_attribute(objc_runtime_name) -# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X))) -#else -# define SWIFT_RUNTIME_NAME(X) -#endif -#if __has_attribute(swift_name) -# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X))) -#else -# define SWIFT_COMPILE_NAME(X) -#endif -#if __has_attribute(objc_method_family) -# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X))) -#else -# define SWIFT_METHOD_FAMILY(X) -#endif -#if __has_attribute(noescape) -# define SWIFT_NOESCAPE __attribute__((noescape)) -#else -# define SWIFT_NOESCAPE -#endif -#if __has_attribute(ns_consumed) -# define SWIFT_RELEASES_ARGUMENT __attribute__((ns_consumed)) -#else -# define SWIFT_RELEASES_ARGUMENT -#endif -#if __has_attribute(warn_unused_result) -# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) -#else -# define SWIFT_WARN_UNUSED_RESULT -#endif -#if __has_attribute(noreturn) -# define SWIFT_NORETURN __attribute__((noreturn)) -#else -# define SWIFT_NORETURN -#endif -#if !defined(SWIFT_CLASS_EXTRA) -# define SWIFT_CLASS_EXTRA -#endif -#if !defined(SWIFT_PROTOCOL_EXTRA) -# define SWIFT_PROTOCOL_EXTRA -#endif -#if !defined(SWIFT_ENUM_EXTRA) -# define SWIFT_ENUM_EXTRA -#endif -#if !defined(SWIFT_CLASS) -# if __has_attribute(objc_subclassing_restricted) -# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA -# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA -# else -# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA -# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA -# endif -#endif -#if !defined(SWIFT_RESILIENT_CLASS) -# if __has_attribute(objc_class_stub) -# define SWIFT_RESILIENT_CLASS(SWIFT_NAME) SWIFT_CLASS(SWIFT_NAME) __attribute__((objc_class_stub)) -# define SWIFT_RESILIENT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_class_stub)) SWIFT_CLASS_NAMED(SWIFT_NAME) -# else -# define SWIFT_RESILIENT_CLASS(SWIFT_NAME) SWIFT_CLASS(SWIFT_NAME) -# define SWIFT_RESILIENT_CLASS_NAMED(SWIFT_NAME) SWIFT_CLASS_NAMED(SWIFT_NAME) -# endif -#endif - -#if !defined(SWIFT_PROTOCOL) -# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA -# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA -#endif - -#if !defined(SWIFT_EXTENSION) -# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__) -#endif - -#if !defined(OBJC_DESIGNATED_INITIALIZER) -# if __has_attribute(objc_designated_initializer) -# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) -# else -# define OBJC_DESIGNATED_INITIALIZER -# endif -#endif -#if !defined(SWIFT_ENUM_ATTR) -# if defined(__has_attribute) && __has_attribute(enum_extensibility) -# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility))) -# else -# define SWIFT_ENUM_ATTR(_extensibility) -# endif -#endif -#if !defined(SWIFT_ENUM) -# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type -# if __has_feature(generalized_swift_name) -# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type -# else -# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility) -# endif -#endif -#if !defined(SWIFT_UNAVAILABLE) -# define SWIFT_UNAVAILABLE __attribute__((unavailable)) -#endif -#if !defined(SWIFT_UNAVAILABLE_MSG) -# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg))) -#endif -#if !defined(SWIFT_AVAILABILITY) -# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__))) -#endif -#if !defined(SWIFT_WEAK_IMPORT) -# define SWIFT_WEAK_IMPORT __attribute__((weak_import)) -#endif -#if !defined(SWIFT_DEPRECATED) -# define SWIFT_DEPRECATED __attribute__((deprecated)) -#endif -#if !defined(SWIFT_DEPRECATED_MSG) -# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__))) -#endif -#if __has_feature(attribute_diagnose_if_objc) -# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning"))) -#else -# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg) -#endif -#if !defined(IBSegueAction) -# define IBSegueAction -#endif -#if __has_feature(modules) -#if __has_warning("-Watimport-in-framework-header") -#pragma clang diagnostic ignored "-Watimport-in-framework-header" -#endif -@import Foundation; -@import ObjectiveC; -#endif - -#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch" -#pragma clang diagnostic ignored "-Wduplicate-method-arg" -#if __has_warning("-Wpragma-clang-attribute") -# pragma clang diagnostic ignored "-Wpragma-clang-attribute" -#endif -#pragma clang diagnostic ignored "-Wunknown-pragmas" -#pragma clang diagnostic ignored "-Wnullability" - -#if __has_attribute(external_source_symbol) -# pragma push_macro("any") -# undef any -# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="AmneziaVPN",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol)) -# pragma pop_macro("any") -#endif - - -@class NSString; -@class NSData; -enum ConnectionState : NSInteger; -@class NSDate; -@class NSNumber; -@class VPNIPAddressRange; - -SWIFT_CLASS("_TtC10AmneziaVPN18IOSVpnProtocolImpl") -@interface IOSVpnProtocolImpl : NSObject -- (nonnull instancetype)initWithBundleID:(NSString * _Nonnull)bundleID privateKey:(NSData * _Nonnull)privateKey deviceIpv4Address:(NSString * _Nonnull)deviceIpv4Address deviceIpv6Address:(NSString * _Nonnull)deviceIpv6Address closure:(void (^ _Nonnull)(enum ConnectionState, NSDate * _Nullable))closure callback:(void (^ _Nonnull)(BOOL))callback OBJC_DESIGNATED_INITIALIZER; -- (nonnull instancetype)initWithBundleID:(NSString * _Nonnull)bundleID config:(NSString * _Nonnull)config closure:(void (^ _Nonnull)(enum ConnectionState, NSDate * _Nullable))closure callback:(void (^ _Nonnull)(BOOL))callback; -- (nonnull instancetype)initWithBundleID:(NSString * _Nonnull)bundleID tunnelConfig:(NSString * _Nonnull)tunnelConfig ssConfig:(NSString * _Nonnull)ssConfig closure:(void (^ _Nonnull)(enum ConnectionState, NSDate * _Nullable))closure callback:(void (^ _Nonnull)(BOOL))callback; -- (void)connectWithDnsServer:(NSString * _Nonnull)dnsServer serverIpv6Gateway:(NSString * _Nonnull)serverIpv6Gateway serverPublicKey:(NSString * _Nonnull)serverPublicKey presharedKey:(NSString * _Nonnull)presharedKey serverIpv4AddrIn:(NSString * _Nonnull)serverIpv4AddrIn serverPort:(NSInteger)serverPort allowedIPAddressRanges:(NSArray * _Nonnull)allowedIPAddressRanges ipv6Enabled:(Boolean)enabled reason:(NSInteger)reason failureCallback:(void (^ _Nonnull)(void))failureCallback; -- (void)connectWithOvpnConfig:(NSString * _Nonnull)ovpnConfig failureCallback:(void (^ _Nonnull)(void))failureCallback; -- (void)connectWithSsConfig:(NSString * _Nonnull)ssConfig ovpnConfig:(NSString * _Nonnull)ovpnConfig failureCallback:(void (^ _Nonnull)(void))failureCallback; -- (void)disconnect; -- (void)checkStatusWithCallback:(void (^ _Nonnull)(NSString * _Nonnull, NSString * _Nonnull, NSString * _Nonnull))callback; -- (nonnull instancetype)init SWIFT_UNAVAILABLE; -+ (nonnull instancetype)new SWIFT_UNAVAILABLE_MSG("-init is unavailable"); -@end - -typedef SWIFT_ENUM(NSInteger, ConnectionState, closed) { - ConnectionStateError = 0, - ConnectionStateConnected = 1, - ConnectionStateDisconnected = 2, -}; - -SWIFT_CLASS("_TtC10AmneziaVPN17VPNIPAddressRange") -@interface VPNIPAddressRange : NSObject -- (nonnull instancetype)initWithAddress:(NSString * _Nonnull)address networkPrefixLength:(uint8_t)networkPrefixLength isIpv6:(BOOL)isIpv6 OBJC_DESIGNATED_INITIALIZER; -- (nonnull instancetype)init SWIFT_UNAVAILABLE; -+ (nonnull instancetype)new SWIFT_UNAVAILABLE_MSG("-init is unavailable"); -@end - -#if __has_attribute(external_source_symbol) -# pragma clang attribute pop -#endif -#pragma clang diagnostic pop -#endif /* AmneziaVPN_Swift_h */ - diff --git a/client/AmneziaVPN.entitlements b/client/AmneziaVPN.entitlements deleted file mode 100644 index dd0d73f2..00000000 --- a/client/AmneziaVPN.entitlements +++ /dev/null @@ -1,14 +0,0 @@ - - - - - com.apple.security.application-groups - - group.org.amnezia.AmneziaVPN - - keychain-access-groups - - $(AppIdentifierPrefix)group.org.amnezia.AmneziaVPN - - - diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index d86431d5..f2346ec5 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -1,14 +1,11 @@ cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR) set(PROJECT AmneziaVPN) -project(${PROJECT} VERSION 2.1.2) -set(BUILD_ID 1) -SET(QT_BUILD_TOOLS_WHEN_CROSS_COMPILING ON) +project(${PROJECT}) + +set(QT_BUILD_TOOLS_WHEN_CROSS_COMPILING ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.17) - cmake_policy(SET CMP0099 OLD) -endif() if(ANDROID) # For a some reason cmake do not applying GNU_SOURCE/BSD_SOURCE flags on Android platform. @@ -16,34 +13,43 @@ if(ANDROID) add_definitions(-D_BSD_SOURCE) endif() -if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) - cmake_policy(SET CMP0114 NEW) -endif() - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER "Autogen") set_property(GLOBAL PROPERTY AUTOMOC_TARGETS_FOLDER "Autogen") set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "Autogen") -find_package(Qt6 REQUIRED COMPONENTS - Widgets Core Gui Network Xml - RemoteObjects Quick Svg QuickControls2 - Core5Compat Concurrent +set(PACKAGES + Widgets Core Gui Network Xml + RemoteObjects Quick Svg QuickControls2 + Core5Compat Concurrent ) +if(IOS) + set(PACKAGES + ${PACKAGES} + Multimedia + ) +endif() + +find_package(Qt6 REQUIRED COMPONENTS ${PACKAGES}) + set(LIBS ${LIBS} Qt6::Widgets Qt6::Core Qt6::Gui Qt6::Network Qt6::Xml Qt6::RemoteObjects Qt6::Quick Qt6::Svg Qt6::QuickControls2 Qt6::Core5Compat Qt6::Concurrent ) +if(IOS) + set(LIBS + ${LIBS} + Qt6::Multimedia + ) +endif() qt_standard_project_setup() if(IOS) - execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/scripts/openvpn.sh args + #execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/scripts/run-build-cloak.sh) + execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/ios/scripts/openvpn.sh args WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) endif() @@ -64,6 +70,8 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) +configure_file(${CMAKE_CURRENT_LIST_DIR}/../version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) + set(HEADERS ${HEADERS} ${CMAKE_CURRENT_LIST_DIR}/migrations.h ${CMAKE_CURRENT_LIST_DIR}/../ipc/ipc.h @@ -82,6 +90,7 @@ set(HEADERS ${HEADERS} ${CMAKE_CURRENT_LIST_DIR}/ui/uilogic.h ${CMAKE_CURRENT_LIST_DIR}/ui/qautostart.h ${CMAKE_CURRENT_LIST_DIR}/protocols/vpnprotocol.h + ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_LIST_DIR}/core/sshclient.h ) @@ -151,6 +160,11 @@ qt6_add_resources(QRC ${QRC} ${CMAKE_CURRENT_LIST_DIR}/resources.qrc) if(WIN32) add_compile_definitions(MVPN_WINDOWS) + configure_file( + ${CMAKE_CURRENT_LIST_DIR}/platforms/windows/amneziavpn.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/amneziavpn.rc + ) + set(HEADERS ${HEADERS} ${CMAKE_CURRENT_LIST_DIR}/protocols/ikev2_vpn_protocol_windows.h ) @@ -160,7 +174,7 @@ if(WIN32) ) set(RESOURCES ${RESOURCES} - ${CMAKE_CURRENT_LIST_DIR}/platforms/windows/amneziavpn.rc + ${CMAKE_CURRENT_BINARY_DIR}/amneziavpn.rc ) set(LIBS ${LIBS} @@ -176,6 +190,9 @@ if(WIN32) endif() if(APPLE) + cmake_policy(SET CMP0099 OLD) + cmake_policy(SET CMP0114 NEW) + if(NOT BUILD_OSX_APP_IDENTIFIER) set(BUILD_OSX_APP_IDENTIFIER org.amnezia.AmneziaVPN CACHE STRING "OSX Application identifier") endif() @@ -193,7 +210,6 @@ if(APPLE) set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${BUILD_VPN_DEVELOPMENT_TEAM}) set(CMAKE_XCODE_ATTRIBUTE_GROUP_ID_IOS ${BUILD_IOS_GROUP_IDENTIFIER}) - #set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../build) if(NOT IOS) set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE INTERNAL "" FORCE) @@ -201,9 +217,13 @@ if(APPLE) set(HEADERS ${HEADERS} ${CMAKE_CURRENT_LIST_DIR}/ui/macos_util.h) set(SOURCES ${SOURCES} ${CMAKE_CURRENT_LIST_DIR}/ui/macos_util.mm) - set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15) add_compile_definitions(MVPN_MACOS) - # ICON = $$PWD/images/app.icns + + set(ICON_FILE ${CMAKE_CURRENT_SOURCE_DIR}/images/app.icns) + set(MACOSX_BUNDLE_ICON_FILE app.icns) + set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + set(SOURCES ${SOURCES} ${ICON_FILE}) find_library(FW_COCOA Cocoa) find_library(FW_APPLICATIONSERVICES ApplicationServices) @@ -212,7 +232,7 @@ if(APPLE) find_library(FW_APPKIT AppKit) find_library(FW_SECURITY Security) - set(LIBS ${LIBS} + set(LIBS ${LIBS} ${FW_COCOA} ${FW_APPLICATIONSERVICES} ${FW_FOUNDATION} ${FW_APPKIT} ${FW_SECURITY} ${FW_CORESERVICES} @@ -221,7 +241,6 @@ if(APPLE) endif() endif() - if(LINUX AND NOT ANDROID) add_compile_definitions(MVPN_LINUX) @@ -231,7 +250,7 @@ endif() if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID)) message("Client desktop build") add_compile_definitions(AMNEZIA_DESKTOP) - + set(HEADERS ${HEADERS} ${CMAKE_CURRENT_LIST_DIR}/core/ipcclient.h ${CMAKE_CURRENT_LIST_DIR}/core/privileged_process.h @@ -302,26 +321,24 @@ if(IOS) add_compile_definitions(MVPN_IOS) set(HEADERS ${HEADERS} - ${CMAKE_CURRENT_LIST_DIR}/protocols/ios_vpnprotocol.h - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/iosnotificationhandler.h - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/json.h - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/bigint.h - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/bigintipv6addr.h - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/ipaddress.h - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/ipaddressrange.h - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/QtAppDelegate.h + ${CMAKE_CURRENT_LIST_DIR}/protocols/ios_vpnprotocol.h + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/iosnotificationhandler.h + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/bigint.h + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/bigintipv6addr.h + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/ipaddress.h + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/ipaddressrange.h + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/QtAppDelegate.h ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/QtAppDelegate-C-Interface.h ) set(SOURCES ${SOURCES} - ${CMAKE_CURRENT_LIST_DIR}/protocols/ios_vpnprotocol.mm - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/iosnotificationhandler.mm - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/json.cpp - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/iosglue.mm - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/ipaddress.cpp - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/ipaddressrange.cpp - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/QRCodeReaderBase.mm - ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/QtAppDelegate.mm + ${CMAKE_CURRENT_LIST_DIR}/protocols/ios_vpnprotocol.mm + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/iosnotificationhandler.mm + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/iosglue.mm + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/ipaddress.cpp + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/ipaddressrange.cpp + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/QRCodeReaderBase.mm + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/QtAppDelegate.mm ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/MobileUtils.mm ) endif() @@ -336,9 +353,7 @@ qt_add_translations(${PROJECT} TS_FILES ${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_ru.ts) if(APPLE AND NOT IOS) - set_target_properties(AmneziaVPN PROPERTIES - MACOSX_BUNDLE TRUE - ) + set_target_properties(${PROJECT} PROPERTIES MACOSX_BUNDLE TRUE) endif() if(IOS) @@ -346,66 +361,66 @@ if(IOS) enable_language(OBJCXX) enable_language(Swift) - #disable in cicd include(cmake/osxtools.cmake) - # set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY TRUE) - - set_target_properties(${PROJECT} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") - set_target_properties(${PROJECT} PROPERTIES XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon") - - set_target_properties(${PROJECT} PROPERTIES XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION) - set(CMAKE_XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../../Frameworks") - set(CMAKE_XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS ${CMAKE_CURRENT_LIST_DIR}/3rd/OpenVPNAdapter/build/Release-iphoneos) - - - #need to change for debug and release - set_target_properties(${PROJECT} - PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.amnezia.${PROJECT}" - XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1" - XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "X7UJ388FXK" - XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Apple Distribution" - ) - - set_target_properties(${PROJECT} - PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.amnezia.${PROJECT}" - XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1" - XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "X7UJ388FXK" - XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY[variant=Debug] "Apple Development" - ) set(LIBS ${LIBS} ${CMAKE_CURRENT_LIST_DIR}/3rd/OpenSSL/lib/ios/iphone/libcrypto.a ${CMAKE_CURRENT_LIST_DIR}/3rd/OpenSSL/lib/ios/iphone/libssl.a - ) + ) target_include_directories(${PROJECT} PRIVATE ${Qt6Gui_PRIVATE_INCLUDE_DIRS}) + set(APPLE_PROJECT_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH}) + + set_target_properties(${PROJECT} PROPERTIES + XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION + + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_LIST_DIR}/ios/app/Info.plist.in + MACOSX_BUNDLE_ICON_FILE "AppIcon" + MACOSX_BUNDLE_INFO_STRING "AmneziaVPN" + MACOSX_BUNDLE_BUNDLE_NAME "AmneziaVPN" + MACOSX_BUNDLE_GUI_IDENTIFIER "${BUILD_IOS_APP_IDENTIFIER}" + MACOSX_BUNDLE_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION_TWEAK}" + MACOSX_BUNDLE_LONG_VERSION_STRING "${APPLE_PROJECT_VERSION}-${CMAKE_PROJECT_VERSION_TWEAK}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${APPLE_PROJECT_VERSION}" + + XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${BUILD_IOS_APP_IDENTIFIER}" + XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_LIST_DIR}/ios/app/main.entitlements" + XCODE_ATTRIBUTE_MARKETING_VERSION "${APPLE_PROJECT_VERSION}" + XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION "${CMAKE_PROJECT_VERSION_TWEAK}" + XCODE_ATTRIBUTE_PRODUCT_NAME "AmneziaVPN" + XCODE_ATTRIBUTE_BUNDLE_INFO_STRING "AmneziaVPN" + + XCODE_GENERATE_SCHEME TRUE + XCODE_ATTRIBUTE_ENABLE_BITCODE "NO" + XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon" + XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2" + + XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY ON + XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION + + XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks" + + XCODE_EMBED_APP_EXTENSIONS networkextension + + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Apple Distribution" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY[variant=Debug] "Apple Development" + + XCODE_ATTRIBUTE_CODE_SIGN_STYLE Manual + XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER "match AppStore org.amnezia.AmneziaVPN" + XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER[variant=Debug] "match Development org.amnezia.AmneziaVPN" + ) + set_target_properties(${PROJECT} PROPERTIES XCODE_ATTRIBUTE_SWIFT_VERSION "5.0" XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES "YES" XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "${CMAKE_CURRENT_LIST_DIR}/platforms/ios/WireGuard-Bridging-Header.h" XCODE_ATTRIBUTE_SWIFT_PRECOMPILE_BRIDGING_HEADER "NO" - XCODE_ATTRIBUTE_SWIFT_OPTIMIZATION_LEVEL "-Onone" XCODE_ATTRIBUTE_SWIFT_OBJC_INTERFACE_HEADER_NAME "AmneziaVPN-Swift.h" ) set_target_properties(${PROJECT} PROPERTIES - OUTPUT_NAME "AmneziaVPN" - MACOSX_BUNDLE ON - MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_LIST_DIR}/ios/app/Info.plist.in - MACOSX_BUNDLE_BUNDLE_NAME "AmneziaVPN" - MACOSX_BUNDLE_BUNDLE_VERSION "${BUILD_ID}" - MACOSX_BUNDLE_COPYRIGHT "MPL-2.0" - MACOSX_BUNDLE_GUI_IDENTIFIER "${BUILD_IOS_APP_IDENTIFIER}" - MACOSX_BUNDLE_INFO_STRING "AmneziaVPN" - MACOSX_BUNDLE_LONG_VERSION_STRING "${CMAKE_PROJECT_VERSION}-${BUILD_ID}" - MACOSX_BUNDLE_SHORT_VERSION_STRING "${CMAKE_PROJECT_VERSION}" - XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${BUILD_IOS_APP_IDENTIFIER}" - XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_LIST_DIR}/ios/app/main.entitlements" - XCODE_ATTRIBUTE_MARKETING_VERSION "${CMAKE_PROJECT_VERSION}" - XCODE_GENERATE_SCHEME TRUE - MACOSX_BUNDLE_ICON_FILE "AppIcon" - + XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "X7UJ388FXK" ) target_include_directories(${PROJECT} PRIVATE ${CMAKE_CURRENT_LIST_DIR}) @@ -415,8 +430,10 @@ if(IOS) -DVPN_NE_BUNDLEID=\"${BUILD_IOS_APP_IDENTIFIER}.network-extension\" ) + target_sources(${PROJECT} PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/iosvpnprotocol.swift + ${CMAKE_CURRENT_LIST_DIR}/platforms/ios/ioslogger.swift - target_sources(${PROJECT} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/3rd/wireguard-apple/Sources/Shared/Keychain.swift ${CMAKE_CURRENT_LIST_DIR}/3rd/wireguard-apple/Sources/WireGuardKit/IPAddressRange.swift ${CMAKE_CURRENT_LIST_DIR}/3rd/wireguard-apple/Sources/WireGuardKit/InterfaceConfiguration.swift @@ -433,75 +450,43 @@ if(IOS) ${CMAKE_CURRENT_LIST_DIR}/3rd/wireguard-apple/Sources/WireGuardKit/PrivateKey.swift ) - target_sources(${PROJECT} PRIVATE - platforms/ios/iosvpnprotocol.swift - platforms/ios/ioslogger.swift - ) - target_sources(${PROJECT} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/ios/app/launch.png ${CMAKE_CURRENT_LIST_DIR}/ios/app/AmneziaVPNLaunchScreen.storyboard + ${CMAKE_CURRENT_LIST_DIR}/ios/Media.xcassets ) set_source_files_properties( ${CMAKE_CURRENT_LIST_DIR}/ios/app/launch.png ${CMAKE_CURRENT_LIST_DIR}/ios/app/AmneziaVPNLaunchScreen.storyboard + ${CMAKE_CURRENT_LIST_DIR}/ios/Media.xcassets PROPERTIES MACOSX_PACKAGE_LOCATION "Resources" ) - target_sources(${PROJECT} PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/ios/Media.xcassets - ) - set_source_files_properties( - ${CMAKE_CURRENT_LIST_DIR}/ios/Media.xcassets - PROPERTIES MACOSX_PACKAGE_LOCATION "Resources" - ) add_subdirectory(ios/networkextension) add_dependencies(${PROJECT} networkextension) - set_target_properties(${PROJECT} PROPERTIES XCODE_EMBED_APP_EXTENSIONS networkextension) set_property(TARGET ${PROJECT} PROPERTY XCODE_EMBED_FRAMEWORKS "${CMAKE_CURRENT_LIST_DIR}/3rd/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework" ) - set_target_properties(${PROJECT} PROPERTIES XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY ON) - set_target_properties(${PROJECT} PROPERTIES XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION) + set(CMAKE_XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS ${CMAKE_CURRENT_LIST_DIR}/3rd/OpenVPNAdapter/build/Release-iphoneos) + target_link_libraries("networkextension" PRIVATE "${CMAKE_CURRENT_LIST_DIR}/3rd/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework") - set_target_properties("networkextension" - PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.amnezia.${PROJECT}.network-extension" - XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1" - XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "X7UJ388FXK" - XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Apple Distribution" - ) - - set_target_properties("networkextension" - PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.amnezia.${PROJECT}.network-extension" - XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1" - XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "X7UJ388FXK" - XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY[variant=Debug] "Apple Development" - ) - - set_target_properties (${PROJECT} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_STYLE Manual) - set_target_properties(${PROJECT} PROPERTIES XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER "match AppStore org.amnezia.AmneziaVPN") - set_target_properties(${PROJECT} PROPERTIES XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER[variant=Debug] "match Development org.amnezia.AmneziaVPN") - - set_target_properties("networkextension" PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_STYLE Manual) - set_target_properties("networkextension" PROPERTIES XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER "match AppStore org.amnezia.AmneziaVPN.network-extension") - set_target_properties("networkextension" PROPERTIES XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER[variant=Debug] "match Development org.amnezia.AmneziaVPN.network-extension") endif() if(ANDROID) add_custom_command( TARGET ${PROJECT} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_LIST_DIR}/android/AndroidManifest.xml - ${CMAKE_CURRENT_LIST_DIR}/android/build.gradle - ${CMAKE_CURRENT_LIST_DIR}/android/gradle/wrapper/gradle-wrapper.jar - ${CMAKE_CURRENT_LIST_DIR}/android/gradle/wrapper/gradle-wrapper.properties - ${CMAKE_CURRENT_LIST_DIR}/android/gradlew - ${CMAKE_CURRENT_LIST_DIR}/android/gradlew.bat - ${CMAKE_CURRENT_LIST_DIR}/android/gradle.properties - ${CMAKE_CURRENT_LIST_DIR}/android/res/values/libs.xml + ${CMAKE_CURRENT_LIST_DIR}/android/AndroidManifest.xml + ${CMAKE_CURRENT_LIST_DIR}/android/build.gradle + ${CMAKE_CURRENT_LIST_DIR}/android/gradle/wrapper/gradle-wrapper.jar + ${CMAKE_CURRENT_LIST_DIR}/android/gradle/wrapper/gradle-wrapper.properties + ${CMAKE_CURRENT_LIST_DIR}/android/gradlew + ${CMAKE_CURRENT_LIST_DIR}/android/gradlew.bat + ${CMAKE_CURRENT_LIST_DIR}/android/gradle.properties + ${CMAKE_CURRENT_LIST_DIR}/android/res/values/libs.xml ${CMAKE_CURRENT_LIST_DIR}/android/res/xml/fileprovider.xml ${CMAKE_CURRENT_LIST_DIR}/android/src/org/amnezia/vpn/AuthHelper.java ${CMAKE_CURRENT_LIST_DIR}/android/src/org/amnezia/vpn/IPCContract.kt @@ -514,14 +499,13 @@ if(ANDROID) ${CMAKE_CURRENT_LIST_DIR}/android/src/org/amnezia/vpn/qt/AmneziaApp.kt ${CMAKE_CURRENT_LIST_DIR}/android/src/org/amnezia/vpn/qt/PackageManagerHelper.java ${CMAKE_CURRENT_LIST_DIR}/android/src/org/amnezia/vpn/qt/VPNActivity.kt - ${CMAKE_CURRENT_LIST_DIR}/android/src/org/amnezia/vpn/qt/VPNApplication.java ${CMAKE_CURRENT_LIST_DIR}/android/src/org/amnezia/vpn/qt/VPNClientBinder.kt ${CMAKE_CURRENT_LIST_DIR}/android/src/org/amnezia/vpn/qt/VPNPermissionHelper.kt ${CMAKE_CURRENT_BINARY_DIR} ) set_property(TARGET ${PROJECT} PROPERTY - QT_ANDROID_PACKAGE_SOURCE_DIR + QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/android ) @@ -537,12 +521,6 @@ if(ANDROID) ${CMAKE_CURRENT_LIST_DIR}/android/lib/wireguard/${abi}/libwg.so ${CMAKE_CURRENT_LIST_DIR}/android/lib/wireguard/${abi}/libwg-go.so ${CMAKE_CURRENT_LIST_DIR}/android/lib/wireguard/${abi}/libwg-quick.so - - ${CMAKE_CURRENT_LIST_DIR}/android/lib/openvpn/${abi}/libjbcrypto.so - ${CMAKE_CURRENT_LIST_DIR}/android/lib/openvpn/${abi}/libopenvpn.so - ${CMAKE_CURRENT_LIST_DIR}/android/lib/openvpn/${abi}/libopvpnutil.so - ${CMAKE_CURRENT_LIST_DIR}/android/lib/openvpn/${abi}/libovpn3.so - ${CMAKE_CURRENT_LIST_DIR}/android/lib/openvpn/${abi}/libovpnexec.so ) endforeach() @@ -588,5 +566,5 @@ if(WIN32) ) endif() if(IOS) - #include(cmake/ios-arch-fixup.cmake) + include(cmake/ios-arch-fixup.cmake) endif() diff --git a/client/Info.plist b/client/Info.plist deleted file mode 100644 index fa592af0..00000000 --- a/client/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIconFile - ${ASSETCATALOG_COMPILER_APPICON_NAME} - CFBundleIdentifier - ${PRODUCT_BUNDLE_IDENTIFIER} - CFBundlePackageType - APPL - CFBundleSignature - ${QMAKE_PKGINFO_TYPEINFO} - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} - NOTE - This file was generated by Qt/QMake. - NSPrincipalClass - NSApplication - NSSupportsAutomaticGraphicsSwitching - - - diff --git a/client/WireGuard-Bridging-Header.h b/client/WireGuard-Bridging-Header.h deleted file mode 100644 index 40b6c89d..00000000 --- a/client/WireGuard-Bridging-Header.h +++ /dev/null @@ -1,29 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "wireguard-go-version.h" -#include "3rd/wireguard-apple/Sources/WireGuardKitC/WireGuardKitC.h" - -#include -#include - -#define WG_KEY_LEN (32) -#define WG_KEY_LEN_BASE64 (45) -#define WG_KEY_LEN_HEX (65) - -void key_to_base64(char base64[WG_KEY_LEN_BASE64], - const uint8_t key[WG_KEY_LEN]); -bool key_from_base64(uint8_t key[WG_KEY_LEN], const char* base64); - -void key_to_hex(char hex[WG_KEY_LEN_HEX], const uint8_t key[WG_KEY_LEN]); -bool key_from_hex(uint8_t key[WG_KEY_LEN], const char* hex); - -bool key_eq(const uint8_t key1[WG_KEY_LEN], const uint8_t key2[WG_KEY_LEN]); - -void write_msg_to_log(const char* tag, const char* msg); - -#import "TargetConditionals.h" -#if TARGET_OS_OSX -# include -#endif diff --git a/client/amnezia_application.cpp b/client/amnezia_application.cpp index b89e5ba9..7159aa4f 100644 --- a/client/amnezia_application.cpp +++ b/client/amnezia_application.cpp @@ -1,13 +1,18 @@ #include "amnezia_application.h" +#include #include -#include +#include #include +#include #include #include +#include -#include "defines.h" + +#include "core/servercontroller.h" #include "logger.h" +#include "version.h" #include "platforms/ios/QRCodeReaderBase.h" @@ -28,7 +33,7 @@ AmneziaApplication::AmneziaApplication(int &argc, char *argv[], bool allowSecond setQuitOnLastWindowClosed(false); // Fix config file permissions -#ifdef Q_OS_LINUX +#ifdef Q_OS_LINUX && !defined(Q_OS_ANDROID) { QSettings s(ORGANIZATION_NAME, APPLICATION_NAME); s.setValue("permFixed", true); @@ -41,7 +46,6 @@ AmneziaApplication::AmneziaApplication(int &argc, char *argv[], bool allowSecond QString configLoc2 = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).first() + "/" + ORGANIZATION_NAME + "/" + APPLICATION_NAME + "/" + APPLICATION_NAME + ".conf"; QFile::setPermissions(configLoc2, QFileDevice::ReadOwner | QFileDevice::WriteOwner); - #endif m_settings = std::shared_ptr(new Settings); @@ -126,16 +130,32 @@ void AmneziaApplication::init() // m_uiLogic->showOnStartup(); // #endif - // // TODO - fix - // #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) - // if (isPrimary()) { - // QObject::connect(this, &SingleApplication::instanceStarted, m_uiLogic, [this](){ - // qDebug() << "Secondary instance started, showing this window instead"; - // emit m_uiLogic->show(); - // emit m_uiLogic->raise(); - // }); - // } - // #endif +#endif + + // TODO - fix +#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) + if (isPrimary()) { + QObject::connect(this, &SingleApplication::instanceStarted, m_uiLogic, [this](){ + qDebug() << "Secondary instance started, showing this window instead"; + emit m_uiLogic->show(); + emit m_uiLogic->raise(); + }); + } +#endif + +// Android TextField clipboard workaround +// https://bugreports.qt.io/browse/QTBUG-113461 +#ifdef Q_OS_ANDROID + QObject::connect(qApp, &QApplication::applicationStateChanged, [](Qt::ApplicationState state) { + if (state == Qt::ApplicationActive) { + if (qApp->clipboard()->mimeData()->formats().contains("text/html")) { + QTextDocument doc; + doc.setHtml(qApp->clipboard()->mimeData()->html()); + qApp->clipboard()->setText(doc.toPlainText()); + } + } + }); +#endif } void AmneziaApplication::registerTypes() diff --git a/client/android/build.gradle b/client/android/build.gradle index c54784d9..26d8ee83 100644 --- a/client/android/build.gradle +++ b/client/android/build.gradle @@ -11,6 +11,8 @@ buildscript { streamsupportVersion = '1.7.0' threetenabpVersion = '1.1.1' groupName = 'org.amnezia.vpn' + minSdkVer = '24' + cmakeMinVersion = "3.25.0+" } repositories { @@ -36,9 +38,8 @@ apply plugin: 'kotlin-kapt' dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) - + implementation group: 'org.json', name: 'json', version: '20220924' implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.4.1' implementation "androidx.security:security-crypto:1.1.0-alpha03" @@ -135,9 +136,9 @@ android { defaultConfig { resConfig "en" minSdkVersion = 24 - targetSdkVersion = 31 - versionCode 10 // Change to a higher number - versionName "2.0.10" // Change to a higher number + targetSdkVersion = 34 + versionCode 22 // Change to a higher number + versionName "3.0.7" // Change to a higher number javaCompileOptions.annotationProcessorOptions.arguments = [ "room.schemaLocation": "${qtAndroidDir}/schemas".toString() @@ -150,7 +151,10 @@ android { minifyEnabled false externalNativeBuild { cmake { - arguments "-DANDROID_PACKAGE_NAME=${groupName}", "-DGRADLE_USER_HOME=${project.gradle.gradleUserHomeDir}" + version cmakeMinVersion + arguments "-DANDROID_PACKAGE_NAME=${groupName}", + "-DGRADLE_USER_HOME=${project.gradle.gradleUserHomeDir}", + "-DANDROID_PLATFORM=${minSdkVer}" } } } @@ -160,7 +164,10 @@ android { minifyEnabled false externalNativeBuild { cmake { - arguments "-DANDROID_PACKAGE_NAME=${groupName}", "-DGRADLE_USER_HOME=${project.gradle.gradleUserHomeDir}" + version cmakeMinVersion + arguments "-DANDROID_PACKAGE_NAME=${groupName}", + "-DGRADLE_USER_HOME=${project.gradle.gradleUserHomeDir}", + "-DANDROID_PLATFORM=${minSdkVer}" } } } @@ -172,11 +179,12 @@ android { // } // } -// externalNativeBuild { -// cmake { -// path 'openvpn/src/main/cpp/CMakeLists.txt' -// } -// } + externalNativeBuild { + cmake { + version cmakeMinVersion + path "${projectDir}/cpp/CMakeLists.txt" + } + } } diff --git a/client/android/cpp/CMakeLists.txt b/client/android/cpp/CMakeLists.txt new file mode 100644 index 00000000..24de1176 --- /dev/null +++ b/client/android/cpp/CMakeLists.txt @@ -0,0 +1,267 @@ +cmake_minimum_required(VERSION 3.4.1) +project(AmneziaVPN) +# Git version string + +include(GetGitRevisionDescription.cmake) +git_describe(OPENVPN2_GIT "${CMAKE_CURRENT_SOURCE_DIR}/openvpn" "--tags" "--always" "--long") +git_describe(OPENVPN3_GIT "${CMAKE_CURRENT_SOURCE_DIR}/openvpn3" "--tags" "--always" "--long") +message("OpenVPN 2.x version ${OPENVPN2_GIT}") +message("OpenVPN 3.x version ${OPENVPN3_GIT}") + +# Set mbedtls options +OPTION(ENABLE_PROGRAMS "" OFF) +OPTION(USE_SHARED_MBEDTLS_LIBRARY "" OFF) +OPTION(ENABLE_TESTING "" OFF) + +# Own options +OPTION(OPENVPN2MBED "Use mbed TLS for OpenVPN2" OFF) +OPTION(OPENVPN3OSSL "Use OpenSSL for OpenVPN3" ON) +SET(OPENVPN2MBED OFF) +SET(OPENVPN3OSSL ON) + +# STATIC or SHARED +SET(SSLLIBTYPE STATIC) +SET(OPENSSL_PATH "openssl") + +set(CMAKE_CXX_STANDARD 17) + + +#add_subdirectory(lzo) +include(tools.cmake) +include(lzo.cmake) +include(lz4.cmake) +include(openssl/openssl.cmake) +include(cloak.cmake) + +if(NOT ${OPENVPN3OSSL} OR ${OPENVPN2MBED}) + add_subdirectory(mbedtls) +endif() + + FIND_PACKAGE(SWIG 3.0 REQUIRED) + + add_custom_command(OUTPUT "ovpncli_wrap.cxx" + COMMAND ${CMAKE_COMMAND} -E make_directory ovpn3 + COMMAND ${SWIG_EXECUTABLE} -outdir ovpn3 + -c++ + -java -package net.openvpn.ovpn3 + -outcurrentdir + -DOPENVPN_PLATFORM_ANDROID + -I${CMAKE_CURRENT_SOURCE_DIR}/openvpn3/client + -I${CMAKE_CURRENT_SOURCE_DIR}/openvpn3 + ${CMAKE_CURRENT_SOURCE_DIR}/openvpn3/client/ovpncli.i) + + + link_directories(${CMAKE_CURRENT_SOURCE_DIR}/cloak/${ANDROID_ABI}/) + + + message("${CMAKE_CURRENT_SOURCE_DIR}/cloak/${ANDROID_ABI}/"}) + + set(ovpn3_SRCS + openvpn3/client/ovpncli.cpp + openvpn3/openvpn/openssl/xkey/xkey_provider.c + openvpn3/openvpn/openssl/xkey/xkey_helper.c + ovpncli_wrap.cxx) + + add_library(ovpn3 SHARED ${ovpn3_SRCS}) + + target_include_directories(ovpn3 PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/lzo/include + ${CMAKE_CURRENT_SOURCE_DIR}/openvpn3 + ${CMAKE_CURRENT_SOURCE_DIR}/asio/asio/include + ${CMAKE_CURRENT_SOURCE_DIR}/openvpn3/client + ${CMAKE_CURRENT_SOURCE_DIR}/mbedtls/include + ) + + if (${OPENVPN3OSSL}) + target_compile_definitions(ovpn3 PRIVATE + -DUSE_OPENSSL + ) + target_link_libraries(ovpn3 crypto ssl lzo lz4 libck-ovpn-plugin) + else () + target_compile_definitions(ovpn3 PRIVATE + -DUSE_MBEDTLS + ) + target_link_libraries(ovpn3 mbedtls mbedx509 mbedcrypto lzo lz4) + endif () + + target_compile_definitions(ovpn3 PRIVATE + -DHAVE_CONFIG_H + -DHAVE_LZO + -DHAVE_LZ4 + -DASIO_STANDALONE + -DUSE_ASIO + -DGIT_VERSION_STRING=\"${OPENVPN3_GIT}\" + -DOPENVPN_SHOW_SESSION_TOKEN + -DOPENSSL_API_COMPAT=0x10200000L + -DOPENVPN_ALLOW_INSECURE_CERTPROFILE + -DENABLE_EXTERNAL_PKI + ) +#else () +# message("Not budiling OpenVPN for output dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +#endif () + +add_library(ovpnutil SHARED ovpnutil/jniglue.c) +target_compile_definitions(ovpnutil PRIVATE -DTARGET_ARCH_ABI=\"${ANDROID_ABI}\" + -DOPENVPN2_GIT_REVISION=\"${OPENVPN2_GIT}\" + -DOPENVPN3_GIT_REVISION=\"${OPENVPN3_GIT}\" + ) +target_link_libraries(ovpnutil log) + +add_library(rsapss SHARED ovpnutil/rsapss.cpp) +target_link_libraries(rsapss log crypto ssl) + +if (NOT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} MATCHES "build/intermediates/cmake/.*skeleton.*/") + add_library(osslspeedtest SHARED ovpnutil/sslspeed.c) + target_link_libraries(osslspeedtest log crypto ssl) +else () + message("Not budiling SSLSpeedTest for output dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +endif () + +set(openvpn_srcs + src/compat/compat-basename.c + src/compat/compat-daemon.c + src/compat/compat-dirname.c + src/compat/compat-gettimeofday.c + src/openvpn/argv.c + src/openvpn/auth_token.c + src/openvpn/base64.c + src/openvpn/buffer.c + src/openvpn/clinat.c + src/openvpn/console.c + src/openvpn/console_builtin.c + src/openvpn/crypto.c + src/openvpn/crypto_openssl.c + src/openvpn/crypto_mbedtls.c + src/openvpn/cryptoapi.c + src/openvpn/dhcp.c + src/openvpn/dns.c + src/openvpn/dns.h + src/openvpn/error.c + src/openvpn/event.c + src/openvpn/env_set.c + src/openvpn/fdmisc.c + src/openvpn/forward.c + src/openvpn/fragment.c + src/openvpn/gremlin.c + src/openvpn/helper.c + src/openvpn/httpdigest.c + src/openvpn/init.c + src/openvpn/interval.c + src/openvpn/list.c + src/openvpn/lladdr.c + src/openvpn/lzo.c + src/openvpn/manage.c + src/openvpn/mbuf.c + src/openvpn/misc.c + src/openvpn/mroute.c + src/openvpn/mss.c + src/openvpn/mstats.c + src/openvpn/mtcp.c + src/openvpn/mtu.c + src/openvpn/mudp.c + src/openvpn/multi.c + src/openvpn/ntlm.c + src/openvpn/occ.c + src/openvpn/openvpn.c + src/openvpn/options.c + src/openvpn/options_util.c + src/openvpn/otime.c + src/openvpn/packet_id.c + src/openvpn/perf.c + src/openvpn/ping.c + src/openvpn/pkcs11.c + src/openvpn/pkcs11_openssl.c + src/openvpn/platform.c + src/openvpn/plugin.c + src/openvpn/pool.c + src/openvpn/proto.c + src/openvpn/proxy.c + src/openvpn/ps.c + src/openvpn/push.c + src/openvpn/reliable.c + src/openvpn/route.c + src/openvpn/run_command.c + src/openvpn/schedule.c + src/openvpn/session_id.c + src/openvpn/shaper.c + src/openvpn/sig.c + src/openvpn/socket.c + src/openvpn/socks.c + src/openvpn/ssl.c + src/openvpn/ssl_openssl.c + src/openvpn/ssl_mbedtls.c + src/openvpn/ssl_ncp.c + src/openvpn/ssl_pkt.c + src/openvpn/ssl_pkt.h + src/openvpn/ssl_util.c + src/openvpn/ssl_verify.c + src/openvpn/ssl_verify_openssl.c + src/openvpn/ssl_verify_mbedtls.c + src/openvpn/status.c + src/openvpn/tls_crypt.c + src/openvpn/tun.c + src/openvpn/vlan.c + src/openvpn/xkey_helper.c + src/openvpn/xkey_provider.c + src/openvpn/comp-lz4.c + src/openvpn/comp.c + src/openvpn/compstub.c + ) + +PREPEND(openvpn_srcs_with_path "openvpn" ${openvpn_srcs}) + +add_library(openvpn SHARED ${openvpn_srcs_with_path}) + +target_include_directories(openvpn PRIVATE + openvpn-config + openvpn/src/compat + openvpn/include + mbedtls/include + lzo/include + openvpn + ) +target_compile_definitions(openvpn PRIVATE + -DHAVE_CONFIG_H + -DCONFIGURE_GIT_REVISION=\"${OPENVPN2_GIT}\" + -DCONFIGURE_GIT_FLAGS=\"\" + -DTARGET_ABI=\"${ANDROID_ABI}\" + -DOPENSSL_API_COMPAT=0x11000000L + ) + +if (${OPENVPN2MBED}) + target_compile_definitions(openvpn PRIVATE + -DENABLE_CRYPTO_MBEDTLS=1 + ) + target_link_libraries(openvpn mbedtls mbedx509 mbedcrypto lzo lz4) +else () + target_compile_definitions(openvpn PRIVATE + -DENABLE_CRYPTO_OPENSSL=1 + ) + target_link_libraries(openvpn crypto ssl lzo lz4) +endif () + +add_executable(libovpnexec.so minivpn/minivpn.c) +target_compile_options(libovpnexec.so PRIVATE -fPIE) +target_link_libraries(libovpnexec.so PRIVATE openvpn -fPIE -pie) + +add_executable(pie_openvpn.${ANDROID_ABI} minivpn/minivpn.c) +target_compile_options(pie_openvpn.${ANDROID_ABI} PRIVATE -fPIE) +target_link_libraries(pie_openvpn.${ANDROID_ABI} PRIVATE openvpn -fPIE -pie) + +# Hack to copy OpenVPN binaries to assets directory +SET(OVPN_ASSET_DIR ${CMAKE_SOURCE_DIR}/../../../build/ovpnassets) + +add_custom_target(makeassetdir ALL + COMMAND ${CMAKE_COMMAND} -E make_directory ${OVPN_ASSET_DIR}) + +add_custom_command(TARGET pie_openvpn.${ANDROID_ABI} POST_BUILD + COMMAND + ${CMAKE_COMMAND} -E copy + $ + ${OVPN_ASSET_DIR} + ) + +# Hack that these targets are really executed +add_dependencies(ovpnutil pie_openvpn.${ANDROID_ABI}) +add_dependencies(pie_openvpn.${ANDROID_ABI} makeassetdir) + diff --git a/client/android/cpp/GetGitRevisionDescription.cmake b/client/android/cpp/GetGitRevisionDescription.cmake new file mode 100644 index 00000000..54dfbe50 --- /dev/null +++ b/client/android/cpp/GetGitRevisionDescription.cmake @@ -0,0 +1,169 @@ +# From https://raw.githubusercontent.com/rpavlik/cmake-modules/master/GetGitRevisionDescription.cmake.in +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# git_local_changes() +# +# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. +# Uses the return code of "git diff-index --quiet HEAD --". +# Does not regard untracked files. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar path) + set(GIT_PARENT_DIR "${path}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + # check if this is a submodule + if(NOT IS_DIRECTORY ${GIT_DIR}) + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_describe _var path) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash ${path}) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${hash} + ${ARGN} + WORKING_DIRECTORY + ${path} + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var path) + git_describe(out ${path} --exact-match ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_local_changes _var path) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash path) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + diff-index --quiet HEAD -- + WORKING_DIRECTORY + ${path} + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(res EQUAL 0) + set(${_var} "CLEAN" PARENT_SCOPE) + else() + set(${_var} "DIRTY" PARENT_SCOPE) + endif() +endfunction() diff --git a/client/android/cpp/GetGitRevisionDescription.cmake.in b/client/android/cpp/GetGitRevisionDescription.cmake.in new file mode 100644 index 00000000..4005c47a --- /dev/null +++ b/client/android/cpp/GetGitRevisionDescription.cmake.in @@ -0,0 +1,42 @@ +# From https://raw.githubusercontent.com/rpavlik/cmake-modules/master/GetGitRevisionDescription.cmake.in +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + else() + configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) + file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) + if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") + set(HEAD_HASH "${CMAKE_MATCH_1}") + endif() + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/client/android/cpp/asio b/client/android/cpp/asio new file mode 160000 index 00000000..4915cfd8 --- /dev/null +++ b/client/android/cpp/asio @@ -0,0 +1 @@ +Subproject commit 4915cfd8a1653c157a1480162ae5601318553eb8 diff --git a/client/android/cpp/cloak b/client/android/cpp/cloak new file mode 160000 index 00000000..28890e1c --- /dev/null +++ b/client/android/cpp/cloak @@ -0,0 +1 @@ +Subproject commit 28890e1c69e0b02b052fe6e438f5c3642137ab7a diff --git a/client/android/cpp/cloak.cmake b/client/android/cpp/cloak.cmake new file mode 100644 index 00000000..8199ebcc --- /dev/null +++ b/client/android/cpp/cloak.cmake @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR) + +set(TARGET ck_ovpn_plugin_go) + +set(CLOAK_SRCS cloak/cmd/ck-ovpn-plugin/ck-ovpn-plugin.go) +set(CLOAK_LIB libck-ovpn-plugin.so) + +list(APPEND CMAKE_PROGRAM_PATH "/usr/local/go/bin") +find_program(GO_EXEC go) + +set(BUILD_CMD_ARGS build) +list(APPEND BUILD_CMD_ARGS -buildmode=c-shared -o ${CMAKE_CURRENT_BINARY_DIR}/${CLOAK_LIB} ${CMAKE_GO_FLAGS} ./...) + +set(PREPARE_ENV_ARGS env) +list(APPEND PREPARE_ENV_ARGS -w CGO_ENABLED=1 GOOS=android) + + +string(REGEX MATCH "[0-9]+$" ANDROID_API_LEVEL ${ANDROID_PLATFORM}) +message(WARNING "build cloak plugin abi=${ANDROID_ABI}, ANDROID_API_LEVEL=${ANDROID_API_LEVEL}") + +if ("${ANDROID_ABI}" STREQUAL "x86") + list(APPEND PREPARE_ENV_ARGS GOARCH=386) + list(APPEND PREPARE_ENV_ARGS CC=${ANDROID_TOOLCHAIN_ROOT}/bin/i686-linux-android${ANDROID_API_LEVEL}-clang) +elseif ("${ANDROID_ABI}" STREQUAL "x86_64") + list(APPEND PREPARE_ENV_ARGS GOARCH=amd64) + list(APPEND PREPARE_ENV_ARGS CC=${ANDROID_TOOLCHAIN_ROOT}/bin/x86_64-linux-android${ANDROID_API_LEVEL}-clang) +elseif ("${ANDROID_ABI}" STREQUAL "arm64-v8a") + list(APPEND PREPARE_ENV_ARGS GOARCH=arm64) + list(APPEND PREPARE_ENV_ARGS CC=${ANDROID_TOOLCHAIN_ROOT}/bin/aarch64-linux-android${ANDROID_API_LEVEL}-clang) +elseif ("${ANDROID_ABI}" STREQUAL "armeabi-v7a") + list(APPEND PREPARE_ENV_ARGS GOARCH=arm) + list(APPEND PREPARE_ENV_ARGS GOARM=7) + list(APPEND PREPARE_ENV_ARGS CC=${ANDROID_TOOLCHAIN_ROOT}/bin/armv7a-linux-androideabi${ANDROID_API_LEVEL}-clang) +endif () + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CLOAK_LIB} + DEPENDS ${CLOAK_SRCS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cloak/cmd/ck-ovpn-plugin + COMMAND ${GO_EXEC} ${PREPARE_ENV_ARGS} + COMMAND ${GO_EXEC} ${BUILD_CMD_ARGS} + COMMENT "Building Go library") + +add_custom_target(${TARGET} DEPENDS ${CLOAK_LIB} ${HEADER}) +add_library(libck-ovpn-plugin STATIC IMPORTED GLOBAL) +add_dependencies(libck-ovpn-plugin ${TARGET}) +set_target_properties(libck-ovpn-plugin + PROPERTIES + IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${CLOAK_LIB} + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/client/android/cpp/lz4 b/client/android/cpp/lz4 new file mode 160000 index 00000000..d4437184 --- /dev/null +++ b/client/android/cpp/lz4 @@ -0,0 +1 @@ +Subproject commit d44371841a2f1728a3f36839fd4b7e872d0927d3 diff --git a/client/android/cpp/lz4.cmake b/client/android/cpp/lz4.cmake new file mode 100644 index 00000000..d5e618c6 --- /dev/null +++ b/client/android/cpp/lz4.cmake @@ -0,0 +1,7 @@ +set(lz4_srcs + lz4.c + ) + +PREPEND(lz4_src_with_path "lz4/lib/" ${lz4_srcs}) +add_library(lz4 ${lz4_src_with_path}) +target_include_directories(lz4 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lz4/lib") diff --git a/client/android/cpp/lzo b/client/android/cpp/lzo new file mode 160000 index 00000000..5754571c --- /dev/null +++ b/client/android/cpp/lzo @@ -0,0 +1 @@ +Subproject commit 5754571c8968245f77cf180da872f8f52fe52a40 diff --git a/client/android/cpp/lzo.cmake b/client/android/cpp/lzo.cmake new file mode 100644 index 00000000..d791b14f --- /dev/null +++ b/client/android/cpp/lzo.cmake @@ -0,0 +1,78 @@ +# Lzo's own cmake is rather throublesome + +set(lzo_srcs + lzo1.c + lzo1_99.c + lzo1a.c + lzo1a_99.c + lzo1b_1.c + lzo1b_2.c + lzo1b_3.c + lzo1b_4.c + lzo1b_5.c + lzo1b_6.c + lzo1b_7.c + lzo1b_8.c + lzo1b_9.c + lzo1b_99.c + lzo1b_9x.c + lzo1b_cc.c + lzo1b_d1.c + lzo1b_d2.c + lzo1b_rr.c + lzo1b_xx.c + lzo1c_1.c + lzo1c_2.c + lzo1c_3.c + lzo1c_4.c + lzo1c_5.c + lzo1c_6.c + lzo1c_7.c + lzo1c_8.c + lzo1c_9.c + lzo1c_99.c + lzo1c_9x.c + lzo1c_cc.c + lzo1c_d1.c + lzo1c_d2.c + lzo1c_rr.c + lzo1c_xx.c + lzo1f_1.c + lzo1f_9x.c + lzo1f_d1.c + lzo1f_d2.c + lzo1x_1.c + lzo1x_1k.c + lzo1x_1l.c + lzo1x_1o.c + lzo1x_9x.c + lzo1x_d1.c + lzo1x_d2.c + lzo1x_d3.c + lzo1x_o.c + lzo1y_1.c + lzo1y_9x.c + lzo1y_d1.c + lzo1y_d2.c + lzo1y_d3.c + lzo1y_o.c + lzo1z_9x.c + lzo1z_d1.c + lzo1z_d2.c + lzo1z_d3.c + lzo2a_9x.c + lzo2a_d1.c + lzo2a_d2.c + lzo_crc.c + lzo_init.c + lzo_ptr.c + lzo_str.c + lzo_util.c + ) + +PREPEND(lzo_src_with_path "lzo/src" ${lzo_srcs}) +add_library(lzo ${lzo_src_with_path}) +target_include_directories(lzo PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lzo/include") +if (${ANDROID_ABI} STREQUAL "armeabi-v7a") + target_compile_options(lzo PRIVATE -O0) +endif() \ No newline at end of file diff --git a/client/android/cpp/mbedtls b/client/android/cpp/mbedtls new file mode 160000 index 00000000..b1c8e41a --- /dev/null +++ b/client/android/cpp/mbedtls @@ -0,0 +1 @@ +Subproject commit b1c8e41ae3b36a9a88e0cbee10ed38a577b54726 diff --git a/client/android/cpp/minivpn/minivpn.c b/client/android/cpp/minivpn/minivpn.c new file mode 100644 index 00000000..e69de29b diff --git a/client/android/cpp/openssl b/client/android/cpp/openssl new file mode 160000 index 00000000..5a6a7d0c --- /dev/null +++ b/client/android/cpp/openssl @@ -0,0 +1 @@ +Subproject commit 5a6a7d0c955b168ccaecbd16d5a8ae4d20304ff4 diff --git a/client/android/cpp/openvpn b/client/android/cpp/openvpn new file mode 160000 index 00000000..b1ae5974 --- /dev/null +++ b/client/android/cpp/openvpn @@ -0,0 +1 @@ +Subproject commit b1ae59746c150da85aa93c8e0ac1e8a0e670d6ef diff --git a/client/android/cpp/openvpn-config/config.h b/client/android/cpp/openvpn-config/config.h new file mode 100644 index 00000000..e4a50944 --- /dev/null +++ b/client/android/cpp/openvpn-config/config.h @@ -0,0 +1,684 @@ + +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + + +/* DISABLE PERSISTEN TUN */ +#undef TUNSETPERSIST + +/* Enable deferred authentication */ +#define CONFIGURE_DEF_AUTH 1 + +/* Enable internal packet filter */ +#undef CONFIGURE_PF //1 + +/* enable iproute2 support */ +#undef CONFIG_FEATURE_IPROUTE + +/* Use memory debugging function in OpenSSL */ +/* #undef CRYPTO_MDEBUG */ +#define HAVE_BASENAME +/* Use dmalloc memory debugging library */ +/* #undef DMALLOC */ + +/* Dimension to use for empty array declaration */ +#define EMPTY_ARRAY_SIZE 0 + +/* Enable client capability only */ +#define ENABLE_CLIENT_ONLY 1 + +/* Enable debugging support */ +#define ENABLE_DEBUG 1 + +/* Enable internal fragmentation support */ +#define ENABLE_FRAGMENT 1 + +/* Enable HTTP proxy support */ +#define ENABLE_HTTP_PROXY 1 + +/* Enable management server capability */ +#define ENABLE_MANAGEMENT 1 + +/* Enable multi-homed UDP server capability */ +#define ENABLE_MULTIHOME 0 + +/* Allow --askpass and --auth-user-pass passwords to be read from a file */ +#define ENABLE_PASSWORD_SAVE 1 + +/* Enable TCP Server port sharing */ +#define ENABLE_PORT_SHARE 1 + +/* Enable smaller executable size */ +/* #undef ENABLE_SMALL */ + +/* Enable Socks proxy support */ +#define ENABLE_SOCKS 1 + +/* Define to 1 if you have the `accept' function. */ +#define HAVE_ACCEPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the `bind' function. */ +#define HAVE_BIND 1 + +/* Define to 1 if you have the `chdir' function. */ +#define HAVE_CHDIR 1 + +/* Define to 1 if you have the `chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `chsize' function. */ +/* #undef HAVE_CHSIZE */ + +/* struct cmsghdr needed for extended socket error support */ +#define HAVE_CMSGHDR 1 + +/* Define to 1 if you have the `connect' function. */ +#define HAVE_CONNECT 1 + +/* Define to 1 if your compiler supports GNU GCC-style variadic macros */ +#define HAVE_CPP_VARARG_MACRO_GCC 1 + +/* Define to 1 if your compiler supports ISO C99 variadic macros */ +#define HAVE_CPP_VARARG_MACRO_ISO 1 + +/* Define to 1 if you have the `ctime' function. */ +#define HAVE_CTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_CTYPE_H 1 + +/* Define to 1 if you have the `daemon' function. */ +#define HAVE_DAEMON 1 + +/* Define to 1 if you have the `dup' function. */ +#define HAVE_DUP 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the `ENGINE_cleanup' function. */ +#define HAVE_ENGINE_CLEANUP 0 + +/* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */ +#define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 0 + +/* Define to 1 if you have the `ENGINE_register_all_complete' function. */ +#define HAVE_ENGINE_REGISTER_ALL_COMPLETE 0 + +/* epoll_create function is defined */ +#define HAVE_EPOLL_CREATE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERR_H 1 + +/* Define to 1 if you have the `EVP_CIPHER_CTX_set_key_length' function. */ +#define HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH 1 + +/* Define to 1 if you have the `execve' function. */ +#define HAVE_EXECVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `getgrnam' function. */ +#define HAVE_GETGRNAM 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define to 1 if you have the `getpass' function. */ +/* #define HAVE_GETPASS 1 */ + +/* Define to 1 if you have the `getpeereid' function. */ +/* #undef HAVE_GETPEEREID */ + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpwnam' function. */ +#define HAVE_GETPWNAM 1 + +/* Define to 1 if you have the `getsockname' function. */ +#define HAVE_GETSOCKNAME 1 + +/* Define to 1 if you have the `getsockopt' function. */ +#define HAVE_GETSOCKOPT 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define to 1 if you have the `inet_ntoa' function. */ +#define HAVE_INET_NTOA 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* struct in_pktinfo needed for IP_PKTINFO support */ +#define HAVE_IN_PKTINFO 1 + +#define HAVE_IPI_SPEC_DST 1 + +/* struct iovec needed for IPv6 support */ +#define HAVE_IOVEC 1 + +/* struct iphdr needed for IPv6 support */ +#define HAVE_IPHDR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_ERRQUEUE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_IF_TUN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_SOCKIOS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_TYPES_H 1 + +/* Define to 1 if you have the `listen' function. */ +#define HAVE_LISTEN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the `mlockall' function. */ +/* #define HAVE_MLOCKALL 1*/ + +/* struct msghdr needed for extended socket error support */ +#define HAVE_MSGHDR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETDB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IF_ETHER_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_SYSTM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_TCP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NET_IF_TUN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NET_TUN_IF_TUN_H */ + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openlog' function. */ +#define HAVE_OPENLOG 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_OPENSSL_ENGINE_H 0 + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define if you have POSIX threads libraries and header files. */ +/* #undef HAVE_PTHREAD */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `readv' function. */ +#define HAVE_READV 1 + +/* Define to 1 if you have the `recv' function. */ +#define HAVE_RECV 1 + +/* Define to 1 if you have the `recvfrom' function. */ +#define HAVE_RECVFROM 1 + +/* Define to 1 if you have the `recvmsg' function. */ +#define HAVE_RECVMSG 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_RESOLV_H 1 + +/* Indicates if res_init is available */ +#define HAVE_RES_INIT 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `send' function. */ +#define HAVE_SEND 1 + +/* Define to 1 if you have the `sendmsg' function. */ +#define HAVE_SENDMSG 1 + +/* Define to 1 if you have the `sendto' function. */ +#define HAVE_SENDTO 1 + +/* SELinux support */ +/* #undef HAVE_SETCON */ + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define to 1 if you have the `setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setsockopt' function. */ +#define HAVE_SETSOCKOPT 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `socket' function. */ +#define HAVE_SOCKET 1 + +/* struct sock_extended_err needed for extended socket error support */ +#define HAVE_SOCK_EXTENDED_ERR 1 + +/* Define to 1 if you have the `stat' function. */ +#define HAVE_STAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STROPTS_H 1 + +/* Define to 1 if you have the `syslog' function. */ + #define HAVE_SYSLOG 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the `system' function. */ +#define HAVE_SYSTEM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SOCKIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `time' function. */ +#define HAVE_TIME 1 + +/* struct tun_pi needed for IPv6 support */ +#define HAVE_TUN_PI 1 + +/* Define to 1 if you have the `umask' function. */ +#define HAVE_UMASK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlink' function. */ +#define HAVE_UNLINK 1 + +/* Define to 1 if you have the `vfork' function. */ +#define HAVE_VFORK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VFORK_H */ + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define to 1 if `fork' works. */ +#define HAVE_WORKING_FORK 1 + +/* Define to 1 if `vfork' works. */ +#define HAVE_WORKING_VFORK 1 + +/* Define to 1 if you have the `writev' function. */ +#define HAVE_WRITEV 1 + +/* Path to ifconfig tool */ +#define IFCONFIG_PATH "/system/xbin/ifconfig" + +/* Path to iproute tool */ +#define IPROUTE_PATH "ip" + +/* Use lzo/ directory prefix for LZO header files (for LZO 2.0) */ +#define LZO_HEADER_DIR 1 + +/* LZO version number */ +#define LZO_VERSION_NUM "2" + +/* Name of package */ +#define PACKAGE "openvpn" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "openvpn-users@lists.sourceforge.net" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "OpenVPN" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "OpenVPN 2.6-icsopenvpn" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "openvpn" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "2.6_master" + +/* Define to the necessary symbol if this constant uses a non-standard name on + your system. */ +/* #undef PTHREAD_CREATE_JOINABLE */ + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Path to route tool */ +#define ROUTE_PATH "/system/xbin/route" + +/* The size of `unsigned int', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_INT 4 + +/* The size of `unsigned long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG 4 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Enable strict options check between peers */ +/* #undef STRICT_OPTIONS_CHECK */ + +/* The TAP-Win32 id defined in tap-win32/SOURCES */ +#define TAP_ID "tap0901" + +/* The TAP-Win32 version number is defined in tap-win32/SOURCES */ +#define TAP_WIN32_MIN_MAJOR 9 + +/* The TAP-Win32 version number is defined in tap-win32/SOURCES */ +#define TAP_WIN32_MIN_MINOR 1 + +/* A string representing our target */ +#define TARGET_ALIAS TARGET_ABI + +/* Are we running on Mac OS X? */ +/* #undef TARGET_DARWIN */ + +/* Are we running on DragonFlyBSD? */ +/* #undef TARGET_DRAGONFLY */ + +/* Are we running on FreeBSD? */ +/* #undef TARGET_FREEBSD */ + +/* Are we running on Android Linux? */ +/* TARGET_LINUX is not enable since the TARGET_XXX options mainly + control different tun/tap, ifconfig behaviour and Android VpnProvider + is very different from Linux */ +#define TARGET_ANDROID + +/* Are we running on Linux? */ +/* #define TARGET_LINUX 1 */ + +/* Are we running NetBSD? */ +/* #undef TARGET_NETBSD */ + +/* Are we running on OpenBSD? */ +/* #undef TARGET_OPENBSD */ + +/* Are we running on Solaris? */ +/* #undef TARGET_SOLARIS */ + +/* Are we running WIN32? */ +/* #undef TARGET_WIN32 */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Win32 builtin */ +/* #undef UF */ + +/* Use OpenSSL crypto library */ +#define USE_CRYPTO 1 + +/* Use libdl for dynamic library loading */ +#define USE_LIBDL 1 + +/* Use LoadLibrary to load DLLs on Windows */ +/* #undef USE_LOAD_LIBRARY */ + +/* Use LZO compression library */ +#define ENABLE_LZO 1 +#define ENABLE_SNAPPY 1 +#define ENABLE_LZ4 1 +#define NEED_COMPAT_LZ4 1 + +/* Enable PKCS11 capability */ +/* #undef USE_PKCS11 */ + +/* Use pthread-based multithreading */ +/* #undef USE_PTHREAD */ + +/* Use OpenSSL SSL library */ +#define ENABLE_SSL 1 +#define USE_SSL 1 +#define ENABLE_CRYPTO 1 + +/* via android.mk */ +/*#define ENABLE_CRYPTO_OPENSSL 1*/ +/* #define ENABLE_CRYPTO_POLARSSL 1 */ + +/* Use valgrind memory debugging library */ +/* #undef USE_VALGRIND */ + +/* Version number of package */ +//#define VERSION "2.3.1" + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Some systems don't define in_addr_t */ +/* #undef in_addr_t */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* type to use in place of socklen_t if not defined */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* 16-bit unsigned type */ +/* #undef uint16_t */ + +/* 32-bit unsigned type */ +/* #undef uint32_t */ + +/* 8-bit unsigned type */ +/* #undef uint8_t */ + +/* Define as `fork' if `vfork' does not work. */ +/* #undef vfork */ + +/* Define to empty if the keyword `volatile' does not work. Warning: valid + code using `volatile' can become incorrect without. Disable with care. */ +/* #undef volatile */ + +// New version +#define HAVE_INET_NTOP 1 +#define HAVE_INET_PTON 1 +#define HAVE_LZO_LZOUTIL_H 1 +#define HAVE_LZO_LZO1X_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_TIME_H 1 +// #define HAVE_CONFIG_VERSION_H 1 +#define PATH_SEPARATOR_STR "/" +#define HAVE_SA_FAMILY_T 1 + + +// Workaround for bionc +#define IPPROTO_IP IPPROTO_IP +#define IPPROTO_TCP IPPROTO_TCP + +int res_init(); + +#define HAVE_AEAD_CIPHER_MODES 1 + +#define HAVE_EVP_MD_CTX_RESET 1 +#define HAVE_EVP_MD_CTX_FREE 1 +#define HAVE_EVP_MD_CTX_NEW 1 +#define HAVE_EVP_CIPHER_CTX_FREE 1 +#define HAVE_EVP_CIPHER_CTX_NEW 1 +#define HAVE_HMAC_CTX_RESET 1 +#define HAVE_HMAC_CTX_FREE 1 +#define HAVE_HMAC_CTX_NEW 1 +#define HAVE_SSL_CTX_GET_DEFAULT_PASSWD_CB_USERDATA 1 +#define HAVE_SSL_CTX_GET_DEFAULT_PASSWD_CB 1 +#define HAVE_X509_GET0_PUBKEY 1 +#define HAVE_X509_STORE_GET0_OBJECTS 1 +#define HAVE_X509_OBJECT_FREE 1 +#define HAVE_X509_OBJECT_GET_TYPE 1 +#define HAVE_EVP_PKEY_GET0_RSA 1 +#define HAVE_EVP_PKEY_ID 1 +#define HAVE_EVP_PKEY_GET0_DSA 1 +#define HAVE_RSA_SET_FLAGS 1 +#define HAVE_RSA_GET0_KEY 1 +#define HAVE_RSA_SET0_KEY 1 +#define HAVE_RSA_BITS 1 +#define HAVE_DSA_BITS 1 +#define HAVE_DSA_GET0_PQG 1 +#define HAVE_RSA_METH_NEW 1 +#define HAVE_RSA_METH_FREE 1 +#define HAVE_RSA_METH_SET_PUB_ENC 1 +#define HAVE_RSA_METH_SET_PUB_DEC 1 +#define HAVE_RSA_METH_SET_PRIV_DEC 1 +#define HAVE_RSA_METH_SET_PRIV_ENC 1 +#define HAVE_RSA_METH_SET_INIT 1 +#define HAVE_RSA_METH_SET_FINISH 1 +#define HAVE_RSA_METH_SET0_APP_DATA 1 +#define HAVE_EVP_PKEY_GET0_EC_KEY 1 +#define HAVE_EC_GROUP_ORDER_BITS 1 +#define HAVE_RSA_METH_GET0_APP_DATA 1 +#define HAVE_RSA_METH_SET_SIGN 1 + +#define ENABLE_OFB_CFB_MODE 1 + +#define HAVE_X509_GET0_NOTBEFORE 1 +#define HAVE_X509_GET0_NOTAFTER 1 + +#define HAVE_OPENSSL_VERSION 1 +#define HAVE_EVP_CIPHER_CTX_RESET + + +#define _SOCKLEN_T_DECLARED 1 diff --git a/client/android/cpp/openvpn-config/openvpn-plugin.h b/client/android/cpp/openvpn-config/openvpn-plugin.h new file mode 100644 index 00000000..83d22d4b --- /dev/null +++ b/client/android/cpp/openvpn-config/openvpn-plugin.h @@ -0,0 +1,875 @@ +/* include/openvpn-plugin.h. Generated from openvpn-plugin.h.in by configure. */ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single TCP/UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * packet encryption, packet authentication, and + * packet compression. + * + * Copyright (C) 2002-2018 OpenVPN Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef OPENVPN_PLUGIN_H_ +#define OPENVPN_PLUGIN_H_ + +#define OPENVPN_PLUGIN_VERSION 3 + +#ifdef ENABLE_CRYPTO_MBEDTLS +#include +#ifndef __OPENVPN_X509_CERT_T_DECLARED +#define __OPENVPN_X509_CERT_T_DECLARED +typedef mbedtls_x509_crt openvpn_x509_cert_t; +#endif +#else /* ifdef ENABLE_CRYPTO_MBEDTLS */ +#include +#ifndef __OPENVPN_X509_CERT_T_DECLARED +#define __OPENVPN_X509_CERT_T_DECLARED +typedef X509 openvpn_x509_cert_t; +#endif +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Provide some basic version information to plug-ins at OpenVPN compile time + * This is will not be the complete version + */ +#define OPENVPN_VERSION_MAJOR 2 +#define OPENVPN_VERSION_MINOR 5 +#define OPENVPN_VERSION_PATCH "_git" + +/* + * Plug-in types. These types correspond to the set of script callbacks + * supported by OpenVPN. + * + * This is the general call sequence to expect when running in server mode: + * + * Initial Server Startup: + * + * FUNC: openvpn_plugin_open_v1 + * FUNC: openvpn_plugin_client_constructor_v1 (this is the top-level "generic" + * client template) + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_UP + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_ROUTE_UP + * + * New Client Connection: + * + * FUNC: openvpn_plugin_client_constructor_v1 + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_ENABLE_PF + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_TLS_VERIFY (called once for every cert + * in the server chain) + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_TLS_FINAL + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_IPCHANGE + * + * [If OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY returned OPENVPN_PLUGIN_FUNC_DEFERRED, + * we don't proceed until authentication is verified via auth_control_file] + * + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_CLIENT_CONNECT_V2 + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_LEARN_ADDRESS + * + * [Client session ensues] + * + * For each "TLS soft reset", according to reneg-sec option (or similar): + * + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_ENABLE_PF + * + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_TLS_VERIFY (called once for every cert + * in the server chain) + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_TLS_FINAL + * + * [If OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY returned OPENVPN_PLUGIN_FUNC_DEFERRED, + * we expect that authentication is verified via auth_control_file within + * the number of seconds defined by the "hand-window" option. Data channel traffic + * will continue to flow uninterrupted during this period.] + * + * [Client session continues] + * + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_CLIENT_DISCONNECT + * FUNC: openvpn_plugin_client_destructor_v1 + * + * [ some time may pass ] + * + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_LEARN_ADDRESS (this coincides with a + * lazy free of initial + * learned addr object) + * Server Shutdown: + * + * FUNC: openvpn_plugin_func_v1 OPENVPN_PLUGIN_DOWN + * FUNC: openvpn_plugin_client_destructor_v1 (top-level "generic" client) + * FUNC: openvpn_plugin_close_v1 + */ +#define OPENVPN_PLUGIN_UP 0 +#define OPENVPN_PLUGIN_DOWN 1 +#define OPENVPN_PLUGIN_ROUTE_UP 2 +#define OPENVPN_PLUGIN_IPCHANGE 3 +#define OPENVPN_PLUGIN_TLS_VERIFY 4 +#define OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY 5 +#define OPENVPN_PLUGIN_CLIENT_CONNECT 6 +#define OPENVPN_PLUGIN_CLIENT_DISCONNECT 7 +#define OPENVPN_PLUGIN_LEARN_ADDRESS 8 +#define OPENVPN_PLUGIN_CLIENT_CONNECT_V2 9 +#define OPENVPN_PLUGIN_TLS_FINAL 10 +#define OPENVPN_PLUGIN_ENABLE_PF 11 +#define OPENVPN_PLUGIN_ROUTE_PREDOWN 12 +#define OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER 13 +#define OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER_V2 14 +#define OPENVPN_PLUGIN_CLIENT_CRRESPONSE 15 +#define OPENVPN_PLUGIN_N 16 + +/* + * Build a mask out of a set of plug-in types. + */ +#define OPENVPN_PLUGIN_MASK(x) (1<<(x)) + +/* + * A pointer to a plugin-defined object which contains + * the object state. + */ +typedef void *openvpn_plugin_handle_t; + +/* + * Return value for openvpn_plugin_func_v1 function + */ +#define OPENVPN_PLUGIN_FUNC_SUCCESS 0 +#define OPENVPN_PLUGIN_FUNC_ERROR 1 +#define OPENVPN_PLUGIN_FUNC_DEFERRED 2 + +/* + * For Windows (needs to be modified for MSVC) + */ +#if defined(_WIN32) && !defined(OPENVPN_PLUGIN_H) +#define OPENVPN_EXPORT __declspec(dllexport) +#else +#define OPENVPN_EXPORT +#endif + +/* + * If OPENVPN_PLUGIN_H is defined, we know that we are being + * included in an OpenVPN compile, rather than a plugin compile. + */ +#ifdef OPENVPN_PLUGIN_H + +/* + * We are compiling OpenVPN. + */ +#define OPENVPN_PLUGIN_DEF typedef +#define OPENVPN_PLUGIN_FUNC(name) (*name) + +#else /* ifdef OPENVPN_PLUGIN_H */ + +/* + * We are compiling plugin. + */ +#define OPENVPN_PLUGIN_DEF OPENVPN_EXPORT +#define OPENVPN_PLUGIN_FUNC(name) name + +#endif + +/* + * Used by openvpn_plugin_func to return structured + * data. The plugin should allocate all structure + * instances, name strings, and value strings with + * malloc, since OpenVPN will assume that it + * can free the list by calling free() over the same. + */ +struct openvpn_plugin_string_list +{ + struct openvpn_plugin_string_list *next; + char *name; + char *value; +}; + + +/* openvpn_plugin_{open,func}_v3() related structs */ + +/** + * Defines version of the v3 plugin argument structs + * + * Whenever one or more of these structs are modified, this constant + * must be updated. A changelog should be appended in this comment + * as well, to make it easier to see what information is available + * in the different versions. + * + * Version Comment + * 1 Initial plugin v3 structures providing the same API as + * the v2 plugin interface, X509 certificate information + + * a logging API for plug-ins. + * + * 2 Added ssl_api member in struct openvpn_plugin_args_open_in + * which identifies the SSL implementation OpenVPN is compiled + * against. + * + * 3 Added ovpn_version, ovpn_version_major, ovpn_version_minor + * and ovpn_version_patch to provide the runtime version of + * OpenVPN to plug-ins. + * + * 4 Exported secure_memzero() as plugin_secure_memzero() + * + * 5 Exported openvpn_base64_encode() as plugin_base64_encode() + * Exported openvpn_base64_decode() as plugin_base64_decode() + */ +#define OPENVPN_PLUGINv3_STRUCTVER 5 + +/** + * Definitions needed for the plug-in callback functions. + */ +typedef enum +{ + PLOG_ERR = (1 << 0),/* Error condition message */ + PLOG_WARN = (1 << 1),/* General warning message */ + PLOG_NOTE = (1 << 2),/* Informational message */ + PLOG_DEBUG = (1 << 3),/* Debug message, displayed if verb >= 7 */ + + PLOG_ERRNO = (1 << 8),/* Add error description to message */ + PLOG_NOMUTE = (1 << 9), /* Mute setting does not apply for message */ + +} openvpn_plugin_log_flags_t; + + +#ifdef __GNUC__ +#if __USE_MINGW_ANSI_STDIO +#define _ovpn_chk_fmt(a, b) __attribute__ ((format(gnu_printf, (a), (b)))) +#else +#define _ovpn_chk_fmt(a, b) __attribute__ ((format(__printf__, (a), (b)))) +#endif +#else /* ifdef __GNUC__ */ +#define _ovpn_chk_fmt(a, b) +#endif + +typedef void (*plugin_log_t)(openvpn_plugin_log_flags_t flags, + const char *plugin_name, + const char *format, ...) _ovpn_chk_fmt (3, 4); + +typedef void (*plugin_vlog_t)(openvpn_plugin_log_flags_t flags, + const char *plugin_name, + const char *format, + va_list arglist) _ovpn_chk_fmt (3, 0); +/* #undef _ovpn_chk_fmt */ + +/** + * Export of secure_memzero() to be used inside plug-ins + * + * @param data Pointer to data to zeroise + * @param len Length of data, in bytes + * + */ +typedef void (*plugin_secure_memzero_t)(void *data, size_t len); + +/** + * Export of openvpn_base64_encode() to be used inside plug-ins + * + * @param data Pointer to data to BASE64 encode + * @param size Length of data, in bytes + * @param *str Pointer to the return buffer. This needed memory is + * allocated by openvpn_base64_encode() and needs to be free()d + * after use. + * + * @return int Returns the length of the buffer created, or -1 on error. + * + */ +typedef int (*plugin_base64_encode_t)(const void *data, int size, char **str); + +/** + * Export of openvpn_base64_decode() to be used inside plug-ins + * + * @param str Pointer to the BASE64 encoded data + * @param data Pointer to the buffer where save the decoded data + * @param size Size of the destination buffer + * + * @return int Returns the length of the decoded data, or -1 on error or + * if the destination buffer is too small. + * + */ +typedef int (*plugin_base64_decode_t)(const char *str, void *data, int size); + + +/** + * Used by the openvpn_plugin_open_v3() function to pass callback + * function pointers to the plug-in. + * + * plugin_log + * plugin_vlog : Use these functions to add information to the OpenVPN log file. + * Messages will only be displayed if the plugin_name parameter + * is set. PLOG_DEBUG messages will only be displayed with plug-in + * debug log verbosity (at the time of writing that's verb >= 7). + * + * plugin_secure_memzero + * : Use this function to securely wipe sensitive information from + * memory. This function is declared in a way that the compiler + * will not remove these function calls during the compiler + * optimization phase. + */ +struct openvpn_plugin_callbacks +{ + plugin_log_t plugin_log; + plugin_vlog_t plugin_vlog; + plugin_secure_memzero_t plugin_secure_memzero; + plugin_base64_encode_t plugin_base64_encode; + plugin_base64_decode_t plugin_base64_decode; +}; + +/** + * Used by the openvpn_plugin_open_v3() function to indicate to the + * plug-in what kind of SSL implementation OpenVPN uses. This is + * to avoid SEGV issues when OpenVPN is complied against mbed TLS + * and the plug-in against OpenSSL. + */ +typedef enum { + SSLAPI_NONE, + SSLAPI_OPENSSL, + SSLAPI_MBEDTLS +} ovpnSSLAPI; + +/** + * Arguments used to transport variables to the plug-in. + * The struct openvpn_plugin_args_open_in is only used + * by the openvpn_plugin_open_v3() function. + * + * STRUCT MEMBERS + * + * type_mask : Set by OpenVPN to the logical OR of all script + * types which this version of OpenVPN supports. + * + * argv : a NULL-terminated array of options provided to the OpenVPN + * "plug-in" directive. argv[0] is the dynamic library pathname. + * + * envp : a NULL-terminated array of OpenVPN-set environmental + * variables in "name=value" format. Note that for security reasons, + * these variables are not actually written to the "official" + * environmental variable store of the process. + * + * callbacks : a pointer to the plug-in callback function struct. + * + */ +struct openvpn_plugin_args_open_in +{ + const int type_mask; + const char **const argv; + const char **const envp; + struct openvpn_plugin_callbacks *callbacks; + const ovpnSSLAPI ssl_api; + const char *ovpn_version; + const unsigned int ovpn_version_major; + const unsigned int ovpn_version_minor; + const char *const ovpn_version_patch; +}; + + +/** + * Arguments used to transport variables from the plug-in back + * to the OpenVPN process. The struct openvpn_plugin_args_open_return + * is only used by the openvpn_plugin_open_v3() function. + * + * STRUCT MEMBERS + * + * type_mask : The plug-in should set this value to the logical OR of all script + * types which the plug-in wants to intercept. For example, if the + * script wants to intercept the client-connect and client-disconnect + * script types: + * + * type_mask = OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_CONNECT) + * | OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_DISCONNECT) + * + * handle : Pointer to a global plug-in context, created by the plug-in. This pointer + * is passed on to the other plug-in calls. + * + * return_list : used to return data back to OpenVPN. + * + */ +struct openvpn_plugin_args_open_return +{ + int type_mask; + openvpn_plugin_handle_t handle; + struct openvpn_plugin_string_list **return_list; +}; + +/** + * Arguments used to transport variables to and from the + * plug-in. The struct openvpn_plugin_args_func is only used + * by the openvpn_plugin_func_v3() function. + * + * STRUCT MEMBERS: + * + * type : one of the PLUGIN_x types. + * + * argv : a NULL-terminated array of "command line" options which + * would normally be passed to the script. argv[0] is the dynamic + * library pathname. + * + * envp : a NULL-terminated array of OpenVPN-set environmental + * variables in "name=value" format. Note that for security reasons, + * these variables are not actually written to the "official" + * environmental variable store of the process. + * + * handle : Pointer to a global plug-in context, created by the plug-in's openvpn_plugin_open_v3(). + * + * per_client_context : the per-client context pointer which was returned by + * openvpn_plugin_client_constructor_v1, if defined. + * + * current_cert_depth : Certificate depth of the certificate being passed over + * + * *current_cert : X509 Certificate object received from the client + * + */ +struct openvpn_plugin_args_func_in +{ + const int type; + const char **const argv; + const char **const envp; + openvpn_plugin_handle_t handle; + void *per_client_context; + int current_cert_depth; + openvpn_x509_cert_t *current_cert; +}; + + +/** + * Arguments used to transport variables to and from the + * plug-in. The struct openvpn_plugin_args_func is only used + * by the openvpn_plugin_func_v3() function. + * + * STRUCT MEMBERS: + * + * return_list : used to return data back to OpenVPN for further processing/usage by + * the OpenVPN executable. + * + */ +struct openvpn_plugin_args_func_return +{ + struct openvpn_plugin_string_list **return_list; +}; + +/* + * Multiple plugin modules can be cascaded, and modules can be + * used in tandem with scripts. The order of operation is that + * the module func() functions are called in the order that + * the modules were specified in the config file. If a script + * was specified as well, it will be called last. If the + * return code of the module/script controls an authentication + * function (such as tls-verify or auth-user-pass-verify), then + * every module and script must return success (0) in order for + * the connection to be authenticated. + * + * Notes: + * + * Plugins which use a privilege-separation model (by forking in + * their initialization function before the main OpenVPN process + * downgrades root privileges and/or executes a chroot) must + * daemonize after a fork if the "daemon" environmental variable is + * set. In addition, if the "daemon_log_redirect" variable is set, + * the plugin should preserve stdout/stderr across the daemon() + * syscall. See the daemonize() function in plugin/auth-pam/auth-pam.c + * for an example. + */ + +/* + * Prototypes for functions which OpenVPN plug-ins must define. + */ + +/* + * FUNCTION: openvpn_plugin_open_v2 + * + * REQUIRED: YES + * + * Called on initial plug-in load. OpenVPN will preserve plug-in state + * across SIGUSR1 restarts but not across SIGHUP restarts. A SIGHUP reset + * will cause the plugin to be closed and reopened. + * + * ARGUMENTS + * + * *type_mask : Set by OpenVPN to the logical OR of all script + * types which this version of OpenVPN supports. The plug-in + * should set this value to the logical OR of all script types + * which the plug-in wants to intercept. For example, if the + * script wants to intercept the client-connect and + * client-disconnect script types: + * + * *type_mask = OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_CONNECT) + * | OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_CLIENT_DISCONNECT) + * + * argv : a NULL-terminated array of options provided to the OpenVPN + * "plug-in" directive. argv[0] is the dynamic library pathname. + * + * envp : a NULL-terminated array of OpenVPN-set environmental + * variables in "name=value" format. Note that for security reasons, + * these variables are not actually written to the "official" + * environmental variable store of the process. + * + * return_list : used to return data back to OpenVPN. + * + * RETURN VALUE + * + * An openvpn_plugin_handle_t value on success, NULL on failure + */ +OPENVPN_PLUGIN_DEF openvpn_plugin_handle_t OPENVPN_PLUGIN_FUNC(openvpn_plugin_open_v2) + (unsigned int *type_mask, + const char *argv[], + const char *envp[], + struct openvpn_plugin_string_list **return_list); + +/* + * FUNCTION: openvpn_plugin_func_v2 + * + * Called to perform the work of a given script type. + * + * REQUIRED: YES + * + * ARGUMENTS + * + * handle : the openvpn_plugin_handle_t value which was returned by + * openvpn_plugin_open. + * + * type : one of the PLUGIN_x types + * + * argv : a NULL-terminated array of "command line" options which + * would normally be passed to the script. argv[0] is the dynamic + * library pathname. + * + * envp : a NULL-terminated array of OpenVPN-set environmental + * variables in "name=value" format. Note that for security reasons, + * these variables are not actually written to the "official" + * environmental variable store of the process. + * + * per_client_context : the per-client context pointer which was returned by + * openvpn_plugin_client_constructor_v1, if defined. + * + * return_list : used to return data back to OpenVPN. + * + * RETURN VALUE + * + * OPENVPN_PLUGIN_FUNC_SUCCESS on success, OPENVPN_PLUGIN_FUNC_ERROR on failure + * + * In addition, OPENVPN_PLUGIN_FUNC_DEFERRED may be returned by + * OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY. This enables asynchronous + * authentication where the plugin (or one of its agents) may indicate + * authentication success/failure some number of seconds after the return + * of the OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY handler by writing a single + * char to the file named by auth_control_file in the environmental variable + * list (envp). + * + * first char of auth_control_file: + * '0' -- indicates auth failure + * '1' -- indicates auth success + * + * OpenVPN will delete the auth_control_file after it goes out of scope. + * + * If an OPENVPN_PLUGIN_ENABLE_PF handler is defined and returns success + * for a particular client instance, packet filtering will be enabled for that + * instance. OpenVPN will then attempt to read the packet filter configuration + * from the temporary file named by the environmental variable pf_file. This + * file may be generated asynchronously and may be dynamically updated during the + * client session, however the client will be blocked from sending or receiving + * VPN tunnel packets until the packet filter file has been generated. OpenVPN + * will periodically test the packet filter file over the life of the client + * instance and reload when modified. OpenVPN will delete the packet filter file + * when the client instance goes out of scope. + * + * Packet filter file grammar: + * + * [CLIENTS DROP|ACCEPT] + * {+|-}common_name1 + * {+|-}common_name2 + * . . . + * [SUBNETS DROP|ACCEPT] + * {+|-}subnet1 + * {+|-}subnet2 + * . . . + * [END] + * + * Subnet: IP-ADDRESS | IP-ADDRESS/NUM_NETWORK_BITS + * + * CLIENTS refers to the set of clients (by their common-name) which + * this instance is allowed ('+') to connect to, or is excluded ('-') + * from connecting to. Note that in the case of client-to-client + * connections, such communication must be allowed by the packet filter + * configuration files of both clients. + * + * SUBNETS refers to IP addresses or IP address subnets which this + * instance may connect to ('+') or is excluded ('-') from connecting + * to. + * + * DROP or ACCEPT defines default policy when there is no explicit match + * for a common-name or subnet. The [END] tag must exist. A special + * purpose tag called [KILL] will immediately kill the client instance. + * A given client or subnet rule applies to both incoming and outgoing + * packets. + * + * See plugin/defer/simple.c for an example on using asynchronous + * authentication and client-specific packet filtering. + */ +OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_func_v2) + (openvpn_plugin_handle_t handle, + const int type, + const char *argv[], + const char *envp[], + void *per_client_context, + struct openvpn_plugin_string_list **return_list); + + +/* + * FUNCTION: openvpn_plugin_open_v3 + * + * REQUIRED: YES + * + * Called on initial plug-in load. OpenVPN will preserve plug-in state + * across SIGUSR1 restarts but not across SIGHUP restarts. A SIGHUP reset + * will cause the plugin to be closed and reopened. + * + * ARGUMENTS + * + * version : fixed value, defines the API version of the OpenVPN plug-in API. The plug-in + * should validate that this value is matching the OPENVPN_PLUGINv3_STRUCTVER + * value. + * + * arguments : Structure with all arguments available to the plug-in. + * + * retptr : used to return data back to OpenVPN. + * + * RETURN VALUE + * + * OPENVPN_PLUGIN_FUNC_SUCCESS on success, OPENVPN_PLUGIN_FUNC_ERROR on failure + */ +OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_open_v3) + (const int version, + struct openvpn_plugin_args_open_in const *arguments, + struct openvpn_plugin_args_open_return *retptr); + +/* + * FUNCTION: openvpn_plugin_func_v3 + * + * Called to perform the work of a given script type. + * + * REQUIRED: YES + * + * ARGUMENTS + * + * version : fixed value, defines the API version of the OpenVPN plug-in API. The plug-in + * should validate that this value is matching the OPENVPN_PLUGIN_VERSION value. + * + * handle : the openvpn_plugin_handle_t value which was returned by + * openvpn_plugin_open. + * + * return_list : used to return data back to OpenVPN. + * + * RETURN VALUE + * + * OPENVPN_PLUGIN_FUNC_SUCCESS on success, OPENVPN_PLUGIN_FUNC_ERROR on failure + * + * In addition, OPENVPN_PLUGIN_FUNC_DEFERRED may be returned by + * OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY. This enables asynchronous + * authentication where the plugin (or one of its agents) may indicate + * authentication success/failure some number of seconds after the return + * of the OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY handler by writing a single + * char to the file named by auth_control_file in the environmental variable + * list (envp). + * + * first char of auth_control_file: + * '0' -- indicates auth failure + * '1' -- indicates auth success + * + * OpenVPN will delete the auth_control_file after it goes out of scope. + * + * If an OPENVPN_PLUGIN_ENABLE_PF handler is defined and returns success + * for a particular client instance, packet filtering will be enabled for that + * instance. OpenVPN will then attempt to read the packet filter configuration + * from the temporary file named by the environmental variable pf_file. This + * file may be generated asynchronously and may be dynamically updated during the + * client session, however the client will be blocked from sending or receiving + * VPN tunnel packets until the packet filter file has been generated. OpenVPN + * will periodically test the packet filter file over the life of the client + * instance and reload when modified. OpenVPN will delete the packet filter file + * when the client instance goes out of scope. + * + * Packet filter file grammar: + * + * [CLIENTS DROP|ACCEPT] + * {+|-}common_name1 + * {+|-}common_name2 + * . . . + * [SUBNETS DROP|ACCEPT] + * {+|-}subnet1 + * {+|-}subnet2 + * . . . + * [END] + * + * Subnet: IP-ADDRESS | IP-ADDRESS/NUM_NETWORK_BITS + * + * CLIENTS refers to the set of clients (by their common-name) which + * this instance is allowed ('+') to connect to, or is excluded ('-') + * from connecting to. Note that in the case of client-to-client + * connections, such communication must be allowed by the packet filter + * configuration files of both clients. + * + * SUBNETS refers to IP addresses or IP address subnets which this + * instance may connect to ('+') or is excluded ('-') from connecting + * to. + * + * DROP or ACCEPT defines default policy when there is no explicit match + * for a common-name or subnet. The [END] tag must exist. A special + * purpose tag called [KILL] will immediately kill the client instance. + * A given client or subnet rule applies to both incoming and outgoing + * packets. + * + * See plugin/defer/simple.c for an example on using asynchronous + * authentication and client-specific packet filtering. + */ +OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_func_v3) + (const int version, + struct openvpn_plugin_args_func_in const *arguments, + struct openvpn_plugin_args_func_return *retptr); + +/* + * FUNCTION: openvpn_plugin_close_v1 + * + * REQUIRED: YES + * + * ARGUMENTS + * + * handle : the openvpn_plugin_handle_t value which was returned by + * openvpn_plugin_open. + * + * Called immediately prior to plug-in unload. + */ +OPENVPN_PLUGIN_DEF void OPENVPN_PLUGIN_FUNC(openvpn_plugin_close_v1) + (openvpn_plugin_handle_t handle); + +/* + * FUNCTION: openvpn_plugin_abort_v1 + * + * REQUIRED: NO + * + * ARGUMENTS + * + * handle : the openvpn_plugin_handle_t value which was returned by + * openvpn_plugin_open. + * + * Called when OpenVPN is in the process of aborting due to a fatal error. + * Will only be called on an open context returned by a prior successful + * openvpn_plugin_open callback. + */ +OPENVPN_PLUGIN_DEF void OPENVPN_PLUGIN_FUNC(openvpn_plugin_abort_v1) + (openvpn_plugin_handle_t handle); + +/* + * FUNCTION: openvpn_plugin_client_constructor_v1 + * + * Called to allocate a per-client memory region, which + * is then passed to the openvpn_plugin_func_v2 function. + * This function is called every time the OpenVPN server + * constructs a client instance object, which normally + * occurs when a session-initiating packet is received + * by a new client, even before the client has authenticated. + * + * This function should allocate the private memory needed + * by the plugin to track individual OpenVPN clients, and + * return a void * to this memory region. + * + * REQUIRED: NO + * + * ARGUMENTS + * + * handle : the openvpn_plugin_handle_t value which was returned by + * openvpn_plugin_open. + * + * RETURN VALUE + * + * void * pointer to plugin's private per-client memory region, or NULL + * if no memory region is required. + */ +OPENVPN_PLUGIN_DEF void *OPENVPN_PLUGIN_FUNC(openvpn_plugin_client_constructor_v1) + (openvpn_plugin_handle_t handle); + +/* + * FUNCTION: openvpn_plugin_client_destructor_v1 + * + * This function is called on client instance object destruction. + * + * REQUIRED: NO + * + * ARGUMENTS + * + * handle : the openvpn_plugin_handle_t value which was returned by + * openvpn_plugin_open. + * + * per_client_context : the per-client context pointer which was returned by + * openvpn_plugin_client_constructor_v1, if defined. + */ +OPENVPN_PLUGIN_DEF void OPENVPN_PLUGIN_FUNC(openvpn_plugin_client_destructor_v1) + (openvpn_plugin_handle_t handle, void *per_client_context); + +/* + * FUNCTION: openvpn_plugin_select_initialization_point_v1 + * + * Several different points exist in OpenVPN's initialization sequence where + * the openvpn_plugin_open function can be called. While the default is + * OPENVPN_PLUGIN_INIT_PRE_DAEMON, this function can be used to select a + * different initialization point. For example, if your plugin needs to + * return configuration parameters to OpenVPN, use + * OPENVPN_PLUGIN_INIT_PRE_CONFIG_PARSE. + * + * REQUIRED: NO + * + * RETURN VALUE: + * + * An OPENVPN_PLUGIN_INIT_x value. + */ +#define OPENVPN_PLUGIN_INIT_PRE_CONFIG_PARSE 1 +#define OPENVPN_PLUGIN_INIT_PRE_DAEMON 2 /* default */ +#define OPENVPN_PLUGIN_INIT_POST_DAEMON 3 +#define OPENVPN_PLUGIN_INIT_POST_UID_CHANGE 4 + +OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_select_initialization_point_v1) + (void); + +/* + * FUNCTION: openvpn_plugin_min_version_required_v1 + * + * This function is called by OpenVPN to query the minimum + * plugin interface version number required by the plugin. + * + * REQUIRED: NO + * + * RETURN VALUE + * + * The minimum OpenVPN plugin interface version number necessary to support + * this plugin. + */ +OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_min_version_required_v1) + (void); + +/* + * Deprecated functions which are still supported for backward compatibility. + */ + +OPENVPN_PLUGIN_DEF openvpn_plugin_handle_t OPENVPN_PLUGIN_FUNC(openvpn_plugin_open_v1) + (unsigned int *type_mask, + const char *argv[], + const char *envp[]); + +OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_func_v1) + (openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[]); + +#ifdef __cplusplus +} +#endif + +#endif /* OPENVPN_PLUGIN_H_ */ diff --git a/client/android/cpp/openvpn3 b/client/android/cpp/openvpn3 new file mode 160000 index 00000000..dd6e82ba --- /dev/null +++ b/client/android/cpp/openvpn3 @@ -0,0 +1 @@ +Subproject commit dd6e82ba9fff32e4f4a3965750f3ec9106131a44 diff --git a/client/android/cpp/ovpnutil/jniglue.c b/client/android/cpp/ovpnutil/jniglue.c new file mode 100644 index 00000000..65a13406 --- /dev/null +++ b/client/android/cpp/ovpnutil/jniglue.c @@ -0,0 +1,40 @@ +#include +#include +#include +#include + + +#include "jniglue.h" + +jint JNI_OnLoad(JavaVM *vm, void *reserved) { +#ifndef NDEBUG + __android_log_write(ANDROID_LOG_DEBUG,"openvpn", "Loading openvpn native library $id$ compiled on " __DATE__ " " __TIME__ ); +#endif + return JNI_VERSION_1_2; +} + + +void android_openvpn_log(int level,const char* prefix,const char* prefix_sep,const char* m1) +{ + __android_log_print(ANDROID_LOG_DEBUG,"openvpn","%s%s%s",prefix,prefix_sep,m1); +} + + +//! Hack to get the current installed ABI of the libraries. See also https://github.com/schwabe/ics-openvpn/issues/391 +jstring Java_de_blinkt_openvpn_core_NativeUtils_getJNIAPI(JNIEnv *env, jclass jo) +{ + + return (*env)->NewStringUTF(env, TARGET_ARCH_ABI); +} + +jstring Java_de_blinkt_openvpn_core_NativeUtils_getOpenVPN2GitVersion(JNIEnv *env, jclass jo) +{ + + return (*env)->NewStringUTF(env, OPENVPN2_GIT_REVISION); +} + +jstring Java_de_blinkt_openvpn_core_NativeUtils_getOpenVPN3GitVersion(JNIEnv *env, jclass jo) +{ + + return (*env)->NewStringUTF(env, OPENVPN3_GIT_REVISION); +} diff --git a/client/android/cpp/ovpnutil/jniglue.h b/client/android/cpp/ovpnutil/jniglue.h new file mode 100644 index 00000000..8f813b64 --- /dev/null +++ b/client/android/cpp/ovpnutil/jniglue.h @@ -0,0 +1,21 @@ +// +// jniglue.h +// xcopenvpn +// +// Created by Arne Schwabe on 29.03.12. +// Copyright (c) 2012 Universität Paderborn. All rights reserved. +// + +#ifndef xcopenvpn_jniglue_h +#define xcopenvpn_jniglue_h +void android_openvpn_log(int level,const char* prefix,const char* prefix_sep,const char* m1); +#endif + +#ifdef __cplusplus +extern "C" { +#endif + int jniThrowException(JNIEnv* env, const char* className, const char* msg); + +#ifdef __cplusplus +} +#endif diff --git a/client/android/cpp/ovpnutil/rsapss.cpp b/client/android/cpp/ovpnutil/rsapss.cpp new file mode 100644 index 00000000..112c2fe4 --- /dev/null +++ b/client/android/cpp/ovpnutil/rsapss.cpp @@ -0,0 +1,146 @@ +/* Adapted from OpenSSL's rsa_pss.c from OpenSSL 3.0.1 */ + +/* + * Copyright 2005-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ +#include "jni.h" + +#include +#include +#include + +#include + +static const unsigned char zeroes[] = {0, 0, 0, 0, 0, 0, 0, 0}; + +static char opensslerr[1024]; +extern "C" jbyteArray Java_de_blinkt_openvpn_core_NativeUtils_rsapss(JNIEnv *env, + jclass, + jint hashtype, + jint MSBits, + jint rsa_size, + jbyteArray from) { + + /* + unsigned char *EM, + const unsigned char *mHash, + const EVP_MD *Hash, const EVP_MD *mgf1Hash, + int sLen) +*/ + + jbyte *data = env->GetByteArrayElements(from, nullptr); + int datalen = env->GetArrayLength(from); + + const auto *mHash = reinterpret_cast(data); + + const EVP_MD *Hash; + + if (hashtype == 0) { + Hash = EVP_md5(); + } else if (hashtype == 1) { + Hash = EVP_sha1(); + } else if (hashtype == 2) { + Hash = EVP_sha224(); + } else if (hashtype == 3) { + Hash = EVP_sha256(); + } else if (hashtype == 4) { + Hash = EVP_sha384(); + } else if (hashtype == 5) { + Hash = EVP_sha512(); + } + + const EVP_MD *mgf1Hash = Hash; + + int ret = 0; + int maskedDBLen, emLen; + unsigned char *H, *salt = nullptr, *p; + EVP_MD_CTX *ctx = nullptr; + + int hLen = EVP_MD_get_size(Hash); + int sLen = hLen; /* RSA_PSS_SALTLEN_DIGEST */ + + std::array buf{}; + unsigned char *EM = buf.data(); + + if (hLen < 0) + goto err; + + emLen = rsa_size; + if (MSBits == 0) { + *EM++ = 0; + emLen--; + } + if (emLen < hLen + 2) { + goto err; + } + if (sLen == RSA_PSS_SALTLEN_MAX) { + sLen = emLen - hLen - 2; + } else if (sLen > emLen - hLen - 2) { + goto err; + } + + if (sLen > 0) { + salt = (unsigned char *) OPENSSL_malloc(sLen); + if (salt == nullptr) { + goto err; + } + if (RAND_bytes_ex(nullptr, salt, sLen, 0) <= 0) + goto err; + } + maskedDBLen = emLen - hLen - 1; + H = EM + maskedDBLen; + ctx = EVP_MD_CTX_new(); + if (ctx == nullptr) + goto err; + if (!EVP_DigestInit_ex(ctx, Hash, nullptr) + || !EVP_DigestUpdate(ctx, zeroes, sizeof(zeroes)) + || !EVP_DigestUpdate(ctx, mHash, hLen)) + goto err; + if (sLen && !EVP_DigestUpdate(ctx, salt, sLen)) + goto err; + if (!EVP_DigestFinal_ex(ctx, H, nullptr)) + goto err; + + /* Generate dbMask in place then perform XOR on it */ + if (PKCS1_MGF1(EM, maskedDBLen, H, hLen, mgf1Hash)) + goto err; + + p = EM; + + /* + * Initial PS XORs with all zeroes which is a NOP so just update pointer. + * Note from a test above this value is guaranteed to be non-negative. + */ + p += emLen - sLen - hLen - 2; + *p++ ^= 0x1; + if (sLen > 0) { + for (int i = 0; i < sLen; i++) + *p++ ^= salt[i]; + } + if (MSBits) + EM[0] &= 0xFF >> (8 - MSBits); + + /* H is already in place so just set final 0xbc */ + + EM[emLen - 1] = 0xbc; + + ret = 1; + + err: + EVP_MD_CTX_free(ctx); + OPENSSL_clear_free(salt, (size_t) sLen); /* salt != NULL implies sLen > 0 */ + + + jbyteArray jb; + + jb = env->NewByteArray(emLen); + + env->SetByteArrayRegion(jb, 0, emLen, (jbyte *) EM); + + return jb; +} \ No newline at end of file diff --git a/client/android/cpp/ovpnutil/sslspeed.c b/client/android/cpp/ovpnutil/sslspeed.c new file mode 100644 index 00000000..a1703ea2 --- /dev/null +++ b/client/android/cpp/ovpnutil/sslspeed.c @@ -0,0 +1,334 @@ +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * The ECDH and ECDSA speed test software is originally written by + * Sumit Gupta of Sun Microsystems Laboratories. + * + */ + +// Modified by Arne Schwabe to give a simple openssl evp speed java api + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "jniglue.h" +#include + +#include +#include +#include +#include +#include +#include +#include + + +/* This file just contains code thrown together until it works */ + + +#undef SECONDS +#define SECONDS 3 +#define PRIME_SECONDS 10 +#define RSA_SECONDS 10 +#define DSA_SECONDS 10 +#define ECDSA_SECONDS 10 +#define ECDH_SECONDS 10 + + +typedef struct loopargs_st { + unsigned char *buf; + unsigned char *buf2; + unsigned char *buf_malloc; + unsigned char *buf2_malloc; + unsigned int siglen; + EVP_CIPHER_CTX *ctx; + HMAC_CTX *hctx; +} loopargs_t; + +#undef BUFSIZE +#define BUFSIZE (1024*16+1) +#define MAX_MISALIGNMENT 63 + + +#define MAX_BLOCK_SIZE 128 +static unsigned char iv[2 * MAX_BLOCK_SIZE / 8]; + +#define SIZE_NUM 7 +static const int lengths[SIZE_NUM] = { + 16, 64, 256, 1024, 1500, 8 * 1024, 16 * 1024 +}; + +static int testnum; + +# define COND(unused_cond) (run && count<0x7fffffff) + +static volatile int run = 0; + +#ifdef SIGALRM +# if defined(__STDC__) || defined(sgi) || defined(_AIX) +# define SIGRETTYPE void +# else +# define SIGRETTYPE int +# endif + + +#define START 0 +#define STOP 1 +#define TM_START 0 +#define TM_STOP 1 + +static int usertime = 1; + +double app_tminterval(int stop, int usertime) +{ + double ret = 0; + struct tms rus; + clock_t now = times(&rus); + static clock_t tmstart; + + if (usertime) + now = rus.tms_utime; + + if (stop == TM_START) + tmstart = now; + else { + long int tck = sysconf(_SC_CLK_TCK); + ret = (now - tmstart) / (double)tck; + } + + return (ret); +} + + + + +static double Time_F(int s) +{ + double ret = app_tminterval(s, usertime); + if (s == STOP) + alarm(0); + return ret; +} + +#endif + + +static long save_count = 0; +static int decrypt = 0; +static int EVP_Update_loop(void *args) +{ + loopargs_t *tempargs = *(loopargs_t **)args; + unsigned char *buf = tempargs->buf; + EVP_CIPHER_CTX *ctx = tempargs->ctx; + int outl, count; + + if (decrypt) + for (count = 0; COND(nb_iter); count++) + EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[testnum]); + else + for (count = 0; COND(nb_iter); count++) + EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[testnum]); + if (decrypt) + EVP_DecryptFinal_ex(ctx, buf, &outl); + else + EVP_EncryptFinal_ex(ctx, buf, &outl); + return count; +} + +static const EVP_MD *evp_md = NULL; +static int EVP_Digest_loop(void *args) +{ + loopargs_t *tempargs = *(loopargs_t **)args; + unsigned char *buf = tempargs->buf; + unsigned char md[EVP_MAX_MD_SIZE]; + int count; + + for (count = 0; COND(nb_iter); count++) { + if (!EVP_Digest(buf, lengths[testnum], md, NULL, evp_md, NULL)) + return -1; + } + return count; +} + + +static int run_benchmark(int async_jobs, + int (*loop_function)(void *), loopargs_t *loopargs) +{ + int job_op_count = 0; + int total_op_count = 0; + int num_inprogress = 0; + int error = 0, i = 0, ret = 0; + OSSL_ASYNC_FD job_fd = 0; + size_t num_job_fds = 0; + + run = 1; + + if (async_jobs == 0) { + return loop_function((void *)&loopargs); + } + return 1234567; +} + + +static void* stop_run(void* arg) +{ + __android_log_write(ANDROID_LOG_DEBUG,"openvpn", "stop run thread started"); + sleep(3); + run=0; + __android_log_write(ANDROID_LOG_DEBUG,"openvpn", "stop run thread stopped"); + return NULL; +} + +jdoubleArray Java_de_blinkt_openvpn_core_NativeUtils_getOpenSSLSpeed(JNIEnv* env, jclass thiz, jstring algorithm, jint testnumber) +{ + + OSSL_PROVIDER *legacy; + OSSL_PROVIDER *deflt; + + OSSL_LIB_CTX *lib_ctx = OSSL_LIB_CTX_new(); + + /* Load Multiple providers into the default (NULL) library context */ + legacy = OSSL_PROVIDER_load(lib_ctx, "legacy"); + if (legacy == NULL) { + __android_log_write(ANDROID_LOG_DEBUG,"openvpn", "Failed to load Legacy provider\n"); + return NULL; + } + deflt = OSSL_PROVIDER_load(lib_ctx, "default"); + if (deflt == NULL) { + __android_log_write(ANDROID_LOG_DEBUG,"openvpn", "Failed to load Default provider\n"); + OSSL_PROVIDER_unload(legacy); + return NULL; + } + + static const unsigned char key16[16] = { + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, + 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12 + }; + const EVP_CIPHER *evp_cipher = NULL; + + const char* alg = (*env)->GetStringUTFChars( env, algorithm , NULL ) ; + + evp_cipher = EVP_CIPHER_fetch(lib_ctx, alg, NULL); + if (evp_cipher == NULL) + evp_md = EVP_MD_fetch(lib_ctx, alg, NULL); + if (evp_cipher == NULL && evp_md == NULL) { + // BIO_printf(bio_err, "%s: %s is an unknown cipher or digest\n", prog, opt_arg()); + //jniThrowException(env, "java/security/NoSuchAlgorithmException", "Algorithm not found"); + __android_log_write(ANDROID_LOG_DEBUG,"openvpn", "Algorithm not found"); + return NULL; + } + + loopargs_t *loopargs = NULL; + int loopargs_len = 1; + int async_jobs = 0; + loopargs = malloc(loopargs_len * sizeof(loopargs_t)); + memset(loopargs, 0, loopargs_len * sizeof(loopargs_t)); + + + jdoubleArray ret = (*env)->NewDoubleArray(env, 3); + + if (testnum < 0 || testnum >= SIZE_NUM) + goto error; + + testnum = testnumber; + + + for (int i = 0; i < loopargs_len; i++) { + int misalign=0; + loopargs[i].buf_malloc = malloc((int)BUFSIZE + MAX_MISALIGNMENT + 1); + loopargs[i].buf2_malloc = malloc((int)BUFSIZE + MAX_MISALIGNMENT + 1); + /* Align the start of buffers on a 64 byte boundary */ + loopargs[i].buf = loopargs[i].buf_malloc + misalign; + loopargs[i].buf2 = loopargs[i].buf2_malloc + misalign; + } + + + int count; + double d; + if (evp_cipher) { + /* + * -O3 -fschedule-insns messes up an optimization here! + * names[D_EVP] somehow becomes NULL + */ + + + for (int k = 0; k < loopargs_len; k++) { + loopargs[k].ctx = EVP_CIPHER_CTX_new(); + if (decrypt) + EVP_DecryptInit_ex(loopargs[k].ctx, evp_cipher, NULL, key16, iv); + else + EVP_EncryptInit_ex(loopargs[k].ctx, evp_cipher, NULL, key16, iv); + EVP_CIPHER_CTX_set_padding(loopargs[k].ctx, 0); + } + + Time_F(START); + pthread_t timer_thread; + + if (pthread_create(&timer_thread, NULL, stop_run, NULL)) + goto error; + + count = run_benchmark(async_jobs, EVP_Update_loop, loopargs); + d = Time_F(STOP); + for (int k = 0; k < loopargs_len; k++) { + EVP_CIPHER_CTX_free(loopargs[k].ctx); + } + } + if (evp_md) { + pthread_t timer_thread; + if (pthread_create(&timer_thread, NULL, stop_run, NULL)) + { + __android_log_write(ANDROID_LOG_DEBUG,"openvpn", "creating thread failed"); + goto error; + } + + Time_F(START); + count = run_benchmark(async_jobs, EVP_Digest_loop, loopargs); + d = Time_F(STOP); + } + + // Save results in hacky way + double results[] = {(double) lengths[testnum], (double) count, d}; + + + (*env)->SetDoubleArrayRegion(env, ret, 0, 3, results); + // print_result(D_EVP, testnum, count, d); + + OSSL_LIB_CTX_free(lib_ctx); + free(loopargs); + return ret; +error: + for (int k = 0; k < loopargs_len; k++) { + EVP_CIPHER_CTX_free(loopargs[k].ctx); + } + free(loopargs); + + OSSL_LIB_CTX_free(lib_ctx); + return NULL; +} diff --git a/client/android/cpp/tools.cmake b/client/android/cpp/tools.cmake new file mode 100644 index 00000000..2bd25b4b --- /dev/null +++ b/client/android/cpp/tools.cmake @@ -0,0 +1,7 @@ +FUNCTION(PREPEND var prefix) + SET(listVar "") + FOREACH(f ${ARGN}) + LIST(APPEND listVar "${prefix}/${f}") + ENDFOREACH(f) + SET(${var} "${listVar}" PARENT_SCOPE) +ENDFUNCTION(PREPEND) diff --git a/client/android/lib/openvpn/arm64-v8a/libjbcrypto.so b/client/android/lib/openvpn/arm64-v8a/libjbcrypto.so deleted file mode 100644 index 5d83f84a..00000000 Binary files a/client/android/lib/openvpn/arm64-v8a/libjbcrypto.so and /dev/null differ diff --git a/client/android/lib/openvpn/arm64-v8a/libopenvpn.so b/client/android/lib/openvpn/arm64-v8a/libopenvpn.so deleted file mode 100644 index c5be388e..00000000 Binary files a/client/android/lib/openvpn/arm64-v8a/libopenvpn.so and /dev/null differ diff --git a/client/android/lib/openvpn/arm64-v8a/libopvpnutil.so b/client/android/lib/openvpn/arm64-v8a/libopvpnutil.so deleted file mode 100644 index bf79f795..00000000 Binary files a/client/android/lib/openvpn/arm64-v8a/libopvpnutil.so and /dev/null differ diff --git a/client/android/lib/openvpn/arm64-v8a/libovpn3.so b/client/android/lib/openvpn/arm64-v8a/libovpn3.so deleted file mode 100644 index ad359d3a..00000000 Binary files a/client/android/lib/openvpn/arm64-v8a/libovpn3.so and /dev/null differ diff --git a/client/android/lib/openvpn/arm64-v8a/libovpnexec.so b/client/android/lib/openvpn/arm64-v8a/libovpnexec.so deleted file mode 100644 index 8addf510..00000000 Binary files a/client/android/lib/openvpn/arm64-v8a/libovpnexec.so and /dev/null differ diff --git a/client/android/lib/openvpn/armeabi-v7a/libjbcrypto.so b/client/android/lib/openvpn/armeabi-v7a/libjbcrypto.so deleted file mode 100644 index 422d669a..00000000 Binary files a/client/android/lib/openvpn/armeabi-v7a/libjbcrypto.so and /dev/null differ diff --git a/client/android/lib/openvpn/armeabi-v7a/libopenvpn.so b/client/android/lib/openvpn/armeabi-v7a/libopenvpn.so deleted file mode 100644 index 0943d2b0..00000000 Binary files a/client/android/lib/openvpn/armeabi-v7a/libopenvpn.so and /dev/null differ diff --git a/client/android/lib/openvpn/armeabi-v7a/libopvpnutil.so b/client/android/lib/openvpn/armeabi-v7a/libopvpnutil.so deleted file mode 100644 index ded4881e..00000000 Binary files a/client/android/lib/openvpn/armeabi-v7a/libopvpnutil.so and /dev/null differ diff --git a/client/android/lib/openvpn/armeabi-v7a/libovpn3.so b/client/android/lib/openvpn/armeabi-v7a/libovpn3.so deleted file mode 100644 index b6334b6b..00000000 Binary files a/client/android/lib/openvpn/armeabi-v7a/libovpn3.so and /dev/null differ diff --git a/client/android/lib/openvpn/armeabi-v7a/libovpnexec.so b/client/android/lib/openvpn/armeabi-v7a/libovpnexec.so deleted file mode 100644 index 517a1dd9..00000000 Binary files a/client/android/lib/openvpn/armeabi-v7a/libovpnexec.so and /dev/null differ diff --git a/client/android/lib/openvpn/x86/libjbcrypto.so b/client/android/lib/openvpn/x86/libjbcrypto.so deleted file mode 100644 index 67419bc1..00000000 Binary files a/client/android/lib/openvpn/x86/libjbcrypto.so and /dev/null differ diff --git a/client/android/lib/openvpn/x86/libopenvpn.so b/client/android/lib/openvpn/x86/libopenvpn.so deleted file mode 100644 index 728a395d..00000000 Binary files a/client/android/lib/openvpn/x86/libopenvpn.so and /dev/null differ diff --git a/client/android/lib/openvpn/x86/libopvpnutil.so b/client/android/lib/openvpn/x86/libopvpnutil.so deleted file mode 100644 index 3329fe9a..00000000 Binary files a/client/android/lib/openvpn/x86/libopvpnutil.so and /dev/null differ diff --git a/client/android/lib/openvpn/x86/libovpn3.so b/client/android/lib/openvpn/x86/libovpn3.so deleted file mode 100644 index 5ae500a4..00000000 Binary files a/client/android/lib/openvpn/x86/libovpn3.so and /dev/null differ diff --git a/client/android/lib/openvpn/x86/libovpnexec.so b/client/android/lib/openvpn/x86/libovpnexec.so deleted file mode 100644 index 29b4cc2b..00000000 Binary files a/client/android/lib/openvpn/x86/libovpnexec.so and /dev/null differ diff --git a/client/android/lib/openvpn/x86_64/libjbcrypto.so b/client/android/lib/openvpn/x86_64/libjbcrypto.so deleted file mode 100644 index 1158d07a..00000000 Binary files a/client/android/lib/openvpn/x86_64/libjbcrypto.so and /dev/null differ diff --git a/client/android/lib/openvpn/x86_64/libopenvpn.so b/client/android/lib/openvpn/x86_64/libopenvpn.so deleted file mode 100644 index a30256eb..00000000 Binary files a/client/android/lib/openvpn/x86_64/libopenvpn.so and /dev/null differ diff --git a/client/android/lib/openvpn/x86_64/libopvpnutil.so b/client/android/lib/openvpn/x86_64/libopvpnutil.so deleted file mode 100644 index cdbfaae8..00000000 Binary files a/client/android/lib/openvpn/x86_64/libopvpnutil.so and /dev/null differ diff --git a/client/android/lib/openvpn/x86_64/libovpn3.so b/client/android/lib/openvpn/x86_64/libovpn3.so deleted file mode 100644 index 00e792ed..00000000 Binary files a/client/android/lib/openvpn/x86_64/libovpn3.so and /dev/null differ diff --git a/client/android/lib/openvpn/x86_64/libovpnexec.so b/client/android/lib/openvpn/x86_64/libovpnexec.so deleted file mode 100644 index a315dd2f..00000000 Binary files a/client/android/lib/openvpn/x86_64/libovpnexec.so and /dev/null differ diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_Config.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_Config.java index 396ff49f..c4abf8b8 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_Config.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_Config.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -117,12 +117,12 @@ public class ClientAPI_Config { return ovpncliJNI.ClientAPI_Config_protoVersionOverride_get(swigCPtr, this); } - public void setIpv6(String value) { - ovpncliJNI.ClientAPI_Config_ipv6_set(swigCPtr, this, value); + public void setAllowUnusedAddrFamilies(String value) { + ovpncliJNI.ClientAPI_Config_allowUnusedAddrFamilies_set(swigCPtr, this, value); } - public String getIpv6() { - return ovpncliJNI.ClientAPI_Config_ipv6_get(swigCPtr, this); + public String getAllowUnusedAddrFamilies() { + return ovpncliJNI.ClientAPI_Config_allowUnusedAddrFamilies_get(swigCPtr, this); } public void setConnTimeout(int value) { @@ -221,14 +221,6 @@ public class ClientAPI_Config { return ovpncliJNI.ClientAPI_Config_defaultKeyDirection_get(swigCPtr, this); } - public void setForceAesCbcCiphersuites(boolean value) { - ovpncliJNI.ClientAPI_Config_forceAesCbcCiphersuites_set(swigCPtr, this, value); - } - - public boolean getForceAesCbcCiphersuites() { - return ovpncliJNI.ClientAPI_Config_forceAesCbcCiphersuites_get(swigCPtr, this); - } - public void setTlsVersionMinOverride(String value) { ovpncliJNI.ClientAPI_Config_tlsVersionMinOverride_set(swigCPtr, this, value); } @@ -366,6 +358,14 @@ public class ClientAPI_Config { return ovpncliJNI.ClientAPI_Config_gremlinConfig_get(swigCPtr, this); } + public void setUsePluggableTransports(boolean value) { + ovpncliJNI.ClientAPI_Config_usePluggableTransports_set(swigCPtr, this, value); + } + + public boolean getUsePluggableTransports() { + return ovpncliJNI.ClientAPI_Config_usePluggableTransports_get(swigCPtr, this); + } + public void setWintun(boolean value) { ovpncliJNI.ClientAPI_Config_wintun_set(swigCPtr, this, value); } @@ -374,6 +374,30 @@ public class ClientAPI_Config { return ovpncliJNI.ClientAPI_Config_wintun_get(swigCPtr, this); } + public void setAllowLocalDnsResolvers(boolean value) { + ovpncliJNI.ClientAPI_Config_allowLocalDnsResolvers_set(swigCPtr, this, value); + } + + public boolean getAllowLocalDnsResolvers() { + return ovpncliJNI.ClientAPI_Config_allowLocalDnsResolvers_get(swigCPtr, this); + } + + public void setEnableLegacyAlgorithms(boolean value) { + ovpncliJNI.ClientAPI_Config_enableLegacyAlgorithms_set(swigCPtr, this, value); + } + + public boolean getEnableLegacyAlgorithms() { + return ovpncliJNI.ClientAPI_Config_enableLegacyAlgorithms_get(swigCPtr, this); + } + + public void setEnableNonPreferredDCAlgorithms(boolean value) { + ovpncliJNI.ClientAPI_Config_enableNonPreferredDCAlgorithms_set(swigCPtr, this, value); + } + + public boolean getEnableNonPreferredDCAlgorithms() { + return ovpncliJNI.ClientAPI_Config_enableNonPreferredDCAlgorithms_get(swigCPtr, this); + } + public ClientAPI_Config() { this(ovpncliJNI.new_ClientAPI_Config(), true); } diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_ConnectionInfo.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_ConnectionInfo.java index b7e554ab..26742231 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_ConnectionInfo.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_ConnectionInfo.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_DynamicChallenge.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_DynamicChallenge.java index e1290d26..99d6d569 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_DynamicChallenge.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_DynamicChallenge.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_EvalConfig.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_EvalConfig.java index ce4ed170..790e85e3 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_EvalConfig.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_EvalConfig.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_Event.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_Event.java index 6a12786c..80cfe99e 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_Event.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_Event.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKIBase.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKIBase.java index 41b6890b..aa80ac77 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKIBase.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKIBase.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKICertRequest.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKICertRequest.java index d3e152f0..decd5baf 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKICertRequest.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKICertRequest.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKIRequestBase.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKIRequestBase.java index 7e9ea388..75a6072e 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKIRequestBase.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKIRequestBase.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKISignRequest.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKISignRequest.java index e0757035..bd91e4f1 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKISignRequest.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_ExternalPKISignRequest.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_InterfaceStats.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_InterfaceStats.java index 72875f24..f486589f 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_InterfaceStats.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_InterfaceStats.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_KeyValue.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_KeyValue.java index a815d447..055677be 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_KeyValue.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_KeyValue.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_LLVector.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_LLVector.java index 011a8665..c1443386 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_LLVector.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_LLVector.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_LogInfo.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_LogInfo.java index 07e08db2..008aeb22 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_LogInfo.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_LogInfo.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_MergeConfig.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_MergeConfig.java index 9286d72f..74d37c77 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_MergeConfig.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_MergeConfig.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_OpenVPNClient.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_OpenVPNClient.java index d65027e9..19701ab3 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_OpenVPNClient.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_OpenVPNClient.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -56,26 +56,6 @@ public class ClientAPI_OpenVPNClient extends ClientAPI_TunBuilderBase { ovpncliJNI.ClientAPI_OpenVPNClient_director_connect(this, swigCPtr, true, true); } - public static ClientAPI_MergeConfig merge_config_static(String path, boolean follow_references) { - return new ClientAPI_MergeConfig(ovpncliJNI.ClientAPI_OpenVPNClient_merge_config_static(path, follow_references), true); - } - - public static ClientAPI_MergeConfig merge_config_string_static(String config_content) { - return new ClientAPI_MergeConfig(ovpncliJNI.ClientAPI_OpenVPNClient_merge_config_string_static(config_content), true); - } - - public static ClientAPI_EvalConfig eval_config_static(ClientAPI_Config config) { - return new ClientAPI_EvalConfig(ovpncliJNI.ClientAPI_OpenVPNClient_eval_config_static(ClientAPI_Config.getCPtr(config), config), true); - } - - public static int max_profile_size() { - return ovpncliJNI.ClientAPI_OpenVPNClient_max_profile_size(); - } - - public static boolean parse_dynamic_challenge(String cookie, ClientAPI_DynamicChallenge dc) { - return ovpncliJNI.ClientAPI_OpenVPNClient_parse_dynamic_challenge(cookie, ClientAPI_DynamicChallenge.getCPtr(dc), dc); - } - public ClientAPI_EvalConfig eval_config(ClientAPI_Config arg0) { return new ClientAPI_EvalConfig(ovpncliJNI.ClientAPI_OpenVPNClient_eval_config(swigCPtr, this, ClientAPI_Config.getCPtr(arg0), arg0), true); } @@ -176,20 +156,4 @@ public class ClientAPI_OpenVPNClient extends ClientAPI_TunBuilderBase { if (getClass() == ClientAPI_OpenVPNClient.class) ovpncliJNI.ClientAPI_OpenVPNClient_clock_tick(swigCPtr, this); else ovpncliJNI.ClientAPI_OpenVPNClient_clock_tickSwigExplicitClientAPI_OpenVPNClient(swigCPtr, this); } - public static String crypto_self_test() { - return ovpncliJNI.ClientAPI_OpenVPNClient_crypto_self_test(); - } - - public static int app_expire() { - return ovpncliJNI.ClientAPI_OpenVPNClient_app_expire(); - } - - public static String platform() { - return ovpncliJNI.ClientAPI_OpenVPNClient_platform(); - } - - public static String copyright() { - return ovpncliJNI.ClientAPI_OpenVPNClient_copyright(); - } - } diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_OpenVPNClientHelper.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_OpenVPNClientHelper.java new file mode 100644 index 00000000..47488823 --- /dev/null +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_OpenVPNClientHelper.java @@ -0,0 +1,75 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package net.openvpn.ovpn3; + +public class ClientAPI_OpenVPNClientHelper { + private transient long swigCPtr; + protected transient boolean swigCMemOwn; + + protected ClientAPI_OpenVPNClientHelper(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(ClientAPI_OpenVPNClientHelper obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + @SuppressWarnings("deprecation") + protected void finalize() { + delete(); + } + + public synchronized void delete() { + if (swigCPtr != 0) { + if (swigCMemOwn) { + swigCMemOwn = false; + ovpncliJNI.delete_ClientAPI_OpenVPNClientHelper(swigCPtr); + } + swigCPtr = 0; + } + } + + public ClientAPI_OpenVPNClientHelper() { + this(ovpncliJNI.new_ClientAPI_OpenVPNClientHelper(), true); + } + + public ClientAPI_MergeConfig merge_config(String path, boolean follow_references) { + return new ClientAPI_MergeConfig(ovpncliJNI.ClientAPI_OpenVPNClientHelper_merge_config(swigCPtr, this, path, follow_references), true); + } + + public ClientAPI_MergeConfig merge_config_string(String config_content) { + return new ClientAPI_MergeConfig(ovpncliJNI.ClientAPI_OpenVPNClientHelper_merge_config_string(swigCPtr, this, config_content), true); + } + + public ClientAPI_EvalConfig eval_config(ClientAPI_Config config) { + return new ClientAPI_EvalConfig(ovpncliJNI.ClientAPI_OpenVPNClientHelper_eval_config(swigCPtr, this, ClientAPI_Config.getCPtr(config), config), true); + } + + public static int max_profile_size() { + return ovpncliJNI.ClientAPI_OpenVPNClientHelper_max_profile_size(); + } + + public static boolean parse_dynamic_challenge(String cookie, ClientAPI_DynamicChallenge dc) { + return ovpncliJNI.ClientAPI_OpenVPNClientHelper_parse_dynamic_challenge(cookie, ClientAPI_DynamicChallenge.getCPtr(dc), dc); + } + + public String crypto_self_test() { + return ovpncliJNI.ClientAPI_OpenVPNClientHelper_crypto_self_test(swigCPtr, this); + } + + public static String platform() { + return ovpncliJNI.ClientAPI_OpenVPNClientHelper_platform(); + } + + public static String copyright() { + return ovpncliJNI.ClientAPI_OpenVPNClientHelper_copyright(); + } + +} diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_ProvideCreds.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_ProvideCreds.java index 7bddeeab..f82a9c35 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_ProvideCreds.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_ProvideCreds.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_RemoteOverride.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_RemoteOverride.java index 64209913..80bdde67 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_RemoteOverride.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_RemoteOverride.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_ServerEntry.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_ServerEntry.java index 0efd034a..f5f48f56 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_ServerEntry.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_ServerEntry.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_ServerEntryVector.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_ServerEntryVector.java index 49f5b0c0..3a899ca5 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_ServerEntryVector.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_ServerEntryVector.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_SessionToken.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_SessionToken.java index 457be0a2..ce2050c0 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_SessionToken.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_SessionToken.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_Status.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_Status.java index 37900c67..4c138901 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_Status.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_Status.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_StringVec.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_StringVec.java index d95230ea..ad4bfe62 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_StringVec.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_StringVec.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_TransportStats.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_TransportStats.java index 8ec734ad..6a2f3726 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_TransportStats.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_TransportStats.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ClientAPI_TunBuilderBase.java b/client/android/src/net/openvpn/ovpn3/ClientAPI_TunBuilderBase.java index 761e2cdf..3c8358d6 100644 --- a/client/android/src/net/openvpn/ovpn3/ClientAPI_TunBuilderBase.java +++ b/client/android/src/net/openvpn/ovpn3/ClientAPI_TunBuilderBase.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -104,8 +104,8 @@ public class ClientAPI_TunBuilderBase { return ovpncliJNI.ClientAPI_TunBuilderBase_tun_builder_add_wins_server(swigCPtr, this, address); } - public boolean tun_builder_set_block_ipv6(boolean block_ipv6) { - return ovpncliJNI.ClientAPI_TunBuilderBase_tun_builder_set_block_ipv6(swigCPtr, this, block_ipv6); + public boolean tun_builder_set_allow_family(int af, boolean allow) { + return ovpncliJNI.ClientAPI_TunBuilderBase_tun_builder_set_allow_family(swigCPtr, this, af, allow); } public boolean tun_builder_set_adapter_domain_suffix(String name) { diff --git a/client/android/src/net/openvpn/ovpn3/SWIGTYPE_p_std__string.java b/client/android/src/net/openvpn/ovpn3/SWIGTYPE_p_std__string.java index 78a5c3fc..e49f5874 100644 --- a/client/android/src/net/openvpn/ovpn3/SWIGTYPE_p_std__string.java +++ b/client/android/src/net/openvpn/ovpn3/SWIGTYPE_p_std__string.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/SWIGTYPE_p_std__vectorT_openvpn__ClientAPI__KeyValue_t.java b/client/android/src/net/openvpn/ovpn3/SWIGTYPE_p_std__vectorT_openvpn__ClientAPI__KeyValue_t.java index 487eb5cf..15ff7a0f 100644 --- a/client/android/src/net/openvpn/ovpn3/SWIGTYPE_p_std__vectorT_openvpn__ClientAPI__KeyValue_t.java +++ b/client/android/src/net/openvpn/ovpn3/SWIGTYPE_p_std__vectorT_openvpn__ClientAPI__KeyValue_t.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ovpncli.java b/client/android/src/net/openvpn/ovpn3/ovpncli.java index 344ddf0e..944d22ed 100644 --- a/client/android/src/net/openvpn/ovpn3/ovpncli.java +++ b/client/android/src/net/openvpn/ovpn3/ovpncli.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/client/android/src/net/openvpn/ovpn3/ovpncliJNI.java b/client/android/src/net/openvpn/ovpn3/ovpncliJNI.java index 4fc25720..875629ea 100644 --- a/client/android/src/net/openvpn/ovpn3/ovpncliJNI.java +++ b/client/android/src/net/openvpn/ovpn3/ovpncliJNI.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 + * Version 4.0.1 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -73,7 +73,7 @@ public class ovpncliJNI { public final static native boolean ClientAPI_TunBuilderBase_tun_builder_set_proxy_http(long jarg1, ClientAPI_TunBuilderBase jarg1_, String jarg2, int jarg3); public final static native boolean ClientAPI_TunBuilderBase_tun_builder_set_proxy_https(long jarg1, ClientAPI_TunBuilderBase jarg1_, String jarg2, int jarg3); public final static native boolean ClientAPI_TunBuilderBase_tun_builder_add_wins_server(long jarg1, ClientAPI_TunBuilderBase jarg1_, String jarg2); - public final static native boolean ClientAPI_TunBuilderBase_tun_builder_set_block_ipv6(long jarg1, ClientAPI_TunBuilderBase jarg1_, boolean jarg2); + public final static native boolean ClientAPI_TunBuilderBase_tun_builder_set_allow_family(long jarg1, ClientAPI_TunBuilderBase jarg1_, int jarg2, boolean jarg3); public final static native boolean ClientAPI_TunBuilderBase_tun_builder_set_adapter_domain_suffix(long jarg1, ClientAPI_TunBuilderBase jarg1_, String jarg2); public final static native int ClientAPI_TunBuilderBase_tun_builder_establish(long jarg1, ClientAPI_TunBuilderBase jarg1_); public final static native boolean ClientAPI_TunBuilderBase_tun_builder_persist(long jarg1, ClientAPI_TunBuilderBase jarg1_); @@ -183,8 +183,8 @@ public class ovpncliJNI { public final static native String ClientAPI_Config_protoOverride_get(long jarg1, ClientAPI_Config jarg1_); public final static native void ClientAPI_Config_protoVersionOverride_set(long jarg1, ClientAPI_Config jarg1_, int jarg2); public final static native int ClientAPI_Config_protoVersionOverride_get(long jarg1, ClientAPI_Config jarg1_); - public final static native void ClientAPI_Config_ipv6_set(long jarg1, ClientAPI_Config jarg1_, String jarg2); - public final static native String ClientAPI_Config_ipv6_get(long jarg1, ClientAPI_Config jarg1_); + public final static native void ClientAPI_Config_allowUnusedAddrFamilies_set(long jarg1, ClientAPI_Config jarg1_, String jarg2); + public final static native String ClientAPI_Config_allowUnusedAddrFamilies_get(long jarg1, ClientAPI_Config jarg1_); public final static native void ClientAPI_Config_connTimeout_set(long jarg1, ClientAPI_Config jarg1_, int jarg2); public final static native int ClientAPI_Config_connTimeout_get(long jarg1, ClientAPI_Config jarg1_); public final static native void ClientAPI_Config_tunPersist_set(long jarg1, ClientAPI_Config jarg1_, boolean jarg2); @@ -209,8 +209,6 @@ public class ovpncliJNI { public final static native String ClientAPI_Config_privateKeyPassword_get(long jarg1, ClientAPI_Config jarg1_); public final static native void ClientAPI_Config_defaultKeyDirection_set(long jarg1, ClientAPI_Config jarg1_, int jarg2); public final static native int ClientAPI_Config_defaultKeyDirection_get(long jarg1, ClientAPI_Config jarg1_); - public final static native void ClientAPI_Config_forceAesCbcCiphersuites_set(long jarg1, ClientAPI_Config jarg1_, boolean jarg2); - public final static native boolean ClientAPI_Config_forceAesCbcCiphersuites_get(long jarg1, ClientAPI_Config jarg1_); public final static native void ClientAPI_Config_tlsVersionMinOverride_set(long jarg1, ClientAPI_Config jarg1_, String jarg2); public final static native String ClientAPI_Config_tlsVersionMinOverride_get(long jarg1, ClientAPI_Config jarg1_); public final static native void ClientAPI_Config_tlsCertProfileOverride_set(long jarg1, ClientAPI_Config jarg1_, String jarg2); @@ -245,8 +243,16 @@ public class ovpncliJNI { public final static native long ClientAPI_Config_clockTickMS_get(long jarg1, ClientAPI_Config jarg1_); public final static native void ClientAPI_Config_gremlinConfig_set(long jarg1, ClientAPI_Config jarg1_, String jarg2); public final static native String ClientAPI_Config_gremlinConfig_get(long jarg1, ClientAPI_Config jarg1_); + public final static native void ClientAPI_Config_usePluggableTransports_set(long jarg1, ClientAPI_Config jarg1_, boolean jarg2); + public final static native boolean ClientAPI_Config_usePluggableTransports_get(long jarg1, ClientAPI_Config jarg1_); public final static native void ClientAPI_Config_wintun_set(long jarg1, ClientAPI_Config jarg1_, boolean jarg2); public final static native boolean ClientAPI_Config_wintun_get(long jarg1, ClientAPI_Config jarg1_); + public final static native void ClientAPI_Config_allowLocalDnsResolvers_set(long jarg1, ClientAPI_Config jarg1_, boolean jarg2); + public final static native boolean ClientAPI_Config_allowLocalDnsResolvers_get(long jarg1, ClientAPI_Config jarg1_); + public final static native void ClientAPI_Config_enableLegacyAlgorithms_set(long jarg1, ClientAPI_Config jarg1_, boolean jarg2); + public final static native boolean ClientAPI_Config_enableLegacyAlgorithms_get(long jarg1, ClientAPI_Config jarg1_); + public final static native void ClientAPI_Config_enableNonPreferredDCAlgorithms_set(long jarg1, ClientAPI_Config jarg1_, boolean jarg2); + public final static native boolean ClientAPI_Config_enableNonPreferredDCAlgorithms_get(long jarg1, ClientAPI_Config jarg1_); public final static native long new_ClientAPI_Config(); public final static native void delete_ClientAPI_Config(long jarg1); public final static native void ClientAPI_Event_error_set(long jarg1, ClientAPI_Event jarg1_, boolean jarg2); @@ -372,13 +378,18 @@ public class ovpncliJNI { public final static native String ClientAPI_RemoteOverride_error_get(long jarg1, ClientAPI_RemoteOverride jarg1_); public final static native long new_ClientAPI_RemoteOverride(); public final static native void delete_ClientAPI_RemoteOverride(long jarg1); + public final static native long new_ClientAPI_OpenVPNClientHelper(); + public final static native void delete_ClientAPI_OpenVPNClientHelper(long jarg1); + public final static native long ClientAPI_OpenVPNClientHelper_merge_config(long jarg1, ClientAPI_OpenVPNClientHelper jarg1_, String jarg2, boolean jarg3); + public final static native long ClientAPI_OpenVPNClientHelper_merge_config_string(long jarg1, ClientAPI_OpenVPNClientHelper jarg1_, String jarg2); + public final static native long ClientAPI_OpenVPNClientHelper_eval_config(long jarg1, ClientAPI_OpenVPNClientHelper jarg1_, long jarg2, ClientAPI_Config jarg2_); + public final static native int ClientAPI_OpenVPNClientHelper_max_profile_size(); + public final static native boolean ClientAPI_OpenVPNClientHelper_parse_dynamic_challenge(String jarg1, long jarg2, ClientAPI_DynamicChallenge jarg2_); + public final static native String ClientAPI_OpenVPNClientHelper_crypto_self_test(long jarg1, ClientAPI_OpenVPNClientHelper jarg1_); + public final static native String ClientAPI_OpenVPNClientHelper_platform(); + public final static native String ClientAPI_OpenVPNClientHelper_copyright(); public final static native long new_ClientAPI_OpenVPNClient(); public final static native void delete_ClientAPI_OpenVPNClient(long jarg1); - public final static native long ClientAPI_OpenVPNClient_merge_config_static(String jarg1, boolean jarg2); - public final static native long ClientAPI_OpenVPNClient_merge_config_string_static(String jarg1); - public final static native long ClientAPI_OpenVPNClient_eval_config_static(long jarg1, ClientAPI_Config jarg1_); - public final static native int ClientAPI_OpenVPNClient_max_profile_size(); - public final static native boolean ClientAPI_OpenVPNClient_parse_dynamic_challenge(String jarg1, long jarg2, ClientAPI_DynamicChallenge jarg2_); public final static native long ClientAPI_OpenVPNClient_eval_config(long jarg1, ClientAPI_OpenVPNClient jarg1_, long jarg2, ClientAPI_Config jarg2_); public final static native long ClientAPI_OpenVPNClient_provide_creds(long jarg1, ClientAPI_OpenVPNClient jarg1_, long jarg2, ClientAPI_ProvideCreds jarg2_); public final static native boolean ClientAPI_OpenVPNClient_socket_protect(long jarg1, ClientAPI_OpenVPNClient jarg1_, int jarg2, String jarg3, boolean jarg4); @@ -408,10 +419,6 @@ public class ovpncliJNI { public final static native void ClientAPI_OpenVPNClient_remote_overrideSwigExplicitClientAPI_OpenVPNClient(long jarg1, ClientAPI_OpenVPNClient jarg1_, long jarg2, ClientAPI_RemoteOverride jarg2_); public final static native void ClientAPI_OpenVPNClient_clock_tick(long jarg1, ClientAPI_OpenVPNClient jarg1_); public final static native void ClientAPI_OpenVPNClient_clock_tickSwigExplicitClientAPI_OpenVPNClient(long jarg1, ClientAPI_OpenVPNClient jarg1_); - public final static native String ClientAPI_OpenVPNClient_crypto_self_test(); - public final static native int ClientAPI_OpenVPNClient_app_expire(); - public final static native String ClientAPI_OpenVPNClient_platform(); - public final static native String ClientAPI_OpenVPNClient_copyright(); public final static native void ClientAPI_OpenVPNClient_director_connect(ClientAPI_OpenVPNClient obj, long cptr, boolean mem_own, boolean weak_global); public final static native void ClientAPI_OpenVPNClient_change_ownership(ClientAPI_OpenVPNClient obj, long cptr, boolean take_or_release); public final static native long ClientAPI_ExternalPKICertRequest_SWIGUpcast(long jarg1); @@ -469,8 +476,8 @@ public class ovpncliJNI { public static boolean SwigDirector_ClientAPI_OpenVPNClient_tun_builder_add_wins_server(ClientAPI_OpenVPNClient jself, String address) { return jself.tun_builder_add_wins_server(address); } - public static boolean SwigDirector_ClientAPI_OpenVPNClient_tun_builder_set_block_ipv6(ClientAPI_OpenVPNClient jself, boolean block_ipv6) { - return jself.tun_builder_set_block_ipv6(block_ipv6); + public static boolean SwigDirector_ClientAPI_OpenVPNClient_tun_builder_set_allow_family(ClientAPI_OpenVPNClient jself, int af, boolean allow) { + return jself.tun_builder_set_allow_family(af, allow); } public static boolean SwigDirector_ClientAPI_OpenVPNClient_tun_builder_set_adapter_domain_suffix(ClientAPI_OpenVPNClient jself, String name) { return jself.tun_builder_set_adapter_domain_suffix(name); diff --git a/client/android/src/org/amnezia/vpn/OpenVPNThreadv3.kt b/client/android/src/org/amnezia/vpn/OpenVPNThreadv3.kt index 847156d4..1ebd9a51 100644 --- a/client/android/src/org/amnezia/vpn/OpenVPNThreadv3.kt +++ b/client/android/src/org/amnezia/vpn/OpenVPNThreadv3.kt @@ -14,6 +14,7 @@ import com.wireguard.android.util.SharedLibraryLoader import com.wireguard.config.* import com.wireguard.crypto.Key import org.json.JSONObject +import java.util.Base64 import net.openvpn.ovpn3.ClientAPI_Config import net.openvpn.ovpn3.ClientAPI_EvalConfig @@ -25,6 +26,7 @@ import net.openvpn.ovpn3.ClientAPI_OpenVPNClient import net.openvpn.ovpn3.ClientAPI_ProvideCreds import net.openvpn.ovpn3.ClientAPI_Status import net.openvpn.ovpn3.ClientAPI_TransportStats +import java.lang.StringBuilder class OpenVPNThreadv3(var service: VPNService): ClientAPI_OpenVPNClient(), Runnable { private val tag = "OpenVPNThreadv3" @@ -59,7 +61,48 @@ class OpenVPNThreadv3(var service: VPNService): ClientAPI_OpenVPNClient(), Runna override fun run() { val config: ClientAPI_Config = ClientAPI_Config() - config.content = mService.getVpnConfig().getJSONObject("openvpn_config_data").getString("config") + + val jsonVpnConfig = mService.getVpnConfig() + val ovpnConfig = jsonVpnConfig.getJSONObject("openvpn_config_data").getString("config") + + val resultingConfig = StringBuilder() + resultingConfig.append(ovpnConfig) + + if (jsonVpnConfig.getString("protocol") == "cloak") { + val cloakConfigJson: JSONObject = jsonVpnConfig.getJSONObject("cloak_config_data") + + if (cloakConfigJson.keySet().contains("NumConn")) { + cloakConfigJson.put("NumConn", 1) + } + + if (cloakConfigJson.keySet().contains("ProxyMethod")) { + cloakConfigJson.put("ProxyMethod", "openvpn") + } + + if (cloakConfigJson.keySet().contains("port")) { + val portValue = cloakConfigJson.get("port") + cloakConfigJson.remove("port") + cloakConfigJson.put("RemotePort", portValue) + } + + if (cloakConfigJson.keySet().contains("remote")) { + val hostValue = cloakConfigJson.get("remote") + cloakConfigJson.remove("remote") + cloakConfigJson.put("RemoteHost", hostValue) + } + + val cloakConfig = Base64.getEncoder().encodeToString( + jsonVpnConfig.getJSONObject("cloak_config_data").toString().toByteArray() + ) + + resultingConfig.append("\n\n") + resultingConfig.append(cloakConfig) + resultingConfig.append("\n\n") + + config.setUsePluggableTransports(true) + } + + config.content = resultingConfig.toString() eval_config(config) @@ -67,7 +110,6 @@ class OpenVPNThreadv3(var service: VPNService): ClientAPI_OpenVPNClient(), Runna if (status.getError()) { Log.i(tag, "connect() error: " + status.getError() + ": " + status.getMessage()) } - } override fun log(arg0: ClientAPI_LogInfo){ diff --git a/client/android/src/org/amnezia/vpn/VPNService.kt b/client/android/src/org/amnezia/vpn/VPNService.kt index f2e649ac..8f6966ef 100644 --- a/client/android/src/org/amnezia/vpn/VPNService.kt +++ b/client/android/src/org/amnezia/vpn/VPNService.kt @@ -176,7 +176,6 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { } override fun onUnbind(intent: Intent?): Boolean { - Log.v(tag, "Aman: onUnbind....................") if (!isUp) { // If the Qt Client got closed while we were not connected // we do not need to stay as a foreground service. @@ -185,12 +184,17 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { return super.onUnbind(intent) } + override fun onDestroy() { + turnOff() + + super.onDestroy() + } + /** * EntryPoint for the Service, gets Called when AndroidController.cpp * calles bindService. Returns the [VPNServiceBinder] so QT can send Requests to it. */ override fun onBind(intent: Intent): IBinder { - Log.v(tag, "Aman: onBind....................") when (mProtocol) { "shadowsocks" -> { @@ -214,7 +218,6 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { * or from Booting the device and having "connect on boot" enabled. */ override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { - Log.v(tag, "Aman: onStartCommand....................") this.intent = intent this.flags = flags this.startId = startId @@ -278,6 +281,7 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { var isUp: Boolean = false get() { return when (mProtocol) { + "cloak", "openvpn" -> { field } @@ -303,6 +307,7 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { val deviceIpv4: String = "" val status = when (mProtocol) { + "cloak", "openvpn" -> { if (mOpenVPNThreadv3 == null) { Status(null, null, null, null) @@ -373,7 +378,9 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { Log.i(tag, "Config: $mConfig") mProtocol = mConfig!!.getString("protocol") Log.i(tag, "Protocol: $mProtocol") + when (mProtocol) { + "cloak", "openvpn" -> { startOpenVpn() } @@ -447,8 +454,13 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { fun turnOff() { Log.v(tag, "Aman: turnOff....................") when (mProtocol) { - "wireguard" -> wgTurnOff(currentTunnelHandle) - "openvpn" -> ovpnTurnOff() + "wireguard" -> { + wgTurnOff(currentTunnelHandle) + } + "cloak", + "openvpn" -> { + ovpnTurnOff() + } "shadowsocks" -> { stopRunner(false) stopTest() @@ -457,6 +469,7 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { Log.e(tag, "No protocol") } } + currentTunnelHandle = -1 stopForeground(true) isUp = false @@ -688,6 +701,10 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { } private fun startOpenVpn() { + if (isUp || mOpenVPNThreadv3 != null) { + ovpnTurnOff() + } + mOpenVPNThreadv3 = OpenVPNThreadv3(this) Thread({ diff --git a/client/android/src/org/amnezia/vpn/qt/AmneziaApp.kt b/client/android/src/org/amnezia/vpn/qt/AmneziaApp.kt index 24c33ffc..77332efa 100644 --- a/client/android/src/org/amnezia/vpn/qt/AmneziaApp.kt +++ b/client/android/src/org/amnezia/vpn/qt/AmneziaApp.kt @@ -7,7 +7,7 @@ import org.qtproject.qt.android.bindings.QtActivity import org.qtproject.qt.android.bindings.QtApplication import android.app.Application -class AmneziaApp: Application() { +class AmneziaApp: org.qtproject.qt.android.bindings.QtApplication() { override fun onCreate() { super.onCreate() @@ -19,4 +19,4 @@ class AmneziaApp: Application() { super.onConfigurationChanged(newConfig) Core.updateNotificationChannels() } -} \ No newline at end of file +} diff --git a/client/android/src/org/amnezia/vpn/qt/VPNActivity.kt b/client/android/src/org/amnezia/vpn/qt/VPNActivity.kt index dab60b3a..a8aa73d6 100644 --- a/client/android/src/org/amnezia/vpn/qt/VPNActivity.kt +++ b/client/android/src/org/amnezia/vpn/qt/VPNActivity.kt @@ -5,8 +5,6 @@ package org.amnezia.vpn.qt; import android.Manifest -import android.content.ClipData -import android.content.ClipboardManager import android.content.ComponentName import android.content.ContentResolver import android.content.Context @@ -73,10 +71,6 @@ class VPNActivity : org.qtproject.qt.android.bindings.QtActivity() { @JvmStatic fun saveFileAs(fileContent: String, suggestedName: String) { VPNActivity.getInstance().saveFile(fileContent, suggestedName) } - - @JvmStatic fun putTextToClipboard(text: String) { - VPNActivity.getInstance().putToClipboard(text) - } } override fun onCreate(savedInstanceState: Bundle?) { @@ -109,18 +103,6 @@ class VPNActivity : org.qtproject.qt.android.bindings.QtActivity() { startActivityForResult(intent, CREATE_FILE_ACTION_CODE) } - override fun getSystemService(name: String): Any? { - return if (Build.VERSION.SDK_INT >= 29 && name == "clipboard") { - // QT will always attempt to read the clipboard if content is there. - // since we have no use of the clipboard in android 10+ - // we _can_ return null - // And we definitely should since android 12 displays clipboard access. - null - } else { - super.getSystemService(name) - } - } - external fun handleBackButton(): Boolean external fun onServiceMessage(actionCode: Int, body: String?) @@ -317,15 +299,4 @@ class VPNActivity : org.qtproject.qt.android.bindings.QtActivity() { tmpFileContentToSave = "" } - - private fun putToClipboard(text: String) { - this.runOnUiThread { - val clipboard = applicationContext.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager? - - if (clipboard != null) { - val clip: ClipData = ClipData.newPlainText("", text) - clipboard.setPrimaryClip(clip) - } - } - } } diff --git a/client/android/src/org/amnezia/vpn/qt/VPNApplication.java b/client/android/src/org/amnezia/vpn/qt/VPNApplication.java deleted file mode 100644 index 639b5a1e..00000000 --- a/client/android/src/org/amnezia/vpn/qt/VPNApplication.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.amnezia.vpn.qt; - -import android.content.res.Configuration; -import androidx.annotation.NonNull; -import org.amnezia.vpn.shadowsocks.core.Core; -import org.amnezia.vpn.shadowsocks.core.VpnManager; - -public class VPNApplication extends org.qtproject.qt.android.bindings.QtApplication { - private static VPNApplication instance; - - @Override - public void onCreate() { - super.onCreate(); - VPNApplication.instance = this; -// Core.INSTANCE.init(this, VPNActivity.class); -// VpnManager.Companion.getInstance().init(this); - } - - @Override - public void onConfigurationChanged(@NonNull Configuration newConfig) { - super.onConfigurationChanged(newConfig); -// Core.INSTANCE.updateNotificationChannels(); - } -} diff --git a/client/client.pro b/client/client.pro deleted file mode 100644 index 2472581b..00000000 --- a/client/client.pro +++ /dev/null @@ -1,415 +0,0 @@ -QT += widgets core gui network xml remoteobjects quick svg quickcontrols2 -equals(QT_MAJOR_VERSION, 6): QT += core5compat - -TARGET = AmneziaVPN -TEMPLATE = app - -# silent builds on CI env -IS_CI=$$(CI) -!isEmpty(IS_CI){ - message("Detected CI env") - CONFIG += silent #ccache -} - -CONFIG += qtquickcompiler - -include("3rd/QtSsh/src/ssh/qssh.pri") -include("3rd/QtSsh/src/botan/botan.pri") -!android:!ios:include("3rd/SingleApplication/singleapplication.pri") -include ("3rd/SortFilterProxyModel/SortFilterProxyModel.pri") - -include("3rd/qrcodegen/qrcodegen.pri") -include("3rd/QSimpleCrypto/QSimpleCrypto.pri") -include("3rd/qtkeychain/qtkeychain.pri") - -INCLUDEPATH += $$PWD/3rd/QSimpleCrypto/include -INCLUDEPATH += $$PWD/3rd/OpenSSL/include -INCLUDEPATH += $$PWD/3rd/qtkeychain/include -INCLUDEPATH += $$PWD/3rd/libssh/include -DEPENDPATH += $$PWD/3rd/OpenSSL/include - -HEADERS += \ - ../ipc/ipc.h \ - amnezia_application.h \ - configurators/cloak_configurator.h \ - configurators/configurator_base.h \ - configurators/ikev2_configurator.h \ - configurators/shadowsocks_configurator.h \ - configurators/ssh_configurator.h \ - configurators/vpn_configurator.h \ - configurators/wireguard_configurator.h \ - containers/containers_defs.h \ - core/defs.h \ - core/errorstrings.h \ - configurators/openvpn_configurator.h \ - core/scripts_registry.h \ - core/server_defs.h \ - core/servercontroller.h \ - defines.h \ - logger.h \ - managementserver.h \ - platforms/ios/MobileUtils.h \ - platforms/linux/leakdetector.h \ - protocols/protocols_defs.h \ - secure_qsettings.h \ - settings.h \ - ui/notificationhandler.h \ - ui/models/containers_model.h \ - ui/models/protocols_model.h \ - ui/pages.h \ - ui/pages_logic/AppSettingsLogic.h \ - ui/pages_logic/GeneralSettingsLogic.h \ - ui/pages_logic/NetworkSettingsLogic.h \ - ui/pages_logic/NewServerProtocolsLogic.h \ - ui/pages_logic/PageLogicBase.h \ - ui/pages_logic/QrDecoderLogic.h \ - ui/pages_logic/ServerConfiguringProgressLogic.h \ - ui/pages_logic/ServerContainersLogic.h \ - ui/pages_logic/ServerListLogic.h \ - ui/pages_logic/ServerSettingsLogic.h \ - ui/pages_logic/ShareConnectionLogic.h \ - ui/pages_logic/SitesLogic.h \ - ui/pages_logic/StartPageLogic.h \ - ui/pages_logic/ViewConfigLogic.h \ - ui/pages_logic/VpnLogic.h \ - ui/pages_logic/WizardLogic.h \ - ui/pages_logic/protocols/CloakLogic.h \ - ui/pages_logic/protocols/OpenVpnLogic.h \ - ui/pages_logic/protocols/OtherProtocolsLogic.h \ - ui/pages_logic/protocols/PageProtocolLogicBase.h \ - ui/pages_logic/protocols/ShadowSocksLogic.h \ - ui/pages_logic/protocols/WireGuardLogic.h \ - ui/property_helper.h \ - ui/models/servers_model.h \ - ui/uilogic.h \ - ui/qautostart.h \ - ui/models/sites_model.h \ - utilities.h \ - vpnconnection.h \ - protocols/vpnprotocol.h \ - constants.h \ - platforms/ios/QRCodeReaderBase.h - -SOURCES += \ - amnezia_application.cpp \ - configurators/cloak_configurator.cpp \ - configurators/configurator_base.cpp \ - configurators/ikev2_configurator.cpp \ - configurators/shadowsocks_configurator.cpp \ - configurators/ssh_configurator.cpp \ - configurators/vpn_configurator.cpp \ - configurators/wireguard_configurator.cpp \ - containers/containers_defs.cpp \ - core/errorstrings.cpp \ - configurators/openvpn_configurator.cpp \ - core/scripts_registry.cpp \ - core/server_defs.cpp \ - core/servercontroller.cpp \ - logger.cpp \ - main.cpp \ - managementserver.cpp \ - platforms/ios/MobileUtils.cpp \ - platforms/linux/leakdetector.cpp \ - protocols/protocols_defs.cpp \ - secure_qsettings.cpp \ - settings.cpp \ - ui/notificationhandler.cpp \ - ui/models/containers_model.cpp \ - ui/models/protocols_model.cpp \ - ui/pages_logic/AppSettingsLogic.cpp \ - ui/pages_logic/GeneralSettingsLogic.cpp \ - ui/pages_logic/NetworkSettingsLogic.cpp \ - ui/pages_logic/NewServerProtocolsLogic.cpp \ - ui/pages_logic/PageLogicBase.cpp \ - ui/pages_logic/QrDecoderLogic.cpp \ - ui/pages_logic/ServerConfiguringProgressLogic.cpp \ - ui/pages_logic/ServerContainersLogic.cpp \ - ui/pages_logic/ServerListLogic.cpp \ - ui/pages_logic/ServerSettingsLogic.cpp \ - ui/pages_logic/ShareConnectionLogic.cpp \ - ui/pages_logic/SitesLogic.cpp \ - ui/pages_logic/StartPageLogic.cpp \ - ui/pages_logic/ViewConfigLogic.cpp \ - ui/pages_logic/VpnLogic.cpp \ - ui/pages_logic/WizardLogic.cpp \ - ui/pages_logic/protocols/CloakLogic.cpp \ - ui/pages_logic/protocols/OpenVpnLogic.cpp \ - ui/pages_logic/protocols/OtherProtocolsLogic.cpp \ - ui/pages_logic/protocols/PageProtocolLogicBase.cpp \ - ui/pages_logic/protocols/ShadowSocksLogic.cpp \ - ui/models/servers_model.cpp \ - ui/pages_logic/protocols/WireGuardLogic.cpp \ - ui/uilogic.cpp \ - ui/qautostart.cpp \ - ui/models/sites_model.cpp \ - utilities.cpp \ - vpnconnection.cpp \ - protocols/vpnprotocol.cpp \ - platforms/ios/QRCodeReaderBase.cpp - -RESOURCES += \ - resources.qrc - -TRANSLATIONS = \ - translations/amneziavpn_ru.ts - -win32 { - DEFINES += MVPN_WINDOWS - - OTHER_FILES += platforms/windows/amneziavpn.rc - RC_FILE = platforms/windows/amneziavpn.rc - - HEADERS += \ - protocols/ikev2_vpn_protocol_windows.h \ - - SOURCES += \ - protocols/ikev2_vpn_protocol_windows.cpp \ - - VERSION = 2.0.0.0 - QMAKE_TARGET_COMPANY = "AmneziaVPN" - QMAKE_TARGET_PRODUCT = "AmneziaVPN" - - - LIBS += \ - -luser32 \ - -lrasapi32 \ - -lshlwapi \ - -liphlpapi \ - -lws2_32 \ - -lgdi32 - - QMAKE_LFLAGS_WINDOWS += /entry:mainCRTStartup - - !contains(QMAKE_TARGET.arch, x86_64) { - message("Windows x86 build") - LIBS += -L$$PWD/3rd/OpenSSL/lib/windows/x86/ -llibssl -llibcrypto - } - else { - message("Windows x86_64 build") - LIBS += -L$$PWD/3rd/OpenSSL/lib/windows/x86_64/ -llibssl -llibcrypto - } -} - -macx { - DEFINES += MVPN_MACOS - - ICON = $$PWD/images/app.icns - - HEADERS += ui/macos_util.h - SOURCES += ui/macos_util.mm - - LIBS += -framework Cocoa -framework ApplicationServices -framework CoreServices -framework Foundation -framework AppKit -framework Security - - LIBS += $$PWD/3rd/OpenSSL/lib/macos/x86_64/libcrypto.a - LIBS += $$PWD/3rd/OpenSSL/lib/macos/x86_64/libssl.a -} - -linux:!android { - DEFINES += MVPN_LINUX - LIBS += /usr/lib/x86_64-linux-gnu/libcrypto.a - LIBS += /usr/lib/x86_64-linux-gnu/libssl.a - LIBS += $$PWD/3rd/libssh/build/src/libssh.a - LIBS += -lz - - INCLUDEPATH += $$PWD/platforms/linux -} - -win32|macx|linux:!android { - DEFINES += AMNEZIA_DESKTOP - - HEADERS += \ - core/ipcclient.h \ - core/privileged_process.h \ - ui/systemtray_notificationhandler.h \ - protocols/openvpnprotocol.h \ - protocols/openvpnovercloakprotocol.h \ - protocols/shadowsocksvpnprotocol.h \ - protocols/wireguardprotocol.h \ - - SOURCES += \ - core/ipcclient.cpp \ - core/privileged_process.cpp \ - ui/systemtray_notificationhandler.cpp \ - protocols/openvpnprotocol.cpp \ - protocols/openvpnovercloakprotocol.cpp \ - protocols/shadowsocksvpnprotocol.cpp \ - protocols/wireguardprotocol.cpp \ - - REPC_REPLICA += ../ipc/ipc_interface.rep - REPC_REPLICA += ../ipc/ipc_process_interface.rep -} - -android { - message(Platform: android) - message("$$ANDROID_TARGET_ARCH") - versionAtLeast(QT_VERSION, 6.0.0) { - # We need to include qtprivate api's - # As QAndroidBinder is not yet implemented with a public api - QT += core-private - ANDROID_ABIS = $$ANDROID_TARGET_ARCH - } - - DEFINES += MVPN_ANDROID - - INCLUDEPATH += platforms/android - - HEADERS += \ - platforms/android/android_controller.h \ - platforms/android/android_notificationhandler.h \ - protocols/android_vpnprotocol.h \ - platforms/android/androidutils.h \ - platforms/android/androidvpnactivity.h - - SOURCES += \ - platforms/android/android_controller.cpp \ - platforms/android/android_notificationhandler.cpp \ - protocols/android_vpnprotocol.cpp \ - platforms/android/androidutils.cpp \ - platforms/android/androidvpnactivity.cpp - - DISTFILES += \ - android/AndroidManifest.xml \ - android/build.gradle \ - android/gradle/wrapper/gradle-wrapper.jar \ - android/gradle/wrapper/gradle-wrapper.properties \ - android/gradlew \ - android/gradlew.bat \ - android/gradle.properties \ - android/res/values/libs.xml \ - android/res/xml/fileprovider.xml \ - android/src/org/amnezia/vpn/AuthHelper.java \ - android/src/org/amnezia/vpn/IPCContract.kt \ - android/src/org/amnezia/vpn/NotificationUtil.kt \ - android/src/org/amnezia/vpn/OpenVPNThreadv3.kt \ - android/src/org/amnezia/vpn/Prefs.kt \ - android/src/org/amnezia/vpn/VpnLogger.kt \ - android/src/org/amnezia/vpn/VpnService.kt \ - android/src/org/amnezia/vpn/VpnServiceBinder.kt \ - android/src/org/amnezia/vpn/qt/AmneziaApp.kt \ - android/src/org/amnezia/vpn/qt/PackageManagerHelper.java \ - android/src/org/amnezia/vpn/qt/VPNActivity.kt \ - android/src/org/amnezia/vpn/qt/VPNApplication.java \ - android/src/org/amnezia/vpn/qt/VPNPermissionHelper.kt - - ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android - - for (abi, ANDROID_ABIS): { - - equals(ANDROID_TARGET_ARCH,$$abi) { - LIBS += $$PWD/3rd/OpenSSL/lib/android/$${abi}/libcrypto.a - LIBS += $$PWD/3rd/OpenSSL/lib/android/$${abi}/libssl.a - } - - ANDROID_EXTRA_LIBS += $$PWD/android/lib/wireguard/$${abi}/libwg.so - ANDROID_EXTRA_LIBS += $$PWD/android/lib/wireguard/$${abi}/libwg-go.so - ANDROID_EXTRA_LIBS += $$PWD/android/lib/wireguard/$${abi}/libwg-quick.so - - ANDROID_EXTRA_LIBS += $$PWD/android/lib/openvpn/$${abi}/libjbcrypto.so - ANDROID_EXTRA_LIBS += $$PWD/android/lib/openvpn/$${abi}/libopenvpn.so - ANDROID_EXTRA_LIBS += $$PWD/android/lib/openvpn/$${abi}/libopvpnutil.so - ANDROID_EXTRA_LIBS += $$PWD/android/lib/openvpn/$${abi}/libovpn3.so - ANDROID_EXTRA_LIBS += $$PWD/android/lib/openvpn/$${abi}/libovpnexec.so - } -} - -ios { - message("Client iOS build") - CONFIG += static - CONFIG += file_copies - - # For the authentication - LIBS += -framework AuthenticationServices - - # For notifications - LIBS += -framework UIKit - LIBS += -framework Foundation - LIBS += -framework StoreKit - LIBS += -framework UserNotifications - LIBS += -framework AVFoundation - - DEFINES += MVPN_IOS - - HEADERS += \ - protocols/ios_vpnprotocol.h \ - platforms/ios/iosnotificationhandler.h \ - platforms/ios/json.h \ - platforms/ios/bigint.h \ - platforms/ios/bigintipv6addr.h \ - platforms/ios/ipaddress.h \ - platforms/ios/ipaddressrange.h \ - platforms/ios/QtAppDelegate.h \ - platforms/ios/QtAppDelegate-C-Interface.h - - SOURCES -= \ - platforms/ios/QRCodeReaderBase.cpp \ - platforms/ios/MobileUtils.cpp - - SOURCES += \ - protocols/ios_vpnprotocol.mm \ - platforms/ios/iosnotificationhandler.mm \ - platforms/ios/json.cpp \ - platforms/ios/iosglue.mm \ - platforms/ios/ipaddress.cpp \ - platforms/ios/ipaddressrange.cpp \ - platforms/ios/QRCodeReaderBase.mm \ - platforms/ios/QtAppDelegate.mm \ - platforms/ios/MobileUtils.mm - - Q_ENABLE_BITCODE.value = NO - Q_ENABLE_BITCODE.name = ENABLE_BITCODE - QMAKE_MAC_XCODE_SETTINGS += Q_ENABLE_BITCODE - -# CONFIG(iphoneos, iphoneos|iphonesimulator) { - iphoneos { - message("Building for iPhone OS") - QMAKE_TARGET_BUNDLE_PREFIX = org.amnezia - QMAKE_BUNDLE = AmneziaVPN - QMAKE_IOS_DEPLOYMENT_TARGET = 13.0 - QMAKE_APPLE_TARGETED_DEVICE_FAMILY = 1 - QMAKE_DEVELOPMENT_TEAM = X7UJ388FXK - QMAKE_PROVISIONING_PROFILE = f2fefb59-14aa-4aa9-ac14-1d5531b06dcc - QMAKE_XCODE_CODE_SIGN_IDENTITY = "Apple Distribution" - QMAKE_INFO_PLIST = $$PWD/ios/app/Info.plist - - XCODEBUILD_FLAGS += -allowProvisioningUpdates - - DEFINES += iphoneos - - contains(QT_ARCH, arm64) { - message("Building for iOS/ARM v8 64-bit architecture") - ARCH_TAG = "ios_armv8_64" - - LIBS += $$PWD/3rd/OpenSSL/lib/ios/iphone/libcrypto.a - LIBS += $$PWD/3rd/OpenSSL/lib/ios/iphone/libssl.a - } else { - message("Building for iOS/ARM v7 (32-bit) architecture") - ARCH_TAG = "ios_armv7" - } - } -# } - - -# CONFIG(iphonesimulator, iphoneos|iphonesimulator) { -# iphonesimulator { -# message("Building for iPhone Simulator") -# ARCH_TAG = "ios_x86_64" -# -# DEFINES += iphonesimulator -# -# LIBS += $$PWD/3rd/OpenSSL/lib/ios/simulator/libcrypto.a -# LIBS += $$PWD/3rd/OpenSSL/lib/ios/simulator/libssl.a -# } -# } - - NETWORKEXTENSION=1 -# ! build_pass: system(ruby $$PWD/scripts/xcode_patcher.rb "$$PWD" "$$OUT_PWD/AmneziaVPN.xcodeproj" "2.0" "2.0.0" "ios" "$$NETWORKEXTENSION"|| echo "Failed to merge xcode with wireguard") - - - -#ruby %{sourceDir}/client/ios/xcode_patcher.rb "%{buildDir}/AmneziaVPN.xcodeproj" "2.0" "2.0.0" "ios" "1" - #cd client/ && /Users/md/Qt/5.15.2/ios/bin/qmake -o Makefile /Users/md/amnezia/desktop-client/client/client.pro -spec macx-ios-clang CONFIG+=iphonesimulator CONFIG+=simulator CONFIG+=qml_debug -after -# %{sourceDir}/client/ios/xcode_patcher.rb %{buildDir}/client/AmneziaVPN.xcodeproj 2.0 2.0.0 ios 1 -} - - - diff --git a/client/configurators/cloak_configurator.cpp b/client/configurators/cloak_configurator.cpp index 6206d141..fab378e2 100644 --- a/client/configurators/cloak_configurator.cpp +++ b/client/configurators/cloak_configurator.cpp @@ -39,14 +39,11 @@ QString CloakConfigurator::genCloakConfig(const ServerCredentials &credentials, config.insert("UID", cloakBypassUid); config.insert("PublicKey", cloakPublicKey); config.insert("ServerName", "$FAKE_WEB_SITE_ADDRESS"); - config.insert("NumConn", 4); + config.insert("NumConn", 1); config.insert("BrowserSig", "chrome"); config.insert("StreamTimeout", 300); - - // transfer params to protocol runner - config.insert(config_key::transport_proto, "tcp"); - config.insert(config_key::remote, credentials.hostName); - config.insert(config_key::port, "$CLOAK_SERVER_PORT"); + config.insert("RemoteHost", credentials.hostName); + config.insert("RemotePort", "$CLOAK_SERVER_PORT"); QString textCfg = serverController.replaceVars(QJsonDocument(config).toJson(), serverController.genVarsForScript(credentials, container, containerConfig)); diff --git a/client/containers/containers_defs.cpp b/client/containers/containers_defs.cpp index 7c7c000b..c7de220b 100644 --- a/client/containers/containers_defs.cpp +++ b/client/containers/containers_defs.cpp @@ -155,6 +155,7 @@ bool ContainerProps::isSupportedByCurrentPlatform(DockerContainer c) switch (c) { case DockerContainer::WireGuard: return true; case DockerContainer::OpenVpn: return true; + case DockerContainer::Cloak: return true; // case DockerContainer::ShadowSocks: return true; default: return false; } @@ -170,6 +171,7 @@ bool ContainerProps::isSupportedByCurrentPlatform(DockerContainer c) case DockerContainer::WireGuard: return true; case DockerContainer::OpenVpn: return true; case DockerContainer::ShadowSocks: return true; + case DockerContainer::Cloak: return true; default: return false; } diff --git a/client/core/sshclient.cpp b/client/core/sshclient.cpp index e8d021ad..49405fa3 100644 --- a/client/core/sshclient.cpp +++ b/client/core/sshclient.cpp @@ -265,7 +265,6 @@ namespace libssh { int bytesWritten = sftp_write(file, buffer, bufferSize); std::string chunk(buffer, bufferSize); - qDebug() << "sftp write: " << QString(chunk.c_str()); if (bytesWritten != bufferSize) { fin.close(); @@ -280,7 +279,6 @@ namespace libssh { fin.read(buffer, lastChunkSize); std::string chunk(buffer, lastChunkSize); - qDebug() << "sftp write: " << QString(chunk.c_str()); int bytesWritten = sftp_write(file, buffer, lastChunkSize); diff --git a/client/defines.h b/client/defines.h deleted file mode 100644 index c64eb458..00000000 --- a/client/defines.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef DEFINES_H -#define DEFINES_H - -#define APPLICATION_NAME "AmneziaVPN" -#define SERVICE_NAME "AmneziaVPN-service" -#define ORGANIZATION_NAME "AmneziaVPN.ORG" -#define APP_MAJOR_VERSION "2.1.2" -#define APP_VERSION "2.1.2.0" - -#endif // DEFINES_H diff --git a/client/images/AmneziaVPN_Full_logo.svg b/client/images/AmneziaVPN_Full_logo.svg new file mode 100644 index 00000000..1fb2b0af --- /dev/null +++ b/client/images/AmneziaVPN_Full_logo.svg @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/images/AmneziaVPN_Full_logo.svg.license b/client/images/AmneziaVPN_Full_logo.svg.license new file mode 100644 index 00000000..2f4da365 --- /dev/null +++ b/client/images/AmneziaVPN_Full_logo.svg.license @@ -0,0 +1,2 @@ +File AmneziaVPN_Full_logo.svg licensed by CC-BY-SA 4.0 +Full license text - https://creativecommons.org/licenses/by-sa/4.0/legalcode.txt \ No newline at end of file diff --git a/client/ios/app/Info.plist b/client/ios/app/Info.plist deleted file mode 100644 index f5681a20..00000000 --- a/client/ios/app/Info.plist +++ /dev/null @@ -1,92 +0,0 @@ - - - - - CFBundleAllowMixedLocalizations - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - AmneziaVPN - CFBundleDocumentTypes - - - CFBundleTypeName - Amnezia VPN config - LSHandlerRank - Alternate - LSItemContentTypes - - org.amnezia.AmneziaVPN.amnezia-config - - - - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIcons - - CFBundleIcons~ipad - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${APP_DISPLAY_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - $(MARKETING_VERSION) - CFBundleVersion - 7 - ITSAppUsesNonExemptEncryption - - LSRequiresIPhoneOS - - UIFileSharingEnabled - - LSSupportsOpeningDocumentsInPlace - - NSCameraUsageDescription - Amnezia VPN needs access to the camera for reading QR-codes. - UILaunchStoryboardName - AmneziaVPNLaunchScreen - UIRequiresFullScreen - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationPortrait - - UISupportedInterfaceOrientations~ipad - - UIUserInterfaceStyle - Light - UTImportedTypeDeclarations - - - UTTypeConformsTo - - public.data - - UTTypeDescription - Amnezia VPN config - UTTypeIconFiles - - UTTypeIdentifier - org.amnezia.AmneziaVPN.amnezia-config - UTTypeTagSpecification - - public.filename-extension - - vpn - - public.mime-type - - text/plain - - - - - - diff --git a/client/ios/app/Info.plist.in b/client/ios/app/Info.plist.in index 97f88953..19272c89 100644 --- a/client/ios/app/Info.plist.in +++ b/client/ios/app/Info.plist.in @@ -80,6 +80,92 @@ + + UTTypeConformsTo + + public.data + + UTTypeDescription + WireGuard config + UTTypeIconFiles + + UTTypeIdentifier + org.amnezia.AmneziaVPN.wireguard-config + UTTypeTagSpecification + + public.filename-extension + + conf + cfg + + public.mime-type + + text/plain + + + + + UTTypeConformsTo + + public.data + + UTTypeDescription + OpenVPN config + UTTypeIconFiles + + UTTypeIdentifier + org.amnezia.AmneziaVPN.openvpn-config + UTTypeTagSpecification + + public.filename-extension + + ovpn + + public.mime-type + + text/plain + + + + + UTTypeConformsTo + + public.data + + UTTypeDescription + AmneziaVPN backup file + UTTypeIconFiles + + UTTypeIdentifier + org.amnezia.AmneziaVPN.backup-config + UTTypeTagSpecification + + public.filename-extension + + backup + + public.mime-type + + text/plain + + + + CFBundleDocumentTypes + + + CFBundleTypeName + Amnezia VPN config + LSHandlerRank + Alternate + LSItemContentTypes + + org.amnezia.AmneziaVPN.amnezia-config + org.amnezia.AmneziaVPN.wireguard-config + org.amnezia.AmneziaVPN.openvpn-config + org.amnezia.AmneziaVPN.backup-config + + + - \ No newline at end of file + diff --git a/client/ios/networkextension/CMakeLists.txt b/client/ios/networkextension/CMakeLists.txt index bbe591c8..f15b2115 100644 --- a/client/ios/networkextension/CMakeLists.txt +++ b/client/ios/networkextension/CMakeLists.txt @@ -4,26 +4,47 @@ set(CLIENT_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..) add_executable(networkextension) set_target_properties(networkextension PROPERTIES - OUTPUT_NAME "AmneziaVPNNetworkExtension" XCODE_PRODUCT_TYPE com.apple.product-type.app-extension BUNDLE_EXTENSION appex - MACOSX_BUNDLE ON + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in - MACOSX_BUNDLE_BUNDLE_NAME "AmneziaVPNNetworkExtension" - MACOSX_BUNDLE_BUNDLE_VERSION "${BUILD_ID}" - MACOSX_BUNDLE_COPYRIGHT "MPL-2.0" - MACOSX_BUNDLE_GUI_IDENTIFIER "${BUILD_IOS_APP_IDENTIFIER}.network-extension" MACOSX_BUNDLE_INFO_STRING "AmneziaVPNNetworkExtension" - MACOSX_BUNDLE_LONG_VERSION_STRING "${CMAKE_PROJECT_VERSION}-${BUILD_ID}" - MACOSX_BUNDLE_SHORT_VERSION_STRING "${CMAKE_PROJECT_VERSION}" + MACOSX_BUNDLE_BUNDLE_NAME "AmneziaVPNNetworkExtension" + MACOSX_BUNDLE_GUI_IDENTIFIER "${BUILD_IOS_APP_IDENTIFIER}.network-extension" + MACOSX_BUNDLE_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION_TWEAK}" + MACOSX_BUNDLE_LONG_VERSION_STRING "${APPLE_PROJECT_VERSION}-${CMAKE_PROJECT_VERSION_TWEAK}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${APPLE_PROJECT_VERSION}" + XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${BUILD_IOS_APP_IDENTIFIER}.network-extension" + XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${CMAKE_CURRENT_SOURCE_DIR}/AmneziaVPNNetworkExtension.entitlements + XCODE_ATTRIBUTE_MARKETING_VERSION "${APP_MAJOR_VERSION}" + XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION "${BUILD_ID}" + XCODE_ATTRIBUTE_PRODUCT_NAME "AmneziaVPNNetworkExtension" + + XCODE_ATTRIBUTE_APPLICATION_EXTENSION_API_ONLY "YES" + XCODE_ATTRIBUTE_ENABLE_BITCODE "NO" + XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2" + + XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../../Frameworks" + + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Apple Distribution" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY[variant=Debug] "Apple Development" + + XCODE_ATTRIBUTE_CODE_SIGN_STYLE Manual + XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER "match AppStore org.amnezia.AmneziaVPN.network-extension" + XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER[variant=Debug] "match Development org.amnezia.AmneziaVPN.network-extension" +) + +set_target_properties(networkextension PROPERTIES XCODE_ATTRIBUTE_SWIFT_VERSION "5.0" XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES "YES" XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/WireGuardNetworkExtension-Bridging-Header.h" + XCODE_ATTRIBUTE_SWIFT_OPTIMIZATION_LEVEL "-Onone" XCODE_ATTRIBUTE_SWIFT_PRECOMPILE_BRIDGING_HEADER "NO" - XCODE_ATTRIBUTE_APPLICATION_EXTENSION_API_ONLY "YES" - XCODE_ATTRIBUTE_ENABLE_BITCODE "NO" - XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${CMAKE_CURRENT_SOURCE_DIR}/AmneziaVPNNetworkExtension.entitlements +) + +set_target_properties("networkextension" PROPERTIES + XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "X7UJ388FXK" ) find_library(FW_ASSETS_LIBRARY AssetsLibrary) @@ -83,7 +104,7 @@ include(${CLIENT_ROOT_DIR}/cmake/golang.cmake) ## Build the wireguard go library for iOS simulation. ## TODO: Some special handling around GOARCH for execute_process(OUTPUT_VARIABLE SIM_SDKROOT OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND xcrun --sdk iphonesimulator --show-sdk-path) -build_go_archive(${CMAKE_CURRENT_BINARY_DIR}/libwg-sim.a ${CMAKE_SOURCE_DIR}/3rd/wireguard-apple/Sources/WireGuardKitGo/go.mod +build_go_archive(${CMAKE_CURRENT_BINARY_DIR}/libwg-sim.a ${CLIENT_ROOT_DIR}/3rd/wireguard-apple/Sources/WireGuardKitGo/go.mod GOOS ios GOARCH amd64 CGO_CFLAGS -arch x86_64 -isysroot ${SIM_SDKROOT} @@ -92,7 +113,7 @@ build_go_archive(${CMAKE_CURRENT_BINARY_DIR}/libwg-sim.a ${CMAKE_SOURCE_DIR}/3rd ## Build the wireguard go library for iOS devices. execute_process(OUTPUT_VARIABLE IOS_SDKROOT OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND xcrun --sdk ${CMAKE_OSX_SYSROOT} --show-sdk-path) -build_go_archive(${CMAKE_CURRENT_BINARY_DIR}/libwg-dev.a ${CMAKE_SOURCE_DIR}/3rd/wireguard-apple/Sources/WireGuardKitGo/go.mod +build_go_archive(${CMAKE_CURRENT_BINARY_DIR}/libwg-dev.a ${CLIENT_ROOT_DIR}/3rd/wireguard-apple/Sources/WireGuardKitGo/go.mod GOOS ios GOARCH arm64 CGO_CFLAGS -arch arm64 -isysroot ${IOS_SDKROOT} @@ -111,4 +132,4 @@ add_custom_target(libwg_builder ## Link and depend on the wireguard library. add_dependencies(networkextension libwg_builder) -target_link_libraries(networkextension PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/libwg-unified.a) \ No newline at end of file +target_link_libraries(networkextension PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/libwg-unified.a) diff --git a/client/ios/networkextension/Info.plist b/client/ios/networkextension/Info.plist deleted file mode 100644 index 6941af53..00000000 --- a/client/ios/networkextension/Info.plist +++ /dev/null @@ -1,52 +0,0 @@ - - - - - CFBundleExecutable - $(EXECUTABLE_NAME) - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - - CFBundleInfoDictionaryVersion - 6.0 - - CFBundleName - $(PRODUCT_NAME) - - CFBundlePackageType - $(PRODUCT_BUNDLE_PACKAGE_TYPE) - - CFBundleShortVersionString - $(MARKETING_VERSION) - - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - - ITSAppUsesNonExemptEncryption - - - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - - CFBundleDisplayName - MozillaVPNNetworkExtension - - NSExtension - - NSExtensionPointIdentifier - com.apple.networkextension.packet-tunnel - NSExtensionPrincipalClass - $(PRODUCT_MODULE_NAME).PacketTunnelProvider - - - com.wireguard.ios.app_group_id - group.$(APP_ID_IOS) - - com.wireguard.macos.app_group_id - $(DEVELOPMENT_TEAM).group.$(APP_ID_MACOS) - - \ No newline at end of file diff --git a/client/ios/scripts/clangwrap.sh b/client/ios/scripts/clangwrap.sh new file mode 100755 index 00000000..763187e3 --- /dev/null +++ b/client/ios/scripts/clangwrap.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# go/clangwrap.sh + +SDK_PATH=`xcrun --sdk $SDK --show-sdk-path` +CLANG=`xcrun --sdk $SDK --find clang` + +if [ "$GOARCH" == "amd64" ]; then + CARCH="x86_64" +elif [ "$GOARCH" == "arm64" ]; then + CARCH="arm64" +fi + +exec $CLANG -arch $CARCH -isysroot $SDK_PATH -mios-version-min=10.0 "$@" diff --git a/client/scripts/openvpn.sh b/client/ios/scripts/openvpn.sh old mode 100644 new mode 100755 similarity index 95% rename from client/scripts/openvpn.sh rename to client/ios/scripts/openvpn.sh index 2da9e1e8..544b8078 --- a/client/scripts/openvpn.sh +++ b/client/ios/scripts/openvpn.sh @@ -1,13 +1,12 @@ - XCODEBUILD="/usr/bin/xcodebuild" WORKINGDIR=`pwd` PATCH="/usr/bin/patch" - - cat $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/Project.xcconfig > $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/amnezia.xcconfig - cat << EOF >> $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/amnezia.xcconfig + + cat $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/Project.xcconfig > $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/amnezia.xcconfig + cat << EOF >> $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/amnezia.xcconfig PROJECT_TEMP_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/OpenVPNAdapter.build CONFIGURATION_BUILD_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/Release-iphoneos - BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/Release-iphoneos + BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/Release-iphoneos EOF @@ -18,4 +17,3 @@ EOF echo "OpenVPNAdapter build failed" fi cd ../../ - diff --git a/client/ios/xcode.xconfig b/client/ios/xcode.xconfig deleted file mode 100644 index 1b4f1000..00000000 --- a/client/ios/xcode.xconfig +++ /dev/null @@ -1,13 +0,0 @@ -DEVELOPMENT_TEAM = - -# MacOS configuration -GROUP_ID_MACOS = <> -APP_ID_MACOS = <> -NETEXT_ID_MACOS = <> -LOGIN_ID_MACOS = <> -NATIVEMESSAGING_ID_MACOS = <> - -# IOS configuration -GROUP_ID_IOS = group.org.mozilla.ios.Guardian -APP_ID_IOS = org.mozilla.ios.FirefoxVPN -NETEXT_ID_IOS = org.mozilla.ios.FirefoxVPN.network-extension diff --git a/client/logger.cpp b/client/logger.cpp index 107d477f..9a0dd077 100644 --- a/client/logger.cpp +++ b/client/logger.cpp @@ -9,7 +9,7 @@ #include -#include "defines.h" +#include "version.h" #include "utilities.h" #ifdef AMNEZIA_DESKTOP diff --git a/client/main.cpp b/client/main.cpp index f20c5dd1..8f1a8f75 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -1,9 +1,7 @@ -#include #include -#include #include "amnezia_application.h" -#include "defines.h" +#include "version.h" #include "migrations.h" #ifdef Q_OS_WIN @@ -20,7 +18,6 @@ int main(int argc, char *argv[]) Migrations migrationsManager; migrationsManager.doMigrations(); - QLoggingCategory::setFilterRules(QStringLiteral("qtc.ssh=false")); QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); #ifdef Q_OS_WIN diff --git a/client/migrations.cpp b/client/migrations.cpp index 6fac6be7..8086d1db 100644 --- a/client/migrations.cpp +++ b/client/migrations.cpp @@ -5,7 +5,7 @@ #include #include -#include "defines.h" +#include "version.h" Migrations::Migrations(QObject *parent) : QObject{parent} diff --git a/client/platforms/android/android_controller.cpp b/client/platforms/android/android_controller.cpp index ad00abdf..81b04b8a 100644 --- a/client/platforms/android/android_controller.cpp +++ b/client/platforms/android/android_controller.cpp @@ -249,7 +249,7 @@ void AndroidController::cleanupBackendLogs() { } void AndroidController::importConfig(const QString& data){ - m_startPageLogic->selectConfigFormat(data); + m_startPageLogic->importAnyFile(data); } const QJsonObject &AndroidController::vpnConfig() const @@ -267,11 +267,6 @@ void AndroidController::startQrReaderActivity() AndroidVPNActivity::instance()->startQrCodeReader(); } -void AndroidController::copyTextToClipboard(QString text) -{ - AndroidVPNActivity::instance()->copyTextToClipboard(text); -} - void AndroidController::scheduleStatusCheckSlot() { QTimer::singleShot(1000, [this]() { diff --git a/client/platforms/android/android_controller.h b/client/platforms/android/android_controller.h index 00b37225..7e5b52c8 100644 --- a/client/platforms/android/android_controller.h +++ b/client/platforms/android/android_controller.h @@ -43,7 +43,6 @@ public: void setVpnConfig(const QJsonObject &newVpnConfig); void startQrReaderActivity(); - void copyTextToClipboard(QString text); signals: void connectionStateChanged(VpnProtocol::VpnConnectionState state); diff --git a/client/platforms/android/androidvpnactivity.cpp b/client/platforms/android/androidvpnactivity.cpp index 9431597b..2076280d 100644 --- a/client/platforms/android/androidvpnactivity.cpp +++ b/client/platforms/android/androidvpnactivity.cpp @@ -65,14 +65,6 @@ void AndroidVPNActivity::saveFileAs(QString fileContent, QString suggestedFilena QJniObject::fromString(suggestedFilename).object()); } -void AndroidVPNActivity::copyTextToClipboard(QString text) -{ - QJniObject::callStaticMethod( - CLASSNAME, - "putTextToClipboard", "(Ljava/lang/String;)V", - QJniObject::fromString(text).object()); -} - // static AndroidVPNActivity* AndroidVPNActivity::instance() { if (s_instance == nullptr) { diff --git a/client/platforms/android/androidvpnactivity.h b/client/platforms/android/androidvpnactivity.h index 5844ff6d..db128b1b 100644 --- a/client/platforms/android/androidvpnactivity.h +++ b/client/platforms/android/androidvpnactivity.h @@ -76,7 +76,6 @@ public: static void connectService(); static void startQrCodeReader(); static void saveFileAs(QString fileContent, QString suggestedFilename); - static void copyTextToClipboard(QString text); signals: void serviceConnected(); diff --git a/client/platforms/ios/QtAppDelegate.mm b/client/platforms/ios/QtAppDelegate.mm index 0b1092db..f65856d9 100644 --- a/client/platforms/ios/QtAppDelegate.mm +++ b/client/platforms/ios/QtAppDelegate.mm @@ -73,15 +73,13 @@ NSLog(@"Application openURL: %@", url); if (url.fileURL) { QString filePath(url.path.UTF8String); - qDebug() << "filePath:" << filePath; if (filePath.isEmpty()) return NO; QFile file(filePath); bool isOpenFile = file.open(QIODevice::ReadOnly); - qDebug() << "isOpenFile:" << isOpenFile; QByteArray data = file.readAll(); - [QtAppDelegate sharedQtAppDelegate].startPageLogic->importConnectionFromCode(QString(data)); + [QtAppDelegate sharedQtAppDelegate].startPageLogic->importAnyFile(QString(data)); return YES; } return NO; diff --git a/client/platforms/ios/ioscontroller.swift b/client/platforms/ios/ioscontroller.swift index 40bb7006..352cc82a 100644 --- a/client/platforms/ios/ioscontroller.swift +++ b/client/platforms/ios/ioscontroller.swift @@ -236,7 +236,6 @@ public class IOSControllerImpl : NSObject { } @objc func checkStatus(callback: @escaping (String, String, String) -> Void) { - Logger.global?.log(message: "Check status") assert(tunnel != nil) let proto = tunnel!.protocolConfiguration as? NETunnelProviderProtocol diff --git a/client/platforms/ios/ioslogger.swift b/client/platforms/ios/ioslogger.swift index 644f7581..f6fbe866 100644 --- a/client/platforms/ios/ioslogger.swift +++ b/client/platforms/ios/ioslogger.swift @@ -48,7 +48,7 @@ func wg_log(_ type: OSLogType, staticMessage msg: StaticString) { } func wg_log(_ type: OSLogType, message msg: String) { - os_log("%{public}s", log: OSLog.default, type: type, msg) + os_log("%{AMNEZIA}s", log: OSLog.default, type: type, msg) Logger.global?.log(message: msg) NSLog("AMNEZIA: \(msg)") } diff --git a/client/platforms/ios/iostunnel.swift b/client/platforms/ios/iostunnel.swift index e34ef3f8..5c7ebeb4 100644 --- a/client/platforms/ios/iostunnel.swift +++ b/client/platforms/ios/iostunnel.swift @@ -688,23 +688,18 @@ class PacketTunnelProvider: NEPacketTunnelProvider { } */ private func setupAndlaunchOpenVPN(withConfig ovpnConfiguration: Data, withShadowSocks viaSS: Bool = false, completionHandler: @escaping (Error?) -> Void) { - wg_log(.info, message: "Inside setupAndlaunchOpenVPN()") let str = String(decoding: ovpnConfiguration, as: UTF8.self) - wg_log(.info, message: "OPENVPN config: \(str)") - + let configuration = OpenVPNConfiguration() configuration.fileContent = ovpnConfiguration - if viaSS { -// configuration.settings = [ -// "remote": "137.74.6.148 1194", -// "proto": "tcp", -// "link-mtu": "1480", -// "tun-mtu": "1460", -// ] + if(str.contains("cloak")){ + configuration.setPTCloak(); } + let evaluation: OpenVPNConfigurationEvaluation do { evaluation = try ovpnAdapter.apply(configuration: configuration) + } catch { completionHandler(error) return diff --git a/client/platforms/ios/iosvpnprotocol.swift b/client/platforms/ios/iosvpnprotocol.swift index 95505b21..96f4675b 100644 --- a/client/platforms/ios/iosvpnprotocol.swift +++ b/client/platforms/ios/iosvpnprotocol.swift @@ -41,8 +41,6 @@ public class IOSVpnProtocolImpl : NSObject { super.init() Logger.configureGlobal(tagged: "APP", withFilePath: "") - print("Config from caller: \(config)") - vpnBundleID = bundleID; precondition(!vpnBundleID.isEmpty) @@ -296,7 +294,7 @@ public class IOSVpnProtocolImpl : NSObject { @objc func connect(ssConfig: String, ovpnConfig: String, failureCallback: @escaping () -> Void) { - Logger.global?.log(message: "Connecting") + Logger.global?.log(message: "Logger Connecting") // assert(tunnel != nil) self.openVPNConfig = ovpnConfig @@ -315,7 +313,7 @@ public class IOSVpnProtocolImpl : NSObject { } @objc func connect(ovpnConfig: String, failureCallback: @escaping () -> Void) { - Logger.global?.log(message: "Connecting") + Logger.global?.log(message: "Logger Connecting") // assert(tunnel != nil) let addr: String = ovpnConfig @@ -331,7 +329,7 @@ public class IOSVpnProtocolImpl : NSObject { } @objc func connect(dnsServer: String, serverIpv6Gateway: String, serverPublicKey: String, presharedKey: String, serverIpv4AddrIn: String, serverPort: Int, allowedIPAddressRanges: Array, ipv6Enabled: Bool, reason: Int, failureCallback: @escaping () -> Void) { - Logger.global?.log(message: "Connecting") + Logger.global?.log(message: "Logger Connecting") // assert(tunnel != nil) // Let's remove the previous config if it exists. @@ -525,11 +523,7 @@ public class IOSVpnProtocolImpl : NSObject { } @objc func checkStatus(callback: @escaping (String, String, String) -> Void) { - Logger.global?.log(message: "Check status") -// assert(tunnel != nil) - print("check status") let protoType = (tunnel!.localizedDescription ?? "").toTunnelType - print(protoType); switch protoType { case .wireguard: @@ -545,7 +539,6 @@ public class IOSVpnProtocolImpl : NSObject { } private func checkShadowSocksStatus(callback: @escaping (String, String, String) -> Void) { - Logger.global?.log(message: "Check ShadowSocks") guard let proto = tunnel?.protocolConfiguration as? NETunnelProviderProtocol else { callback("", "", "") return @@ -557,11 +550,8 @@ public class IOSVpnProtocolImpl : NSObject { callback("", "", "") return } - - print("server IP: \(serverIpv4Gateway)") - + let deviceIpv4Address = getWiFiAddress() - print("device IP: \(serverIpv4Gateway)") if deviceIpv4Address == nil { callback("", "", "") return @@ -591,7 +581,6 @@ public class IOSVpnProtocolImpl : NSObject { } private func checkOVPNStatus(callback: @escaping (String, String, String) -> Void) { - Logger.global?.log(message: "Check OpenVPN") guard let proto = tunnel?.protocolConfiguration as? NETunnelProviderProtocol else { callback("", "", "") return @@ -607,13 +596,8 @@ public class IOSVpnProtocolImpl : NSObject { .splitToArray(separator: "\n", trimmingCharacters: nil) .first { $0.starts(with: "remote ") } .splitToArray(separator: " ", trimmingCharacters: nil)[1] - - print("server IP: \(serverIpv4Gateway)") - - - + let deviceIpv4Address = getWiFiAddress() - print("device IP: \(deviceIpv4Address)") if deviceIpv4Address == nil { callback("", "", "") return diff --git a/client/platforms/ios/json.cpp b/client/platforms/ios/json.cpp deleted file mode 100644 index 0cf2a0af..00000000 --- a/client/platforms/ios/json.cpp +++ /dev/null @@ -1,732 +0,0 @@ -/** - * QtJson - A simple class for parsing JSON data into a QVariant hierarchies and vice-versa. - * Copyright (C) 2011 Eeli Reilin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file json.cpp - */ - -#include -#include -#include "json.h" - -namespace QtJson { - static QString dateFormat, dateTimeFormat; - static bool prettySerialize = false; - - static QString sanitizeString(QString str); - static QByteArray join(const QList &list, const QByteArray &sep); - static QVariant parseValue(const QString &json, int &index, bool &success); - static QVariant parseObject(const QString &json, int &index, bool &success); - static QVariant parseArray(const QString &json, int &index, bool &success); - static QVariant parseString(const QString &json, int &index, bool &success); - static QVariant parseNumber(const QString &json, int &index); - static int lastIndexOfNumber(const QString &json, int index); - static void eatWhitespace(const QString &json, int &index); - static int lookAhead(const QString &json, int index); - static int nextToken(const QString &json, int &index); - - template - QByteArray serializeMap(const T &map, bool &success, int _level = 0) { - QByteArray newline; - QByteArray tabs; - QByteArray tabsFields; - if (prettySerialize && !map.isEmpty()) { - newline = "\n"; - for (uint l=1; l<_level; l++) { - tabs += " "; - } - tabsFields = tabs + " "; - } - - QByteArray str = "{" + newline; - QList pairs; - for (typename T::const_iterator it = map.begin(), itend = map.end(); it != itend; ++it) { - bool otherSuccess = true; - QByteArray serializedValue = serialize(it.value(), otherSuccess, _level); - if (serializedValue.isNull()) { - success = false; - break; - } - pairs << tabsFields + sanitizeString(it.key()).toUtf8() + ":" + (prettySerialize ? " " : "") + serializedValue; - } - - str += join(pairs, "," + newline) + newline; - str += tabs + "}"; - return str; - } - - void insert(QVariant &v, const QString &key, const QVariant &value); - void append(QVariant &v, const QVariant &value); - - template - void cloneMap(QVariant &json, const T &map) { - for (typename T::const_iterator it = map.begin(), itend = map.end(); it != itend; ++it) { - insert(json, it.key(), (*it)); - } - } - - template - void cloneList(QVariant &json, const T &list) { - for (typename T::const_iterator it = list.begin(), itend = list.end(); it != itend; ++it) { - append(json, (*it)); - } - } - - /** - * parse - */ - QVariant parse(const QString &json) { - bool success = true; - return parse(json, success); - } - - /** - * parse - */ - QVariant parse(const QString &json, bool &success) { - success = true; - - // Return an empty QVariant if the JSON data is either null or empty - if (!json.isNull() || !json.isEmpty()) { - QString data = json; - // We'll start from index 0 - int index = 0; - - // Parse the first value - QVariant value = parseValue(data, index, success); - - // Return the parsed value - return value; - } else { - // Return the empty QVariant - return QVariant(); - } - } - - /** - * clone - */ - QVariant clone(const QVariant &data) { - QVariant v; - - if (data.type() == QVariant::Map) { - cloneMap(v, data.toMap()); - } else if (data.type() == QVariant::Hash) { - cloneMap(v, data.toHash()); - } else if (data.type() == QVariant::List) { - cloneList(v, data.toList()); - } else if (data.type() == QVariant::StringList) { - cloneList(v, data.toStringList()); - } else { - v = QVariant(data); - } - - return v; - } - - /** - * insert value (map case) - */ - void insert(QVariant &v, const QString &key, const QVariant &value) { - if (!v.canConvert()) v = QVariantMap(); - QVariantMap *p = (QVariantMap *)v.data(); - p->insert(key, clone(value)); - } - - /** - * append value (list case) - */ - void append(QVariant &v, const QVariant &value) { - if (!v.canConvert()) v = QVariantList(); - QVariantList *p = (QVariantList *)v.data(); - p->append(value); - } - - QByteArray serialize(const QVariant &data) { - bool success = true; - return serialize(data, success); - } - - QByteArray serialize(const QVariant &data, bool &success, int _level /*= 0*/) { - QByteArray newline; - QByteArray tabs; - QByteArray tabsFields; - if (prettySerialize) { - newline = "\n"; - for (uint l=0; l<_level; l++) { - tabs += " "; - } - tabsFields = tabs + " "; - } - - QByteArray str; - success = true; - - if (!data.isValid()) { // invalid or null? - str = "null"; - } else if ((data.type() == QVariant::List) || - (data.type() == QVariant::StringList)) { // variant is a list? - QList values; - const QVariantList list = data.toList(); - Q_FOREACH(const QVariant& v, list) { - bool otherSuccess = true; - QByteArray serializedValue = serialize(v, otherSuccess, _level+1); - if (serializedValue.isNull()) { - success = false; - break; - } - values << tabsFields + serializedValue; - } - - if (!values.isEmpty()) { - str = "[" + newline + join( values, "," + newline ) + newline + tabs + "]"; - } else { - str = "[]"; - } - } else if (data.type() == QVariant::Hash) { // variant is a hash? - str = serializeMap<>(data.toHash(), success, _level+1); - } else if (data.type() == QVariant::Map) { // variant is a map? - str = serializeMap<>(data.toMap(), success, _level+1); - } else if ((data.type() == QVariant::String) || - (data.type() == QVariant::ByteArray)) {// a string or a byte array? - str = sanitizeString(data.toString()).toUtf8(); - } else if (data.type() == QVariant::Double) { // double? - double value = data.toDouble(&success); - if (success) { - str = QByteArray::number(value, 'g'); - if (!str.contains(".") && ! str.contains("e")) { - str += ".0"; - } - } - } else if (data.type() == QVariant::Bool) { // boolean value? - str = data.toBool() ? "true" : "false"; - } else if (data.type() == QVariant::ULongLong) { // large unsigned number? - str = QByteArray::number(data.value()); - } else if (data.canConvert()) { // any signed number? - str = QByteArray::number(data.value()); - } else if (data.canConvert()) { //TODO: this code is never executed because all smaller types can be converted to qlonglong - str = QString::number(data.value()).toUtf8(); - } else if (data.type() == QVariant::DateTime) { // datetime value? - str = sanitizeString(dateTimeFormat.isEmpty() - ? data.toDateTime().toString() - : data.toDateTime().toString(dateTimeFormat)).toUtf8(); - } else if (data.type() == QVariant::Date) { // date value? - str = sanitizeString(dateTimeFormat.isEmpty() - ? data.toDate().toString() - : data.toDate().toString(dateFormat)).toUtf8(); - } else if (data.canConvert()) { // can value be converted to string? - // this will catch QUrl, ... (all other types which can be converted to string) - str = sanitizeString(data.toString()).toUtf8(); - } else { - success = false; - } - - if (success) { - return str; - } - return QByteArray(); - } - - QString serializeStr(const QVariant &data) { - return QString::fromUtf8(serialize(data)); - } - - QString serializeStr(const QVariant &data, bool &success) { - return QString::fromUtf8(serialize(data, success)); - } - - - /** - * \enum JsonToken - */ - enum JsonToken { - JsonTokenNone = 0, - JsonTokenCurlyOpen = 1, - JsonTokenCurlyClose = 2, - JsonTokenSquaredOpen = 3, - JsonTokenSquaredClose = 4, - JsonTokenColon = 5, - JsonTokenComma = 6, - JsonTokenString = 7, - JsonTokenNumber = 8, - JsonTokenTrue = 9, - JsonTokenFalse = 10, - JsonTokenNull = 11 - }; - - static QString sanitizeString(QString str) { - str.replace(QLatin1String("\\"), QLatin1String("\\\\")); - str.replace(QLatin1String("\""), QLatin1String("\\\"")); - str.replace(QLatin1String("\b"), QLatin1String("\\b")); - str.replace(QLatin1String("\f"), QLatin1String("\\f")); - str.replace(QLatin1String("\n"), QLatin1String("\\n")); - str.replace(QLatin1String("\r"), QLatin1String("\\r")); - str.replace(QLatin1String("\t"), QLatin1String("\\t")); - return QString(QLatin1String("\"%1\"")).arg(str); - } - - static QByteArray join(const QList &list, const QByteArray &sep) { - QByteArray res; - Q_FOREACH(const QByteArray &i, list) { - if (!res.isEmpty()) { - res += sep; - } - res += i; - } - return res; - } - - /** - * parseValue - */ - static QVariant parseValue(const QString &json, int &index, bool &success) { - // Determine what kind of data we should parse by - // checking out the upcoming token - switch(lookAhead(json, index)) { - case JsonTokenString: - return parseString(json, index, success); - case JsonTokenNumber: - return parseNumber(json, index); - case JsonTokenCurlyOpen: - return parseObject(json, index, success); - case JsonTokenSquaredOpen: - return parseArray(json, index, success); - case JsonTokenTrue: - nextToken(json, index); - return QVariant(true); - case JsonTokenFalse: - nextToken(json, index); - return QVariant(false); - case JsonTokenNull: - nextToken(json, index); - return QVariant(); - case JsonTokenNone: - break; - } - - // If there were no tokens, flag the failure and return an empty QVariant - success = false; - return QVariant(); - } - - /** - * parseObject - */ - static QVariant parseObject(const QString &json, int &index, bool &success) { - QVariantMap map; - int token; - - // Get rid of the whitespace and increment index - nextToken(json, index); - - // Loop through all of the key/value pairs of the object - bool done = false; - while (!done) { - // Get the upcoming token - token = lookAhead(json, index); - - if (token == JsonTokenNone) { - success = false; - return QVariantMap(); - } else if (token == JsonTokenComma) { - nextToken(json, index); - } else if (token == JsonTokenCurlyClose) { - nextToken(json, index); - return map; - } else { - // Parse the key/value pair's name - QString name = parseString(json, index, success).toString(); - - if (!success) { - return QVariantMap(); - } - - // Get the next token - token = nextToken(json, index); - - // If the next token is not a colon, flag the failure - // return an empty QVariant - if (token != JsonTokenColon) { - success = false; - return QVariant(QVariantMap()); - } - - // Parse the key/value pair's value - QVariant value = parseValue(json, index, success); - - if (!success) { - return QVariantMap(); - } - - // Assign the value to the key in the map - map[name] = value; - } - } - - // Return the map successfully - return QVariant(map); - } - - /** - * parseArray - */ - static QVariant parseArray(const QString &json, int &index, bool &success) { - QVariantList list; - - nextToken(json, index); - - bool done = false; - while(!done) { - int token = lookAhead(json, index); - - if (token == JsonTokenNone) { - success = false; - return QVariantList(); - } else if (token == JsonTokenComma) { - nextToken(json, index); - } else if (token == JsonTokenSquaredClose) { - nextToken(json, index); - break; - } else { - QVariant value = parseValue(json, index, success); - if (!success) { - return QVariantList(); - } - list.push_back(value); - } - } - - return QVariant(list); - } - - /** - * parseString - */ - static QVariant parseString(const QString &json, int &index, bool &success) { - QString s; - QChar c; - - eatWhitespace(json, index); - - c = json[index++]; - - bool complete = false; - while(!complete) { - if (index == json.size()) { - break; - } - - c = json[index++]; - - if (c == '\"') { - complete = true; - break; - } else if (c == '\\') { - if (index == json.size()) { - break; - } - - c = json[index++]; - - if (c == '\"') { - s.append('\"'); - } else if (c == '\\') { - s.append('\\'); - } else if (c == '/') { - s.append('/'); - } else if (c == 'b') { - s.append('\b'); - } else if (c == 'f') { - s.append('\f'); - } else if (c == 'n') { - s.append('\n'); - } else if (c == 'r') { - s.append('\r'); - } else if (c == 't') { - s.append('\t'); - } else if (c == 'u') { - int remainingLength = json.size() - index; - if (remainingLength >= 4) { - QString unicodeStr = json.mid(index, 4); - - int symbol = unicodeStr.toInt(0, 16); - - s.append(QChar(symbol)); - - index += 4; - } else { - break; - } - } - } else { - s.append(c); - } - } - - if (!complete) { - success = false; - return QVariant(); - } - - return QVariant(s); - } - - /** - * parseNumber - */ - static QVariant parseNumber(const QString &json, int &index) { - eatWhitespace(json, index); - - int lastIndex = lastIndexOfNumber(json, index); - int charLength = (lastIndex - index) + 1; - QString numberStr; - - numberStr = json.mid(index, charLength); - - index = lastIndex + 1; - bool ok; - - if (numberStr.contains('.')) { - return QVariant(numberStr.toDouble(NULL)); - } else if (numberStr.startsWith('-')) { - int i = numberStr.toInt(&ok); - if (!ok) { - qlonglong ll = numberStr.toLongLong(&ok); - return ok ? ll : QVariant(numberStr); - } - return i; - } else { - uint u = numberStr.toUInt(&ok); - if (!ok) { - qulonglong ull = numberStr.toULongLong(&ok); - return ok ? ull : QVariant(numberStr); - } - return u; - } - } - - /** - * lastIndexOfNumber - */ - static int lastIndexOfNumber(const QString &json, int index) { - int lastIndex; - - for(lastIndex = index; lastIndex < json.size(); lastIndex++) { - if (QString("0123456789+-.eE").indexOf(json[lastIndex]) == -1) { - break; - } - } - - return lastIndex -1; - } - - /** - * eatWhitespace - */ - static void eatWhitespace(const QString &json, int &index) { - for(; index < json.size(); index++) { - if (QString(" \t\n\r").indexOf(json[index]) == -1) { - break; - } - } - } - - /** - * lookAhead - */ - static int lookAhead(const QString &json, int index) { - int saveIndex = index; - return nextToken(json, saveIndex); - } - - /** - * nextToken - */ - static int nextToken(const QString &json, int &index) { - eatWhitespace(json, index); - - if (index == json.size()) { - return JsonTokenNone; - } - - QChar c = json[index]; - index++; - switch(c.toLatin1()) { - case '{': return JsonTokenCurlyOpen; - case '}': return JsonTokenCurlyClose; - case '[': return JsonTokenSquaredOpen; - case ']': return JsonTokenSquaredClose; - case ',': return JsonTokenComma; - case '"': return JsonTokenString; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case '-': return JsonTokenNumber; - case ':': return JsonTokenColon; - } - index--; // ^ WTF? - - int remainingLength = json.size() - index; - - // True - if (remainingLength >= 4) { - if (json[index] == 't' && json[index + 1] == 'r' && - json[index + 2] == 'u' && json[index + 3] == 'e') { - index += 4; - return JsonTokenTrue; - } - } - - // False - if (remainingLength >= 5) { - if (json[index] == 'f' && json[index + 1] == 'a' && - json[index + 2] == 'l' && json[index + 3] == 's' && - json[index + 4] == 'e') { - index += 5; - return JsonTokenFalse; - } - } - - // Null - if (remainingLength >= 4) { - if (json[index] == 'n' && json[index + 1] == 'u' && - json[index + 2] == 'l' && json[index + 3] == 'l') { - index += 4; - return JsonTokenNull; - } - } - - return JsonTokenNone; - } - - void setDateTimeFormat(const QString &format) { - dateTimeFormat = format; - } - - void setDateFormat(const QString &format) { - dateFormat = format; - } - - QString getDateTimeFormat() { - return dateTimeFormat; - } - - QString getDateFormat() { - return dateFormat; - } - - void setPrettySerialize(bool enabled) { - prettySerialize = enabled; - } - - bool isPrettySerialize() { - return prettySerialize; - } - - - - QQueue BuilderJsonObject::created_list; - - BuilderJsonObject::BuilderJsonObject() { - // clean objects previous "created" - while (!BuilderJsonObject::created_list.isEmpty()) { - delete BuilderJsonObject::created_list.dequeue(); - } - } - - BuilderJsonObject::BuilderJsonObject(JsonObject &json) { - BuilderJsonObject(); - - obj = json; - } - - BuilderJsonObject *BuilderJsonObject::set(const QString &key, const QVariant &value) { - obj[key] = value; - - return this; - } - - BuilderJsonObject *BuilderJsonObject::set(const QString &key, BuilderJsonObject *builder) { - return set(key, builder->create()); - } - - BuilderJsonObject *BuilderJsonObject::set(const QString &key, BuilderJsonArray *builder) { - return set(key, builder->create()); - } - - JsonObject BuilderJsonObject::create() { - BuilderJsonObject::created_list.enqueue(this); - - return obj; - } - - - QQueue BuilderJsonArray::created_list; - - BuilderJsonArray::BuilderJsonArray() { - // clean objects previous "created" - while (!BuilderJsonArray::created_list.isEmpty()) { - delete BuilderJsonArray::created_list.dequeue(); - } - } - - BuilderJsonArray::BuilderJsonArray(JsonArray &json) { - BuilderJsonArray(); - - array = json; - } - - BuilderJsonArray *BuilderJsonArray::add(const QVariant &element) { - array.append(element); - - return this; - } - - BuilderJsonArray *BuilderJsonArray::add(BuilderJsonObject *builder) { - return add(builder->create()); - } - - BuilderJsonArray *BuilderJsonArray::add(BuilderJsonArray *builder) { - return add(builder->create()); - } - - JsonArray BuilderJsonArray::create() { - BuilderJsonArray::created_list.enqueue(this); - - return array; - } - - - - - BuilderJsonObject *objectBuilder() { - return new BuilderJsonObject(); - } - - BuilderJsonObject *objectBuilder(JsonObject &json) { - return new BuilderJsonObject(json); - } - - BuilderJsonArray *arrayBuilder() { - return new BuilderJsonArray(); - } - - BuilderJsonArray *arrayBuilder(JsonArray &json) { - return new BuilderJsonArray(json); - } - -} //end namespace diff --git a/client/platforms/ios/json.h b/client/platforms/ios/json.h deleted file mode 100644 index bd37c381..00000000 --- a/client/platforms/ios/json.h +++ /dev/null @@ -1,265 +0,0 @@ -/** - * QtJson - A simple class for parsing JSON data into a QVariant hierarchies and vice-versa. - * Copyright (C) 2011 Eeli Reilin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file json.h - */ - -#ifndef JSON_H -#define JSON_H - -#include -#include -#include - - -/** - * \namespace QtJson - * \brief A JSON data parser - * - * Json parses a JSON data into a QVariant hierarchy. - */ -namespace QtJson { - typedef QVariantMap JsonObject; - typedef QVariantList JsonArray; - - /** - * Clone a JSON object (makes a deep copy) - * - * \param data The JSON object - */ - QVariant clone(const QVariant &data); - - /** - * Insert value to JSON object (QVariantMap) - * - * \param v The JSON object - * \param key The key - * \param value The value - */ - void insert(QVariant &v, const QString &key, const QVariant &value); - - /** - * Append value to JSON array (QVariantList) - * - * \param v The JSON array - * \param value The value - */ - void append(QVariant &v, const QVariant &value); - - /** - * Parse a JSON string - * - * \param json The JSON data - */ - QVariant parse(const QString &json); - - /** - * Parse a JSON string - * - * \param json The JSON data - * \param success The success of the parsing - */ - QVariant parse(const QString &json, bool &success); - - /** - * This method generates a textual JSON representation - * - * \param data The JSON data generated by the parser. - * - * \return QByteArray Textual JSON representation in UTF-8 - */ - QByteArray serialize(const QVariant &data); - - /** - * This method generates a textual JSON representation - * - * \param data The JSON data generated by the parser. - * \param success The success of the serialization - * - * \return QByteArray Textual JSON representation in UTF-8 - */ - QByteArray serialize(const QVariant &data, bool &success, int _level = 0); - - /** - * This method generates a textual JSON representation - * - * \param data The JSON data generated by the parser. - * - * \return QString Textual JSON representation - */ - QString serializeStr(const QVariant &data); - - /** - * This method generates a textual JSON representation - * - * \param data The JSON data generated by the parser. - * \param success The success of the serialization - * - * \return QString Textual JSON representation - */ - QString serializeStr(const QVariant &data, bool &success, int _level = 0); - - /** - * This method sets date(time) format to be used for QDateTime::toString - * If QString is empty, Qt::TextDate is used. - * - * \param format The JSON data generated by the parser. - */ - void setDateTimeFormat(const QString& format); - void setDateFormat(const QString& format); - - /** - * This method gets date(time) format to be used for QDateTime::toString - * If QString is empty, Qt::TextDate is used. - */ - QString getDateTimeFormat(); - QString getDateFormat(); - - /** - * @brief setPrettySerialize enable/disabled pretty-print when serialize() a json - * @param enabled - */ - void setPrettySerialize(bool enabled); - - /** - * @brief isPrettySerialize check if is enabled pretty-print when serialize() a json - * @return - */ - bool isPrettySerialize(); - - - - - /** - * QVariant based Json object - */ - class Object : public QVariant { - template - Object& insertKey(Object* ptr, const QString& key) { - T* p = (T*)ptr->data(); - if (!p->contains(key)) p->insert(key, QVariant()); - return *reinterpret_cast(&p->operator[](key)); - } - template - void removeKey(Object *ptr, const QString& key) { - T* p = (T*)ptr->data(); - p->remove(key); - } - public: - Object() : QVariant() {} - Object(const Object& ref) : QVariant(ref) {} - - Object& operator=(const QVariant& rhs) { - /** It maybe more robust when running under Qt versions below 4.7 */ - QObject * obj = qvariant_cast(rhs); - // setValue(rhs); - setValue(obj); - return *this; - } - Object& operator[](const QString& key) { - if (type() == QVariant::Map) - return insertKey(this, key); - else if (type() == QVariant::Hash) - return insertKey(this, key); - - setValue(QVariantMap()); - - return insertKey(this, key); - } - const Object& operator[](const QString& key) const { - return const_cast(this)->operator[](key); - } - void remove(const QString& key) { - if (type() == QVariant::Map) - removeKey(this, key); - else if (type() == QVariant::Hash) - removeKey(this, key); - } - }; - - - class BuilderJsonArray; - - /** - * @brief The BuilderJsonObject class - */ - class BuilderJsonObject { - - public: - BuilderJsonObject(); - BuilderJsonObject(JsonObject &json); - - BuilderJsonObject *set(const QString &key, const QVariant &value); - BuilderJsonObject *set(const QString &key, BuilderJsonObject *builder); - BuilderJsonObject *set(const QString &key, BuilderJsonArray *builder); - JsonObject create(); - - private: - static QQueue created_list; - - JsonObject obj; - }; - - /** - * @brief The BuilderJsonArray class - */ - class BuilderJsonArray { - - public: - BuilderJsonArray(); - BuilderJsonArray(JsonArray &json); - - BuilderJsonArray *add(const QVariant &element); - BuilderJsonArray *add(BuilderJsonObject *builder); - BuilderJsonArray *add(BuilderJsonArray *builder); - JsonArray create(); - - private: - static QQueue created_list; - - JsonArray array; - }; - - - /** - * @brief Create a BuilderJsonObject - * @return - */ - BuilderJsonObject *objectBuilder(); - - /** - * @brief Create a BuilderJsonObject starting from copy of another json - * @return - */ - BuilderJsonObject *objectBuilder(JsonObject &json); - - /** - * @brief Create a BuilderJsonArray - * @return - */ - BuilderJsonArray *arrayBuilder(); - - /** - * @brief Create a BuilderJsonArray starting from copy of another json - * @return - */ - BuilderJsonArray *arrayBuilder(JsonArray &json); -} - -#endif //JSON_H \ No newline at end of file diff --git a/client/platforms/windows/amneziavpn.rc b/client/platforms/windows/amneziavpn.rc.in similarity index 62% rename from client/platforms/windows/amneziavpn.rc rename to client/platforms/windows/amneziavpn.rc.in index 05365077..f3fd6721 100644 --- a/client/platforms/windows/amneziavpn.rc +++ b/client/platforms/windows/amneziavpn.rc.in @@ -3,41 +3,33 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US IDI_ICON1 ICON "../../images/app.ico" -#define VER_FILEVERSION 2,0,0,0 -#define VER_FILEVERSION_STR "2.0.0.0\0" - -#define VER_PRODUCTVERSION 2,0,0,0 -#define VER_PRODUCTVERSION_STR "2.0.0.0\0" - #define VER_COMPANYNAME_STR "AmneziaVPN" -#define VER_FILEDESCRIPTION_STR "AmneziaVPN" -#define VER_INTERNALNAME_STR "AmneziaVPN" +#define VER_FILEDESCRIPTION_STR VER_COMPANYNAME_STR +#define VER_INTERNALNAME_STR VER_COMPANYNAME_STR #define VER_LEGALCOPYRIGHT_STR "AmneziaVPN." #define VER_LEGALTRADEMARKS1_STR "All Rights Reserved" #define VER_LEGALTRADEMARKS2_STR VER_LEGALTRADEMARKS1_STR #define VER_ORIGINALFILENAME_STR "amneziavpn.exe" -#define VER_PRODUCTNAME_STR "AmneziaVPN" - -#define VER_COMPANYDOMAIN_STR "https://amnezia.org/" +#define VER_PRODUCTNAME_STR VER_COMPANYNAME_STR VS_VERSION_INFO VERSIONINFO -FILEVERSION VER_FILEVERSION -PRODUCTVERSION VER_PRODUCTVERSION +FILEVERSION @CMAKE_PROJECT_VERSION_MAJOR@,@CMAKE_PROJECT_VERSION_MINOR@,@CMAKE_PROJECT_VERSION_PATCH@,@CMAKE_PROJECT_VERSION_TWEAK@ +PRODUCTVERSION @CMAKE_PROJECT_VERSION_MAJOR@,@CMAKE_PROJECT_VERSION_MINOR@,@CMAKE_PROJECT_VERSION_PATCH@ BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" BEGIN VALUE "CompanyName", VER_COMPANYNAME_STR - VALUE "FileDescription", VER_FILEDESCRIPTION_STR - VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "FileDescription", "@CMAKE_PROJECT_DESCRIPTION@" + VALUE "FileVersion", "@CMAKE_PROJECT_VERSION@" VALUE "InternalName", VER_INTERNALNAME_STR VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR VALUE "ProductName", VER_PRODUCTNAME_STR - VALUE "ProductVersion", VER_PRODUCTVERSION_STR + VALUE "ProductVersion", "@CMAKE_PROJECT_VERSION@" END END diff --git a/client/protocols/ios_vpnprotocol.h b/client/protocols/ios_vpnprotocol.h index 6daa46bd..ed5b45b0 100644 --- a/client/protocols/ios_vpnprotocol.h +++ b/client/protocols/ios_vpnprotocol.h @@ -1,7 +1,6 @@ #ifndef IOS_VPNPROTOCOL_H #define IOS_VPNPROTOCOL_H -#include "platforms/ios/json.h" #include "vpnprotocol.h" #include "protocols/protocols_defs.h" @@ -50,15 +49,17 @@ private: bool m_isChangingState = false; - void setupWireguardProtocol(const QtJson::JsonObject& result); - void setupOpenVPNProtocol(const QtJson::JsonObject& result); - void setupShadowSocksProtocol(const QtJson::JsonObject& result); + void setupWireguardProtocol(const QJsonObject& rawConfig); + void setupOpenVPNProtocol(const QJsonObject& rawConfig); + void setupCloakProtocol(const QJsonObject& rawConfig); + void setupShadowSocksProtocol(const QJsonObject& rawConfig); - void launchWireguardTunnel(const QtJson::JsonObject &result); - void launchOpenVPNTunnel(const QtJson::JsonObject &result); - void launchShadowSocksTunnel(const QtJson::JsonObject &result); + void launchWireguardTunnel(const QJsonObject& rawConfig); + void launchOpenVPNTunnel(const QJsonObject& rawConfig); + void launchCloakTunnel(const QJsonObject& rawConfig); + void launchShadowSocksTunnel(const QJsonObject& rawConfig); - QString serializeSSConfig(const QtJson::JsonObject &ssConfig); + QString serializeSSConfig(const QJsonObject &ssConfig); }; diff --git a/client/protocols/ios_vpnprotocol.mm b/client/protocols/ios_vpnprotocol.mm index 28d5b8bf..dda32982 100644 --- a/client/protocols/ios_vpnprotocol.mm +++ b/client/protocols/ios_vpnprotocol.mm @@ -35,34 +35,22 @@ IOSVpnProtocol* IOSVpnProtocol::instance() { } bool IOSVpnProtocol::initialize() -{ - qDebug() << "Initializing Swift Controller"; - - - qDebug() << "RECEIVED CONFIG FROM SERVER SIDE =>"; - qDebug() << QJsonDocument(m_rawConfig).toJson(); - - if (!m_controller) { - bool ok; - QtJson::JsonObject result = QtJson::parse(QJsonDocument(m_rawConfig).toJson(), ok).toMap(); - - if(!ok) { - qDebug() << QString("An error occurred during parsing"); - return false; - } - - QString protoName = result["protocol"].toString(); - qDebug() << "PROTOCOL: " << protoName; +{ + if (!m_controller) { + QString protoName = m_rawConfig["protocol"].toString(); if (protoName == "wireguard") { - setupWireguardProtocol(result); + setupWireguardProtocol(m_rawConfig); currentProto = amnezia::Proto::WireGuard; } else if (protoName == "openvpn") { - setupOpenVPNProtocol(result); + setupOpenVPNProtocol(m_rawConfig); currentProto = amnezia::Proto::OpenVpn; } else if (protoName == "shadowsocks") { - setupShadowSocksProtocol(result); + setupShadowSocksProtocol(m_rawConfig); currentProto = amnezia::Proto::ShadowSocks; + } else if (protoName == "cloak") { + setupCloakProtocol(m_rawConfig); + currentProto = amnezia::Proto::Cloak; } else { return false; } @@ -72,39 +60,39 @@ bool IOSVpnProtocol::initialize() ErrorCode IOSVpnProtocol::start() -{ - bool ok; - QtJson::JsonObject result = QtJson::parse(QJsonDocument(m_rawConfig).toJson(), ok).toMap(); - qDebug() << "current protocol: " << currentProto; - qDebug() << "new protocol: " << m_protocol; - qDebug() << "config: " << result; - - if(!ok) { - qDebug() << QString("An error occurred during config parsing"); - return InternalError; - } - +{ if (m_isChangingState) return NoError; - - QString protocol = result["protocol"].toString(); - + if (!m_controller) initialize(); switch (m_protocol) { + case amnezia::Proto::Cloak: + if (currentProto != m_protocol) { + if (m_controller) { + stop(); + initialize(); + } + launchCloakTunnel(m_rawConfig); + currentProto = amnezia::Proto::OpenVpn; + return NoError; + } + initialize(); + launchCloakTunnel(m_rawConfig); + break; case amnezia::Proto::OpenVpn: if (currentProto != m_protocol) { if (m_controller) { stop(); initialize(); } - launchOpenVPNTunnel(result); + launchOpenVPNTunnel(m_rawConfig); currentProto = amnezia::Proto::OpenVpn; return NoError; } initialize(); - launchOpenVPNTunnel(result); + launchOpenVPNTunnel(m_rawConfig); break; case amnezia::Proto::WireGuard: if (currentProto != m_protocol) { @@ -112,12 +100,12 @@ ErrorCode IOSVpnProtocol::start() stop(); initialize(); } - launchWireguardTunnel(result); + launchWireguardTunnel(m_rawConfig); currentProto = amnezia::Proto::WireGuard; return NoError; } initialize(); - launchWireguardTunnel(result); + launchWireguardTunnel(m_rawConfig); break; case amnezia::Proto::ShadowSocks: if (currentProto != m_protocol) { @@ -125,12 +113,12 @@ ErrorCode IOSVpnProtocol::start() stop(); initialize(); } - launchShadowSocksTunnel(result); + launchShadowSocksTunnel(m_rawConfig); currentProto = amnezia::Proto::ShadowSocks; return NoError; } initialize(); - launchShadowSocksTunnel(result); + launchShadowSocksTunnel(m_rawConfig); break; default: break; @@ -143,11 +131,6 @@ void IOSVpnProtocol::stop() { if (!m_controller) { qDebug() << "Not correctly initialized"; - -// dispatch_async(dispatch_get_main_queue(), ^{ -// emit connectionStateChanged(Disconnected); -// }); - return; } @@ -165,16 +148,12 @@ void IOSVpnProtocol::resume_start() } void IOSVpnProtocol::checkStatus() -{ - qDebug() << "Checking status"; - +{ if (m_checkingStatus) { - qDebug() << "We are still waiting for the previous status."; return; } if (!m_controller) { - qDebug() << "Not correctly initialized"; return; } @@ -206,9 +185,6 @@ void IOSVpnProtocol::checkStatus() } } - qDebug() << "ServerIpv4Gateway:" << QString::fromNSString(serverIpv4Gateway) - << "DeviceIpv4Address:" << QString::fromNSString(deviceIpv4Address) - << "RxBytes:" << rxBytes << "TxBytes:" << txBytes; emit newTransmittedDataCount(rxBytes, txBytes); }]; } @@ -255,22 +231,18 @@ void IOSVpnProtocol::cleanupBackendLogs() file.remove(); } -void IOSVpnProtocol::setupWireguardProtocol(const QtJson::JsonObject &result) +void IOSVpnProtocol::setupWireguardProtocol(const QJsonObject& rawConfig) { static bool creating = false; // No nested creation! Q_ASSERT(creating == false); creating = true; - QtJson::JsonObject config = result["wireguard_config_data"].toMap(); + QJsonObject config = rawConfig["wireguard_config_data"].toObject(); QString privateKey = config["client_priv_key"].toString(); QByteArray key = QByteArray::fromBase64(privateKey.toLocal8Bit()); - qDebug() << " - " << "client_priv_key: " << config["client_priv_key"].toString(); - qDebug() << " - " << "client_pub_key: " << config["client_pub_key"].toString(); - qDebug() << " - " << "interface config: " << config["config"].toString(); - QString addr = config["config"].toString().split("\n").takeAt(1).split(" = ").takeLast(); QString dns = config["config"].toString().split("\n").takeAt(2).split(" = ").takeLast(); QString privkey = config["config"].toString().split("\n").takeAt(3).split(" = ").takeLast(); @@ -279,25 +251,12 @@ void IOSVpnProtocol::setupWireguardProtocol(const QtJson::JsonObject &result) QString allowedips = config["config"].toString().split("\n").takeAt(8).split(" = ").takeLast(); QString endpoint = config["config"].toString().split("\n").takeAt(9).split(" = ").takeLast(); QString keepalive = config["config"].toString().split("\n").takeAt(10).split(" = ").takeLast(); - qDebug() << " - " << "[Interface] address: " << addr; - qDebug() << " - " << "[Interface] dns: " << dns; - qDebug() << " - " << "[Interface] private key: " << privkey; - qDebug() << " - " << "[Peer] public key: " << pubkey; - qDebug() << " - " << "[Peer] preshared key: " << presharedkey; - qDebug() << " - " << "[Peer] allowed ips: " << allowedips; - qDebug() << " - " << "[Peer] endpoint: " << endpoint; - qDebug() << " - " << "[Peer] keepalive: " << keepalive; - - qDebug() << " - " << "hostName: " << config["hostName"].toString(); - qDebug() << " - " << "psk_key: " << config["psk_key"].toString(); - qDebug() << " - " << "server_pub_key: " << config["server_pub_key"].toString(); m_controller = [[IOSVpnProtocolImpl alloc] initWithBundleID:@VPN_NE_BUNDLEID privateKey:key.toNSData() deviceIpv4Address:addr.toNSString() deviceIpv6Address:@"::/0" closure:^(ConnectionState state, NSDate* date) { - qDebug() << "Creation completed with connection state:" << state; creating = false; switch (state) { @@ -312,7 +271,6 @@ void IOSVpnProtocol::setupWireguardProtocol(const QtJson::JsonObject &result) } case ConnectionStateConnected: { Q_ASSERT(date); -// QDateTime qtDate(QDateTime::fromNSDate(date)); dispatch_async(dispatch_get_main_queue(), ^{ emit connectionStateChanged(VpnConnectionState::Connected); m_isChangingState = false; @@ -320,7 +278,6 @@ void IOSVpnProtocol::setupWireguardProtocol(const QtJson::JsonObject &result) return; } case ConnectionStateDisconnected: - // Just in case we are connecting, let's call disconnect. [m_controller disconnect]; dispatch_async(dispatch_get_main_queue(), ^{ emit connectionStateChanged(VpnConnectionState::Disconnected); @@ -349,16 +306,76 @@ void IOSVpnProtocol::setupWireguardProtocol(const QtJson::JsonObject &result) }]; } -void IOSVpnProtocol::setupOpenVPNProtocol(const QtJson::JsonObject &result) +void IOSVpnProtocol::setupCloakProtocol(const QJsonObject &rawConfig) +{ + static bool creating = false; + // No nested creation! + Q_ASSERT(creating == false); + creating = true; + QJsonObject ovpn = rawConfig["openvpn_config_data"].toObject(); + QString ovpnConfig = ovpn["config"].toString(); + + m_controller = [[IOSVpnProtocolImpl alloc] initWithBundleID:@VPN_NE_BUNDLEID + config:ovpnConfig.toNSString() + closure:^(ConnectionState state, NSDate* date) { + creating = false; + + switch (state) { + case ConnectionStateError: { + [m_controller dealloc]; + m_controller = nullptr; + dispatch_async(dispatch_get_main_queue(), ^{ + emit connectionStateChanged(VpnConnectionState::Error); + m_isChangingState = false; + }); + return; + } + case ConnectionStateConnected: { + Q_ASSERT(date); + dispatch_async(dispatch_get_main_queue(), ^{ + emit connectionStateChanged(VpnConnectionState::Connected); + m_isChangingState = false; + }); + return; + } + case ConnectionStateDisconnected: + // Just in case we are connecting, let's call disconnect. + dispatch_async(dispatch_get_main_queue(), ^{ + emit connectionStateChanged(VpnConnectionState::Disconnected); + m_isChangingState = false; + }); + return; + } + } + callback:^(BOOL a_connected) { + if (currentProto != m_protocol) { + qDebug() << "Protocols switched: " << a_connected; + return; + } + qDebug() << "VPN State changed: " << a_connected; + if (a_connected) { + dispatch_async(dispatch_get_main_queue(), ^{ + emit connectionStateChanged(Connected); + m_isChangingState = false; + }); + return; + } + dispatch_async(dispatch_get_main_queue(), ^{ + emit connectionStateChanged(Disconnected); + m_isChangingState = false; + }); + }]; +} + +void IOSVpnProtocol::setupOpenVPNProtocol(const QJsonObject &rawConfig) { static bool creating = false; // No nested creation! Q_ASSERT(creating == false); creating = true; - QtJson::JsonObject ovpn = result["openvpn_config_data"].toMap(); + QJsonObject ovpn = rawConfig["openvpn_config_data"].toObject(); QString ovpnConfig = ovpn["config"].toString(); -// qDebug() << ovpn; m_controller = [[IOSVpnProtocolImpl alloc] initWithBundleID:@VPN_NE_BUNDLEID config:ovpnConfig.toNSString() @@ -378,7 +395,6 @@ void IOSVpnProtocol::setupOpenVPNProtocol(const QtJson::JsonObject &result) } case ConnectionStateConnected: { Q_ASSERT(date); -// QDateTime qtDate(QDateTime::fromNSDate(date)); dispatch_async(dispatch_get_main_queue(), ^{ emit connectionStateChanged(VpnConnectionState::Connected); m_isChangingState = false; @@ -387,7 +403,6 @@ void IOSVpnProtocol::setupOpenVPNProtocol(const QtJson::JsonObject &result) } case ConnectionStateDisconnected: // Just in case we are connecting, let's call disconnect. -// [m_controller disconnect]; dispatch_async(dispatch_get_main_queue(), ^{ emit connectionStateChanged(VpnConnectionState::Disconnected); m_isChangingState = false; @@ -400,7 +415,7 @@ void IOSVpnProtocol::setupOpenVPNProtocol(const QtJson::JsonObject &result) qDebug() << "Protocols switched: " << a_connected; return; } - qDebug() << "OVPN State changed: " << a_connected; + qDebug() << "VPN State changed: " << a_connected; if (a_connected) { dispatch_async(dispatch_get_main_queue(), ^{ emit connectionStateChanged(Connected); @@ -415,23 +430,21 @@ void IOSVpnProtocol::setupOpenVPNProtocol(const QtJson::JsonObject &result) }]; } -void IOSVpnProtocol::setupShadowSocksProtocol(const QtJson::JsonObject &result) +void IOSVpnProtocol::setupShadowSocksProtocol(const QJsonObject &rawConfig) { static bool creating = false; // No nested creation! Q_ASSERT(creating == false); creating = true; - QtJson::JsonObject ovpn = result["openvpn_config_data"].toMap(); + QJsonObject ovpn = rawConfig["openvpn_config_data"].toObject(); QString ovpnConfig = ovpn["config"].toString(); - qDebug() << "OpenVPN Config:\n" << ovpn; - QtJson::JsonObject ssConfig = result["shadowsocks_config_data"].toMap(); + QJsonObject ssConfig = rawConfig["shadowsocks_config_data"].toObject(); m_controller = [[IOSVpnProtocolImpl alloc] initWithBundleID:@VPN_NE_BUNDLEID tunnelConfig:ovpnConfig.toNSString() ssConfig:serializeSSConfig(ssConfig).toNSString() closure:^(ConnectionState state, NSDate* date) { - qDebug() << "ShadowSocks creation completed with connection state:" << state; creating = false; switch (state) { @@ -446,7 +459,6 @@ void IOSVpnProtocol::setupShadowSocksProtocol(const QtJson::JsonObject &result) } case ConnectionStateConnected: { Q_ASSERT(date); - // QDateTime qtDate(QDateTime::fromNSDate(date)); dispatch_async(dispatch_get_main_queue(), ^{ emit connectionStateChanged(VpnConnectionState::Connected); m_isChangingState = false; @@ -455,7 +467,6 @@ void IOSVpnProtocol::setupShadowSocksProtocol(const QtJson::JsonObject &result) } case ConnectionStateDisconnected: // Just in case we are connecting, let's call disconnect. - // [m_controller disconnect]; dispatch_async(dispatch_get_main_queue(), ^{ emit connectionStateChanged(VpnConnectionState::Disconnected); m_isChangingState = false; @@ -483,9 +494,9 @@ void IOSVpnProtocol::setupShadowSocksProtocol(const QtJson::JsonObject &result) }]; } -void IOSVpnProtocol::launchWireguardTunnel(const QtJson::JsonObject &result) +void IOSVpnProtocol::launchWireguardTunnel(const QJsonObject &rawConfig) { - QtJson::JsonObject config = result["wireguard_config_data"].toMap(); + QJsonObject config = rawConfig["wireguard_config_data"].toObject(); QString clientPrivateKey = config["client_priv_key"].toString(); QByteArray key = QByteArray::fromBase64(clientPrivateKey.toLocal8Bit()); @@ -506,13 +517,6 @@ void IOSVpnProtocol::launchWireguardTunnel(const QtJson::JsonObject &result) QString pskKey = config["psk_key"].toString(); QString serverPubKey = config["server_pub_key"].toString(); - qDebug() << "IOSVPNProtocol starts for" << hostname; - qDebug() << "DNS:" << dnsServersList.takeFirst().toNSString(); - qDebug() << "serverPublicKey:" << serverPubKey.toNSString(); - qDebug() << "serverIpv4AddrIn:" << serverAddr.toNSString(); - qDebug() << "serverPort:" << (uint32_t)port.toInt(); - qDebug() << "allowed ip list" << allowedIPList; - NSMutableArray* allowedIPAddressRangesNS = [NSMutableArray arrayWithCapacity:allowedIPList.length()]; for (const IPAddressRange item : allowedIPList) { @@ -541,9 +545,56 @@ void IOSVpnProtocol::launchWireguardTunnel(const QtJson::JsonObject &result) }]; } -void IOSVpnProtocol::launchOpenVPNTunnel(const QtJson::JsonObject &result) + +void IOSVpnProtocol::launchCloakTunnel(const QJsonObject &rawConfig) +{ + QJsonObject ovpn = rawConfig["openvpn_config_data"].toObject(); + + QString ovpnConfig = ovpn["config"].toString(); + + if(rawConfig["protocol"].toString() == "cloak"){ + QJsonObject cloak = rawConfig["cloak_config_data"].toObject(); + cloak["NumConn"] = 1; + cloak["RemoteHost"] = cloak["remote"].toString(); + cloak["RemotePort"] = cloak["port"].toString(); + + cloak.remove("remote"); + cloak.remove("port"); + + // Convert JSONObject to JSONDocument + QJsonObject jsonObject {}; + foreach(const QString& key, cloak.keys()) { + if(key == "NumConn" or key == "StreamTimeout"){ + jsonObject.insert(key, cloak.value(key).toInt()); + }else{ + jsonObject.insert(key, cloak.value(key).toString()); + } + } + QJsonDocument doc(jsonObject); + QString strJson(doc.toJson(QJsonDocument::Compact)); + + QString cloakBase64 = strJson.toUtf8().toBase64(); + ovpnConfig.append("\n\n"); + ovpnConfig.append(cloakBase64); + ovpnConfig.append("\n\n"); + } + + + [m_controller connectWithOvpnConfig:ovpnConfig.toNSString() + failureCallback:^{ + qDebug() << "IOSVPNProtocol (OpenVPN Cloak) - connection failed"; + dispatch_async(dispatch_get_main_queue(), ^{ + emit connectionStateChanged(Disconnected); + m_isChangingState = false; + }); + }]; +} + + + +void IOSVpnProtocol::launchOpenVPNTunnel(const QJsonObject &rawConfig) { - QtJson::JsonObject ovpn = result["openvpn_config_data"].toMap(); + QJsonObject ovpn = rawConfig["openvpn_config_data"].toObject(); QString ovpnConfig = ovpn["config"].toString(); [m_controller connectWithOvpnConfig:ovpnConfig.toNSString() @@ -556,10 +607,10 @@ void IOSVpnProtocol::launchOpenVPNTunnel(const QtJson::JsonObject &result) }]; } -void IOSVpnProtocol::launchShadowSocksTunnel(const QtJson::JsonObject &result) { - QtJson::JsonObject ovpn = result["openvpn_config_data"].toMap(); +void IOSVpnProtocol::launchShadowSocksTunnel(const QJsonObject &rawConfig) { + QJsonObject ovpn = rawConfig["openvpn_config_data"].toObject(); QString ovpnConfig = ovpn["config"].toString(); - QtJson::JsonObject ssConfig = result["shadowsocks_config_data"].toMap(); + QJsonObject ssConfig = rawConfig["shadowsocks_config_data"].toObject(); QString ss = serializeSSConfig(ssConfig); [m_controller connectWithSsConfig:ss.toNSString() @@ -573,26 +624,18 @@ void IOSVpnProtocol::launchShadowSocksTunnel(const QtJson::JsonObject &result) { }]; } -QString IOSVpnProtocol::serializeSSConfig(const QtJson::JsonObject &ssConfig) { +QString IOSVpnProtocol::serializeSSConfig(const QJsonObject &ssConfig) { QString ssLocalPort = ssConfig["local_port"].toString(); QString ssMethod = ssConfig["method"].toString(); QString ssPassword = ssConfig["password"].toString(); QString ssServer = ssConfig["server"].toString(); QString ssPort = ssConfig["server_port"].toString(); QString ssTimeout = ssConfig["timeout"].toString(); - qDebug() << "\n\nSS CONFIG:"; - qDebug() << " local port -" << ssLocalPort; - qDebug() << " method -" << ssMethod; - qDebug() << " password -" << ssPassword; - qDebug() << " server -" << ssServer; - qDebug() << " port -" << ssPort; - qDebug() << " timeout -" << ssTimeout; QJsonObject shadowSocksConfig = QJsonObject(); shadowSocksConfig.insert("local_addr", "127.0.0.1"); shadowSocksConfig.insert("local_port", ssConfig["local_port"].toInt()); shadowSocksConfig.insert("method", ssConfig["method"].toString()); -// shadowSocksConfig.insert("method", "aes-256-gcm"); shadowSocksConfig.insert("password", ssConfig["password"].toString()); shadowSocksConfig.insert("server", ssConfig["server"].toString()); shadowSocksConfig.insert("server_port", ssConfig["server_port"].toInt()); diff --git a/client/protocols/openvpnovercloakprotocol.cpp b/client/protocols/openvpnovercloakprotocol.cpp index 52bcae4b..61cda85c 100644 --- a/client/protocols/openvpnovercloakprotocol.cpp +++ b/client/protocols/openvpnovercloakprotocol.cpp @@ -18,10 +18,7 @@ OpenVpnOverCloakProtocol::~OpenVpnOverCloakProtocol() { qDebug() << "OpenVpnOverCloakProtocol::~OpenVpnOverCloakProtocol"; OpenVpnOverCloakProtocol::stop(); - QThread::msleep(200); -#ifndef Q_OS_IOS m_ckProcess.close(); -#endif } ErrorCode OpenVpnOverCloakProtocol::start() @@ -30,11 +27,17 @@ ErrorCode OpenVpnOverCloakProtocol::start() setLastError(ErrorCode::CloakExecutableMissing); return lastError(); } -#ifndef Q_OS_IOS + if (Utils::processIsRunning(Utils::executable("ck-client", false))) { Utils::killProcessByName(Utils::executable("ck-client", false)); } + // workaround for desktop releases >= 3.0.7 + if (!m_cloakConfig.contains("RemoteHost") && m_cloakConfig.contains(config_key::remote)) { + m_cloakConfig["RemoteHost"] = m_cloakConfig.value(config_key::remote); + m_cloakConfig["RemotePort"] = m_cloakConfig.value(config_key::port); + } + #ifdef QT_DEBUG m_cloakCfgFile.setAutoRemove(false); #endif @@ -43,15 +46,8 @@ ErrorCode OpenVpnOverCloakProtocol::start() m_cloakCfgFile.close(); QStringList args = QStringList() << "-c" << m_cloakCfgFile.fileName() - << "-s" << m_cloakConfig.value(config_key::remote).toString() - << "-p" << m_cloakConfig.value(config_key::port).toString(amnezia::protocols::cloak::defaultPort) << "-l" << amnezia::protocols::openvpn::defaultPort; - ProtocolEnumNS::TransportProto tp = ProtocolProps::transportProtoFromString(m_cloakConfig.value(config_key::transport_proto).toString()); - if (tp == ProtocolEnumNS::TransportProto::Udp) { - args << "-u"; - } - qDebug().noquote() << "OpenVpnOverCloakProtocol::start()" << cloakExecPath() << args.join(" "); @@ -86,7 +82,6 @@ ErrorCode OpenVpnOverCloakProtocol::start() return OpenVpnProtocol::start(); } else return ErrorCode::CloakExecutableMissing; -#endif } void OpenVpnOverCloakProtocol::stop() @@ -100,9 +95,12 @@ void OpenVpnOverCloakProtocol::stop() Utils::signalCtrl(m_ckProcess.processId(), CTRL_C_EVENT); #endif -#ifndef Q_OS_IOS m_ckProcess.terminate(); -#endif + + if (Utils::processIsRunning(Utils::executable("ck-client", false))) { + QThread::msleep(1000); + Utils::killProcessByName(Utils::executable("ck-client", false)); + } } QString OpenVpnOverCloakProtocol::cloakExecPath() diff --git a/client/protocols/openvpnprotocol.cpp b/client/protocols/openvpnprotocol.cpp index 273d7b76..6a2c8246 100644 --- a/client/protocols/openvpnprotocol.cpp +++ b/client/protocols/openvpnprotocol.cpp @@ -6,7 +6,7 @@ #include #include "logger.h" -#include "defines.h" +#include "version.h" #include "utilities.h" #include "openvpnprotocol.h" diff --git a/client/scripts/apple_compile.sh b/client/scripts/apple_compile.sh deleted file mode 100755 index 403460fa..00000000 --- a/client/scripts/apple_compile.sh +++ /dev/null @@ -1,254 +0,0 @@ -#!/bin/bash - - -. $(dirname $0)/commons.sh - -if [ -f .env ]; then - . .env -fi - -RELEASE=1 -OS= -NETWORKEXTENSION= -WORKINGDIR=`pwd` - -helpFunction() { - print G "Usage:" - print N "\t$0 [-d|--debug] [-n|--networkextension]" - print N "" - print N "By default, the project is compiled in release mode. Use -d or --debug for a debug build." - print N "Use -n or --networkextension to force the network-extension component for MacOS too." - print N "" - print N "If MVPN_IOS_ADJUST_TOKEN env is found, this will be used at compilation time." - print N "" - print G "Config variables:" - print N "\tQT_MACOS_BIN=" - print N "\tQT_IOS_BIN=" - print N "" - exit 0 -} - -print N "This script compiles AmneziaVPN for MacOS/iOS" -print N "" - -while [[ $# -gt 0 ]]; do - key="$1" - - case $key in - -d | --debug) - RELEASE= - shift - ;; - -n | --networkextension) - NETWORKEXTENSION=1 - shift - ;; - -h | --help) - helpFunction - ;; - *) - if [[ "$OS" ]]; then - helpFunction - fi - - OS=$1 - shift - ;; - esac -done - -fetch() { - if command -v "wget" &>/dev/null; then - wget -nc -O "$2" "$1" - return - fi - - if command -v "curl" &>/dev/null; then - curl "$1" -o "$2" -s -L - return - fi - - killProcess "You must have 'wget' or 'curl' installed." -} - -sha256() { - if command -v "sha256sum" &>/dev/null; then - sha256sum "$1" - return 0 - fi - - if command -v "openssl" &>/dev/null; then - openssl dgst -sha256 "$1" - return 0 - fi - - killProcess "You must have 'sha256sum' or 'openssl' installed." -} - -if [[ "$OS" != "macos" ]] && [[ "$OS" != "ios" ]] && [[ "$OS" != "macostest" ]]; then - helpFunction -fi - -if [[ "$OS" == "ios" ]]; then - # Network-extension is the default for IOS - NETWORKEXTENSION=1 -fi - -if ! [ -d "ios" ] || ! [ -d "macos" ]; then - killProcess "This script must be executed at the root of the repository." -fi - -QMAKE=qmake -if [ "$OS" = "macos" ] && ! [ "$QT_MACOS_BIN" = "" ]; then - QMAKE=$QT_MACOS_BIN/qmake -elif [ "$OS" = "macostest" ] && ! [ "$QT_MACOS_BIN" = "" ]; then - QMAKE=$QT_MACOS_BIN/qmake -elif [ "$OS" = "ios" ] && ! [ "$QT_IOS_BIN" = "" ]; then - QMAKE=$QT_IOS_BIN/qmake -fi - -$QMAKE -v &>/dev/null || killProcess "qmake doesn't exist or it fails" - -print Y "Retrieve the wireguard-go version... " -if [ "$OS" = "macos" ]; then - (cd macos/gobridge && go list -m golang.zx2c4.com/wireguard | sed -n 's/.*v\([0-9.]*\).*/#define WIREGUARD_GO_VERSION "\1"/p') > macos/gobridge/wireguard-go-version.h -elif [ "$OS" = "ios" ]; then - if [ ! -f 3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard-go-version.h ]; then - print Y "Creating wireguard-go-version.h file" - touch 3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard-go-version.h - cat <> $WORKINGDIR/3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard-go-version.h -#define WIREGUARD_GO_VERSION "0.0.0" -EOF - fi - (cd 3rd/wireguard-apple/Sources/WireGuardKitGo && go list -m golang.zx2c4.com/wireguard | sed -n 's/.*v\([0-9.]*\).*/#define WIREGUARD_GO_VERSION "\1"/p') > 3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard-go-version.h -fi -print G "done." - -printn Y "Cleaning the existing project... " -rm -rf AmneziaVPN.xcodeproj/ || killProcess "Failed to remove things" -print G "done." - -printn Y "Extract the project version... " -SHORTVERSION=$(cat version.pri | grep VERSION | grep defined | cut -d= -f2 | tr -d \ ) -FULLVERSION=$(cat versionfull.pri | grep BUILDVERSION | grep defined | cut -d= -f2 | tr -d \ ) -print G "$SHORTVERSION - $FULLVERSION" - -MACOS_FLAGS=" - QTPLUGIN+=qsvg - CONFIG-=static - CONFIG+=balrog -" - -MACOSTEST_FLAGS=" - QTPLUGIN+=qsvg - CONFIG-=static - CONFIG+=DUMMY -" - -IOS_FLAGS=" - Q_OS_IOS=1 -" - -printn Y "Mode: " -if [[ "$RELEASE" ]]; then - print G "release" - MODE="CONFIG-=debug CONFIG+=release CONFIG-=debug_and_release" -else - print G "debug" - MODE="CONFIG+=debug CONFIG-=release CONFIG-=debug_and_release" -fi - -OSRUBY=$OS -printn Y "OS: " -print G "$OS" -if [ "$OS" = "macos" ]; then - PLATFORM=$MACOS_FLAGS -elif [ "$OS" = "macostest" ]; then - OSRUBY=macos - PLATFORM=$MACOSTEST_FLAGS -elif [ "$OS" = "ios" ]; then - PLATFORM=$IOS_FLAGS -else - killProcess "Why are we here?" -fi - -VPNMODE= -printn Y "VPN mode: " -if [[ "$NETWORKEXTENSION" ]]; then - print G network-extension - VPNMODE="CONFIG+=networkextension" -else - print G daemon -fi - -printn Y "Web-Extension: " -WEMODE= -if [ "$OS" = "macos" ]; then - print G web-extension - WEMODE="CONFIG+=webextension" -else - print G none -fi - -if [ "$OS" = "ios" ]; then - print Y "Prepare to build OpenVPNAdapter..." - prepare_to_build_vpn - print Y "Building OpenVPNAdapter..." - compile_openvpn_adapter -else - print Y "No OpenVPNAdapter will be built" -fi - -if [ "$OS" = "ios" ]; then - print Y "Prepare to build ShadowSocks..." - prepare_to_build_ss - print Y "Patching the ShadowSocks project..." - patch_ss - ruby ../../scripts/ss_project_patcher.rb "ShadowSocks.xcodeproj" - print G "done." - print Y "Building ShadowSocks Framework..." - compile_ss_frameworks -else - print Y "No ShadowSocket Library will be built" -fi - -if [ "$OS" = "ios" ]; then - print Y "Prepare to build CocoaAsyncSocket..." - prepare_to_build_cas - print Y "Building CocoaAsyncSocket Framework..." - compile_cocoa_async_socket -else - print Y "No CocoaAsyncSocket will be built" -fi - -if [ "$OS" = "ios" ]; then - print Y "Prepare to build Tun2Socks..." - print Y "Building Tun2Socks Framework..." - compile_tun2socks -else - print Y "No Tun2Socks will be built" -fi - -print Y "Creating the Xcode project via qmake..." -$QMAKE \ - VERSION=$SHORTVERSION \ - BUILD_ID=$FULLVERSION \ - -spec macx-xcode \ - $MODE \ - $VPNMODE \ - $WEMODE \ - $PLATFORM \ - ./client.pro || killProcess "Compilation failed" - -print Y "Patching the xcode project..." -ruby scripts/xcode_patcher.rb "AmneziaVPN.xcodeproj" "$SHORTVERSION" "$FULLVERSION" "$OSRUBY" "$NETWORKEXTENSION" || killProcess "Failed to merge xcode with wireguard" -print G "done." - - if command -v "sed" &>/dev/null; then - sed -i '' '/BuildSystemType<\/key>/d' AmneziaVPN.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings - sed -i '' '/Original<\/string>/d' AmneziaVPN.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings - fi - -print G "All done!" -print Y "Opening project in Xcode..." -open AmneziaVPN.xcodeproj diff --git a/client/scripts/build_phase_run_script.sh b/client/scripts/build_phase_run_script.sh deleted file mode 100644 index 510ec6a4..00000000 --- a/client/scripts/build_phase_run_script.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -# add `@executable_path/../../Frameworks` to Runpath Search Paths in Build Settings of extension -# put to run script phase in build phases for extension -# Type a script or drag a script file from your workspace to insert its path. -cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/" -if [[ -d "Frameworks" ]]; then - rm -fr Frameworks -fi \ No newline at end of file diff --git a/client/scripts/cas_ios.xcconfig b/client/scripts/cas_ios.xcconfig deleted file mode 100644 index 80967035..00000000 --- a/client/scripts/cas_ios.xcconfig +++ /dev/null @@ -1,18 +0,0 @@ -SUPPORTED_PLATFORMS = iphoneos -TARGETED_DEVICE_FAMILY = 1,2 - -HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/Source -//CLANG_CXX_LANGUAGE_STANDARD = gnu++14 -//CLANG_CXX_LIBRARY = libc++ - -//////////////////////////////////////////////////////////////////////////////// -// -// iOS-specific settings -// -IPHONEOS_DEPLOYMENT_TARGET = 9.3 - -SDKROOT[arch=arm64] = iphoneos -SDKROOT[arch=armv7] = iphoneos -SDKROOT[arch=armv7s] = iphoneos - -VALID_ARCHS[sdk=iphoneos*] = arm64 diff --git a/client/scripts/cl_ios.xcconfig b/client/scripts/cl_ios.xcconfig deleted file mode 100644 index 24a13c9d..00000000 --- a/client/scripts/cl_ios.xcconfig +++ /dev/null @@ -1,18 +0,0 @@ -SUPPORTED_PLATFORMS = iphoneos -TARGETED_DEVICE_FAMILY = 1,2 - -HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/Sources -//CLANG_CXX_LANGUAGE_STANDARD = gnu++14 -//CLANG_CXX_LIBRARY = libc++ - -//////////////////////////////////////////////////////////////////////////////// -// -// iOS-specific settings -// -IPHONEOS_DEPLOYMENT_TARGET = 9.3 - -SDKROOT[arch=arm64] = iphoneos -SDKROOT[arch=armv7] = iphoneos -SDKROOT[arch=armv7s] = iphoneos - -VALID_ARCHS[sdk=iphoneos*] = arm64 \ No newline at end of file diff --git a/client/scripts/codesign_framework.sh b/client/scripts/codesign_framework.sh deleted file mode 100644 index 9360b961..00000000 --- a/client/scripts/codesign_framework.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh - -# WARNING: You may have to run Clean in Xcode after changing CODE_SIGN_IDENTITY! - -# Verify that $CODE_SIGN_IDENTITY is set -if [ -z "${CODE_SIGN_IDENTITY}" ] ; then - echo "CODE_SIGN_IDENTITY needs to be set for framework code-signing!" - - if [ "${CONFIGURATION}" = "Release" ] ; then - exit 1 - else - # Code-signing is optional for non-release builds. - exit 0 - fi -fi - -if [ -z "${CODE_SIGN_ENTITLEMENTS}" ] ; then - echo "CODE_SIGN_ENTITLEMENTS needs to be set for framework code-signing!" - - if [ "${CONFIGURATION}" = "Release" ] ; then - exit 1 - else - # Code-signing is optional for non-release builds. - exit 0 - fi -fi - -ITEMS="" - -FRAMEWORKS_DIR="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" -if [ -d "$FRAMEWORKS_DIR" ] ; then - FRAMEWORKS=$(find "${FRAMEWORKS_DIR}" -depth -type d -name "*.framework" -or -name "*.dylib" -or -name "*.bundle" | sed -e "s/\(.*framework\)/\1\/Versions\/A\//") - RESULT=$? - if [[ $RESULT != 0 ]] ; then - exit 1 - fi - - ITEMS="${FRAMEWORKS}" -fi - -LOGINITEMS_DIR="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Library/LoginItems/" -if [ -d "$LOGINITEMS_DIR" ] ; then - LOGINITEMS=$(find "${LOGINITEMS_DIR}" -depth -type d -name "*.app") - RESULT=$? - if [[ $RESULT != 0 ]] ; then - exit 1 - fi - - ITEMS="${ITEMS}"$'\n'"${LOGINITEMS}" -fi - -# Prefer the expanded name, if available. -CODE_SIGN_IDENTITY_FOR_ITEMS="${EXPANDED_CODE_SIGN_IDENTITY_NAME}" -if [ "${CODE_SIGN_IDENTITY_FOR_ITEMS}" = "" ] ; then - # Fall back to old behavior. - CODE_SIGN_IDENTITY_FOR_ITEMS="${CODE_SIGN_IDENTITY}" -fi - -echo "Identity:" -echo "${CODE_SIGN_IDENTITY_FOR_ITEMS}" - -echo "Entitlements:" -echo "${CODE_SIGN_ENTITLEMENTS}" - -echo "Found:" -echo "${ITEMS}" - -# Change the Internal Field Separator (IFS) so that spaces in paths will not cause problems below. -SAVED_IFS=$IFS -IFS=$(echo -en "\n\b") - -# Loop through all items. -for ITEM in $ITEMS; -do - echo "Signing '${ITEM}'" - codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" --entitlements "${CODE_SIGN_ENTITLEMENTS}" "${ITEM}" - RESULT=$? - if [[ $RESULT != 0 ]] ; then - echo "Failed to sign '${ITEM}'." - IFS=$SAVED_IFS - exit 1 - fi -done - -# Restore $IFS. -IFS=$SAVED_IFS - -# Save it to a file in your project. -# Mine is called codesign-frameworks.sh. -# Add a “Run Script” build phase right after your “Copy Embedded Frameworks” build phase. -# You can call it “Codesign Embedded Frameworks”. -# Paste ./codesign-frameworks.sh (or whatever you called your script above) into the script editor text field. -# Build your app. All bundled frameworks will be codesigned. -# from http://stackoverflow.com/questions/7697508/how-do-you-codesign-framework-bundles-for-the-mac-app-store \ No newline at end of file diff --git a/client/scripts/commons.sh b/client/scripts/commons.sh deleted file mode 100644 index aebd37b2..00000000 --- a/client/scripts/commons.sh +++ /dev/null @@ -1,148 +0,0 @@ -#!/bin/bash - -printv() { - if [ -t 1 ]; then - NCOLORS=$(tput colors) - - if test -n "$NCOLORS" && test "$NCOLORS" -ge 8; then - NORMAL="$(tput sgr0)" - RED="$(tput setaf 1)" - GREEN="$(tput setaf 2)" - YELLOW="$(tput setaf 3)" - fi - fi - - if [[ $2 = 'G' ]]; then - # shellcheck disable=SC2086 - echo $1 -e "${GREEN}$3${NORMAL}" - elif [[ $2 = 'Y' ]]; then - # shellcheck disable=SC2086 - echo $1 -e "${YELLOW}$3${NORMAL}" - elif [[ $2 = 'N' ]]; then - # shellcheck disable=SC2086 - echo $1 -e "$3" - else - # shellcheck disable=SC2086 - echo $1 -e "${RED}$3${NORMAL}" - fi -} - -print() { - printv '' "$1" "$2" -} - -printn() { - printv "-n" "$1" "$2" -} - -error() { - printv '' R "$1" -} - -XCODEBUILD="/usr/bin/xcodebuild" -WORKINGDIR=`pwd` -PATCH="/usr/bin/patch" -export PATH=$GOPATH:$PATH - -prepare_to_build_vpn() { - cat $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/Project.xcconfig > $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/amnezia.xcconfig - cat << EOF >> $WORKINGDIR/3rd/OpenVPNAdapter/Configuration/amnezia.xcconfig - PROJECT_TEMP_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/OpenVPNAdapter.build - CONFIGURATION_BUILD_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/Release-iphoneos - BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/OpenVPNAdapter/build/Release-iphoneos -EOF -} - -compile_openvpn_adapter() { - cd 3rd/OpenVPNAdapter - if $XCODEBUILD -scheme OpenVPNAdapter -configuration Release -xcconfig Configuration/amnezia.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project OpenVPNAdapter.xcodeproj ; then - print Y "OpenVPNAdapter built successfully" - else - killProcess "OpenVPNAdapter build failed" - fi - cd ../../ -} - -prepare_to_build_ss() { - cat $WORKINGDIR/scripts/ss_ios.xcconfig > $WORKINGDIR/3rd/ShadowSocks/ss_ios.xcconfig - cat << EOF >> $WORKINGDIR/3rd/ShadowSocks/ss_ios.xcconfig -PROJECT_TEMP_DIR = $WORKINGDIR/3rd/ShadowSocks/build/ShadowSocks.build -CONFIGURATION_BUILD_DIR = $WORKINGDIR/3rd/ShadowSocks/build/Release-iphoneos -BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/ShadowSocks/build/Release-iphoneos -EOF -} - -patch_ss() { - cd 3rd/ShadowSocks -} - -compile_ss_frameworks() { - if $XCODEBUILD -scheme ShadowSocks -configuration Release -xcconfig ss_ios.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project ShadowSocks.xcodeproj ; then - print Y "ShadowSocks built successfully" - else - killProcess "ShadowSocks build failed" - fi - cd ../../ -} - -prepare_to_build_cas() { - cat $WORKINGDIR/scripts/cas_ios.xcconfig > $WORKINGDIR/3rd/CocoaAsyncSocket/cas_ios.xcconfig - cat << EOF >> $WORKINGDIR/3rd/CocoaAsyncSocket/cas_ios.xcconfig -PROJECT_TEMP_DIR = $WORKINGDIR/3rd/CocoaAsyncSocket/build/CocoaAsyncSocket.build -CONFIGURATION_BUILD_DIR = $WORKINGDIR/3rd/CocoaAsyncSocket/build/Release-iphoneos -BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/CocoaAsyncSocket/build/Release-iphoneos -EOF -} - -compile_cocoa_async_socket() { - cd 3rd/CocoaAsyncSocket - if $XCODEBUILD -scheme 'iOS Framework' -configuration Release -xcconfig cas_ios.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project CocoaAsyncSocket.xcodeproj ; then - print Y "CocoaAsyncSocket built successfully" - else - killProcess "CocoaAsyncSocket build failed" - fi - cd ../../ -} - -compile_tun2socks() { - cd 3rd/outline-go-tun2socks - go get -d ./... - go get -u golang.org/x/sys - if GOOS=ios GOARCH=arm64 GOFLAGS="-tags=ios" CC=iphoneos-clang CXX=iphoneos-clang++ CGO_CFLAGS="-isysroot iphoneos -miphoneos-version-min=12.0 -fembed-bitcode -arch arm64" CGO_CXXFLAGS="-isysroot iphoneos -miphoneos-version-min=12.0 -fembed-bitcode -arch arm64" CGO_LDFLAGS="-isysroot iphoneos -miphoneos-version-min=12.0 -fembed-bitcode -arch arm64" CGO_ENABLED=1 DARWIN_SDK=iphoneos gomobile bind -a -ldflags="-w -s" -bundleid org.amnezia.tun2socks -target=ios/arm64 -tags ios -o ./build/ios/Tun2Socks.xcframework github.com/Jigsaw-Code/outline-go-tun2socks/outline/apple github.com/Jigsaw-Code/outline-go-tun2socks/outline/shadowsocks ; then - print Y "Tun2Socks built successfully" - else - print "Please check that path to bin folder with gomobile is in your PATH" - print "Usually it's in GOPATH/bin, e.g. /usr/local/go/bin" - killProcess "Tun2Socks build failed" - fi - cd ../../ -} - -prepare_to_build_cl() { - cat $WORKINGDIR/scripts/cl_ios.xcconfig > $WORKINGDIR/3rd/CocoaLumberjack/cl_ios.xcconfig - cat << EOF >> $WORKINGDIR/3rd/CocoaLumberjack/cl_ios.xcconfig -PROJECT_TEMP_DIR = $WORKINGDIR/3rd/CocoaLumberjack/build/CocoaLumberjack.build -CONFIGURATION_BUILD_DIR = $WORKINGDIR/3rd/CocoaLumberjack/build/Release-iphoneos -BUILT_PRODUCTS_DIR = $WORKINGDIR/3rd/CocoaLumberjack/build/Release-iphoneos -EOF -} - -compile_cocoalamberjack() { - cd 3rd/CocoaLumberjack - if $XCODEBUILD -scheme 'CocoaLumberjack' -configuration Release -xcconfig cl_ios.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project Lumberjack.xcodeproj ; then - print Y "CocoaLumberjack built successfully" - else - killProcess "CocoaLumberjack build failed" - fi - cd ../../ -} - -killProcess() { - if [[ "$1" ]]; then - error "$1" - else - error Failed - fi - - exit 1 -} diff --git a/client/scripts/pp_ios.xcconfig b/client/scripts/pp_ios.xcconfig deleted file mode 100644 index 3dd0c4d7..00000000 --- a/client/scripts/pp_ios.xcconfig +++ /dev/null @@ -1,18 +0,0 @@ -SUPPORTED_PLATFORMS = iphoneos -TARGETED_DEVICE_FAMILY = 1,2 - -HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/PacketProcessor -//CLANG_CXX_LANGUAGE_STANDARD = gnu++14 -//CLANG_CXX_LIBRARY = libc++ - -//////////////////////////////////////////////////////////////////////////////// -// -// iOS-specific settings -// -IPHONEOS_DEPLOYMENT_TARGET = 9.3 - -SDKROOT[arch=arm64] = iphoneos -SDKROOT[arch=armv7] = iphoneos -SDKROOT[arch=armv7s] = iphoneos - -VALID_ARCHS[sdk=iphoneos*] = arm64 diff --git a/client/scripts/ss_ios.xcconfig b/client/scripts/ss_ios.xcconfig deleted file mode 100644 index 163b20cb..00000000 --- a/client/scripts/ss_ios.xcconfig +++ /dev/null @@ -1,20 +0,0 @@ -SUPPORTED_PLATFORMS = iphoneos -TARGETED_DEVICE_FAMILY = 1,2 - -HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/ShadowSocks -//HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT)/ShadowSocks $(SRCROOT)/ShadowSocks/libcares/include $(SRCROOT)/ShadowSocks/libev/arm64/include $(SRCROOT)/ShadowSocks/libsodium/include $(SRCROOT)/ShadowSocks/mbedtls/include $(SRCROOT)/ShadowSocks/pcre/arm64/include $(SRCROOT)/ShadowSocks/shadowsocks-libev/include - -//CLANG_CXX_LANGUAGE_STANDARD = gnu++14 -//CLANG_CXX_LIBRARY = libc++ - -//////////////////////////////////////////////////////////////////////////////// -// -// iOS-specific settings -// -IPHONEOS_DEPLOYMENT_TARGET = 9.3 - -SDKROOT[arch=arm64] = iphoneos -SDKROOT[arch=armv7] = iphoneos -SDKROOT[arch=armv7s] = iphoneos - -VALID_ARCHS[sdk=iphoneos*] = arm64 diff --git a/client/scripts/ss_patch.diff b/client/scripts/ss_patch.diff deleted file mode 100644 index de8135e4..00000000 --- a/client/scripts/ss_patch.diff +++ /dev/null @@ -1,87 +0,0 @@ -diff --git a/ShadowPath/Privoxy/pcre/pcreposix.c b/ShadowPath/Privoxy/pcre/pcreposix.c ---- a/ShadowPath/Privoxy/pcre/pcreposix.c -+++ b/ShadowPath/Privoxy/pcre/pcreposix.c -@@ -146,13 +146,13 @@ message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))? - length = strlen(message) + 1; - - addmessage = " at offset "; --addlength = (preg != NULL && (int)preg->re_erroffset != -1)? -+addlength = (preg != NULL && (int)preg->re_nsub != -1)? - strlen(addmessage) + 6 : 0; - - if (errbuf_size > 0) - { - if (addlength > 0 && errbuf_size >= length + addlength) -- sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset); -+ sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_nsub); - else - { - strncpy(errbuf, message, errbuf_size - 1); -@@ -173,7 +173,7 @@ return length + addlength; - void - pcre_regfree(regex_t *preg) - { --(pcre_free)(preg->re_pcre); -+(pcre_free)(preg->re_g); - } - - -@@ -203,12 +203,12 @@ int options = 0; - if ((cflags & REG_ICASE) != 0) options |= PCRE_CASELESS; - if ((cflags & REG_NEWLINE) != 0) options |= PCRE_MULTILINE; - --preg->re_pcre = pcre_compile(pattern, options, &errorptr, &erroffset, NULL); --preg->re_erroffset = erroffset; -+preg->re_g = pcre_compile(pattern, options, &errorptr, &erroffset, NULL); -+preg->re_nsub = erroffset; - --if (preg->re_pcre == NULL) return pcre_posix_error_code(errorptr); -+if (preg->re_g == NULL) return pcre_posix_error_code(errorptr); - --preg->re_nsub = pcre_info(preg->re_pcre, NULL, NULL); -+preg->re_nsub = pcre_info(preg->re_g, NULL, NULL); - return 0; - } - -@@ -235,7 +235,7 @@ int *ovector = NULL; - if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL; - if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL; - --preg->re_erroffset = (size_t)(-1); /* Only has meaning after compile */ -+preg->re_nsub = (size_t)(-1); /* Only has meaning after compile */ - - if (nmatch > 0) - { -@@ -243,7 +243,7 @@ if (nmatch > 0) - if (ovector == NULL) return REG_ESPACE; - } - --rc = pcre_exec(preg->re_pcre, NULL, string, (int)strlen(string), 0, options, -+rc = pcre_exec(preg->re_g, NULL, string, (int)strlen(string), 0, options, - ovector, nmatch * 3); - - if (rc == 0) rc = nmatch; /* All captured slots were filled in */ -diff --git a/ShadowPath/shadowsocks-libev/src/http.h b/ShadowPath/shadowsocks-libev/src/http.h -index 914815a..e312dd3 100644 ---- a/ShadowPath/shadowsocks-libev/src/http.h -+++ b/ShadowPath/shadowsocks-libev/src/http.h -@@ -29,6 +29,6 @@ - #include - #include "protocol.h" - --const protocol_t *const http_protocol; -+extern const protocol_t *const http_protocol; - - #endif -diff --git a/ShadowPath/shadowsocks-libev/src/tls.h b/ShadowPath/shadowsocks-libev/src/tls.h -index 3998913..ddbee11 100644 ---- a/ShadowPath/shadowsocks-libev/src/tls.h -+++ b/ShadowPath/shadowsocks-libev/src/tls.h -@@ -28,6 +28,6 @@ - - #include "protocol.h" - --const protocol_t *const tls_protocol; -+extern const protocol_t *const tls_protocol; - - #endif diff --git a/client/scripts/ss_project_patcher.rb b/client/scripts/ss_project_patcher.rb deleted file mode 100644 index a0582b21..00000000 --- a/client/scripts/ss_project_patcher.rb +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/ruby - -require 'xcodeproj' - -class SSPatcher - attr :project - attr :target_main - - def run(file) - open_project file - open_target_main - - patch_main_target - - @project.save - end - - def open_project(file) - @project = Xcodeproj::Project.open(file) - die 'Failed to open the project file: ' + file if @project.nil? - end - - def open_target_main - @target_main = @project.native_targets - .select { |target| target.name == 'ShadowSocks' } - .first - return @target_main if not @target_main.nil? - - die 'Unable to open ShadowSocks target' - end - - def patch_main_target - @target_main.resources_build_phase.files.each do |f| - puts f.display_name - if f.display_name === "LICENSE" - f.remove_from_project - end - end - end - - def die(msg) - print $msg - exit 1 - end -end - -if ARGV.length < 1 - puts "Usage: - diff --git a/service/CMakeLists.txt b/service/CMakeLists.txt index 567e9d49..cfb3beb2 100644 --- a/service/CMakeLists.txt +++ b/service/CMakeLists.txt @@ -7,10 +7,6 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) if(NOT IOS AND NOT ANDROID) - #include(common.cmake) -#if (qtservice-uselib) -# add_subdirectory(buildlib) -#endif() add_subdirectory(server) endif() diff --git a/service/buildlib/buildlib.pro b/service/buildlib/buildlib.pro deleted file mode 100644 index 1e51cc1d..00000000 --- a/service/buildlib/buildlib.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE=lib -CONFIG += qt dll qtservice-buildlib -mac:CONFIG += absolute_library_soname -win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all -include(../src/qtservice.pri) -TARGET = $$QTSERVICE_LIBNAME -DESTDIR = $$QTSERVICE_LIBDIR -win32 { - DLLDESTDIR = $$[QT_INSTALL_BINS] - QMAKE_DISTCLEAN += $$[QT_INSTALL_BINS]\\$${QTSERVICE_LIBNAME}.dll -} -target.path = $$DESTDIR -INSTALLS += target diff --git a/service/common.pri b/service/common.pri deleted file mode 100644 index d8487537..00000000 --- a/service/common.pri +++ /dev/null @@ -1,10 +0,0 @@ -#exists(config.pri):infile(config.pri, SOLUTIONS_LIBRARY, yes): CONFIG += qtservice-uselib -TEMPLATE += fakelib -QTSERVICE_LIBNAME = QtSolutions_Service-head -CONFIG(debug, debug|release) { - mac:QTSERVICE_LIBNAME = $$member(QTSERVICE_LIBNAME, 0)_debug - else:win32:QTSERVICE_LIBNAME = $$member(QTSERVICE_LIBNAME, 0)d -} -TEMPLATE -= fakelib -QTSERVICE_LIBDIR = $$PWD/lib -unix:qtservice-uselib:!qtservice-buildlib:QMAKE_RPATHDIR += $$QTSERVICE_LIBDIR diff --git a/service/server/CMakeLists.txt b/service/server/CMakeLists.txt index 2b3ff800..adfff92b 100644 --- a/service/server/CMakeLists.txt +++ b/service/server/CMakeLists.txt @@ -9,6 +9,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 REQUIRED COMPONENTS Core Network RemoteObjects Core5Compat Widgets) qt_standard_project_setup() +configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) + set(HEADERS ${CMAKE_CURRENT_LIST_DIR}/../../client/utilities.h ${CMAKE_CURRENT_LIST_DIR}/../../ipc/ipc.h @@ -18,6 +20,7 @@ set(HEADERS ${CMAKE_CURRENT_LIST_DIR}/logger.h ${CMAKE_CURRENT_LIST_DIR}/router.h ${CMAKE_CURRENT_LIST_DIR}/systemservice.h + ${CMAKE_CURRENT_BINARY_DIR}/version.h ) set(SOURCES @@ -91,11 +94,16 @@ include_directories( add_executable(${PROJECT} ${SOURCES} ${HEADERS}) target_link_libraries(${PROJECT} PRIVATE Qt6::Core Qt6::Network Qt6::RemoteObjects Qt6::Core5Compat Qt6::Widgets ${LIBS}) -qt_add_repc_sources(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}/../../ipc/ipc_interface.rep) -if(NOT IOS) - qt_add_repc_sources(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}/../../ipc/ipc_process_interface.rep) +if(APPLE) + set_target_properties(${PROJECT} PROPERTIES + INSTALL_RPATH "@executable_path/../Frameworks" + BUILD_WITH_INSTALL_RPATH TRUE + ) endif() +qt_add_repc_sources(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}/../../ipc/ipc_interface.rep) +qt_add_repc_sources(${PROJECT} ${CMAKE_CURRENT_LIST_DIR}/../../ipc/ipc_process_interface.rep) + # copy deploy artifacts required to run the application to the debug build folder if(WIN32) if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") @@ -109,12 +117,10 @@ elseif(APPLE AND NOT IOS) set(DEPLOY_ARTIFACT_PATH "macos") endif() -if(NOT IOS AND NOT ANDROID) - add_custom_command( - TARGET ${PROJECT} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E $,copy_directory,true> - ${CMAKE_SOURCE_DIR}/deploy/data/${DEPLOY_ARTIFACT_PATH} - $ - COMMAND_EXPAND_LISTS - ) -endif() +add_custom_command( + TARGET ${PROJECT} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E $,copy_directory,true> + ${CMAKE_SOURCE_DIR}/deploy/data/${DEPLOY_ARTIFACT_PATH} + $ + COMMAND_EXPAND_LISTS +) diff --git a/service/server/logger.cpp b/service/server/logger.cpp index 8b44e0c6..f9d2ab4c 100644 --- a/service/server/logger.cpp +++ b/service/server/logger.cpp @@ -5,7 +5,7 @@ #include -#include "defines.h" +#include "version.h" #include "utilities.h" QFile Logger::m_file; diff --git a/service/server/main.cpp b/service/server/main.cpp index fe566652..8834b088 100644 --- a/service/server/main.cpp +++ b/service/server/main.cpp @@ -1,6 +1,6 @@ #include -#include "defines.h" +#include "version.h" #include "localserver.h" #include "logger.h" #include "systemservice.h" diff --git a/service/server/server.pro b/service/server/server.pro deleted file mode 100644 index ca7d85cb..00000000 --- a/service/server/server.pro +++ /dev/null @@ -1,71 +0,0 @@ -TARGET = AmneziaVPN-service -TEMPLATE = app -CONFIG += console qt no_batch -QT += core network remoteobjects -equals(QT_MAJOR_VERSION, 6): QT += core5compat - -HEADERS = \ - ../../client/utilities.h \ - ../../ipc/ipc.h \ - ../../ipc/ipcserver.h \ - ../../ipc/ipcserverprocess.h \ - localserver.h \ - logger.h \ - router.h \ - systemservice.h - -SOURCES = \ - ../../client/utilities.cpp \ - ../../ipc/ipcserver.cpp \ - ../../ipc/ipcserverprocess.cpp \ - localserver.cpp \ - logger.cpp \ - main.cpp \ - router.cpp \ - systemservice.cpp - -win32 { -HEADERS += \ - tapcontroller_win.h \ - router_win.h - -SOURCES += \ - tapcontroller_win.cpp \ - router_win.cpp - -LIBS += \ - -luser32 \ - -lrasapi32 \ - -lshlwapi \ - -liphlpapi \ - -lws2_32 \ - -liphlpapi \ - -lgdi32 \ - -lAdvapi32 \ - -lKernel32 -} - -macx { -HEADERS += \ - router_mac.h \ - helper_route_mac.h - -SOURCES += \ - router_mac.cpp \ - helper_route_mac.c -} - -linux { -HEADERS += \ - router_linux.h - -SOURCES += \ - router_linux.cpp -} - -include(../src/qtservice.pri) - -INCLUDEPATH += "$$PWD/../../client" - -REPC_SOURCE += ../../ipc/ipc_interface.rep -!ios: REPC_SOURCE += ../../ipc/ipc_process_interface.rep diff --git a/service/server/systemservice.cpp b/service/server/systemservice.cpp index 8ec36449..8af7dcb8 100644 --- a/service/server/systemservice.cpp +++ b/service/server/systemservice.cpp @@ -1,4 +1,4 @@ -#include "defines.h" +#include "version.h" #include "localserver.h" #include "systemservice.h" diff --git a/service/service.pro b/service/service.pro deleted file mode 100644 index 4c9a0536..00000000 --- a/service/service.pro +++ /dev/null @@ -1,10 +0,0 @@ -!ios:!android { - TEMPLATE=subdirs - CONFIG += ordered - include(common.pri) - qtservice-uselib:SUBDIRS=buildlib - SUBDIRS+=server -} -win32 { - SUBDIRS+=wireguard-service -} diff --git a/service/src/qtservice.pri b/service/src/qtservice.pri deleted file mode 100644 index 09452981..00000000 --- a/service/src/qtservice.pri +++ /dev/null @@ -1,21 +0,0 @@ -include(../common.pri) -INCLUDEPATH += $$PWD -DEPENDPATH += $$PWD -!win32:QT += network -win32:LIBS += -luser32 - -qtservice-uselib:!qtservice-buildlib { - LIBS += -L$$QTSERVICE_LIBDIR -l$$QTSERVICE_LIBNAME -} else { - HEADERS += $$PWD/qtservice.h \ - $$PWD/qtservice_p.h - SOURCES += $$PWD/qtservice.cpp - win32:SOURCES += $$PWD/qtservice_win.cpp - unix:HEADERS += $$PWD/qtunixsocket.h $$PWD/qtunixserversocket.h - unix:SOURCES += $$PWD/qtservice_unix.cpp $$PWD/qtunixsocket.cpp $$PWD/qtunixserversocket.cpp -} - -win32 { - qtservice-buildlib:shared:DEFINES += QT_QTSERVICE_EXPORT - else:qtservice-uselib:DEFINES += QT_QTSERVICE_IMPORT -} diff --git a/service/wireguard-service/wireguard-service.pro b/service/wireguard-service/wireguard-service.pro deleted file mode 100644 index f248bbbf..00000000 --- a/service/wireguard-service/wireguard-service.pro +++ /dev/null @@ -1,23 +0,0 @@ -TARGET = wireguard-service -TEMPLATE = app -CONFIG += console -CONFIG -= app_bundle -CONFIG -= qt -LIBS += \ - -luser32 \ - -lrasapi32 \ - -lshlwapi \ - -liphlpapi \ - -lws2_32 \ - -liphlpapi \ - -lgdi32 \ - -lAdvapi32 \ - -lKernel32 - -HEADERS = \ - wireguardtunnelservice.h - -SOURCES = \ - main.cpp \ - wireguardtunnelservice.cpp - diff --git a/version.h.in b/version.h.in new file mode 100644 index 00000000..1421bd68 --- /dev/null +++ b/version.h.in @@ -0,0 +1,16 @@ +#ifndef VERSION_H +#define VERSION_H + +#ifndef APP_VERSION +#define APP_VERSION "@CMAKE_PROJECT_VERSION@" +#endif + +#ifndef APP_MAJOR_VERSION +#define APP_MAJOR_VERSION "@APP_MAJOR_VERSION@" +#endif + +#define APPLICATION_NAME "AmneziaVPN" +#define SERVICE_NAME "AmneziaVPN-service" +#define ORGANIZATION_NAME "AmneziaVPN.ORG" + +#endif // VERSION_H