From 4bd6fbd4457956f34247e98d9de37d55abc00ad9 Mon Sep 17 00:00:00 2001 From: Dmitriy Karpushin Date: Mon, 6 Mar 2023 12:11:37 +0300 Subject: [PATCH 1/6] Support of targetSdk 31 with its behaviour changes --- client/android/build.gradle | 2 +- client/android/shadowsocks/build.gradle | 2 +- client/android/shadowsocks/src/main/AndroidManifest.xml | 3 ++- .../src/main/java/org/amnezia/vpn/shadowsocks/core/Core.kt | 6 +++--- client/android/src/org/amnezia/vpn/NotificationUtil.kt | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/android/build.gradle b/client/android/build.gradle index 94604ad8..16507a89 100644 --- a/client/android/build.gradle +++ b/client/android/build.gradle @@ -135,7 +135,7 @@ android { defaultConfig { resConfig "en" minSdkVersion = 24 - targetSdkVersion = 30 + targetSdkVersion = 31 versionCode 10 // Change to a higher number versionName "2.0.10" // Change to a higher number diff --git a/client/android/shadowsocks/build.gradle b/client/android/shadowsocks/build.gradle index d87139fe..69ebd0bd 100644 --- a/client/android/shadowsocks/build.gradle +++ b/client/android/shadowsocks/build.gradle @@ -53,7 +53,7 @@ dependencies { implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0" implementation "androidx.room:room-runtime:2.2.5" // runtime implementation "androidx.preference:preference:1.1.0" - implementation "androidx.work:work-runtime-ktx:2.3.4" + implementation "androidx.work:work-runtime-ktx:2.7.1" implementation "androidx.browser:browser:1.3.0-alpha01" implementation "androidx.constraintlayout:constraintlayout:1.1.3" implementation "com.google.android.material:material:1.2.0-alpha05" diff --git a/client/android/shadowsocks/src/main/AndroidManifest.xml b/client/android/shadowsocks/src/main/AndroidManifest.xml index 9769ab7a..ee498ab8 100644 --- a/client/android/shadowsocks/src/main/AndroidManifest.xml +++ b/client/android/shadowsocks/src/main/AndroidManifest.xml @@ -68,7 +68,8 @@ android:name="org.amnezia.vpn.shadowsocks.core.BootReceiver" android:directBootAware="true" android:enabled="false" - android:process=":QtOnlyProcess"> + android:process=":QtOnlyProcess" + android:exported="true"> diff --git a/client/android/shadowsocks/src/main/java/org/amnezia/vpn/shadowsocks/core/Core.kt b/client/android/shadowsocks/src/main/java/org/amnezia/vpn/shadowsocks/core/Core.kt index 170bfb75..93bfcacc 100644 --- a/client/android/shadowsocks/src/main/java/org/amnezia/vpn/shadowsocks/core/Core.kt +++ b/client/android/shadowsocks/src/main/java/org/amnezia/vpn/shadowsocks/core/Core.kt @@ -84,8 +84,9 @@ object Core { fun init(app: Application, configureClass: KClass) { Core.app = app configureIntent = { - PendingIntent.getActivity(it, 0, Intent(it, configureClass.java) - .setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT), 0) + PendingIntent.getActivity(it, 0, + Intent(it, configureClass.java).setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT), + PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) } if (Build.VERSION.SDK_INT >= 24) { // migrate old files @@ -99,7 +100,6 @@ object Core { // overhead of debug mode is minimal: https://github.com/Kotlin/kotlinx.coroutines/blob/f528898/docs/debugging.md#debug-mode System.setProperty(DEBUG_PROPERTY_NAME, DEBUG_PROPERTY_VALUE_ON) - WorkManager.initialize(deviceStorage, Configuration.Builder().build()) // handle data restored/crash if (Build.VERSION.SDK_INT >= 24 && DataStore.directBootAware && diff --git a/client/android/src/org/amnezia/vpn/NotificationUtil.kt b/client/android/src/org/amnezia/vpn/NotificationUtil.kt index 15e706ed..d2808d5d 100644 --- a/client/android/src/org/amnezia/vpn/NotificationUtil.kt +++ b/client/android/src/org/amnezia/vpn/NotificationUtil.kt @@ -99,7 +99,7 @@ object NotificationUtil { val mainActivityName = "org.amnezia.vpn.qt.VPNActivity" val activity = Class.forName(mainActivityName) val intent = Intent(service, activity) - val pendingIntent = PendingIntent.getActivity(service, 0, intent, 0) + val pendingIntent = PendingIntent.getActivity(service, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) // Build our notification sNotificationBuilder?.let { it.setSmallIcon(org.amnezia.vpn.R.drawable.ic_amnezia_round) From e16d835727a290175d0eba94265983d761b070c6 Mon Sep 17 00:00:00 2001 From: pokamest Date: Thu, 16 Mar 2023 12:35:01 +0000 Subject: [PATCH 2/6] CentOS docker autostart fix --- client/server_scripts/install_docker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/client/server_scripts/install_docker.sh b/client/server_scripts/install_docker.sh index baff7cb6..bb14e4cf 100644 --- a/client/server_scripts/install_docker.sh +++ b/client/server_scripts/install_docker.sh @@ -6,4 +6,5 @@ if [[ -f "$pm_apt" ]]; then export DEBIAN_FRONTEND=noninteractive; fi;\ if [[ -z "$docker_service" ]]; then sudo $pm update -y -q; sudo $pm install -y -q curl $docker_pkg; fi;\ docker_service=$(systemctl list-units --full -all | grep docker.service | grep -v inactive | grep -v dead | grep -v failed);\ if [[ -z "$docker_service" ]]; then sleep 5 && sudo systemctl start docker && sleep 5; fi;\ +if [[ -f "$pm_yum" ]]; then sudo systemctl enable docker && sudo systemctl start docker; fi;\ docker --version From 433e6901c6cd617ba3d1f07282c99fc03c123b3d Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Thu, 16 Mar 2023 16:46:29 +0300 Subject: [PATCH 3/6] fixed a bug when existing containers were overwritten in the GUI when clicking the "scan installed containers" button --- client/ui/pages_logic/ServerListLogic.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ui/pages_logic/ServerListLogic.cpp b/client/ui/pages_logic/ServerListLogic.cpp index 79d13c8b..e91b1e33 100644 --- a/client/ui/pages_logic/ServerListLogic.cpp +++ b/client/ui/pages_logic/ServerListLogic.cpp @@ -21,6 +21,7 @@ void ServerListLogic::onServerListPushbuttonDefaultClicked(int index) void ServerListLogic::onServerListPushbuttonSettingsClicked(int index) { uiLogic()->m_selectedServerIndex = index; + uiLogic()->m_installCredentials = m_settings->serverCredentials(index); uiLogic()->goToPage(Page::ServerSettings); } From a92f1b82d00ee2342ba61ba67d20b72323d7fde4 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Thu, 16 Mar 2023 16:47:26 +0300 Subject: [PATCH 4/6] fixed a bug with incorrect port detection when clicking the "scan installed containers" button --- client/core/servercontroller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/core/servercontroller.cpp b/client/core/servercontroller.cpp index 94968789..c0f6adae 100644 --- a/client/core/servercontroller.cpp +++ b/client/core/servercontroller.cpp @@ -917,7 +917,7 @@ ErrorCode ServerController::getAlreadyInstalledContainers(const ServerCredential if (containerInfo.isEmpty()) { continue; } - const static QRegularExpression containerAndPortRegExp("(amnezia[-a-z]*).*?>([0-9]*)/(udp|tcp).*"); + const static QRegularExpression containerAndPortRegExp("(amnezia[-a-z]*).*?:([0-9]*)->[0-9]*/(udp|tcp).*"); QRegularExpressionMatch containerAndPortMatch = containerAndPortRegExp.match(containerInfo); if (containerAndPortMatch.hasMatch()) { QString name = containerAndPortMatch.captured(1); From 7e1bcf84f0b51e4be1d47c18ea226ab3d75da2b3 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Thu, 16 Mar 2023 18:59:06 +0300 Subject: [PATCH 5/6] fixed saving site from "fake web site" field when configuring openvpn over cloak via wizard --- client/ui/qml/Pages/PageSetupWizardHighLevel.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ui/qml/Pages/PageSetupWizardHighLevel.qml b/client/ui/qml/Pages/PageSetupWizardHighLevel.qml index 8b4bd322..e0f194ff 100644 --- a/client/ui/qml/Pages/PageSetupWizardHighLevel.qml +++ b/client/ui/qml/Pages/PageSetupWizardHighLevel.qml @@ -54,12 +54,12 @@ You SHOULD set this website address to some foreign website which is not blocked text: WizardLogic.lineEditHighWebsiteMaskingText onEditingFinished: { let _text = website_masking.text - _text.replace("http://", ""); - _text.replace("https://", ""); + _text = _text.replace("http://", ""); + _text = _text.replace("https://", ""); if (!_text) { return } - _text = _text.split("/").first(); + _text = _text.split("/")[0]; WizardLogic.lineEditHighWebsiteMaskingText = _text } onAccepted: { From cba78190a86d8b5b03022183364bede5b9bc6ed5 Mon Sep 17 00:00:00 2001 From: pokamest Date: Thu, 16 Mar 2023 11:43:18 -0700 Subject: [PATCH 6/6] iOS build fix --- client/CMakeLists.txt | 26 ++++++++++---------------- client/vpnconnection.cpp | 4 ++-- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 7466c595..50d6d0f7 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -303,13 +303,14 @@ if(IOS) find_library(FW_AUTHENTICATIONSERVICES AuthenticationServices) find_library(FW_UIKIT UIKit) + find_library(FW_AVFOUNDATION AVFoundation) find_library(FW_FOUNDATION Foundation) find_library(FW_STOREKIT StoreKit) find_library(FW_USERNOTIFICATIONS UserNotifications) set(LIBS ${LIBS} ${FW_AUTHENTICATIONSERVICES} ${FW_UIKIT} - ${FW_FOUNDATION} ${FW_STOREKIT} + ${FW_AVFOUNDATION} ${FW_FOUNDATION} ${FW_STOREKIT} ${FW_USERNOTIFICATIONS} ) @@ -463,14 +464,13 @@ if(IOS) 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" -) + 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) @@ -498,19 +498,13 @@ set_source_files_properties( ) 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_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) diff --git a/client/vpnconnection.cpp b/client/vpnconnection.cpp index 4ff67a07..e01f7e61 100644 --- a/client/vpnconnection.cpp +++ b/client/vpnconnection.cpp @@ -105,8 +105,8 @@ void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState sta } else { m_isIOSConnected = false; - m_receivedBytes = 0; - m_sentBytes = 0; +// m_receivedBytes = 0; +// m_sentBytes = 0; } #endif emit connectionStateChanged(state);