diff --git a/.gitignore b/.gitignore index 1b4e16b2..e2fdf13d 100644 --- a/.gitignore +++ b/.gitignore @@ -125,3 +125,4 @@ captures/ # Android Profiling *.hprof +client/3rd/ShadowSocks/ss_ios.xcconfig diff --git a/README.md b/README.md index 4d5cd364..884e2205 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,11 @@ Error 1 Add a user defined variable to both AmneziaVPN and WireGuardNetworkExtension targets' build settings with key `PATH` and value `${PATH}/path/to/bin/folder/with/go/executable`, e.g. `${PATH}:/usr/local/go/bin`. +if above error still persists on you M1 Mac, then most proably you need to install arch based cmake +``` +arch -arm64 brew install cmake +``` + Build might fail with "source files not found" error the first time you try it, because modern XCode build system compiles dependencies in parallel, and some dependencies end up being built after the ones that require them. In this case simply restart the build. diff --git a/client/3rd/ShadowSocks/ss_ios.xcconfig b/client/3rd/ShadowSocks/ss_ios.xcconfig deleted file mode 100644 index 8b67bd01..00000000 --- a/client/3rd/ShadowSocks/ss_ios.xcconfig +++ /dev/null @@ -1,23 +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 -PROJECT_TEMP_DIR = /Users/sanchez/work/vied/ios/vpn/desktop-client-bkp/client/3rd/ShadowSocks/build/ShadowSocks.build -CONFIGURATION_BUILD_DIR = /Users/sanchez/work/vied/ios/vpn/desktop-client-bkp/client/3rd/ShadowSocks/build/Release-iphoneos -BUILT_PRODUCTS_DIR = /Users/sanchez/work/vied/ios/vpn/desktop-client-bkp/client/3rd/ShadowSocks/build/Release-iphoneos diff --git a/client/client.pro b/client/client.pro index 7840ae6a..439ceffa 100644 --- a/client/client.pro +++ b/client/client.pro @@ -301,6 +301,7 @@ ios { LIBS += -framework Foundation LIBS += -framework StoreKit LIBS += -framework UserNotifications + LIBS += -framework AVFoundation DEFINES += MVPN_IOS diff --git a/client/constants.h b/client/constants.h index 9059eccc..90f5e6eb 100644 --- a/client/constants.h +++ b/client/constants.h @@ -107,21 +107,5 @@ constexpr const char* PLATFORM_NAME = constexpr const char* PLACEHOLDER_USER_DNS = "127.0.0.1"; -#if defined(MVPN_ADJUST) -// These are the two auto-generated token from the Adjust dashboard for the -// "Subscription Completed" event. We have two since in the Adjust dashboard we -// have defined two apps for iOS and Android with a event token each. -constexpr const char* ADJUST_SUBSCRIPTION_COMPLETED = -# if defined(MVPN_IOS) - "jl72xm" -# elif defined(MVPN_ANDROID) - "o1mn9m" -# else - "" -# endif - ; -#endif - -}; // namespace Constants - +}; #endif // CONSTANTS_H diff --git a/client/fastlane/report.xml b/client/fastlane/report.xml deleted file mode 100644 index e0cdc969..00000000 --- a/client/fastlane/report.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/client/ios/app/Info.plist b/client/ios/app/Info.plist index 20a28b2a..f5681a20 100644 --- a/client/ios/app/Info.plist +++ b/client/ios/app/Info.plist @@ -38,13 +38,15 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 2 + 7 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS + UIFileSharingEnabled + LSSupportsOpeningDocumentsInPlace - + NSCameraUsageDescription Amnezia VPN needs access to the camera for reading QR-codes. UILaunchStoryboardName diff --git a/client/macos/networkextension/Info.plist b/client/macos/networkextension/Info.plist index 08fc4d0a..96d82459 100644 --- a/client/macos/networkextension/Info.plist +++ b/client/macos/networkextension/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 2 + $(CURRENT_PROJECT_VERSION) ITSAppUsesNonExemptEncryption LSMinimumSystemVersion diff --git a/client/platforms/ios/QtAppDelegate.mm b/client/platforms/ios/QtAppDelegate.mm index f63bea35..e6ec8444 100644 --- a/client/platforms/ios/QtAppDelegate.mm +++ b/client/platforms/ios/QtAppDelegate.mm @@ -2,7 +2,9 @@ #include -@implementation QtAppDelegate +@implementation QtAppDelegate { + UIView *_screen; +} +(QtAppDelegate *)sharedQtAppDelegate { static dispatch_once_t pred; @@ -26,6 +28,13 @@ { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + _screen = [UIScreen.mainScreen snapshotViewAfterScreenUpdates: false]; + UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle: UIBlurEffectStyleDark]; + UIVisualEffectView *blurBackround = [[UIVisualEffectView alloc] initWithEffect: blurEffect]; + [_screen addSubview: blurBackround]; + blurBackround.frame = _screen.frame; + UIWindow *_window = UIApplication.sharedApplication.keyWindow; + [_window addSubview: _screen]; } - (void)applicationDidEnterBackground:(UIApplication *)application @@ -44,6 +53,7 @@ - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + [_screen removeFromSuperview]; } - (void)applicationWillTerminate:(UIApplication *)application diff --git a/client/platforms/ios/iostunnel.swift b/client/platforms/ios/iostunnel.swift index 5209306d..6d87a18d 100644 --- a/client/platforms/ios/iostunnel.swift +++ b/client/platforms/ios/iostunnel.swift @@ -125,7 +125,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) @@ -297,6 +297,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 } diff --git a/client/platforms/ios/iosvpnprotocol.swift b/client/platforms/ios/iosvpnprotocol.swift index 2c028915..95505b21 100644 --- a/client/platforms/ios/iosvpnprotocol.swift +++ b/client/platforms/ios/iosvpnprotocol.swift @@ -388,7 +388,7 @@ public class IOSVpnProtocolImpl : NSObject { proto.providerBundleIdentifier = vpnBundleID tunnel!.protocolConfiguration = proto - tunnel!.localizedDescription = vpnName + tunnel!.localizedDescription = "Amnezia Wireguard" tunnel!.isEnabled = true tunnel!.saveToPreferences { [unowned self] saveError in @@ -527,8 +527,9 @@ 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: @@ -559,7 +560,7 @@ public class IOSVpnProtocolImpl : NSObject { print("server IP: \(serverIpv4Gateway)") - let deviceIpv4Address = getTunIPAddress() + let deviceIpv4Address = getWiFiAddress() print("device IP: \(serverIpv4Gateway)") if deviceIpv4Address == nil { callback("", "", "") @@ -610,8 +611,9 @@ public class IOSVpnProtocolImpl : NSObject { print("server IP: \(serverIpv4Gateway)") - let deviceIpv4Address = getTunIPAddress() - print("device IP: \(serverIpv4Gateway)") + + let deviceIpv4Address = getWiFiAddress() + print("device IP: \(deviceIpv4Address)") if deviceIpv4Address == nil { callback("", "", "") return @@ -690,38 +692,45 @@ public class IOSVpnProtocolImpl : NSObject { } } - private func getTunIPAddress() -> String? { - var address: String? = nil - var interfaces: UnsafeMutablePointer? = nil - var temp_addr: UnsafeMutablePointer? = nil - var success: Int = 0 - - // retrieve the current interfaces - returns 0 on success - success = Int(getifaddrs(&interfaces)) - if success == 0 { - // Loop through linked list of interfaces - temp_addr = interfaces - while temp_addr != nil { - if temp_addr?.pointee.ifa_addr == nil { - continue + func getWiFiAddress() -> String? { + var address : String? + + // Get list of all interfaces on the local machine: + var ifaddr : UnsafeMutablePointer? + guard getifaddrs(&ifaddr) == 0 else { return nil } + guard let firstAddr = ifaddr else { return nil } + + // For each interface ... + for ifptr in sequence(first: firstAddr, next: { $0.pointee.ifa_next }) { + let interface = ifptr.pointee + + // Check for IPv4 or IPv6 interface: + let addrFamily = interface.ifa_addr.pointee.sa_family + //if addrFamily == UInt8(AF_INET) || addrFamily == UInt8(AF_INET6) { // **ipv6 committed + if addrFamily == UInt8(AF_INET){ + + // Check interface name: + let name = String(cString: interface.ifa_name) + if name == "en0" { + + // Convert interface address to a human readable string: + var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST)) + getnameinfo(interface.ifa_addr, socklen_t(interface.ifa_addr.pointee.sa_len), + &hostname, socklen_t(hostname.count), + nil, socklen_t(0), NI_NUMERICHOST) + address = String(cString: hostname) } - if temp_addr?.pointee.ifa_addr.pointee.sa_family == UInt8(AF_INET) { - // Check if interface is en0 which is the wifi connection on the iPhone - if let name = temp_addr?.pointee.ifa_name, ((String(utf8String: name)?.contains("tun")) != nil) { - // Get NSString from C String - if let value = temp_addr?.pointee.ifa_addr as? sockaddr_in { - address = String(utf8String: inet_ntoa(value.sin_addr)) - } - } - } - temp_addr = temp_addr?.pointee.ifa_next } } - freeifaddrs(interfaces) + freeifaddrs(ifaddr) + return address } + + } + enum TunnelType: String { case wireguard, openvpn, shadowsocks, empty } @@ -729,9 +738,9 @@ enum TunnelType: String { extension String { var toTunnelType: TunnelType { switch self { - case "wireguard": return .wireguard - case "openvpn": return .openvpn - case "shadowsocks": return .shadowsocks + case "Amnezia Wireguard": return .wireguard + case "Amnezia OpenVPN": return .openvpn + case "Amnezia ShadowSocks": return .shadowsocks default: return .empty } diff --git a/client/scripts/apple_compile.sh b/client/scripts/apple_compile.sh index fb44af30..403460fa 100755 --- a/client/scripts/apple_compile.sh +++ b/client/scripts/apple_compile.sh @@ -10,13 +10,11 @@ fi RELEASE=1 OS= NETWORKEXTENSION= -ADJUST_SDK_TOKEN= -ADJUST="CONFIG-=adjust" WORKINGDIR=`pwd` helpFunction() { print G "Usage:" - print N "\t$0 [-d|--debug] [-n|--networkextension] [-a|--adjusttoken ]" + 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." @@ -26,7 +24,6 @@ helpFunction() { print G "Config variables:" print N "\tQT_MACOS_BIN=" print N "\tQT_IOS_BIN=" - print N "\tMVPN_IOS_ADJUST_TOKEN=" print N "" exit 0 } @@ -38,11 +35,6 @@ while [[ $# -gt 0 ]]; do key="$1" case $key in - -a | --adjusttoken) - ADJUST_SDK_TOKEN="$2" - shift - shift - ;; -d | --debug) RELEASE= shift @@ -97,11 +89,6 @@ if [[ "$OS" != "macos" ]] && [[ "$OS" != "ios" ]] && [[ "$OS" != "macostest" ]]; helpFunction fi -if ! [[ "$ADJUST_SDK_TOKEN" ]] && [[ "$MVPN_IOS_ADJUST_TOKEN" ]]; then - print Y "Using the MVPN_IOS_ADJUST_TOKEN value for the adjust token" - ADJUST_SDK_TOKEN=$MVPN_IOS_ADJUST_TOKEN -fi - if [[ "$OS" == "ios" ]]; then # Network-extension is the default for IOS NETWORKEXTENSION=1 @@ -150,7 +137,6 @@ MACOS_FLAGS=" QTPLUGIN+=qsvg CONFIG-=static CONFIG+=balrog - MVPN_MACOS=1 " MACOSTEST_FLAGS=" @@ -160,7 +146,6 @@ MACOSTEST_FLAGS=" " IOS_FLAGS=" - MVPN_IOS=1 Q_OS_IOS=1 " @@ -183,11 +168,6 @@ elif [ "$OS" = "macostest" ]; then PLATFORM=$MACOSTEST_FLAGS elif [ "$OS" = "ios" ]; then PLATFORM=$IOS_FLAGS - if [[ "$ADJUST_SDK_TOKEN" ]]; then - printn Y "ADJUST_SDK_TOKEN: " - print G "$ADJUST_SDK_TOKEN" - ADJUST="CONFIG+=adjust" - fi else killProcess "Why are we here?" fi @@ -249,7 +229,7 @@ else print Y "No Tun2Socks will be built" fi -print Y "Creating the xcode project via qmake..." +print Y "Creating the Xcode project via qmake..." $QMAKE \ VERSION=$SHORTVERSION \ BUILD_ID=$FULLVERSION \ @@ -258,11 +238,10 @@ $QMAKE \ $VPNMODE \ $WEMODE \ $PLATFORM \ - $ADJUST \ ./client.pro || killProcess "Compilation failed" print Y "Patching the xcode project..." -ruby scripts/xcode_patcher.rb "AmneziaVPN.xcodeproj" "$SHORTVERSION" "$FULLVERSION" "$OSRUBY" "$NETWORKEXTENSION" "$ADJUST_SDK_TOKEN" || killProcess "Failed to merge xcode with wireguard" +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 @@ -270,6 +249,6 @@ print G "done." sed -i '' '/Original<\/string>/d' AmneziaVPN.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings fi -# print Y "Opening in XCode..." -# open AmneziaVPN.xcodeproj print G "All done!" +print Y "Opening project in Xcode..." +open AmneziaVPN.xcodeproj diff --git a/client/scripts/xcode_patcher.rb b/client/scripts/xcode_patcher.rb index 0a0550ca..6f9c4c41 100644 --- a/client/scripts/xcode_patcher.rb +++ b/client/scripts/xcode_patcher.rb @@ -9,7 +9,7 @@ class XCodeprojPatcher attr :target_main attr :target_extension - def run(file, shortVersion, fullVersion, platform, networkExtension, configHash, adjust_sdk_token) + def run(file, shortVersion, fullVersion, platform, networkExtension, configHash) open_project file setup_project open_target_main @@ -19,13 +19,7 @@ class XCodeprojPatcher group = @project.main_group.new_group('Configuration') @configFile = group.new_file('xcode.xconfig') - setup_target_main shortVersion, fullVersion, platform, networkExtension, configHash, adjust_sdk_token - -# if platform == 'macos' -# setup_target_loginitem shortVersion, fullVersion, configHash -# setup_target_nativemessaging shortVersion, fullVersion, configHash -# end - + setup_target_main shortVersion, fullVersion, platform, networkExtension, configHash if networkExtension setup_target_extension shortVersion, fullVersion, platform, configHash @@ -59,7 +53,7 @@ class XCodeprojPatcher end - def setup_target_main(shortVersion, fullVersion, platform, networkExtension, configHash, adjust_sdk_token) + def setup_target_main(shortVersion, fullVersion, platform, networkExtension, configHash) @target_main.build_configurations.each do |config| config.base_configuration_reference = @configFile @@ -72,10 +66,8 @@ class XCodeprojPatcher "$(PROJECT_DIR)/3rd", "$(PROJECT_DIR)/3rd/OpenVPNAdapter/build/Release-iphoneos", "$(PROJECT_DIR)/3rd/ShadowSocks/build/Release-iphoneos", -# "$(PROJECT_DIR)/3rd/PacketProcessor/build/Release-iphoneos", "$(PROJECT_DIR)/3rd/outline-go-tun2socks/build/ios", "${PROJECT_DIR}/3rd/CocoaAsyncSocket/build/Release-iphoneos", -# "${PROJECT_DIR}/3rd/CocoaLumberjack/build/Release-iphoneos", ] # Versions and names @@ -91,9 +83,6 @@ class XCodeprojPatcher config.build_settings['INFOPLIST_FILE'] ||= platform + '/app/Info.plist' if platform == 'ios' config.build_settings['CODE_SIGN_ENTITLEMENTS'] ||= 'ios/app/main.entitlements' - if adjust_sdk_token != "" - config.build_settings['ADJUST_SDK_TOKEN'] = adjust_sdk_token - end elsif networkExtension config.build_settings['CODE_SIGN_ENTITLEMENTS'] ||= 'macos/app/app.entitlements' else @@ -104,7 +93,7 @@ class XCodeprojPatcher config.build_settings['ENABLE_BITCODE'] ||= 'NO' if platform == 'ios' config.build_settings['SDKROOT'] = 'iphoneos' if platform == 'ios' config.build_settings['SWIFT_PRECOMPILE_BRIDGING_HEADER'] = 'NO' if platform == 'ios' - config.build_settings['PATH'] = '${PATH}:/usr/local/go/bin:/usr/local/bin:/opt/homebrew/bin' + config.build_settings['PATH'] = '${PATH}:/opt/local/bin:/usr/local/go/bin:/usr/local/bin:/opt/homebrew/bin' groupId = ""; if (platform == 'macos') @@ -173,96 +162,23 @@ class XCodeprojPatcher } end - if (platform == 'ios' && adjust_sdk_token != "") + if(platform == 'ios') + frameworks_group = @project.groups.find { |group| group.display_name == 'Frameworks' } frameworks_build_phase = @target_main.build_phases.find { |build_phase| build_phase.to_s == 'FrameworksBuildPhase' } - framework_ref = frameworks_group.new_file('AdServices.framework') - build_file = frameworks_build_phase.add_file_reference(framework_ref) - build_file.settings = { 'ATTRIBUTES' => ['Weak'] } + embed_frameworks_build_phase = project.new(Xcodeproj::Project::Object::PBXCopyFilesBuildPhase) + embed_frameworks_build_phase.name = 'Embed Frameworks' + embed_frameworks_build_phase.symbol_dst_subfolder_spec = :frameworks + @target_main.build_phases << embed_frameworks_build_phase - framework_ref = frameworks_group.new_file('iAd.framework') - frameworks_build_phase.add_file_reference(framework_ref) + framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework') + build_file = embed_frameworks_build_phase.add_file_reference(framework_ref) - # Adjust SDK - group = @project.main_group.new_group('AdjustSDK') - - [ - '3rd/adjust-ios-sdk/Adjust/ADJActivityHandler.h', - '3rd/adjust-ios-sdk/Adjust/ADJActivityKind.h', - '3rd/adjust-ios-sdk/Adjust/ADJActivityPackage.h', - '3rd/adjust-ios-sdk/Adjust/ADJActivityState.h', - '3rd/adjust-ios-sdk/Adjust/ADJAdjustFactory.h', - '3rd/adjust-ios-sdk/Adjust/ADJAdRevenue.h', - '3rd/adjust-ios-sdk/Adjust/ADJAttribution.h', - '3rd/adjust-ios-sdk/Adjust/ADJAttributionHandler.h', - '3rd/adjust-ios-sdk/Adjust/ADJBackoffStrategy.h', - '3rd/adjust-ios-sdk/Adjust/ADJAdditions/NSData+ADJAdditions.h', - '3rd/adjust-ios-sdk/Adjust/ADJAdditions/NSNumber+ADJAdditions.h', - '3rd/adjust-ios-sdk/Adjust/ADJAdditions/NSString+ADJAdditions.h', - '3rd/adjust-ios-sdk/Adjust/ADJConfig.h', - '3rd/adjust-ios-sdk/Adjust/ADJEvent.h', - '3rd/adjust-ios-sdk/Adjust/ADJEventFailure.h', - '3rd/adjust-ios-sdk/Adjust/ADJEventSuccess.h', - '3rd/adjust-ios-sdk/Adjust/ADJLinkResolution.h', - '3rd/adjust-ios-sdk/Adjust/ADJLogger.h', - '3rd/adjust-ios-sdk/Adjust/ADJPackageBuilder.h', - '3rd/adjust-ios-sdk/Adjust/ADJPackageHandler.h', - '3rd/adjust-ios-sdk/Adjust/ADJPackageParams.h', - '3rd/adjust-ios-sdk/Adjust/ADJRequestHandler.h', - '3rd/adjust-ios-sdk/Adjust/ADJResponseData.h', - '3rd/adjust-ios-sdk/Adjust/ADJSdkClickHandler.h', - '3rd/adjust-ios-sdk/Adjust/ADJSessionFailure.h', - '3rd/adjust-ios-sdk/Adjust/ADJSessionParameters.h', - '3rd/adjust-ios-sdk/Adjust/ADJSessionSuccess.h', - '3rd/adjust-ios-sdk/Adjust/ADJSubscription.h', - '3rd/adjust-ios-sdk/Adjust/ADJThirdPartySharing.h', - '3rd/adjust-ios-sdk/Adjust/ADJTimerCycle.h', - '3rd/adjust-ios-sdk/Adjust/ADJTimerOnce.h', - '3rd/adjust-ios-sdk/Adjust/ADJUrlStrategy.h', - '3rd/adjust-ios-sdk/Adjust/ADJUserDefaults.h', - '3rd/adjust-ios-sdk/Adjust/Adjust.h', - '3rd/adjust-ios-sdk/Adjust/ADJUtil.h', - '3rd/adjust-ios-sdk/Adjust/ADJActivityHandler.m', - '3rd/adjust-ios-sdk/Adjust/ADJActivityKind.m', - '3rd/adjust-ios-sdk/Adjust/ADJActivityPackage.m', - '3rd/adjust-ios-sdk/Adjust/ADJActivityState.m', - '3rd/adjust-ios-sdk/Adjust/ADJAdjustFactory.m', - '3rd/adjust-ios-sdk/Adjust/ADJAdRevenue.m', - '3rd/adjust-ios-sdk/Adjust/ADJAttribution.m', - '3rd/adjust-ios-sdk/Adjust/ADJAttributionHandler.m', - '3rd/adjust-ios-sdk/Adjust/ADJBackoffStrategy.m', - '3rd/adjust-ios-sdk/Adjust/ADJAdditions/NSData+ADJAdditions.m', - '3rd/adjust-ios-sdk/Adjust/ADJAdditions/NSNumber+ADJAdditions.m', - '3rd/adjust-ios-sdk/Adjust/ADJAdditions/NSString+ADJAdditions.m', - '3rd/adjust-ios-sdk/Adjust/ADJConfig.m', - '3rd/adjust-ios-sdk/Adjust/ADJEvent.m', - '3rd/adjust-ios-sdk/Adjust/ADJEventFailure.m', - '3rd/adjust-ios-sdk/Adjust/ADJEventSuccess.m', - '3rd/adjust-ios-sdk/Adjust/ADJLinkResolution.m', - '3rd/adjust-ios-sdk/Adjust/ADJLogger.m', - '3rd/adjust-ios-sdk/Adjust/ADJPackageBuilder.m', - '3rd/adjust-ios-sdk/Adjust/ADJPackageHandler.m', - '3rd/adjust-ios-sdk/Adjust/ADJPackageParams.m', - '3rd/adjust-ios-sdk/Adjust/ADJRequestHandler.m', - '3rd/adjust-ios-sdk/Adjust/ADJResponseData.m', - '3rd/adjust-ios-sdk/Adjust/ADJSdkClickHandler.m', - '3rd/adjust-ios-sdk/Adjust/ADJSessionFailure.m', - '3rd/adjust-ios-sdk/Adjust/ADJSessionParameters.m', - '3rd/adjust-ios-sdk/Adjust/ADJSessionSuccess.m', - '3rd/adjust-ios-sdk/Adjust/ADJSubscription.m', - '3rd/adjust-ios-sdk/Adjust/ADJThirdPartySharing.m', - '3rd/adjust-ios-sdk/Adjust/ADJTimerCycle.m', - '3rd/adjust-ios-sdk/Adjust/ADJTimerOnce.m', - '3rd/adjust-ios-sdk/Adjust/ADJUrlStrategy.m', - '3rd/adjust-ios-sdk/Adjust/ADJUserDefaults.m', - '3rd/adjust-ios-sdk/Adjust/Adjust.m', - '3rd/adjust-ios-sdk/Adjust/ADJUtil.m', - ].each { |filename| - file = group.new_file(filename) - file_reference = @target_main.add_file_references([file], '-fobjc-arc') - } + frameworks_build_phase.add_file_reference(framework_ref) + build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy', 'RemoveHeadersOnCopy'] } end + end def setup_target_extension(shortVersion, fullVersion, platform, configHash) @@ -288,12 +204,9 @@ class XCodeprojPatcher "$(PROJECT_DIR)/3rd/OpenVPNAdapter/build/Release-iphoneos", "$(PROJECT_DIR)/3rd/libleaf/lib", "$(PROJECT_DIR)/3rd/ShadowSocks/build/Release-iphoneos", -# "$(PROJECT_DIR)/3rd/PacketProcessor/build/Release-iphoneos", "$(PROJECT_DIR)/3rd/outline-go-tun2socks/build/ios", "${PROJECT_DIR}/3rd/CocoaAsyncSocket/build/Release-iphoneos", -# "${PROJECT_DIR}/3rd/CocoaLumberjack/build/Release-iphoneos", ] -# config.build_settings['LIBRARY_SEARCH_PATHS'] = [config.build_settings['LIBRARY_SEARCH_PATHS'], "$(PROJECT_DIR)/3rd/libleaf/lib"] # Versions and names config.build_settings['MARKETING_VERSION'] ||= shortVersion @@ -325,7 +238,7 @@ class XCodeprojPatcher "-framework", "OpenGLES", ] - config.build_settings['PATH'] = '${PATH}:/usr/local/go/bin' + config.build_settings['PATH'] = '${PATH}:/opt/local/bin:/usr/local/go/bin' end groupId = ""; @@ -379,17 +292,7 @@ class XCodeprojPatcher 'platforms/ios/iostunnel.swift', 'platforms/ios/ioslogger.swift', 'platforms/ios/iosinterface.swift', -# 'platforms/ios/ssprovider.swift', 'platforms/ios/iosglue.mm', -# 'platforms/ios/ssconnectivity.h', -# 'platforms/ios/ssconnectivity.m', -# 'platforms/ios/iosopenvpn2ssadapter.h', -# 'platforms/ios/iosopenvpn2ssadapter.m', -# 'platforms/ios/sspacket.h', -# 'platforms/ios/sspacket.m', -# 'platforms/ios/ssadapterpacketflow.h', -# 'platforms/ios/tun2ssprovider.swift', -# 'platforms/ios/tun2sockswriter.swift', ].each { |filename| file = group.new_file(filename) @target_extension.add_file_references([file]) @@ -402,40 +305,10 @@ class XCodeprojPatcher framework_ref = frameworks_group.new_file('libwg-go.a') frameworks_build_phase.add_file_reference(framework_ref) - -# framework_ref = frameworks_group.new_file('3rd/libleaf/lib/libleaf.a') -# frameworks_build_phase.add_file_reference(framework_ref) framework_ref = frameworks_group.new_file('NetworkExtension.framework') frameworks_build_phase.add_file_reference(framework_ref) -# framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Release-iphoneos/LZ4.framework') -# frameworks_build_phase.add_file_reference(framework_ref) -# -# framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Release-iphoneos/mbedTLS.framework') -# frameworks_build_phase.add_file_reference(framework_ref) -# -# framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Release-iphoneos/OpenVPNClient.framework') -# frameworks_build_phase.add_file_reference(framework_ref) - - framework_ref = frameworks_group.new_file('3rd/OpenVPNAdapter/build/Release-iphoneos/OpenVPNAdapter.framework') - frameworks_build_phase.add_file_reference(framework_ref) - -# framework_ref = frameworks_group.new_file('3rd/ShadowSocks/build/Release-iphoneos/ShadowSocks.framework') -# frameworks_build_phase.add_file_reference(framework_ref) -# -# framework_ref = frameworks_group.new_file('3rd/CocoaAsyncSocket/build/Release-iphoneos/CocoaAsyncSocket.framework') -# frameworks_build_phase.add_file_reference(framework_ref) -# -# framework_ref = frameworks_group.new_file('3rd/outline-go-tun2socks/build/ios/Tun2socks.xcframework') -# frameworks_build_phase.add_file_reference(framework_ref) - -# framework_ref = frameworks_group.new_file('3rd/CocoaLumberjack/build/Release-iphoneos/CocoaLumberjack.framework') -# frameworks_build_phase.add_file_reference(framework_ref) - - - - # This fails: @target_main.add_dependency @target_extension container_proxy = @project.new(Xcodeproj::Project::PBXContainerItemProxy) container_proxy.container_portal = @project.root_object.uuid @@ -492,6 +365,7 @@ class XCodeprojPatcher framework_ref = frameworks_group.new_file('balrog/balrog.a') frameworks_build_phase.add_file_reference(framework_ref) + # This fails: @target_main.add_dependency target_balrog container_proxy = @project.new(Xcodeproj::Project::PBXContainerItemProxy) container_proxy.container_portal = @project.root_object.uuid @@ -599,7 +473,7 @@ class XCodeprojPatcher # other configs config.build_settings['INFOPLIST_FILE'] ||= 'macos/loginitem/Info.plist' - config.build_settings['CODE_SIGN_ENTITLEMENTS'] ||= 'macos/loginitem/MozillaVPNLoginItem.entitlements' + config.build_settings['CODE_SIGN_ENTITLEMENTS'] ||= 'macos/loginitem/MozillaVPNLoginItem.entitlements' #TODO need to check this config.build_settings['CODE_SIGN_IDENTITY'] = 'Apple Development' config.build_settings['SKIP_INSTALL'] = 'YES' @@ -708,7 +582,7 @@ class XCodeprojPatcher copy_nativeMessagingManifest.dst_path = 'Contents/Resources/utils' group = @project.main_group.new_group('WireGuardHelper') - file = group.new_file 'extension/app/manifests/macos/mozillavpn.json' + file = group.new_file 'extension/app/manifests/macos/mozillavpn.json' #TODO Need to check this nativeMessagingManifest_file = copy_nativeMessagingManifest.add_file_reference file nativeMessagingManifest_file.settings = { "ATTRIBUTES" => ['RemoveHeadersOnCopy'] } @@ -744,8 +618,7 @@ configFile.each { |line| platform = "macos" platform = "ios" if ARGV[3] == "ios" networkExtension = true if ARGV[4] == "1" -adjust_sdk_token = ARGV[5] r = XCodeprojPatcher.new -r.run ARGV[0], ARGV[1], ARGV[2], platform, networkExtension, config, adjust_sdk_token +r.run ARGV[0], ARGV[1], ARGV[2], platform, networkExtension, config exit 0 diff --git a/client/ui/pages_logic/AppSettingsLogic.cpp b/client/ui/pages_logic/AppSettingsLogic.cpp index b2907c3d..b22918b2 100644 --- a/client/ui/pages_logic/AppSettingsLogic.cpp +++ b/client/ui/pages_logic/AppSettingsLogic.cpp @@ -83,8 +83,8 @@ void AppSettingsLogic::onPushButtonBackupAppConfigClicked() void AppSettingsLogic::onPushButtonRestoreAppConfigClicked() { - QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open backup"), - QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup"); + QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open backup"), + QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup"); if (fileName.isEmpty()) return; diff --git a/client/ui/pages_logic/StartPageLogic.cpp b/client/ui/pages_logic/StartPageLogic.cpp index 1e28d6cd..a5a0a38d 100644 --- a/client/ui/pages_logic/StartPageLogic.cpp +++ b/client/ui/pages_logic/StartPageLogic.cpp @@ -135,9 +135,8 @@ void StartPageLogic::onPushButtonImport() void StartPageLogic::onPushButtonImportOpenFile() { - QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open profile"), - QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.vpn"); - + QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open profile"), + QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), tr("*.vpn")); if (fileName.isEmpty()) return; QFile file(fileName); diff --git a/client/ui/qml/Pages/PageQrDecoderIos.qml b/client/ui/qml/Pages/PageQrDecoderIos.qml index 7dd077dd..0e796312 100644 --- a/client/ui/qml/Pages/PageQrDecoderIos.qml +++ b/client/ui/qml/Pages/PageQrDecoderIos.qml @@ -40,11 +40,29 @@ PageBase { id: loader anchors.top: caption.bottom - anchors.bottom: parent.bottom + anchors.bottom: progressColumn.top anchors.left: parent.left anchors.right: parent.right } + Column{ + height: 40 + id: progressColumn + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + ProgressBar { + id: progress + anchors.left: parent.left + anchors.right: parent.right + value: QrDecoderLogic.totalChunksCount === 0? 0 : (QrDecoderLogic.receivedChunksCount/QrDecoderLogic.totalChunksCount) + } + Text { + id: chunksCount + text: "Progress: " + QrDecoderLogic.receivedChunksCount +"/"+QrDecoderLogic.totalChunksCount + } + } + Component { id: component diff --git a/client/ui/uilogic.cpp b/client/ui/uilogic.cpp index e1468da7..2d93d429 100644 --- a/client/ui/uilogic.cpp +++ b/client/ui/uilogic.cpp @@ -266,8 +266,6 @@ void UiLogic::onGotoCurrentProtocolsPage() emit goToPage(Page::ServerContainers); } - - //void UiLogic::showEvent(QShowEvent *event) //{ //#if defined Q_OS_MACX diff --git a/client/versionfull.pri b/client/versionfull.pri index 5fc93c79..5ee6310c 100644 --- a/client/versionfull.pri +++ b/client/versionfull.pri @@ -1,2 +1,2 @@ -# current build 1 -!defined(BUILDVERSION, var):BUILDVERSION = 2 \ No newline at end of file +# current build 6 +!defined(BUILDVERSION, var):BUILDVERSION = 7 \ No newline at end of file diff --git a/client/vpnconnection.cpp b/client/vpnconnection.cpp index 6e117ce4..6a981f0c 100644 --- a/client/vpnconnection.cpp +++ b/client/vpnconnection.cpp @@ -1,3 +1,4 @@ +#include "qtimer.h" #include #include #include @@ -34,7 +35,10 @@ VpnConnection::VpnConnection(std::shared_ptr settings, std::shared_ptr serverController, QObject* parent) : QObject(parent), m_settings(settings), m_configurator(configurator), - m_serverController(serverController) + m_serverController(serverController), + m_receivedBytes(0), + m_sentBytes(0), + m_isIOSConnected(false) { } @@ -48,11 +52,16 @@ VpnConnection::~VpnConnection() void VpnConnection::onBytesChanged(quint64 receivedBytes, quint64 sentBytes) { - emit bytesChanged(receivedBytes, sentBytes); + emit bytesChanged(receivedBytes - m_receivedBytes, sentBytes - m_sentBytes); + + m_receivedBytes = receivedBytes; + m_sentBytes = sentBytes; + } void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState state) { + #ifdef AMNEZIA_DESKTOP if (IpcClient::Interface()) { if (state == VpnProtocol::Connected){ @@ -94,9 +103,35 @@ void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState sta } } #endif + +#ifdef Q_OS_IOS + + qDebug() << state; + if(state == VpnProtocol::Connected){ + m_isIOSConnected = true; + checkIOSStatus(); + }else{ + + m_isIOSConnected = false; + m_receivedBytes = 0; + m_sentBytes = 0; + } +#endif emit connectionStateChanged(state); } +void VpnConnection::checkIOSStatus() +{ + QTimer::singleShot(1000, [this]() { + + if(m_isIOSConnected){ + iosVpnProtocol->checkStatus(); + checkIOSStatus(); + } + + } ); +} + const QString &VpnConnection::remoteAddress() const { return m_remoteAddress; @@ -333,7 +368,10 @@ void VpnConnection::connectToVpn(int serverIndex, m_vpnProtocol.reset(androidVpnProtocol); #elif defined Q_OS_IOS Proto proto = ContainerProps::defaultProtocol(container); - IOSVpnProtocol *iosVpnProtocol = new IOSVpnProtocol(proto, m_vpnConfiguration); + //if (iosVpnProtocol==NULL) { + iosVpnProtocol = new IOSVpnProtocol(proto, m_vpnConfiguration); + //} + // IOSVpnProtocol *iosVpnProtocol = new IOSVpnProtocol(proto, m_vpnConfiguration); if (!iosVpnProtocol->initialize()) { qDebug() << QString("Init failed") ; emit VpnProtocol::Error; @@ -384,12 +422,19 @@ void VpnConnection::disconnectFromVpn() VpnProtocol::VpnConnectionState VpnConnection::connectionState() { + + if (!m_vpnProtocol) return VpnProtocol::Disconnected; return m_vpnProtocol->connectionState(); + } bool VpnConnection::isConnected() const { +#ifdef Q_OS_IOS + +#endif + if (!m_vpnProtocol.data()) { return false; } diff --git a/client/vpnconnection.h b/client/vpnconnection.h index 18446e74..28c8ef0b 100644 --- a/client/vpnconnection.h +++ b/client/vpnconnection.h @@ -9,6 +9,7 @@ #include "protocols/vpnprotocol.h" #include "core/defs.h" #include "settings.h" +#include "protocols/ios_vpnprotocol.h" #ifdef AMNEZIA_DESKTOP #include "core/ipcclient.h" @@ -73,6 +74,7 @@ signals: protected slots: void onBytesChanged(quint64 receivedBytes, quint64 sentBytes); void onConnectionStateChanged(VpnProtocol::VpnConnectionState state); + void checkIOSStatus(); protected: QSharedPointer m_vpnProtocol; @@ -85,10 +87,16 @@ private: QJsonObject m_vpnConfiguration; QJsonObject m_routeMode; QString m_remoteAddress; + quint64 m_receivedBytes; + quint64 m_sentBytes; + bool m_isIOSConnected; //remove later move to isConnected, #ifdef AMNEZIA_DESKTOP IpcClient *m_IpcClient {nullptr}; #endif +#ifdef Q_OS_IOS + IOSVpnProtocol * iosVpnProtocol{nullptr}; +#endif }; #endif // VPNCONNECTION_H diff --git a/client/xcode.xconfig b/client/xcode.xconfig index 62778188..bbed6a13 100644 --- a/client/xcode.xconfig +++ b/client/xcode.xconfig @@ -2,4 +2,4 @@ DEVELOPMENT_TEAM = X7UJ388FXK GROUP_ID_IOS = group.org.amnezia.AmneziaVPN APP_ID_IOS = org.amnezia.AmneziaVPN -NETEXT_ID_IOS = org.amnezia.AmneziaVPN.network-extension +NETEXT_ID_IOS = org.amnezia.AmneziaVPN.network-extension \ No newline at end of file