Merge branch 'qmake-to-cmake-migration' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support
This commit is contained in:
commit
cb69298385
16 changed files with 443 additions and 234 deletions
14
client/AmneziaVPN.entitlements
Normal file
14
client/AmneziaVPN.entitlements
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.org.amnezia.AmneziaVPN</string>
|
||||
</array>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>$(AppIdentifierPrefix)group.org.amnezia.AmneziaVPN</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -1,10 +1,21 @@
|
|||
cmake_minimum_required(VERSION 3.23.0 FATAL_ERROR)
|
||||
|
||||
set(PROJECT AmneziaVPN)
|
||||
project(${PROJECT})
|
||||
|
||||
project(${PROJECT} VERSION 2.0.10)
|
||||
set(BUILD_ID 2)
|
||||
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()
|
||||
|
||||
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
|
||||
|
|
@ -13,6 +24,11 @@ find_package(Qt6 REQUIRED COMPONENTS
|
|||
)
|
||||
qt_standard_project_setup()
|
||||
|
||||
if(IOS)
|
||||
execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/scripts/openvpn.sh)
|
||||
|
||||
endif()
|
||||
|
||||
# silent builds on CI env
|
||||
set(IS_CI ${CI})
|
||||
if(IS_CI)
|
||||
|
|
@ -95,7 +111,6 @@ set(HEADERS ${HEADERS}
|
|||
${CMAKE_CURRENT_LIST_DIR}/core/scripts_registry.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/server_defs.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/servercontroller.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/platforms/ios/MobileUtils.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/platforms/linux/leakdetector.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/protocols/protocols_defs.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/notificationhandler.h
|
||||
|
|
@ -104,9 +119,15 @@ 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_LIST_DIR}/platforms/ios/QRCodeReaderBase.h
|
||||
)
|
||||
|
||||
if(NOT IOS)
|
||||
set(HEADERS ${HEADERS}
|
||||
${CMAKE_CURRENT_LIST_DIR}/platforms/ios/MobileUtils.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/platforms/ios/QRCodeReaderBase.h
|
||||
)
|
||||
endif()
|
||||
|
||||
set(SOURCES ${SOURCES}
|
||||
${CMAKE_CURRENT_LIST_DIR}/amnezia_application.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/containers/containers_defs.cpp
|
||||
|
|
@ -114,16 +135,21 @@ set(SOURCES ${SOURCES}
|
|||
${CMAKE_CURRENT_LIST_DIR}/core/scripts_registry.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/server_defs.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/servercontroller.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/platforms/ios/MobileUtils.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/platforms/linux/leakdetector.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/protocols/protocols_defs.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/notificationhandler.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/uilogic.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/ui/qautostart.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/protocols/vpnprotocol.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/platforms/ios/QRCodeReaderBase.cpp
|
||||
)
|
||||
|
||||
if(NOT IOS)
|
||||
set(SOURCES ${SOURCES}
|
||||
${CMAKE_CURRENT_LIST_DIR}/platforms/ios/MobileUtils.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/platforms/ios/QRCodeReaderBase.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
file(GLOB COMMON_FILES_H CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/*.h)
|
||||
file(GLOB COMMON_FILES_CPP CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
|
||||
|
||||
|
|
@ -211,9 +237,17 @@ if(APPLE)
|
|||
set(BUILD_VPN_DEVELOPMENT_TEAM X7UJ388FXK CACHE STRING "Amnezia VPN Development Team")
|
||||
endif()
|
||||
|
||||
set(CMAKE_XCODE_GENERATE_SCHEME FALSE)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${BUILD_VPN_DEVELOPMENT_TEAM})
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GROUP_ID_IOS ${BUILD_IOS_GROUP_IDENTIFIER})
|
||||
|
||||
if(IOS)
|
||||
message("ios in mac")
|
||||
#do nothing, IOS is added in below
|
||||
|
||||
|
||||
|
||||
|
||||
else() #mac
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE INTERNAL "" FORCE)
|
||||
|
||||
|
|
@ -242,7 +276,7 @@ if(APPLE)
|
|||
find_library(FW_APPKIT AppKit)
|
||||
find_library(FW_SECURITY Security)
|
||||
|
||||
set(LIBS ${LIBS} FW_COCOA FW_APPLICATIONSERVICES FW_FOUNDATION FW_APPKIT FW_SECURITY FW_CORESERVICES
|
||||
set(LIBS ${LIBS} FW_COCOA FW_APPLICATIONSERVICES FW_FOUNDATION FW_APPKIT FW_SECURITY FW_CORESERVICES FW_OPENVPN
|
||||
LIB_LIBCRYPTO LIB_SSL)
|
||||
|
||||
|
||||
|
|
@ -317,11 +351,6 @@ endif()
|
|||
if(IOS)
|
||||
message("Client iOS build")
|
||||
|
||||
|
||||
# CONFIG += static
|
||||
# CONFIG += file_copies
|
||||
|
||||
|
||||
find_library(FW_AUTHENTICATIONSERVICES AuthenticationServices)
|
||||
find_library(FW_UIKIT UIKit)
|
||||
find_library(FW_FOUNDATION Foundation)
|
||||
|
|
@ -332,8 +361,6 @@ if(IOS)
|
|||
|
||||
add_compile_definitions(MVPN_IOS)
|
||||
|
||||
message("shahzain ${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(HEADERS ${HEADERS}
|
||||
${CMAKE_CURRENT_LIST_DIR}/protocols/ios_vpnprotocol.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/platforms/ios/iosnotificationhandler.h
|
||||
|
|
@ -346,11 +373,6 @@ if(IOS)
|
|||
${CMAKE_CURRENT_LIST_DIR}/platforms/ios/QtAppDelegate-C-Interface.h
|
||||
)
|
||||
|
||||
# i think in cmake it is not necessary? yes in iOS we are using native
|
||||
# SOURCES -=
|
||||
# platforms/ios/QRCodeReaderBase.cpp
|
||||
# platforms/ios/MobileUtils.cpp
|
||||
|
||||
set(SOURCES ${SOURCES}
|
||||
${CMAKE_CURRENT_LIST_DIR}/protocols/ios_vpnprotocol.mm
|
||||
${CMAKE_CURRENT_LIST_DIR}/platforms/ios/iosnotificationhandler.mm
|
||||
|
|
@ -365,13 +387,6 @@ if(IOS)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Q_ENABLE_BITCODE.value = NO
|
||||
# Q_ENABLE_BITCODE.name = ENABLE_BITCODE
|
||||
# QMAKE_MAC_XCODE_SETTINGS += Q_ENABLE_BITCODE
|
||||
endif()
|
||||
|
||||
if(CMAKE_OSX_SYSROOT STREQUAL "iphoneos")
|
||||
|
|
@ -380,53 +395,8 @@ if(CMAKE_OSX_SYSROOT STREQUAL "iphoneos")
|
|||
|
||||
|
||||
|
||||
|
||||
# find_library(LIB_LIBCRYPTO NAMES "libcrypto.a"
|
||||
# PATHS ${PROJECT_SOURCE_DIR}/3rd/OpenSSL/lib/ios/iphone/ NO_DEFAULT_PATH)
|
||||
|
||||
#find_library(LIB_SSL NAMES "libssl.a"
|
||||
# PATHS ${PROJECT_SOURCE_DIR}/3rd/OpenSSL/lib/ios/iphone/ NO_DEFAULT_PATH)
|
||||
|
||||
|
||||
|
||||
#set(LIBS ${LIBS} LIB_LIBCRYPTO LIB_SSL)
|
||||
|
||||
# target_link_libraries(${PROJECT} PRIVATE ${LIB_LIBCRYPTO})
|
||||
|
||||
# target_link_libraries(${PROJECT} PRIVATE ${LIB_SSL})
|
||||
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
#if(IPHONEOS)
|
||||
# message("Building for iPhone OS")
|
||||
# QMAKE_TARGET_BUNDLE_PREFIX = org.amnezia
|
||||
# QMAKE_BUNDLE = AmneziaVPN
|
||||
# QMAKE_IOS_DEPLOYMENT_TARGET = 12.0
|
||||
# QMAKE_APPLE_TARGETED_DEVICE_FAMILY = 1
|
||||
# QMAKE_DEVELOPMENT_TEAM = X7UJ388FXK
|
||||
# QMAKE_PROVISIONING_PROFILE = f2fefb59-14aa-4aa9-ac14-1d5531b06dcc not added yet
|
||||
# QMAKE_XCODE_CODE_SIGN_IDENTITY = "Apple Distribution"
|
||||
# QMAKE_INFO_PLIST = $$PWD/ios/app/Info.plist
|
||||
|
||||
# XCODEBUILD_FLAGS += -allowProvisioningUpdates not added yet
|
||||
|
||||
# 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"
|
||||
# }
|
||||
#endif()
|
||||
|
||||
|
||||
qt_add_executable(${PROJECT} ${SOURCES} ${HEADERS} ${RESOURCES} ${QRC})
|
||||
qt_add_translations(${PROJECT} TS_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_ru.ts)
|
||||
|
|
@ -438,8 +408,14 @@ if(IOS)
|
|||
enable_language(OBJCXX)
|
||||
enable_language(Swift)
|
||||
include(src/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)
|
||||
|
||||
|
||||
set_target_properties(${PROJECT} PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.amnezia.${PROJECT}"
|
||||
|
|
@ -506,10 +482,32 @@ target_include_directories(${PROJECT} PRIVATE ${CMAKE_SOURCE_DIR})
|
|||
platforms/ios/iosvpnprotocol.swift
|
||||
platforms/ios/ioslogger.swift
|
||||
)
|
||||
|
||||
target_sources(${PROJECT} PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/ios/app/launch.png
|
||||
${CMAKE_SOURCE_DIR}/ios/app/AmneziaVPNLaunchScreen.storyboard)
|
||||
set_source_files_properties(
|
||||
${CMAKE_SOURCE_DIR}/ios/app/launch.png
|
||||
${CMAKE_SOURCE_DIR}/ios/app/AmneziaVPNLaunchScreen.storyboard
|
||||
PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
||||
|
||||
target_sources(${PROJECT} PRIVATE ${CMAKE_SOURCE_DIR}/ios/Media.xcassets)
|
||||
set_source_files_properties(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 "networkextension" PROPERTY XCODE_EMBED_FRAMEWORKS
|
||||
"${CMAKE_CURRENT_LIST_DIR}/3rd/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework"
|
||||
)
|
||||
set_target_properties(networkextension PROPERTIES XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY ON)
|
||||
set_target_properties(networkextension PROPERTIES XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION)
|
||||
|
||||
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
|
|
|
|||
26
client/deploy/data/macos/AmneziaVPN.plist
Normal file
26
client/deploy/data/macos/AmneziaVPN.plist
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>AmneziaVPN-service</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/Applications/AmneziaVPN.app/Contents/MacOS/AmneziaVPN-service</string>
|
||||
</array>
|
||||
<key>KeepAlive</key>
|
||||
<true/>
|
||||
<key>Sockets</key>
|
||||
<dict>
|
||||
<key>Listeners</key>
|
||||
<dict>
|
||||
<key>SockServiceName</key>
|
||||
<string>5959</string>
|
||||
<key>SockType</key>
|
||||
<string>stream</string>
|
||||
<key>SockFamily</key>
|
||||
<string>IPv4</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
client/deploy/data/macos/ck-client
Executable file
BIN
client/deploy/data/macos/ck-client
Executable file
Binary file not shown.
BIN
client/deploy/data/macos/openvpn
Executable file
BIN
client/deploy/data/macos/openvpn
Executable file
Binary file not shown.
35
client/deploy/data/macos/post_install.sh
Executable file
35
client/deploy/data/macos/post_install.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
|
||||
APP_NAME=AmneziaVPN
|
||||
PLIST_NAME=$APP_NAME.plist
|
||||
LAUNCH_DAEMONS_PLIST_NAME=/Library/LaunchDaemons/$PLIST_NAME
|
||||
LOG_FOLDER=/var/log/$APP_NAME
|
||||
LOG_FILE="$LOG_FOLDER/post-install.log"
|
||||
APP_PATH=/Applications/$APP_NAME.app
|
||||
|
||||
if launchctl list "$APP_NAME-service" &> /dev/null; then
|
||||
launchctl unload $LAUNCH_DAEMONS_PLIST_NAME
|
||||
rm -f $LAUNCH_DAEMONS_PLIST_NAME
|
||||
fi
|
||||
|
||||
tar xzf $APP_PATH/$APP_NAME.tar.gz -C $APP_PATH
|
||||
rm -f $APP_PATH/$APP_NAME.tar.gz
|
||||
sudo chmod -R a-w $APP_PATH/
|
||||
sudo chown -R root $APP_PATH/
|
||||
sudo chgrp -R wheel $APP_PATH/
|
||||
|
||||
rm -rf $LOG_FOLDER
|
||||
mkdir -p $LOG_FOLDER
|
||||
|
||||
echo "`date` Script started" > $LOG_FILE
|
||||
|
||||
killall -9 $APP_NAME-service 2>> $LOG_FILE
|
||||
|
||||
mv -f $APP_PATH/$PLIST_NAME $LAUNCH_DAEMONS_PLIST_NAME 2>> $LOG_FILE
|
||||
chown root:wheel $LAUNCH_DAEMONS_PLIST_NAME
|
||||
launchctl load $LAUNCH_DAEMONS_PLIST_NAME
|
||||
|
||||
echo "`date` Service status: $?" >> $LOG_FILE
|
||||
echo "`date` Script finished" >> $LOG_FILE
|
||||
|
||||
#rm -- "$0"
|
||||
14
client/deploy/data/macos/post_uninstall.sh
Executable file
14
client/deploy/data/macos/post_uninstall.sh
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
APP_NAME=AmneziaVPN
|
||||
PLIST_NAME=$APP_NAME.plist
|
||||
LAUNCH_DAEMONS_PLIST_NAME=/Library/LaunchDaemons/$PLIST_NAME
|
||||
|
||||
if launchctl list "$APP_NAME-service" &> /dev/null; then
|
||||
launchctl unload $LAUNCH_DAEMONS_PLIST_NAME
|
||||
rm -f $LAUNCH_DAEMONS_PLIST_NAME
|
||||
fi
|
||||
|
||||
rm -rf "$HOME/Library/Application Support/$APP_NAME"
|
||||
rm -rf /var/log/$APP_NAME
|
||||
rm -rf /Applications/$APP_NAME.app/Contents
|
||||
BIN
client/deploy/data/macos/ss-local
Executable file
BIN
client/deploy/data/macos/ss-local
Executable file
Binary file not shown.
BIN
client/deploy/data/macos/ss-tunnel
Executable file
BIN
client/deploy/data/macos/ss-tunnel
Executable file
Binary file not shown.
74
client/deploy/data/macos/update-resolv-conf.sh
Executable file
74
client/deploy/data/macos/update-resolv-conf.sh
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Mac name-resolution updater based on @cl's script here:
|
||||
# https://blog.netnerds.net/2011/10/openvpn-update-client-dns-on-mac-os-x-using-from-the-command-line/
|
||||
# Openvpn envar parsing taken from the script in debian's openvpn package.
|
||||
# Smushed together and improved by @andrewgdotcom.
|
||||
|
||||
# Parses DHCP options from openvpn to update resolv.conf
|
||||
# To use set as 'up' and 'down' script in your openvpn *.conf:
|
||||
# up /etc/openvpn/update-resolv-conf
|
||||
# down /etc/openvpn/update-resolv-conf
|
||||
|
||||
[ "$script_type" ] || exit 0
|
||||
[ "$dev" ] || exit 0
|
||||
|
||||
PATH=$PATH:/usr/sbin/
|
||||
NMSRVRS=()
|
||||
SRCHS=()
|
||||
|
||||
# Get adapter list
|
||||
IFS=$'\n' read -d '' -ra adapters < <(networksetup -listallnetworkservices |grep -v denotes) || true
|
||||
|
||||
split_into_parts()
|
||||
{
|
||||
part1="$1"
|
||||
part2="$2"
|
||||
part3="$3"
|
||||
}
|
||||
|
||||
update_all_dns()
|
||||
{
|
||||
for adapter in "${adapters[@]}"
|
||||
do
|
||||
echo updating dns for $adapter
|
||||
# set dns server to the vpn dns server
|
||||
if [[ "${SRCHS[@]}" ]]; then
|
||||
networksetup -setsearchdomains "$adapter" "${SRCHS[@]}"
|
||||
fi
|
||||
if [[ "${NMSRVRS[@]}" ]]; then
|
||||
networksetup -setdnsservers "$adapter" "${NMSRVRS[@]}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
clear_all_dns()
|
||||
{
|
||||
for adapter in "${adapters[@]}"
|
||||
do
|
||||
echo updating dns for $adapter
|
||||
networksetup -setdnsservers "$adapter" empty
|
||||
networksetup -setsearchdomains "$adapter" empty
|
||||
done
|
||||
}
|
||||
|
||||
case "$script_type" in
|
||||
up)
|
||||
for optionvarname in ${!foreign_option_*} ; do
|
||||
option="${!optionvarname}"
|
||||
echo "$option"
|
||||
split_into_parts $option
|
||||
if [ "$part1" = "dhcp-option" ] ; then
|
||||
if [ "$part2" = "DNS" ] ; then
|
||||
NMSRVRS=(${NMSRVRS[@]} $part3)
|
||||
elif [ "$part2" = "DOMAIN" ] ; then
|
||||
SRCHS=(${SRCHS[@]} $part3)
|
||||
fi
|
||||
fi
|
||||
done
|
||||
update_all_dns
|
||||
;;
|
||||
down)
|
||||
clear_all_dns
|
||||
;;
|
||||
esac
|
||||
|
|
@ -46,8 +46,36 @@
|
|||
<key>UIUserInterfaceStyle</key>
|
||||
<string>Light</string>
|
||||
<key>com.wireguard.ios.app_group_id</key>
|
||||
<string>group.org.amnezia.amneziavpn</string>
|
||||
<string>group.org.amnezia.AmneziaVPN</string>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<true/>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Amnezia VPN needs access to the camera for reading QR-codes.</string>
|
||||
<key>UTImportedTypeDeclarations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UTTypeConformsTo</key>
|
||||
<array>
|
||||
<string>public.data</string>
|
||||
</array>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>Amnezia VPN config</string>
|
||||
<key>UTTypeIconFiles</key>
|
||||
<array/>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>org.amnezia.AmneziaVPN.amnezia-config</string>
|
||||
<key>UTTypeTagSpecification</key>
|
||||
<dict>
|
||||
<key>public.filename-extension</key>
|
||||
<array>
|
||||
<string>vpn</string>
|
||||
</array>
|
||||
<key>public.mime-type</key>
|
||||
<array>
|
||||
<string>text/plain</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -11,7 +11,7 @@ set_target_properties(networkextension PROPERTIES
|
|||
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 "MozillaVPNNetworkExtension"
|
||||
MACOSX_BUNDLE_INFO_STRING "AmneziaVPNNetworkExtension"
|
||||
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}.network-extension"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
* 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 "3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard-go-version.h"
|
||||
#include "3rd/wireguard-apple/Sources/WireGuardKitC/WireGuardKitC.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@ import Foundation
|
|||
import NetworkExtension
|
||||
import os
|
||||
import Darwin
|
||||
//import OpenVPNAdapter
|
||||
import OpenVPNAdapter
|
||||
//import Tun2socks
|
||||
|
||||
enum TunnelProtoType: String {
|
||||
case wireguard, openvpn, shadowsocks, none
|
||||
}
|
||||
|
|
@ -48,11 +47,11 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
}
|
||||
}()
|
||||
|
||||
// private lazy var ovpnAdapter: OpenVPNAdapter = {
|
||||
// let adapter = OpenVPNAdapter()
|
||||
// adapter.delegate = self
|
||||
// return adapter
|
||||
// }()
|
||||
private lazy var ovpnAdapter: OpenVPNAdapter = {
|
||||
let adapter = OpenVPNAdapter()
|
||||
adapter.delegate = self
|
||||
return adapter
|
||||
}()
|
||||
|
||||
private var shadowSocksConfig: Data? = nil
|
||||
private var openVPNConfig: Data? = nil
|
||||
|
|
@ -70,7 +69,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
// private var session: NWUDPSession? = nil
|
||||
// private var observer: AnyObject?
|
||||
|
||||
// let vpnReachability = OpenVPNReachability()
|
||||
let vpnReachability = OpenVPNReachability()
|
||||
|
||||
var startHandler: ((Error?) -> Void)?
|
||||
var stopHandler: (() -> Void)?
|
||||
|
|
@ -97,8 +96,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
errorNotifier: errorNotifier,
|
||||
completionHandler: completionHandler)
|
||||
case .openvpn:
|
||||
break
|
||||
//startOpenVPN(completionHandler: completionHandler)
|
||||
startOpenVPN(completionHandler: completionHandler)
|
||||
case .shadowsocks:
|
||||
break
|
||||
// startShadowSocks(completionHandler: completionHandler)
|
||||
|
|
@ -112,8 +110,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
case .wireguard:
|
||||
stopWireguard(with: reason, completionHandler: completionHandler)
|
||||
case .openvpn:
|
||||
break
|
||||
// stopOpenVPN(with: reason, completionHandler: completionHandler)
|
||||
stopOpenVPN(with: reason, completionHandler: completionHandler)
|
||||
case .shadowsocks:
|
||||
break
|
||||
// stopShadowSocks(with: reason, completionHandler: completionHandler)
|
||||
|
|
@ -127,7 +124,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
case .wireguard:
|
||||
handleWireguardAppMessage(messageData, completionHandler: completionHandler)
|
||||
case .openvpn:
|
||||
handleWireguardAppMessage(messageData, completionHandler: completionHandler)
|
||||
handleOpenVPNAppMessage(messageData, completionHandler: completionHandler)
|
||||
case .shadowsocks:
|
||||
break
|
||||
// handleShadowSocksAppMessage(messageData, completionHandler: completionHandler)
|
||||
|
|
@ -189,17 +186,17 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
}
|
||||
}
|
||||
|
||||
// private func startOpenVPN(completionHandler: @escaping (Error?) -> Void) {
|
||||
// guard let protocolConfiguration = self.protocolConfiguration as? NETunnelProviderProtocol,
|
||||
// let providerConfiguration = protocolConfiguration.providerConfiguration,
|
||||
// let ovpnConfiguration: Data = providerConfiguration[Constants.ovpnConfigKey] as? Data else {
|
||||
// // TODO: handle errors properly
|
||||
// wg_log(.error, message: "Can't start startOpenVPN()")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// setupAndlaunchOpenVPN(withConfig: ovpnConfiguration, completionHandler: completionHandler)
|
||||
// }
|
||||
private func startOpenVPN(completionHandler: @escaping (Error?) -> Void) {
|
||||
guard let protocolConfiguration = self.protocolConfiguration as? NETunnelProviderProtocol,
|
||||
let providerConfiguration = protocolConfiguration.providerConfiguration,
|
||||
let ovpnConfiguration: Data = providerConfiguration[Constants.ovpnConfigKey] as? Data else {
|
||||
// TODO: handle errors properly
|
||||
wg_log(.error, message: "Can't start startOpenVPN()")
|
||||
return
|
||||
}
|
||||
|
||||
setupAndlaunchOpenVPN(withConfig: ovpnConfiguration, completionHandler: completionHandler)
|
||||
}
|
||||
/*
|
||||
private func startShadowSocks(completionHandler: @escaping (Error?) -> Void) {
|
||||
guard let protocolConfiguration = self.protocolConfiguration as? NETunnelProviderProtocol,
|
||||
|
|
@ -238,13 +235,13 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
}
|
||||
}
|
||||
|
||||
// private func stopOpenVPN(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
|
||||
// stopHandler = completionHandler
|
||||
// if vpnReachability.isTracking {
|
||||
// vpnReachability.stopTracking()
|
||||
// }
|
||||
// ovpnAdapter.disconnect()
|
||||
// }
|
||||
private func stopOpenVPN(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
|
||||
stopHandler = completionHandler
|
||||
if vpnReachability.isTracking {
|
||||
vpnReachability.stopTracking()
|
||||
}
|
||||
ovpnAdapter.disconnect()
|
||||
}
|
||||
/*
|
||||
private func stopShadowSocks(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
|
||||
stopOpenVPN(with: reason) { [weak self] in
|
||||
|
|
@ -299,6 +296,21 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
}
|
||||
}
|
||||
|
||||
private func handleOpenVPNAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)? = nil) {
|
||||
guard let completionHandler = completionHandler else { return }
|
||||
if messageData.count == 1 && messageData[0] == 0 {
|
||||
let bytesin = ovpnAdapter.transportStatistics.bytesIn
|
||||
let strBytesin = "rx_bytes=" + String(bytesin);
|
||||
|
||||
let bytesout = ovpnAdapter.transportStatistics.bytesOut
|
||||
let strBytesout = "tx_bytes=" + String(bytesout);
|
||||
|
||||
let strData = strBytesin + "\n" + strBytesout;
|
||||
let data = Data(strData.utf8)
|
||||
completionHandler(data)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private func handleShadowSocksAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)? = nil) {
|
||||
guard let completionHandler = completionHandler else { return }
|
||||
|
|
@ -402,9 +414,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: -- Leaf provider methods
|
||||
|
||||
private func prepareConfig(onInterface iface: String, fromSSConfig ssConfig: Data, andOvpnConfig ovpnConfig: Data) -> UnsafePointer<CChar>? {
|
||||
guard let ssConfig = try? JSONSerialization.jsonObject(with: ssConfig, options: []) as? [String: Any] else {
|
||||
self.ssCompletion?(0, NSError(domain: Bundle.main.bundleIdentifier ?? "unknown",
|
||||
|
|
@ -412,7 +422,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
userInfo: [NSLocalizedDescriptionKey: "Cannot parse json for ss in tunnel"]))
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let remoteHost = ssConfig[Constants.ssRemoteHost] as? String,
|
||||
let remotePort = ssConfig[Constants.ssRemotePort] as? Int,
|
||||
let method = ssConfig[Constants.ssCipherKey] as? String,
|
||||
|
|
@ -422,19 +431,16 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
userInfo: [NSLocalizedDescriptionKey: "Cannot asign profile params for ss in tunnel"]))
|
||||
return nil
|
||||
}
|
||||
|
||||
var insettings: [String: Any] = .init()
|
||||
insettings["name"] = iface
|
||||
insettings["address"] = "127.0.0.2"
|
||||
insettings["netmask"] = "255.255.255.0"
|
||||
insettings["gateway"] = "127.0.0.1"
|
||||
insettings["mtu"] = 1600
|
||||
|
||||
var inbounds: [String: Any] = .init()
|
||||
inbounds["protocol"] = "tun"
|
||||
inbounds["settings"] = insettings
|
||||
inbounds["tag"] = "tun_in"
|
||||
|
||||
var outbounds: [String: Any] = .init()
|
||||
var outsettings: [String: Any] = .init()
|
||||
outsettings["address"] = remoteHost
|
||||
|
|
@ -444,18 +450,13 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
outbounds["protocol"] = "shadowsocks"
|
||||
outbounds["settings"] = outsettings
|
||||
outbounds["tag"] = "shadowsocks_out"
|
||||
|
||||
var params: [String: Any] = .init()
|
||||
params["inbounds"] = [inbounds]
|
||||
params["outbounds"] = [outbounds]
|
||||
|
||||
wg_log(.error, message: "Config dictionary: \(params)")
|
||||
|
||||
guard let jsonData = try? JSONSerialization.data(withJSONObject: params, options: .prettyPrinted),
|
||||
let jsonString = String(data: jsonData, encoding: .utf8) else { return nil }
|
||||
|
||||
wg_log(.error, message: "JSON String: \(jsonString)")
|
||||
|
||||
var path = ""
|
||||
if let documentDirectory = FileManager.default.urls(for: .documentDirectory,
|
||||
in: .userDomainMask).first {
|
||||
|
|
@ -525,7 +526,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
private func stopLeafRedirector(completion: @escaping () -> Void) {
|
||||
leafProvider?.stopTunnel { error in
|
||||
// TODO: handle errors
|
||||
|
|
@ -558,7 +558,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
wg_log(.error, message: "Error starting ShadowSocks: \(String(describing: errorCode))")
|
||||
return
|
||||
}
|
||||
|
||||
// self.setupAndHandleOpenVPNOverSSConnection(withConfig: ovpnConfig)
|
||||
self.startAndHandleTunnelOverSS(completionHandler: completion)
|
||||
}
|
||||
|
|
@ -688,47 +687,47 @@ 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",
|
||||
//// ]
|
||||
// }
|
||||
// let evaluation: OpenVPNConfigurationEvaluation
|
||||
// do {
|
||||
// evaluation = try ovpnAdapter.apply(configuration: configuration)
|
||||
// } catch {
|
||||
// completionHandler(error)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if !evaluation.autologin {
|
||||
// wg_log(.info, message: "Implement login with user credentials")
|
||||
// }
|
||||
//
|
||||
// vpnReachability.startTracking { [weak self] status in
|
||||
// guard status == .reachableViaWiFi else { return }
|
||||
// self?.ovpnAdapter.reconnect(afterTimeInterval: 5)
|
||||
// }
|
||||
//
|
||||
// startHandler = completionHandler
|
||||
// ovpnAdapter.connect(using: packetFlow)
|
||||
//
|
||||
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",
|
||||
// ]
|
||||
}
|
||||
let evaluation: OpenVPNConfigurationEvaluation
|
||||
do {
|
||||
evaluation = try ovpnAdapter.apply(configuration: configuration)
|
||||
} catch {
|
||||
completionHandler(error)
|
||||
return
|
||||
}
|
||||
|
||||
if !evaluation.autologin {
|
||||
wg_log(.info, message: "Implement login with user credentials")
|
||||
}
|
||||
|
||||
vpnReachability.startTracking { [weak self] status in
|
||||
guard status == .reachableViaWiFi else { return }
|
||||
self?.ovpnAdapter.reconnect(afterTimeInterval: 5)
|
||||
}
|
||||
|
||||
startHandler = completionHandler
|
||||
ovpnAdapter.connect(using: packetFlow)
|
||||
|
||||
// let ifaces = Interface.allInterfaces()
|
||||
// .filter { $0.family == .ipv4 }
|
||||
// .map { iface in iface.name }
|
||||
//
|
||||
|
||||
// wg_log(.error, message: "Available TUN Interfaces: \(ifaces)")
|
||||
// }
|
||||
}
|
||||
|
||||
// MARK: -- Network observing methods
|
||||
|
||||
|
|
@ -798,87 +797,87 @@ extension WireGuardLogLevel {
|
|||
}
|
||||
}
|
||||
|
||||
//extension NEPacketTunnelFlow: OpenVPNAdapterPacketFlow {}
|
||||
extension NEPacketTunnelFlow: OpenVPNAdapterPacketFlow {}
|
||||
|
||||
/* extension NEPacketTunnelFlow: ShadowSocksAdapterPacketFlow {} */
|
||||
|
||||
//extension PacketTunnelProvider: OpenVPNAdapterDelegate {
|
||||
//
|
||||
// // OpenVPNAdapter calls this delegate method to configure a VPN tunnel.
|
||||
// // `completionHandler` callback requires an object conforming to `OpenVPNAdapterPacketFlow`
|
||||
// // protocol if the tunnel is configured without errors. Otherwise send nil.
|
||||
// // `OpenVPNAdapterPacketFlow` method signatures are similar to `NEPacketTunnelFlow` so
|
||||
// // you can just extend that class to adopt `OpenVPNAdapterPacketFlow` protocol and
|
||||
// // send `self.packetFlow` to `completionHandler` callback.
|
||||
// func openVPNAdapter(
|
||||
// _ openVPNAdapter: OpenVPNAdapter,
|
||||
// configureTunnelWithNetworkSettings networkSettings: NEPacketTunnelNetworkSettings?,
|
||||
// completionHandler: @escaping (Error?) -> Void
|
||||
// ) {
|
||||
// // In order to direct all DNS queries first to the VPN DNS servers before the primary DNS servers
|
||||
// // send empty string to NEDNSSettings.matchDomains
|
||||
// networkSettings?.dnsSettings?.matchDomains = [""]
|
||||
//
|
||||
// // Set the network settings for the current tunneling session.
|
||||
// setTunnelNetworkSettings(networkSettings, completionHandler: completionHandler)
|
||||
// }
|
||||
//
|
||||
// // Process events returned by the OpenVPN library
|
||||
// func openVPNAdapter(
|
||||
// _ openVPNAdapter: OpenVPNAdapter,
|
||||
// handleEvent event:
|
||||
// OpenVPNAdapterEvent, message: String?
|
||||
// ) {
|
||||
// switch event {
|
||||
// case .connected:
|
||||
// if reasserting {
|
||||
// reasserting = false
|
||||
// }
|
||||
//
|
||||
// guard let startHandler = startHandler else { return }
|
||||
//
|
||||
// startHandler(nil)
|
||||
// self.startHandler = nil
|
||||
// case .disconnected:
|
||||
// guard let stopHandler = stopHandler else { return }
|
||||
//
|
||||
// if vpnReachability.isTracking {
|
||||
// vpnReachability.stopTracking()
|
||||
// }
|
||||
//
|
||||
// stopHandler()
|
||||
// self.stopHandler = nil
|
||||
// case .reconnecting:
|
||||
// reasserting = true
|
||||
// default:
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Handle errors thrown by the OpenVPN library
|
||||
// func openVPNAdapter(_ openVPNAdapter: OpenVPNAdapter, handleError error: Error) {
|
||||
// // Handle only fatal errors
|
||||
// guard let fatal = (error as NSError).userInfo[OpenVPNAdapterErrorFatalKey] as? Bool,
|
||||
// fatal == true else { return }
|
||||
//
|
||||
// if vpnReachability.isTracking {
|
||||
// vpnReachability.stopTracking()
|
||||
// }
|
||||
//
|
||||
// if let startHandler = startHandler {
|
||||
// startHandler(error)
|
||||
// self.startHandler = nil
|
||||
// } else {
|
||||
// cancelTunnelWithError(error)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Use this method to process any log message returned by OpenVPN library.
|
||||
// func openVPNAdapter(_ openVPNAdapter: OpenVPNAdapter, handleLogMessage logMessage: String) {
|
||||
// // Handle log messages
|
||||
// wg_log(.info, message: logMessage)
|
||||
// }
|
||||
//}
|
||||
extension PacketTunnelProvider: OpenVPNAdapterDelegate {
|
||||
|
||||
// OpenVPNAdapter calls this delegate method to configure a VPN tunnel.
|
||||
// `completionHandler` callback requires an object conforming to `OpenVPNAdapterPacketFlow`
|
||||
// protocol if the tunnel is configured without errors. Otherwise send nil.
|
||||
// `OpenVPNAdapterPacketFlow` method signatures are similar to `NEPacketTunnelFlow` so
|
||||
// you can just extend that class to adopt `OpenVPNAdapterPacketFlow` protocol and
|
||||
// send `self.packetFlow` to `completionHandler` callback.
|
||||
func openVPNAdapter(
|
||||
_ openVPNAdapter: OpenVPNAdapter,
|
||||
configureTunnelWithNetworkSettings networkSettings: NEPacketTunnelNetworkSettings?,
|
||||
completionHandler: @escaping (Error?) -> Void
|
||||
) {
|
||||
// In order to direct all DNS queries first to the VPN DNS servers before the primary DNS servers
|
||||
// send empty string to NEDNSSettings.matchDomains
|
||||
networkSettings?.dnsSettings?.matchDomains = [""]
|
||||
|
||||
// Set the network settings for the current tunneling session.
|
||||
setTunnelNetworkSettings(networkSettings, completionHandler: completionHandler)
|
||||
}
|
||||
|
||||
// Process events returned by the OpenVPN library
|
||||
func openVPNAdapter(
|
||||
_ openVPNAdapter: OpenVPNAdapter,
|
||||
handleEvent event:
|
||||
OpenVPNAdapterEvent, message: String?
|
||||
) {
|
||||
switch event {
|
||||
case .connected:
|
||||
if reasserting {
|
||||
reasserting = false
|
||||
}
|
||||
|
||||
guard let startHandler = startHandler else { return }
|
||||
|
||||
startHandler(nil)
|
||||
self.startHandler = nil
|
||||
case .disconnected:
|
||||
guard let stopHandler = stopHandler else { return }
|
||||
|
||||
if vpnReachability.isTracking {
|
||||
vpnReachability.stopTracking()
|
||||
}
|
||||
|
||||
stopHandler()
|
||||
self.stopHandler = nil
|
||||
case .reconnecting:
|
||||
reasserting = true
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Handle errors thrown by the OpenVPN library
|
||||
func openVPNAdapter(_ openVPNAdapter: OpenVPNAdapter, handleError error: Error) {
|
||||
// Handle only fatal errors
|
||||
guard let fatal = (error as NSError).userInfo[OpenVPNAdapterErrorFatalKey] as? Bool,
|
||||
fatal == true else { return }
|
||||
|
||||
if vpnReachability.isTracking {
|
||||
vpnReachability.stopTracking()
|
||||
}
|
||||
|
||||
if let startHandler = startHandler {
|
||||
startHandler(error)
|
||||
self.startHandler = nil
|
||||
} else {
|
||||
cancelTunnelWithError(error)
|
||||
}
|
||||
}
|
||||
|
||||
// Use this method to process any log message returned by OpenVPN library.
|
||||
func openVPNAdapter(_ openVPNAdapter: OpenVPNAdapter, handleLogMessage logMessage: String) {
|
||||
// Handle log messages
|
||||
wg_log(.info, message: logMessage)
|
||||
}
|
||||
}
|
||||
/*
|
||||
extension PacketTunnelProvider: Tun2socksTunWriterProtocol {
|
||||
func write(_ p0: Data?, n: UnsafeMutablePointer<Int>?) throws {
|
||||
|
|
|
|||
21
client/scripts/openvpn.sh
Normal file
21
client/scripts/openvpn.sh
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
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
|
||||
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
|
||||
|
||||
|
||||
cd 3rd/OpenVPNAdapter
|
||||
if $XCODEBUILD -scheme OpenVPNAdapter -configuration Release -xcconfig Configuration/amnezia.xcconfig -sdk iphoneos -destination 'generic/platform=iOS' -project OpenVPNAdapter.xcodeproj ; then
|
||||
echo "OpenVPNAdapter built successfully"
|
||||
else
|
||||
echo "OpenVPNAdapter build failed"
|
||||
fi
|
||||
cd ../../
|
||||
|
||||
|
|
@ -4,7 +4,8 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
|
||||
#include "qrcodegen.hpp"
|
||||
//#include "qrcodegen.hpp"
|
||||
#include "3rd/qrcodegen/qrcodegen.hpp"
|
||||
|
||||
#include "ShareConnectionLogic.h"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue