mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-11-21 03:52:59 +09:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc02c8910b |
No files matched your search
@@ -14,6 +14,7 @@ runs:
|
||||
- name: Setup provisioning profile
|
||||
shell: bash
|
||||
run: |
|
||||
PROFILES_DIR="$HOME/Library/MobileDevice/Provisioning Profiles"
|
||||
TEMP_FILE=$(mktemp)
|
||||
|
||||
echo "${{ inputs.provisioning_profile_base64 }}" | base64 --decode > "$TEMP_FILE"
|
||||
@@ -25,12 +26,6 @@ runs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PROFILE_EXTENSION=mobileprovision
|
||||
grep -aq "<string>OSX</string>" "$TEMP_FILE" && PROFILE_EXTENSION=provisionprofile
|
||||
|
||||
for PROFILES_DIR in "$HOME/Library/MobileDevice/Provisioning Profiles" "$HOME/Library/Developer/Xcode/UserData/Provisioning Profiles"; do
|
||||
mkdir -p "$PROFILES_DIR"
|
||||
cp "$TEMP_FILE" "$PROFILES_DIR/$PROFILE_UUID.$PROFILE_EXTENSION"
|
||||
done
|
||||
rm -f "$TEMP_FILE"
|
||||
echo "Installed profile: $PROFILE_UUID.$PROFILE_EXTENSION"
|
||||
mkdir -p "$PROFILES_DIR"
|
||||
mv "$TEMP_FILE" "$PROFILES_DIR/$PROFILE_UUID.mobileprovision"
|
||||
echo "Installed profile: $PROFILE_UUID"
|
||||
@@ -1,23 +0,0 @@
|
||||
## Version differences
|
||||
|
||||
### Android
|
||||
* For Android version 11 and higher, you need to use .apk that start with - AmneziaVPN_${VERSION}_android11+
|
||||
* For Android version 9-10, you need to use .apk that start with - AmneziaVPN_${VERSION}_android9-10
|
||||
* ***The app version for Android 7 and 8 is temporarily unavailable***
|
||||
|
||||
### macOS
|
||||
!!! The previous version (4.8.8.2 and lower) of the application (installed via the .dmg installer) must be uninstalled via “move to bin” in the applications folder
|
||||
|
||||
* For macOS version 13 and higher, you need to use .pkg - AmneziaVPN_${VERSION}_macos.pkg
|
||||
* ***The app version for macOS 10.15 - 12, is temporarily unavailable***
|
||||
|
||||
### Linux
|
||||
For Ubuntu you need to install xcb plugin:
|
||||
apt install libxcb-cursor0 libxcb-xinerama0 libxcb-icccm4 libxcb-keysyms1 libopengl0 libxkbcommon-x11-0
|
||||
|
||||
## Changelog
|
||||
|
||||
### General
|
||||
* Improve stability
|
||||
|
||||
**Full Changelog**: https://github.com/amnezia-vpn/amnezia-client/compare/${PREVIOUS_TAG}...${VERSION}
|
||||
+60
-228
@@ -4,8 +4,6 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+.[0-9]+'
|
||||
|
||||
env:
|
||||
QT_MIRROR: https://mirrors.ocf.berkeley.edu/qt/ # https://download.qt.io/static/mirrorlist/
|
||||
@@ -73,12 +71,12 @@ jobs:
|
||||
env:
|
||||
QT_VERSION: 6.10.1
|
||||
QIF_VERSION: 4.7
|
||||
PROD_AGW_PUBLIC_KEY_B64: ${{ secrets.PROD_AGW_PUBLIC_KEY_B64 }}
|
||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||
PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }}
|
||||
FALLBACK_S3_ENDPOINT: ${{ secrets.FALLBACK_S3_ENDPOINT }}
|
||||
SANDBOX_AGW_PUBLIC_KEY_B64: ${{ secrets.SANDBOX_AGW_PUBLIC_KEY_B64 }}
|
||||
SANDBOX_AGW_ENDPOINT: ${{ secrets.SANDBOX_AGW_ENDPOINT }}
|
||||
SANDBOX_S3_ENDPOINT: ${{ secrets.SANDBOX_S3_ENDPOINT }}
|
||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
||||
DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }}
|
||||
DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }}
|
||||
FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }}
|
||||
PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }}
|
||||
|
||||
@@ -188,12 +186,12 @@ jobs:
|
||||
env:
|
||||
QT_VERSION: 6.10.1
|
||||
QIF_VERSION: 4.7
|
||||
PROD_AGW_PUBLIC_KEY_B64: ${{ secrets.PROD_AGW_PUBLIC_KEY_B64 }}
|
||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||
PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }}
|
||||
FALLBACK_S3_ENDPOINT: ${{ secrets.FALLBACK_S3_ENDPOINT }}
|
||||
SANDBOX_AGW_PUBLIC_KEY_B64: ${{ secrets.SANDBOX_AGW_PUBLIC_KEY_B64 }}
|
||||
SANDBOX_AGW_ENDPOINT: ${{ secrets.SANDBOX_AGW_ENDPOINT }}
|
||||
SANDBOX_S3_ENDPOINT: ${{ secrets.SANDBOX_S3_ENDPOINT }}
|
||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
||||
DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }}
|
||||
DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }}
|
||||
FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }}
|
||||
PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }}
|
||||
|
||||
@@ -335,12 +333,12 @@ jobs:
|
||||
QT_VERSION: 6.10.1
|
||||
KEYCHAIN_PASSWORD: ""
|
||||
|
||||
PROD_AGW_PUBLIC_KEY_B64: ${{ secrets.PROD_AGW_PUBLIC_KEY_B64 }}
|
||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||
PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }}
|
||||
FALLBACK_S3_ENDPOINT: ${{ secrets.FALLBACK_S3_ENDPOINT }}
|
||||
SANDBOX_AGW_PUBLIC_KEY_B64: ${{ secrets.SANDBOX_AGW_PUBLIC_KEY_B64 }}
|
||||
SANDBOX_AGW_ENDPOINT: ${{ secrets.SANDBOX_AGW_ENDPOINT }}
|
||||
SANDBOX_S3_ENDPOINT: ${{ secrets.SANDBOX_S3_ENDPOINT }}
|
||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
||||
DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }}
|
||||
DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }}
|
||||
FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }}
|
||||
PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }}
|
||||
|
||||
@@ -377,7 +375,7 @@ jobs:
|
||||
- name: 'Setup xcode'
|
||||
uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: '26.4'
|
||||
xcode-version: '26.0'
|
||||
|
||||
- name: 'Install desktop Qt'
|
||||
uses: jurplel/install-qt-action@v3
|
||||
@@ -417,24 +415,12 @@ jobs:
|
||||
APPSTORE_CONNECT_KEY_ID: ${{ secrets.APPSTORE_CONNECT_KEY_ID }}
|
||||
APPSTORE_CONNECT_ISSUER_ID: ${{ secrets.APPSTORE_CONNECT_ISSUER_ID }}
|
||||
APPSTORE_CONNECT_PRIVATE_KEY: ${{ secrets.APPSTORE_CONNECT_PRIVATE_KEY }}
|
||||
CONFIGURE_ONLY: ${{ startsWith(github.ref, 'refs/tags/') && 'true' || '' }}
|
||||
shell: bash
|
||||
run: |
|
||||
sh deploy/build.sh -t ios | sed -f deploy/hide_secrets.sed
|
||||
|
||||
- name: 'Archive for App Store'
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
working-directory: deploy
|
||||
shell: bash
|
||||
run: fastlane ios archive 2>&1 | sed -f hide_secrets.sed
|
||||
|
||||
- name: 'Upload App Store package'
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
path: deploy/build/ios/AmneziaVPN.ipa
|
||||
archive: false
|
||||
retention-days: 7
|
||||
sh deploy/build.sh -t ios | \
|
||||
sed -e '/-Xcc -DPROD_AGW_PUBLIC_KEY/,/-Xcc/ { /-Xcc/!d; }' -e '/-Xcc -DPROD_AGW_PUBLIC_KEY/d' | \
|
||||
sed -e '/-Xcc -DDEV_AGW_PUBLIC_KEY/,/-Xcc/ { /-Xcc/!d; }' -e '/-Xcc -DDEV_AGW_PUBLIC_KEY/d' | \
|
||||
sed -e '/-DPROD_AGW_PUBLIC_KEY/,/-D/ { /-D/!d; }' -e '/-DPROD_AGW_PUBLIC_KEY/d' | \
|
||||
sed -e '/-DDEV_AGW_PUBLIC_KEY/,/-D/ { /-D/!d; }' -e '/-DDEV_AGW_PUBLIC_KEY/d'
|
||||
|
||||
# ------------------------------------------------------
|
||||
|
||||
@@ -495,12 +481,12 @@ jobs:
|
||||
QT_VERSION: 6.10.1
|
||||
KEYCHAIN_PASSWORD: ""
|
||||
|
||||
PROD_AGW_PUBLIC_KEY_B64: ${{ secrets.PROD_AGW_PUBLIC_KEY_B64 }}
|
||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||
PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }}
|
||||
FALLBACK_S3_ENDPOINT: ${{ secrets.FALLBACK_S3_ENDPOINT }}
|
||||
SANDBOX_AGW_PUBLIC_KEY_B64: ${{ secrets.SANDBOX_AGW_PUBLIC_KEY_B64 }}
|
||||
SANDBOX_AGW_ENDPOINT: ${{ secrets.SANDBOX_AGW_ENDPOINT }}
|
||||
SANDBOX_S3_ENDPOINT: ${{ secrets.SANDBOX_S3_ENDPOINT }}
|
||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
||||
DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }}
|
||||
DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }}
|
||||
FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }}
|
||||
PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }}
|
||||
|
||||
@@ -643,14 +629,19 @@ jobs:
|
||||
|
||||
env:
|
||||
QT_VERSION: 6.10.1
|
||||
KEYCHAIN_PASSWORD: ""
|
||||
|
||||
PROD_AGW_PUBLIC_KEY_B64: ${{ secrets.PROD_AGW_PUBLIC_KEY_B64 }}
|
||||
MAC_TEAM_ID: ${{ secrets.MAC_TEAM_ID }}
|
||||
|
||||
MAC_APP_CERT_CERT: ${{ secrets.MAC_APP_CERT_CERT }}
|
||||
MAC_SIGNER_ID: ${{ secrets.MAC_SIGNER_ID }}
|
||||
MAC_APP_CERT_PW: ${{ secrets.MAC_APP_CERT_PW }}
|
||||
|
||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||
PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }}
|
||||
FALLBACK_S3_ENDPOINT: ${{ secrets.FALLBACK_S3_ENDPOINT }}
|
||||
SANDBOX_AGW_PUBLIC_KEY_B64: ${{ secrets.SANDBOX_AGW_PUBLIC_KEY_B64 }}
|
||||
SANDBOX_AGW_ENDPOINT: ${{ secrets.SANDBOX_AGW_ENDPOINT }}
|
||||
SANDBOX_S3_ENDPOINT: ${{ secrets.SANDBOX_S3_ENDPOINT }}
|
||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
||||
DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }}
|
||||
DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }}
|
||||
FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }}
|
||||
PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }}
|
||||
|
||||
@@ -661,37 +652,13 @@ jobs:
|
||||
submodules: 'true'
|
||||
fetch-depth: 10
|
||||
|
||||
- uses: ./.github/actions/apple-setup-keychain
|
||||
id: setup-keychain
|
||||
- uses: ./.github/actions/apple-setup-provisioning-profile
|
||||
with:
|
||||
keychain-password: ${{ env.KEYCHAIN_PASSWORD }}
|
||||
provisioning_profile_base64: ${{ secrets.MAC_APP_PROVISIONING_PROFILE }}
|
||||
|
||||
- name: 'Install signing certificate'
|
||||
uses: ./.github/actions/apple-install-cert
|
||||
- uses: ./.github/actions/apple-setup-provisioning-profile
|
||||
with:
|
||||
keychain-path: ${{ steps.setup-keychain.outputs.keychain-path }}
|
||||
keychain-password: ${{ env.KEYCHAIN_PASSWORD }}
|
||||
cert-base64: ${{ secrets.IOS_SIGNING_CERT_BASE64 }}
|
||||
cert-password: ${{ secrets.IOS_SIGNING_CERT_PASSWORD }}
|
||||
|
||||
- name: 'Install installer certificate'
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: ./.github/actions/apple-install-cert
|
||||
with:
|
||||
keychain-path: ${{ steps.setup-keychain.outputs.keychain-path }}
|
||||
keychain-password: ${{ env.KEYCHAIN_PASSWORD }}
|
||||
cert-base64: ${{ secrets.MAC_APPSTORE_INSTALLER_CERT_BASE64 }}
|
||||
cert-password: ${{ secrets.MAC_APPSTORE_INSTALLER_CERT_PASSWORD }}
|
||||
|
||||
- name: 'Install app provisioning profile'
|
||||
uses: ./.github/actions/apple-setup-provisioning-profile
|
||||
with:
|
||||
provisioning_profile_base64: ${{ secrets.APPSTORE_CONNECT_MAC_PROVISIONING }}
|
||||
|
||||
- name: 'Install NE provisioning profile'
|
||||
uses: ./.github/actions/apple-setup-provisioning-profile
|
||||
with:
|
||||
provisioning_profile_base64: ${{ secrets.APPSTORE_CONNECT_MAC_NE_PROVISIONING }}
|
||||
provisioning_profile_base64: ${{ secrets.MAC_NE_PROVISIONING_PROFILE }}
|
||||
|
||||
- name: 'Setup xcode'
|
||||
uses: maxim-lobanov/setup-xcode@v1
|
||||
@@ -710,6 +677,18 @@ jobs:
|
||||
set-env: 'true'
|
||||
extra: '--base ${{ env.QT_MIRROR }}'
|
||||
|
||||
- name: 'Install go'
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24'
|
||||
cache: false
|
||||
|
||||
- name: 'Setup gomobile'
|
||||
run: |
|
||||
export PATH=$PATH:~/go/bin
|
||||
go install golang.org/x/mobile/cmd/gomobile@latest
|
||||
gomobile init
|
||||
|
||||
- name: 'Setup python'
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
@@ -719,32 +698,15 @@ jobs:
|
||||
run: pip install "conan==2.28.0"
|
||||
|
||||
- name: 'Build project'
|
||||
env:
|
||||
QT_INSTALL_DIR: ${{ runner.temp }}
|
||||
CONFIGURE_ONLY: ${{ startsWith(github.ref, 'refs/tags/') && 'true' || '' }}
|
||||
shell: bash
|
||||
run: deploy/build.sh -t macos-ne | sed -f deploy/hide_secrets.sed
|
||||
run: |
|
||||
export QT_BIN_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/macos/bin"
|
||||
bash deploy/build_macos_ne.sh
|
||||
|
||||
- name: 'Upload unpacked artifact'
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: AmneziaVPN_MacOS_unpacked
|
||||
path: deploy/build/client/Release/AmneziaVPN.app
|
||||
retention-days: 7
|
||||
|
||||
- name: 'Archive for App Store'
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
working-directory: deploy
|
||||
shell: bash
|
||||
run: fastlane mac archive 2>&1 | sed -f hide_secrets.sed
|
||||
|
||||
- name: 'Upload App Store package'
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
path: deploy/build/osx/AmneziaVPN.pkg
|
||||
archive: false
|
||||
path: deploy/build/client/AmneziaVPN.app
|
||||
retention-days: 7
|
||||
|
||||
# ------------------------------------------------------
|
||||
@@ -840,14 +802,12 @@ jobs:
|
||||
APP_ANDROID_MIN_SDK: ${{ matrix.min_sdk }}
|
||||
APP_ANDROID_MAX_SDK: ${{ matrix.max_sdk }}
|
||||
APP_ANDROID_VERSION_CODE_OFFSET: ${{ matrix.version_code_offset }}
|
||||
CMAKE_C_COMPILER_LAUNCHER: ccache
|
||||
CMAKE_CXX_COMPILER_LAUNCHER: ccache
|
||||
PROD_AGW_PUBLIC_KEY_B64: ${{ secrets.PROD_AGW_PUBLIC_KEY_B64 }}
|
||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||
PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }}
|
||||
FALLBACK_S3_ENDPOINT: ${{ secrets.FALLBACK_S3_ENDPOINT }}
|
||||
SANDBOX_AGW_PUBLIC_KEY_B64: ${{ secrets.SANDBOX_AGW_PUBLIC_KEY_B64 }}
|
||||
SANDBOX_AGW_ENDPOINT: ${{ secrets.SANDBOX_AGW_ENDPOINT }}
|
||||
SANDBOX_S3_ENDPOINT: ${{ secrets.SANDBOX_S3_ENDPOINT }}
|
||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
||||
DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }}
|
||||
DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }}
|
||||
FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }}
|
||||
PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }}
|
||||
|
||||
@@ -936,12 +896,6 @@ jobs:
|
||||
- name: 'Install conan'
|
||||
run: pip install "conan==2.28.0"
|
||||
|
||||
- name: 'Setup ccache'
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: android-${{ matrix.label }}
|
||||
max-size: 1G
|
||||
|
||||
- name: 'Decode keystore secret to file'
|
||||
env:
|
||||
KEYSTORE_BASE64: ${{ secrets.ANDROID_RELEASE_KEYSTORE_BASE64 }}
|
||||
@@ -979,7 +933,8 @@ jobs:
|
||||
fi
|
||||
|
||||
for abi in arm64-v8a armeabi-v7a x86 x86_64; do
|
||||
mv deploy/build/client/android-build/build/outputs/apk/oss/release/*-${abi}-release.apk \
|
||||
deploy/build.sh -t android --sign --abi ${abi} --build ./deploy/build/${abi}
|
||||
mv deploy/build/${abi}/client/android-build/AmneziaVPN.apk \
|
||||
$OUT/AmneziaVPN_${VERSION}_${LABEL}_${abi}.apk
|
||||
done
|
||||
|
||||
@@ -998,9 +953,9 @@ jobs:
|
||||
OUT=deploy/artifacts
|
||||
VERSION=$(grep CMAKE_PROJECT_VERSION:STATIC deploy/build/CMakeCache.txt | cut -d= -f2)
|
||||
|
||||
deploy/build.sh -t android --sign --aab --play
|
||||
deploy/build.sh -t android --sign --aab --play --build ./deploy/build/play
|
||||
|
||||
mv deploy/build/client/android-build/build/outputs/bundle/playRelease/android-build-play-release.aab \
|
||||
mv deploy/build/play/client/android-build/build/outputs/bundle/playRelease/android-build-play-release.aab \
|
||||
$OUT/AmneziaVPN_${VERSION}_${LABEL}_play.aab
|
||||
|
||||
- name: 'Upload universal APK'
|
||||
@@ -1692,126 +1647,3 @@ jobs:
|
||||
disable-animations: true
|
||||
script: bash ci_run_android_tests.sh
|
||||
|
||||
# ------------------------------------------------------
|
||||
|
||||
Pre-Release:
|
||||
if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/') && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'skipped') }}
|
||||
needs: [Build-Linux-Ubuntu, Build-Windows, Build-iOS, Build-MacOS, Build-MacOS-NE, Build-Android]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: 'Get release notes template'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: .github/release-notes.md
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: 'Download Android APKs'
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
pattern: 'AmneziaVPN_*_{android11+,android9-10}_{arm64-v8a,armeabi-v7a,x86,x86_64}.apk'
|
||||
path: dist
|
||||
merge-multiple: true
|
||||
|
||||
- name: 'Download desktop installers'
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
pattern: 'AmneziaVPN_*_{linux_x64.run,macos_x64.pkg}'
|
||||
path: dist
|
||||
merge-multiple: true
|
||||
|
||||
- name: 'Publish pre-release'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
run: |
|
||||
ls -l dist
|
||||
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
|
||||
gh release upload "$TAG" dist/* --repo "$GITHUB_REPOSITORY" --clobber
|
||||
else
|
||||
export VERSION="$TAG"
|
||||
export PREVIOUS_TAG=$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName -q .tagName)
|
||||
envsubst '$VERSION $PREVIOUS_TAG' < .github/release-notes.md > release-notes.md
|
||||
|
||||
gh release create "$TAG" dist/* --repo "$GITHUB_REPOSITORY" \
|
||||
--title "$TAG" --notes-file release-notes.md --draft --prerelease --verify-tag
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------
|
||||
|
||||
TestFlight:
|
||||
if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/') && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'skipped') }}
|
||||
needs: [Build-Linux-Ubuntu, Build-Windows, Build-iOS, Build-MacOS, Build-MacOS-NE, Build-Android]
|
||||
runs-on: macos-26
|
||||
|
||||
env:
|
||||
APPSTORE_CONNECT_KEY_ID: ${{ secrets.APPSTORE_CONNECT_KEY_ID }}
|
||||
APPSTORE_CONNECT_ISSUER_ID: ${{ secrets.APPSTORE_CONNECT_ISSUER_ID }}
|
||||
APPSTORE_CONNECT_PRIVATE_KEY: ${{ secrets.APPSTORE_CONNECT_PRIVATE_KEY }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: deploy
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- name: 'Get fastlane config'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
deploy/fastlane
|
||||
deploy/hide_secrets.sed
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: 'Download iOS package'
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: AmneziaVPN.ipa
|
||||
path: deploy/build/ios
|
||||
|
||||
- name: 'Download macOS package'
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: AmneziaVPN.pkg
|
||||
path: deploy/build/osx
|
||||
|
||||
- name: 'Upload iOS build to TestFlight'
|
||||
run: fastlane ios testflight_upload 2>&1 | sed -f hide_secrets.sed
|
||||
|
||||
- name: 'Upload macOS build to TestFlight'
|
||||
run: fastlane mac testflight_upload 2>&1 | sed -f hide_secrets.sed
|
||||
|
||||
# ------------------------------------------------------
|
||||
|
||||
Google-Play:
|
||||
if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/') && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'skipped') }}
|
||||
needs: [Build-Linux-Ubuntu, Build-Windows, Build-iOS, Build-MacOS, Build-MacOS-NE, Build-Android]
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: deploy
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- name: 'Get fastlane config'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
deploy/fastlane
|
||||
deploy/hide_secrets.sed
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: 'Download Play AABs'
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
pattern: 'AmneziaVPN_*_play.aab'
|
||||
path: deploy/build/android
|
||||
merge-multiple: true
|
||||
|
||||
- name: 'Upload to Google Play beta'
|
||||
env:
|
||||
GOOGLE_PLAY_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
|
||||
run: fastlane android play_upload 2>&1 | sed -f hide_secrets.sed
|
||||
@@ -15,12 +15,12 @@ jobs:
|
||||
env:
|
||||
QT_VERSION: 6.4.1
|
||||
QIF_VERSION: 4.5
|
||||
PROD_AGW_PUBLIC_KEY_B64: ${{ secrets.PROD_AGW_PUBLIC_KEY_B64 }}
|
||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||
PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }}
|
||||
FALLBACK_S3_ENDPOINT: ${{ secrets.FALLBACK_S3_ENDPOINT }}
|
||||
SANDBOX_AGW_PUBLIC_KEY_B64: ${{ secrets.SANDBOX_AGW_PUBLIC_KEY_B64 }}
|
||||
SANDBOX_AGW_ENDPOINT: ${{ secrets.SANDBOX_AGW_ENDPOINT }}
|
||||
SANDBOX_S3_ENDPOINT: ${{ secrets.SANDBOX_S3_ENDPOINT }}
|
||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
||||
DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }}
|
||||
DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }}
|
||||
FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }}
|
||||
PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }}
|
||||
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(PROJECT AmneziaVPN)
|
||||
if(NOT AMNEZIAVPN_VERSION)
|
||||
set(AMNEZIAVPN_VERSION 5.1.1.7 CACHE STRING "Client app version")
|
||||
set(AMNEZIAVPN_VERSION 5.1.0.6 CACHE STRING "Client app version")
|
||||
endif()
|
||||
|
||||
set(QT_CREATOR_SKIP_PACKAGE_MANAGER_SETUP ON CACHE BOOL "" FORCE)
|
||||
@@ -34,7 +34,7 @@ set(RELEASE_DATE "${CURRENT_DATE}")
|
||||
set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
|
||||
|
||||
# bump by 2 on every release, because we're releasing two versions on the play store
|
||||
set(APP_ANDROID_VERSION_CODE 2192)
|
||||
set(APP_ANDROID_VERSION_CODE 2190)
|
||||
if(DEFINED APP_ANDROID_VERSION_CODE_OFFSET)
|
||||
math(EXPR APP_ANDROID_VERSION_CODE "${APP_ANDROID_VERSION_CODE} + ${APP_ANDROID_VERSION_CODE_OFFSET}")
|
||||
endif()
|
||||
|
||||
@@ -25,13 +25,13 @@ execute_process(
|
||||
|
||||
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
|
||||
|
||||
add_definitions(-DPROD_AGW_PUBLIC_KEY_B64="$ENV{PROD_AGW_PUBLIC_KEY_B64}")
|
||||
add_definitions(-DPROD_AGW_PUBLIC_KEY="$ENV{PROD_AGW_PUBLIC_KEY}")
|
||||
add_definitions(-DPROD_S3_ENDPOINT="$ENV{PROD_S3_ENDPOINT}")
|
||||
add_definitions(-DFALLBACK_S3_ENDPOINT="$ENV{FALLBACK_S3_ENDPOINT}")
|
||||
|
||||
add_definitions(-DSANDBOX_AGW_PUBLIC_KEY_B64="$ENV{SANDBOX_AGW_PUBLIC_KEY_B64}")
|
||||
add_definitions(-DSANDBOX_AGW_ENDPOINT="$ENV{SANDBOX_AGW_ENDPOINT}")
|
||||
add_definitions(-DSANDBOX_S3_ENDPOINT="$ENV{SANDBOX_S3_ENDPOINT}")
|
||||
add_definitions(-DDEV_AGW_PUBLIC_KEY="$ENV{DEV_AGW_PUBLIC_KEY}")
|
||||
add_definitions(-DDEV_AGW_ENDPOINT="$ENV{DEV_AGW_ENDPOINT}")
|
||||
add_definitions(-DDEV_S3_ENDPOINT="$ENV{DEV_S3_ENDPOINT}")
|
||||
|
||||
add_definitions(-DFREE_V2_ENDPOINT="$ENV{FREE_V2_ENDPOINT}")
|
||||
add_definitions(-DPREM_V1_ENDPOINT="$ENV{PREM_V1_ENDPOINT}")
|
||||
|
||||
@@ -54,7 +54,6 @@ android {
|
||||
storePassword = providers.environmentVariable("QT_ANDROID_KEYSTORE_STORE_PASS").orNull
|
||||
keyAlias = providers.environmentVariable("QT_ANDROID_KEYSTORE_ALIAS").orNull
|
||||
keyPassword = providers.environmentVariable("QT_ANDROID_KEYSTORE_STORE_PASS").orNull
|
||||
enableV3Signing = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +111,7 @@ android {
|
||||
isEnable = abiList.size > 1
|
||||
reset()
|
||||
include(*abiList.toTypedArray())
|
||||
isUniversalApk = true
|
||||
isUniversalApk = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +122,7 @@ android {
|
||||
outputs.map { it as BaseVariantOutputImpl }
|
||||
.forEach { output ->
|
||||
if (output.outputFileName.endsWith(".apk")) {
|
||||
output.outputFileName = listOfNotNull(outputBaseName, output.getFilter("ABI"), buildType.name)
|
||||
.joinToString("-", postfix = ".apk")
|
||||
output.outputFileName = "$outputBaseName-${buildType.name}.apk"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,15 +143,14 @@ android {
|
||||
val base = outputBaseName.ifEmpty { "android-build" }
|
||||
val unsignedSuffix = if (buildTypeName == "release") "-unsigned" else ""
|
||||
|
||||
val universalOutput = outputs.map { it as BaseVariantOutputImpl }.first { it.getFilter("ABI") == null }
|
||||
|
||||
packageApplicationProvider.configure {
|
||||
doLast {
|
||||
val srcDir = layout.buildDirectory.dir("outputs/apk/oss/$buildTypeName").get().asFile
|
||||
val dstDir = layout.buildDirectory.dir("outputs/apk").get().asFile
|
||||
dstDir.mkdirs()
|
||||
File(srcDir, universalOutput.outputFileName)
|
||||
.copyTo(File(dstDir, "$base-$buildTypeName$unsignedSuffix.apk"), overwrite = true)
|
||||
srcDir.listFiles()?.filter { it.name.endsWith(".apk") }?.forEach { apk ->
|
||||
apk.copyTo(File(dstDir, "$base-$buildTypeName$unsignedSuffix.apk"), overwrite = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,9 @@ class Xray : Protocol() {
|
||||
|
||||
addRoute(InetNetwork("0.0.0.0", 0))
|
||||
addRoute(InetNetwork("2000::0", 3))
|
||||
config.getString("hostName").let {
|
||||
excludeRoute(InetNetwork(it, 32))
|
||||
}
|
||||
|
||||
config.optString("mtu").let {
|
||||
if (it.isNotBlank()) setMtu(it.toInt())
|
||||
|
||||
@@ -32,14 +32,14 @@ endif()
|
||||
|
||||
# -- signing
|
||||
if(NOT CLIENT_IOS_PROVISIONING_PROFILE_SPECIFIER)
|
||||
set(CLIENT_IOS_PROVISIONING_PROFILE_SPECIFIER "distr ios.org.amnezia.amneziaVPN" CACHE STRING "iOS app provisioning profile specifier for release")
|
||||
set(CLIENT_IOS_PROVISIONING_PROFILE_SPECIFIER "distr ios.org.amnezia.AmneziaVPN" CACHE STRING "iOS app provisioning profile specifier for release")
|
||||
endif()
|
||||
if(NOT CLIENT_IOS_PROVISIONING_PROFILE_SPECIFIER_DEBUG)
|
||||
set(CLIENT_IOS_PROVISIONING_PROFILE_SPECIFIER_DEBUG "dev ios.org.amnezia.amneziaVPN" CACHE STRING "iOS app provisioning profile specifier for debug")
|
||||
set(CLIENT_IOS_PROVISIONING_PROFILE_SPECIFIER_DEBUG "dev ios.org.amnezia.AmneziaVPN" CACHE STRING "iOS app provisioning profile specifier for debug")
|
||||
endif()
|
||||
if(NOT CLIENT_IOS_NE_PROVISIONING_PROFILE_SPECIFIER)
|
||||
set(CLIENT_IOS_NE_PROVISIONING_PROFILE_SPECIFIER "distr ios.org.amnezia.amneziaVPN.NE" CACHE STRING "iOS network extension provisioning profile specifier for release")
|
||||
set(CLIENT_IOS_NE_PROVISIONING_PROFILE_SPECIFIER "distr ios.org.amnezia.AmneziaVPN" CACHE STRING "iOS network extension provisioning profile specifier for release")
|
||||
endif()
|
||||
if(NOT CLIENT_IOS_NE_PROVISIONING_PROFILE_SPECIFIER_DEBUG)
|
||||
set(CLIENT_IOS_NE_PROVISIONING_PROFILE_SPECIFIER_DEBUG "dev ios.org.amnezia.amneziaVPN.NE" CACHE STRING "iOS network extension provisioning profile specifier for debug")
|
||||
set(CLIENT_IOS_NE_PROVISIONING_PROFILE_SPECIFIER_DEBUG "dev ios.org.amnezia.AmneziaVPN" CACHE STRING "iOS network extension provisioning profile specifier for debug")
|
||||
endif()
|
||||
@@ -24,7 +24,7 @@ endif()
|
||||
|
||||
# -- signing
|
||||
if(NOT CLIENT_MACOS_PROVISIONING_PROFILE_SPECIFIER)
|
||||
set(CLIENT_MACOS_PROVISIONING_PROFILE_SPECIFIER "distr macos.org.amnezia.amneziaVPN" CACHE STRING "macOS app provisioning profile specifier for release")
|
||||
set(CLIENT_MACOS_PROVISIONING_PROFILE_SPECIFIER "distr macos.org.amnezia.AmneziaVPN" CACHE STRING "macOS app provisioning profile specifier for release")
|
||||
endif()
|
||||
if(NOT CLIENT_MACOS_PROVISIONING_PROFILE_SPECIFIER_DEBUG)
|
||||
set(CLIENT_MACOS_PROVISIONING_PROFILE_SPECIFIER_DEBUG "dev macos.org.amnezia.AmneziaVPN" CACHE STRING "macOS app provisioning profile specifier for debug")
|
||||
|
||||
@@ -156,12 +156,6 @@ message(${QtCore_location})
|
||||
|
||||
get_filename_component(QT_BIN_DIR_DETECTED "${QtCore_location}/../../../../../bin" ABSOLUTE)
|
||||
|
||||
set(MACDEPLOYQT_ARGS -appstore-compliant -qmldir=${CMAKE_CURRENT_SOURCE_DIR})
|
||||
if(Qt6_VERSION VERSION_GREATER_EQUAL 6.11)
|
||||
list(APPEND MACDEPLOYQT_ARGS -no-codesign)
|
||||
endif()
|
||||
|
||||
# $<TARGET_BUNDLE_DIR> points to the build tree; xcodebuild archive builds the bundle elsewhere
|
||||
add_custom_command(TARGET ${PROJECT} POST_BUILD
|
||||
COMMAND ${QT_BIN_DIR_DETECTED}/macdeployqt \${TARGET_BUILD_DIR}/\${WRAPPER_NAME} ${MACDEPLOYQT_ARGS}
|
||||
COMMAND ${QT_BIN_DIR_DETECTED}/macdeployqt $<TARGET_BUNDLE_DIR:${PROJECT}> -appstore-compliant -qmldir=${CMAKE_CURRENT_SOURCE_DIR} -no-codesign
|
||||
)
|
||||
@@ -38,6 +38,7 @@ set(HEADERS ${HEADERS}
|
||||
${CLIENT_ROOT_DIR}/core/installers/mtProxyInstaller.h
|
||||
${CLIENT_ROOT_DIR}/core/installers/telemtInstaller.h
|
||||
${CLIENT_ROOT_DIR}/core/installers/tProxyInstaller.h
|
||||
${CLIENT_ROOT_DIR}/core/installers/whatsAppProxyInstaller.h
|
||||
${CLIENT_ROOT_DIR}/core/controllers/appSplitTunnelingController.h
|
||||
${CLIENT_ROOT_DIR}/core/controllers/ipSplitTunnelingController.h
|
||||
${CLIENT_ROOT_DIR}/core/controllers/allowedDnsController.h
|
||||
@@ -128,6 +129,7 @@ set(SOURCES ${SOURCES}
|
||||
${CLIENT_ROOT_DIR}/core/installers/mtProxyInstaller.cpp
|
||||
${CLIENT_ROOT_DIR}/core/installers/telemtInstaller.cpp
|
||||
${CLIENT_ROOT_DIR}/core/installers/tProxyInstaller.cpp
|
||||
${CLIENT_ROOT_DIR}/core/installers/whatsAppProxyInstaller.cpp
|
||||
${CLIENT_ROOT_DIR}/core/controllers/appSplitTunnelingController.cpp
|
||||
${CLIENT_ROOT_DIR}/core/controllers/ipSplitTunnelingController.cpp
|
||||
${CLIENT_ROOT_DIR}/core/controllers/allowedDnsController.cpp
|
||||
|
||||
@@ -66,8 +66,6 @@ ProtocolConfig AwgConfigurator::createConfig(const ServerCredentials &credential
|
||||
newClientConfig.nativeConfig = awgConfig;
|
||||
newClientConfig.hostName = wgConfig->clientConfig->hostName;
|
||||
newClientConfig.port = wgConfig->clientConfig->port;
|
||||
newClientConfig.cascadeEndpoint = wgConfig->clientConfig->cascadeEndpoint;
|
||||
newClientConfig.cascadePort = wgConfig->clientConfig->cascadePort;
|
||||
newClientConfig.clientIp = wgConfig->clientConfig->clientIp;
|
||||
newClientConfig.clientPrivateKey = wgConfig->clientConfig->clientPrivateKey;
|
||||
newClientConfig.clientPublicKey = wgConfig->clientConfig->clientPublicKey;
|
||||
|
||||
@@ -266,11 +266,6 @@ ProtocolConfig WireguardConfigurator::createConfig(const ServerCredentials &cred
|
||||
clientConfig.nativeConfig = config;
|
||||
clientConfig.hostName = connData.host;
|
||||
clientConfig.port = connData.port.toInt();
|
||||
if (wireguardServerConfig) {
|
||||
clientConfig.setCascade(wireguardServerConfig->cascadeEndpoint, wireguardServerConfig->cascadePort);
|
||||
} else if (awgServerConfig) {
|
||||
clientConfig.setCascade(awgServerConfig->cascadeEndpoint, awgServerConfig->cascadePort);
|
||||
}
|
||||
clientConfig.clientIp = connData.clientIP;
|
||||
clientConfig.clientPrivateKey = connData.clientPrivKey;
|
||||
clientConfig.clientPublicKey = connData.clientPubKey;
|
||||
|
||||
@@ -77,8 +77,11 @@ QFuture<QPair<ErrorCode, QJsonArray>> NewsController::fetchNews()
|
||||
}
|
||||
|
||||
QSharedPointer<GatewayController> gatewayController(
|
||||
new GatewayController(m_appSettingsRepository->gatewayEnvironment(), apiDefs::requestTimeoutMsecs,
|
||||
m_appSettingsRepository->isStrictKillSwitchEnabled(), m_appSettingsRepository),
|
||||
new GatewayController(m_appSettingsRepository->getGatewayEndpoint(),
|
||||
m_appSettingsRepository->isDevGatewayEnv(),
|
||||
apiDefs::requestTimeoutMsecs,
|
||||
m_appSettingsRepository->isStrictKillSwitchEnabled(),
|
||||
m_appSettingsRepository),
|
||||
&QObject::deleteLater);
|
||||
|
||||
// both country codes and service types are arrays here, one entry per gateway stack the user has
|
||||
|
||||
@@ -343,7 +343,7 @@ ErrorCode ServicesCatalogController::fillAvailableServices(QJsonObject &services
|
||||
|
||||
ErrorCode ServicesCatalogController::executeRequest(const QString &endpoint, const QJsonObject &apiPayload, QByteArray &responseBody)
|
||||
{
|
||||
GatewayController gatewayController(m_appSettingsRepository->gatewayEnvironment(), apiDefs::requestTimeoutMsecs,
|
||||
GatewayController gatewayController(m_appSettingsRepository->getGatewayEndpoint(), m_appSettingsRepository->isDevGatewayEnv(), apiDefs::requestTimeoutMsecs,
|
||||
m_appSettingsRepository->isStrictKillSwitchEnabled(), m_appSettingsRepository);
|
||||
return gatewayController.post(endpoint, apiPayload, responseBody);
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ StorePurchaseController::StorePurchaseController(SecureServersRepository *server
|
||||
ErrorCode StorePurchaseController::executeRequest(const QString &endpoint, const QJsonObject &apiPayload,
|
||||
QByteArray &responseBody, bool isTestPurchase)
|
||||
{
|
||||
GatewayController gatewayController(m_appSettingsRepository->gatewayEnvironment(isTestPurchase),
|
||||
apiDefs::requestTimeoutMsecs,
|
||||
GatewayController gatewayController(m_appSettingsRepository->getGatewayEndpoint(isTestPurchase),
|
||||
m_appSettingsRepository->isDevGatewayEnv(isTestPurchase), apiDefs::requestTimeoutMsecs,
|
||||
m_appSettingsRepository->isStrictKillSwitchEnabled(), m_appSettingsRepository);
|
||||
return gatewayController.post(endpoint, apiPayload, responseBody);
|
||||
}
|
||||
|
||||
@@ -196,8 +196,7 @@ void SubscriptionController::updateApiConfigInJson(QJsonObject &serverConfigJson
|
||||
|
||||
ErrorCode SubscriptionController::executeRequest(const QString &endpoint, const QJsonObject &apiPayload, QByteArray &responseBody, bool isTestPurchase)
|
||||
{
|
||||
GatewayController gatewayController(m_appSettingsRepository->gatewayEnvironment(isTestPurchase),
|
||||
apiDefs::requestTimeoutMsecs,
|
||||
GatewayController gatewayController(m_appSettingsRepository->getGatewayEndpoint(isTestPurchase), m_appSettingsRepository->isDevGatewayEnv(isTestPurchase), apiDefs::requestTimeoutMsecs,
|
||||
m_appSettingsRepository->isStrictKillSwitchEnabled(), m_appSettingsRepository);
|
||||
return gatewayController.post(endpoint, apiPayload, responseBody);
|
||||
}
|
||||
@@ -812,9 +811,11 @@ QFuture<QPair<ErrorCode, QString>> SubscriptionController::getRenewalLink(const
|
||||
.addField(apiDefs::key::subscriptionStatus, getSubscriptionStatusForRenewal(apiV2->apiConfig))
|
||||
.build();
|
||||
|
||||
auto gatewayController = QSharedPointer<GatewayController>::create(
|
||||
m_appSettingsRepository->gatewayEnvironment(isTestPurchase), apiDefs::requestTimeoutMsecs,
|
||||
m_appSettingsRepository->isStrictKillSwitchEnabled(), m_appSettingsRepository);
|
||||
auto gatewayController = QSharedPointer<GatewayController>::create(m_appSettingsRepository->getGatewayEndpoint(isTestPurchase),
|
||||
m_appSettingsRepository->isDevGatewayEnv(isTestPurchase),
|
||||
apiDefs::requestTimeoutMsecs,
|
||||
m_appSettingsRepository->isStrictKillSwitchEnabled(),
|
||||
m_appSettingsRepository);
|
||||
auto postFuture = gatewayController->postAsync(QString("%1v1/renewal_link"), apiPayload);
|
||||
auto *watcher = new QFutureWatcher<QPair<ErrorCode, QByteArray>>();
|
||||
QObject::connect(watcher, &QFutureWatcher<QPair<ErrorCode, QByteArray>>::finished,
|
||||
|
||||
@@ -289,15 +289,6 @@ QJsonObject ConnectionController::createConnectionConfiguration(const QPair<QStr
|
||||
ContainerUtils::isAwgContainer(container) ? protocols::awg::defaultMtu :
|
||||
protocols::wireguard::defaultMtu;
|
||||
}
|
||||
|
||||
const QString cascadeEndpoint = vpnConfigData.value(configKey::cascadeEndpoint).toString();
|
||||
if (!cascadeEndpoint.isEmpty()) {
|
||||
vpnConfigData[configKey::hostName] = cascadeEndpoint;
|
||||
}
|
||||
const QString cascadePort = vpnConfigData.value(configKey::cascadePort).toString();
|
||||
if (!cascadePort.isEmpty()) {
|
||||
vpnConfigData[configKey::port] = cascadePort.toInt();
|
||||
}
|
||||
}
|
||||
|
||||
vpnConfiguration.insert(ProtocolUtils::key_proto_config_data(proto), vpnConfigData);
|
||||
|
||||
@@ -120,6 +120,9 @@ void CoreController::initModels()
|
||||
m_tProxyConfigModel = new TProxyConfigModel(this);
|
||||
setQmlContextProperty("TProxyConfigModel", m_tProxyConfigModel);
|
||||
|
||||
m_whatsAppProxyConfigModel = new WhatsAppProxyConfigModel(this);
|
||||
setQmlContextProperty("WhatsAppProxyConfigModel", m_whatsAppProxyConfigModel);
|
||||
|
||||
m_clientManagementModel = new ClientManagementModel(this);
|
||||
setQmlContextProperty("ClientManagementModel", m_clientManagementModel);
|
||||
|
||||
@@ -197,7 +200,7 @@ void CoreController::initControllers()
|
||||
m_ikev2ConfigModel,
|
||||
#endif
|
||||
m_sftpConfigModel, m_socks5ConfigModel, m_mtProxyConfigModel, m_telemtConfigModel,
|
||||
m_tProxyConfigModel,
|
||||
m_tProxyConfigModel, m_whatsAppProxyConfigModel,
|
||||
m_connectionController, this);
|
||||
setQmlContextProperty("InstallController", m_installUiController);
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
#include "ui/models/services/mtProxyConfigModel.h"
|
||||
#include "ui/models/services/telemtConfigModel.h"
|
||||
#include "ui/models/services/tProxyConfigModel.h"
|
||||
#include "ui/models/services/whatsAppProxyConfigModel.h"
|
||||
|
||||
#include "ui/models/ipSplitTunnelingModel.h"
|
||||
#include "ui/models/newsModel.h"
|
||||
@@ -246,6 +247,7 @@ private:
|
||||
MtProxyConfigModel* m_mtProxyConfigModel;
|
||||
TelemtConfigModel* m_telemtConfigModel;
|
||||
TProxyConfigModel* m_tProxyConfigModel;
|
||||
WhatsAppProxyConfigModel* m_whatsAppProxyConfigModel;
|
||||
|
||||
CoreSignalHandlers* m_signalHandlers;
|
||||
};
|
||||
|
||||
@@ -56,9 +56,9 @@ namespace
|
||||
constexpr QLatin1String endpointListSeparator(", ");
|
||||
constexpr QLatin1String legacyEndpointPlaceholder("%1");
|
||||
|
||||
QStringList splitEndpoints(const QString &raw)
|
||||
QStringList splitEndpoints(const char *raw)
|
||||
{
|
||||
return raw.split(endpointListSeparator, Qt::SkipEmptyParts);
|
||||
return QString::fromUtf8(raw).split(endpointListSeparator, Qt::SkipEmptyParts);
|
||||
}
|
||||
|
||||
void logAgwTrace(const QString &path, const int code, const QString &trace)
|
||||
@@ -77,24 +77,32 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
GatewayController::GatewayController(const amnezia::GatewayEnvironment &environment, const int requestTimeoutMsecs,
|
||||
const bool isStrictKillSwitchEnabled,
|
||||
SecureAppSettingsRepository *appSettingsRepository, QObject *parent)
|
||||
GatewayController::GatewayController(const QString &gatewayEndpoint, const bool isDevEnvironment, const int requestTimeoutMsecs,
|
||||
const bool isStrictKillSwitchEnabled, SecureAppSettingsRepository *appSettingsRepository,
|
||||
QObject *parent)
|
||||
: QObject(parent),
|
||||
m_gatewayEndpoint(environment.endpoint),
|
||||
m_gatewayEndpoint(gatewayEndpoint),
|
||||
m_isStrictKillSwitchEnabled(isStrictKillSwitchEnabled),
|
||||
m_appSettingsRepository(appSettingsRepository)
|
||||
{
|
||||
m_publicKeyMissing = environment.publicKey.isEmpty();
|
||||
const QByteArray publicKey = isDevEnvironment ? QByteArray(DEV_AGW_PUBLIC_KEY) : QByteArray(PROD_AGW_PUBLIC_KEY);
|
||||
m_publicKeyMissing = publicKey.isEmpty();
|
||||
|
||||
QStringList primaryEndpoints;
|
||||
QStringList fallbackEndpoints;
|
||||
if (isDevEnvironment) {
|
||||
primaryEndpoints = splitEndpoints(DEV_S3_ENDPOINT);
|
||||
} else {
|
||||
primaryEndpoints = splitEndpoints(PROD_S3_ENDPOINT);
|
||||
fallbackEndpoints = splitEndpoints(FALLBACK_S3_ENDPOINT);
|
||||
}
|
||||
|
||||
QJsonObject config;
|
||||
config[agwConfigKey::gatewayEndpoint] = environment.endpoint;
|
||||
config[agwConfigKey::publicKeyPem] = QString::fromUtf8(environment.publicKey);
|
||||
config[agwConfigKey::s3PrimaryEndpoints] =
|
||||
QJsonArray::fromStringList(splitEndpoints(environment.primaryProxyStorages));
|
||||
config[agwConfigKey::s3FallbackEndpoints] =
|
||||
QJsonArray::fromStringList(splitEndpoints(environment.fallbackProxyStorages));
|
||||
config[agwConfigKey::isDevEnvironment] = environment.isDev;
|
||||
config[agwConfigKey::gatewayEndpoint] = gatewayEndpoint;
|
||||
config[agwConfigKey::publicKeyPem] = QString::fromUtf8(publicKey);
|
||||
config[agwConfigKey::s3PrimaryEndpoints] = QJsonArray::fromStringList(primaryEndpoints);
|
||||
config[agwConfigKey::s3FallbackEndpoints] = QJsonArray::fromStringList(fallbackEndpoints);
|
||||
config[agwConfigKey::isDevEnvironment] = isDevEnvironment;
|
||||
config[agwConfigKey::requestTimeoutMsecs] = requestTimeoutMsecs;
|
||||
config[agwConfigKey::proxyRequestTimeoutMsecs] = apiDefs::proxyRequestTimeoutMsecs;
|
||||
config[agwConfigKey::proxyStorageTimeoutMsecs] = apiDefs::proxyStorageTimeoutMsecs;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/utils/commonStructs.h"
|
||||
#include "core/utils/errorCodes.h"
|
||||
|
||||
#include "agw.h"
|
||||
@@ -21,7 +20,7 @@ class GatewayController : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GatewayController(const amnezia::GatewayEnvironment &environment, const int requestTimeoutMsecs,
|
||||
explicit GatewayController(const QString &gatewayEndpoint, const bool isDevEnvironment, const int requestTimeoutMsecs,
|
||||
const bool isStrictKillSwitchEnabled, SecureAppSettingsRepository *appSettingsRepository,
|
||||
QObject *parent = nullptr);
|
||||
~GatewayController() override;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "core/installers/mtProxyInstaller.h"
|
||||
#include "core/installers/telemtInstaller.h"
|
||||
#include "core/installers/tProxyInstaller.h"
|
||||
#include "core/installers/whatsAppProxyInstaller.h"
|
||||
#include "core/installers/torInstaller.h"
|
||||
#include "core/installers/wireguardInstaller.h"
|
||||
#include "core/installers/xrayInstaller.h"
|
||||
@@ -145,6 +146,7 @@ namespace
|
||||
return container == DockerContainer::MtProxy
|
||||
|| container == DockerContainer::Telemt
|
||||
|| container == DockerContainer::TProxy
|
||||
|| container == DockerContainer::WhatsAppProxy
|
||||
|| container == DockerContainer::Xray;
|
||||
}
|
||||
|
||||
@@ -315,6 +317,8 @@ ErrorCode InstallController::updateServerConfig(const QString &serverId, DockerC
|
||||
ServerCredentials credentials = adminConfig->credentials();
|
||||
SshSession sshSession;
|
||||
TProxyInstaller::uploadClientSettingsSnapshot(sshSession, credentials, container, newConfig);
|
||||
} else if (container == DockerContainer::WhatsAppProxy) {
|
||||
WhatsAppProxyInstaller::uploadClientSettingsSnapshot(sshSession, credentials, container, newConfig);
|
||||
}
|
||||
adminConfig->updateContainerConfig(container, newConfig);
|
||||
m_serversRepository->editServer(serverId, adminConfig->toJson(), serverConfigUtils::ConfigType::SelfHostedAdmin);
|
||||
@@ -372,6 +376,8 @@ ErrorCode InstallController::updateServerConfig(const QString &serverId, DockerC
|
||||
TelemtInstaller::uploadClientSettingsSnapshot(sshSession, credentials, container, newConfig);
|
||||
} else if (container == DockerContainer::TProxy) {
|
||||
TProxyInstaller::uploadClientSettingsSnapshot(sshSession, credentials, container, newConfig);
|
||||
} else if (container == DockerContainer::WhatsAppProxy) {
|
||||
WhatsAppProxyInstaller::uploadClientSettingsSnapshot(sshSession, credentials, container, newConfig);
|
||||
}
|
||||
if (reinstallRequired) {
|
||||
if (container != DockerContainer::Xray) {
|
||||
@@ -729,6 +735,8 @@ ErrorCode InstallController::configureContainerWorker(const ServerCredentials &c
|
||||
TelemtInstaller::uploadClientSettingsSnapshot(sshSession, credentials, container, config);
|
||||
} else if (container == DockerContainer::TProxy) {
|
||||
TProxyInstaller::uploadClientSettingsSnapshot(sshSession, credentials, container, config);
|
||||
} else if (container == DockerContainer::WhatsAppProxy) {
|
||||
WhatsAppProxyInstaller::uploadClientSettingsSnapshot(sshSession, credentials, container, config);
|
||||
}
|
||||
|
||||
return ErrorCode::NoError;
|
||||
@@ -910,6 +918,14 @@ ErrorCode InstallController::isServerPortBusy(const ServerCredentials &credentia
|
||||
}
|
||||
}
|
||||
}
|
||||
if (container == DockerContainer::WhatsAppProxy) {
|
||||
if (const auto *whatsAppProxyConfig = config.getWhatsAppProxyProtocolConfig()) {
|
||||
const QString mediaPort = whatsAppProxyConfig->effectiveMediaPort();
|
||||
if (!fixedPorts.contains(mediaPort) && mediaPort != port) {
|
||||
fixedPorts.append(mediaPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
QString transportProto = config.protocolConfig.transportProto();
|
||||
if (transportProto.isEmpty()) {
|
||||
transportProto = ProtocolUtils::transportProtoToString(ProtocolUtils::defaultTransportProto(protocol), protocol);
|
||||
@@ -1085,6 +1101,14 @@ bool InstallController::isReinstallContainerRequired(DockerContainer container,
|
||||
}
|
||||
}
|
||||
|
||||
if (container == DockerContainer::WhatsAppProxy) {
|
||||
const auto *oldW = oldConfig.getWhatsAppProxyProtocolConfig();
|
||||
const auto *newW = newConfig.getWhatsAppProxyProtocolConfig();
|
||||
if (oldW && newW && !oldW->equalsDockerDeploymentSettings(*newW)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (container == DockerContainer::Socks5Proxy) {
|
||||
return true;
|
||||
}
|
||||
@@ -1122,7 +1146,7 @@ ErrorCode InstallController::installDockerWorker(const ServerCredentials &creden
|
||||
qDebug().noquote() << "InstallController::installDockerWorker" << stdOut;
|
||||
|
||||
if (container == DockerContainer::MtProxy || container == DockerContainer::Telemt
|
||||
|| container == DockerContainer::TProxy) {
|
||||
|| container == DockerContainer::TProxy || container == DockerContainer::WhatsAppProxy) {
|
||||
QString conntrackOut;
|
||||
auto cbConntrack = [&](const QString &data, libssh::Client &) {
|
||||
conntrackOut += data + "\n";
|
||||
@@ -1422,6 +1446,7 @@ QScopedPointer<InstallerBase> InstallController::createInstaller(DockerContainer
|
||||
case DockerContainer::MtProxy: return QScopedPointer<InstallerBase>(new MtProxyInstaller(this));
|
||||
case DockerContainer::Telemt: return QScopedPointer<InstallerBase>(new TelemtInstaller(this));
|
||||
case DockerContainer::TProxy: return QScopedPointer<InstallerBase>(new TProxyInstaller(this));
|
||||
case DockerContainer::WhatsAppProxy: return QScopedPointer<InstallerBase>(new WhatsAppProxyInstaller(this));
|
||||
default: return QScopedPointer<InstallerBase>(new InstallerBase(this));
|
||||
}
|
||||
}
|
||||
@@ -1456,6 +1481,14 @@ ErrorCode InstallController::installContainer(const ServerCredentials &credentia
|
||||
return ErrorCode::InternalError;
|
||||
}
|
||||
}
|
||||
if (container == DockerContainer::WhatsAppProxy) {
|
||||
if (auto *whatsAppProxyConfig = config.getWhatsAppProxyProtocolConfig()) {
|
||||
if (!m_whatsAppProxyInstallMediaPort.isEmpty()) {
|
||||
whatsAppProxyConfig->mediaPort = m_whatsAppProxyInstallMediaPort;
|
||||
}
|
||||
}
|
||||
m_whatsAppProxyInstallMediaPort.clear();
|
||||
}
|
||||
return setupContainer(credentials, container, config, false);
|
||||
}
|
||||
|
||||
@@ -1465,6 +1498,11 @@ void InstallController::setTProxyInstallHints(const QString &hostname, const QSt
|
||||
m_tproxyInstallEmail = email;
|
||||
}
|
||||
|
||||
void InstallController::setWhatsAppProxyInstallHints(const QString &mediaPort)
|
||||
{
|
||||
m_whatsAppProxyInstallMediaPort = mediaPort;
|
||||
}
|
||||
|
||||
|
||||
bool InstallController::isUpdateDockerContainerRequired(DockerContainer container, const ContainerConfig &oldConfig, const ContainerConfig &newConfig)
|
||||
{
|
||||
@@ -1514,6 +1552,13 @@ bool InstallController::isUpdateDockerContainerRequired(DockerContainer containe
|
||||
return true;
|
||||
}
|
||||
return !oldP->equalsDockerDeploymentSettings(*newP);
|
||||
} else if (container == DockerContainer::WhatsAppProxy) {
|
||||
const auto *oldW = oldConfig.getWhatsAppProxyProtocolConfig();
|
||||
const auto *newW = newConfig.getWhatsAppProxyProtocolConfig();
|
||||
if (!oldW || !newW) {
|
||||
return true;
|
||||
}
|
||||
return !oldW->equalsDockerDeploymentSettings(*newW);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1945,6 +1990,11 @@ ErrorCode InstallController::getAlreadyInstalledContainers(const ServerCredentia
|
||||
TProxyInstaller::applyDockerPublishedPorts(containerInfo, *tProxyConfig);
|
||||
}
|
||||
}
|
||||
if (container == DockerContainer::WhatsAppProxy) {
|
||||
if (auto *whatsAppProxyConfig = config.getWhatsAppProxyProtocolConfig()) {
|
||||
WhatsAppProxyInstaller::applyDockerPublishedPorts(containerInfo, *whatsAppProxyConfig);
|
||||
}
|
||||
}
|
||||
ErrorCode extractError = installer->extractConfigFromContainer(container, credentials, &sshSession, config);
|
||||
|
||||
if (extractError != ErrorCode::NoError && extractError != ErrorCode::ServerContainerMissingError) {
|
||||
@@ -1975,6 +2025,11 @@ ErrorCode InstallController::getAlreadyInstalledContainers(const ServerCredentia
|
||||
TProxyInstaller::applyDockerPublishedPorts(containerInfo, *tProxyConfig);
|
||||
}
|
||||
}
|
||||
if (container == DockerContainer::WhatsAppProxy) {
|
||||
if (auto *whatsAppProxyConfig = config.getWhatsAppProxyProtocolConfig()) {
|
||||
WhatsAppProxyInstaller::applyDockerPublishedPorts(containerInfo, *whatsAppProxyConfig);
|
||||
}
|
||||
}
|
||||
ErrorCode extractError = installer->extractConfigFromContainer(container, credentials, &sshSession, config);
|
||||
|
||||
if (extractError != ErrorCode::NoError && extractError != ErrorCode::ServerContainerMissingError) {
|
||||
@@ -1991,7 +2046,7 @@ ErrorCode InstallController::getAlreadyInstalledContainers(const ServerCredentia
|
||||
ErrorCode InstallController::setDockerContainerEnabledState(const QString &serverId, DockerContainer container, bool enabled)
|
||||
{
|
||||
if (container != DockerContainer::MtProxy && container != DockerContainer::Telemt
|
||||
&& container != DockerContainer::TProxy) {
|
||||
&& container != DockerContainer::TProxy && container != DockerContainer::WhatsAppProxy) {
|
||||
return ErrorCode::InternalError;
|
||||
}
|
||||
auto adminConfig = m_serversRepository->selfHostedAdminConfig(serverId);
|
||||
@@ -2021,6 +2076,9 @@ ErrorCode InstallController::setDockerContainerEnabledState(const QString &serve
|
||||
} else if (auto *tProxyConfig = currentConfig.getTProxyProtocolConfig()) {
|
||||
tProxyConfig->isEnabled = enabled;
|
||||
persist = true;
|
||||
} else if (auto *whatsAppProxyConfig = currentConfig.getWhatsAppProxyProtocolConfig()) {
|
||||
whatsAppProxyConfig->isEnabled = enabled;
|
||||
persist = true;
|
||||
}
|
||||
if (persist) {
|
||||
adminConfig->updateContainerConfig(container, currentConfig);
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
QString fetchDockerContainerSecret(const QString &serverId, DockerContainer container);
|
||||
|
||||
void setTProxyInstallHints(const QString &hostname, const QString &email);
|
||||
void setWhatsAppProxyInstallHints(const QString &mediaPort);
|
||||
|
||||
ContainerConfig generateConfig(DockerContainer container, int port, TransportProto transportProto);
|
||||
ErrorCode getAlreadyInstalledContainers(const ServerCredentials &credentials, QMap<DockerContainer, ContainerConfig> &installedContainers, SshSession &sshSession);
|
||||
@@ -136,6 +137,7 @@ private:
|
||||
bool m_cancelInstallation = false;
|
||||
QString m_tproxyInstallHostname;
|
||||
QString m_tproxyInstallEmail;
|
||||
QString m_whatsAppProxyInstallMediaPort;
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
QList<QSharedPointer<QProcess>> m_sftpMountProcesses;
|
||||
|
||||
@@ -300,25 +300,19 @@ bool SettingsController::isDevModeEnabled() const
|
||||
return m_isDevModeEnabled;
|
||||
}
|
||||
|
||||
QString SettingsController::devGatewayEndpoint() const
|
||||
void SettingsController::resetGatewayEndpoint()
|
||||
{
|
||||
return m_appSettingsRepository->devGatewayEndpoint();
|
||||
m_appSettingsRepository->resetGatewayEndpoint();
|
||||
}
|
||||
|
||||
QString SettingsController::devGatewayProxyStorages() const
|
||||
void SettingsController::setGatewayEndpoint(const QString &endpoint)
|
||||
{
|
||||
return m_appSettingsRepository->devGatewayProxyStorages();
|
||||
m_appSettingsRepository->setGatewayEndpoint(endpoint);
|
||||
}
|
||||
|
||||
QString SettingsController::devGatewayPublicKey() const
|
||||
QString SettingsController::getGatewayEndpoint() const
|
||||
{
|
||||
return m_appSettingsRepository->devGatewayPublicKey();
|
||||
}
|
||||
|
||||
void SettingsController::setDevGatewayConfig(const QString &endpoint, const QString &proxyStorages,
|
||||
const QString &publicKey)
|
||||
{
|
||||
m_appSettingsRepository->setDevGatewayConfig(endpoint, proxyStorages, publicKey);
|
||||
return m_appSettingsRepository->isDevGatewayEnv() ? "Dev endpoint" : m_appSettingsRepository->getGatewayEndpoint();
|
||||
}
|
||||
|
||||
bool SettingsController::isDevGatewayEnv() const
|
||||
@@ -329,6 +323,11 @@ bool SettingsController::isDevGatewayEnv() const
|
||||
void SettingsController::toggleDevGatewayEnv(bool enabled)
|
||||
{
|
||||
m_appSettingsRepository->toggleDevGatewayEnv(enabled);
|
||||
if (enabled) {
|
||||
m_appSettingsRepository->setDevGatewayEndpoint();
|
||||
} else {
|
||||
m_appSettingsRepository->resetGatewayEndpoint();
|
||||
}
|
||||
}
|
||||
|
||||
bool SettingsController::isHomeAdLabelVisible() const
|
||||
|
||||
@@ -76,10 +76,9 @@ public:
|
||||
QString nextAvailableServerName() const;
|
||||
bool isDevModeEnabled() const;
|
||||
|
||||
QString devGatewayEndpoint() const;
|
||||
QString devGatewayProxyStorages() const;
|
||||
QString devGatewayPublicKey() const;
|
||||
void setDevGatewayConfig(const QString &endpoint, const QString &proxyStorages, const QString &publicKey);
|
||||
void resetGatewayEndpoint();
|
||||
void setGatewayEndpoint(const QString &endpoint);
|
||||
QString getGatewayEndpoint() const;
|
||||
bool isDevGatewayEnv() const;
|
||||
void toggleDevGatewayEnv(bool enabled);
|
||||
|
||||
|
||||
@@ -139,9 +139,11 @@ void UpdateController::checkForUpdates()
|
||||
}
|
||||
setUpdateCheckRunning(true);
|
||||
|
||||
auto gatewayController = QSharedPointer<GatewayController>::create(
|
||||
m_appSettingsRepository->gatewayEnvironment(), apiDefs::requestTimeoutMsecs,
|
||||
m_appSettingsRepository->isStrictKillSwitchEnabled(), m_appSettingsRepository);
|
||||
auto gatewayController = QSharedPointer<GatewayController>::create(m_appSettingsRepository->getGatewayEndpoint(),
|
||||
m_appSettingsRepository->isDevGatewayEnv(),
|
||||
apiDefs::requestTimeoutMsecs,
|
||||
m_appSettingsRepository->isStrictKillSwitchEnabled(),
|
||||
m_appSettingsRepository);
|
||||
|
||||
QJsonObject apiPayload = GatewayPayloadBuilder(m_appSettingsRepository).build();
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#include "installerBase.h"
|
||||
|
||||
#include <QRandomGenerator>
|
||||
#include <iterator>
|
||||
|
||||
#include "core/utils/containerEnum.h"
|
||||
#include "core/utils/containers/containerUtils.h"
|
||||
#include "core/utils/protocolEnum.h"
|
||||
@@ -88,10 +85,8 @@ ContainerConfig InstallerBase::createBaseConfig(DockerContainer container, int p
|
||||
srv.transport = protocols::xray::defaultTransport;
|
||||
srv.security = protocols::xray::defaultSecurity;
|
||||
srv.flow = protocols::xray::defaultFlow;
|
||||
const int siteIndex =
|
||||
QRandomGenerator::global()->bounded(static_cast<int>(std::size(protocols::xray::defaultSites)));
|
||||
srv.site = protocols::xray::defaultSites[siteIndex];
|
||||
srv.sni = srv.site;
|
||||
srv.site = protocols::xray::defaultSite;
|
||||
srv.sni = protocols::xray::defaultSni;
|
||||
srv.alpn = protocols::xray::defaultAlpn;
|
||||
srv.fingerprint = protocols::xray::defaultFingerprint;
|
||||
config.protocolConfig = xrayConfig;
|
||||
@@ -130,6 +125,13 @@ ContainerConfig InstallerBase::createBaseConfig(DockerContainer container, int p
|
||||
config.protocolConfig = tProxyConfig;
|
||||
break;
|
||||
}
|
||||
case Proto::WhatsAppProxy: {
|
||||
WhatsAppProxyProtocolConfig whatsAppProxyConfig;
|
||||
whatsAppProxyConfig.port = portStr.isEmpty() ? QString(protocols::whatsAppProxy::defaultPort) : portStr;
|
||||
whatsAppProxyConfig.mediaPort = QString(protocols::whatsAppProxy::defaultMediaPort);
|
||||
config.protocolConfig = whatsAppProxyConfig;
|
||||
break;
|
||||
}
|
||||
case Proto::Ikev2: {
|
||||
Ikev2ProtocolConfig ikev2Config;
|
||||
config.protocolConfig = ikev2Config;
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
#include "whatsAppProxyInstaller.h"
|
||||
|
||||
#include "core/models/containerConfig.h"
|
||||
#include "core/utils/containerEnum.h"
|
||||
#include "core/utils/selfhosted/sshSession.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr QLatin1String kClientJsonPath("/data/amnezia-whatsappproxy-client.json");
|
||||
constexpr QLatin1String kClientJsonUploadPath("data/amnezia-whatsappproxy-client.json");
|
||||
}
|
||||
|
||||
void WhatsAppProxyInstaller::applyDockerPublishedPorts(const QString &dockerPsPortsLine,
|
||||
WhatsAppProxyProtocolConfig &config)
|
||||
{
|
||||
static const QRegularExpression chatRe(QStringLiteral(":(\\d+)->443/tcp"));
|
||||
static const QRegularExpression mediaRe(QStringLiteral(":(\\d+)->587/tcp"));
|
||||
const QRegularExpressionMatch chatMatch = chatRe.match(dockerPsPortsLine);
|
||||
const QRegularExpressionMatch mediaMatch = mediaRe.match(dockerPsPortsLine);
|
||||
if (chatMatch.hasMatch()) {
|
||||
config.port = chatMatch.captured(1);
|
||||
}
|
||||
if (mediaMatch.hasMatch()) {
|
||||
config.mediaPort = mediaMatch.captured(1);
|
||||
}
|
||||
}
|
||||
|
||||
WhatsAppProxyInstaller::WhatsAppProxyInstaller(QObject *parent) : InstallerBase(parent)
|
||||
{
|
||||
}
|
||||
|
||||
ErrorCode WhatsAppProxyInstaller::extractConfigFromContainer(DockerContainer container,
|
||||
const ServerCredentials &credentials,
|
||||
SshSession *sshSession, ContainerConfig &config)
|
||||
{
|
||||
if (container != DockerContainer::WhatsAppProxy || !sshSession) {
|
||||
return ErrorCode::NoError;
|
||||
}
|
||||
|
||||
WhatsAppProxyProtocolConfig *wc = config.getWhatsAppProxyProtocolConfig();
|
||||
if (!wc) {
|
||||
return ErrorCode::NoError;
|
||||
}
|
||||
|
||||
ErrorCode jsonErr = ErrorCode::NoError;
|
||||
const QByteArray jsonRaw =
|
||||
sshSession->getTextFileFromContainer(container, credentials, QString(kClientJsonPath), jsonErr);
|
||||
if (jsonErr != ErrorCode::NoError || jsonRaw.trimmed().isEmpty()) {
|
||||
return ErrorCode::NoError;
|
||||
}
|
||||
|
||||
QJsonParseError parseError;
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(jsonRaw.trimmed(), &parseError);
|
||||
if (parseError.error != QJsonParseError::NoError || !doc.isObject()) {
|
||||
return ErrorCode::NoError;
|
||||
}
|
||||
|
||||
const WhatsAppProxyProtocolConfig snapshot = WhatsAppProxyProtocolConfig::fromJson(doc.object());
|
||||
wc->publicHost = snapshot.publicHost;
|
||||
wc->isEnabled = snapshot.isEnabled;
|
||||
return ErrorCode::NoError;
|
||||
}
|
||||
|
||||
void WhatsAppProxyInstaller::uploadClientSettingsSnapshot(SshSession &sshSession, const ServerCredentials &credentials,
|
||||
DockerContainer container, const ContainerConfig &config)
|
||||
{
|
||||
const WhatsAppProxyProtocolConfig *wc = config.getWhatsAppProxyProtocolConfig();
|
||||
if (!wc) {
|
||||
return;
|
||||
}
|
||||
const QByteArray payload = QJsonDocument(wc->toJson()).toJson(QJsonDocument::Compact);
|
||||
const ErrorCode err = sshSession.uploadTextFileToContainer(container, credentials, QString::fromUtf8(payload),
|
||||
QString(kClientJsonUploadPath));
|
||||
if (err != ErrorCode::NoError) {
|
||||
qWarning() << "WhatsAppProxyInstaller::uploadClientSettingsSnapshot failed" << err;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef WHATSAPPPROXYINSTALLER_H
|
||||
#define WHATSAPPPROXYINSTALLER_H
|
||||
|
||||
#include "installerBase.h"
|
||||
|
||||
#include "core/models/protocols/whatsAppProxyProtocolConfig.h"
|
||||
|
||||
class WhatsAppProxyInstaller : public InstallerBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WhatsAppProxyInstaller(QObject *parent = nullptr);
|
||||
|
||||
amnezia::ErrorCode extractConfigFromContainer(amnezia::DockerContainer container,
|
||||
const amnezia::ServerCredentials &credentials, SshSession *sshSession,
|
||||
amnezia::ContainerConfig &config) override;
|
||||
|
||||
static void applyDockerPublishedPorts(const QString &dockerPsPortsLine, amnezia::WhatsAppProxyProtocolConfig &config);
|
||||
|
||||
static void uploadClientSettingsSnapshot(SshSession &sshSession, const amnezia::ServerCredentials &credentials,
|
||||
amnezia::DockerContainer container, const amnezia::ContainerConfig &config);
|
||||
};
|
||||
|
||||
#endif // WHATSAPPPROXYINSTALLER_H
|
||||
@@ -143,6 +143,16 @@ const TProxyProtocolConfig* ContainerConfig::getTProxyProtocolConfig() const
|
||||
return protocolConfig.as<TProxyProtocolConfig>();
|
||||
}
|
||||
|
||||
WhatsAppProxyProtocolConfig* ContainerConfig::getWhatsAppProxyProtocolConfig()
|
||||
{
|
||||
return protocolConfig.as<WhatsAppProxyProtocolConfig>();
|
||||
}
|
||||
|
||||
const WhatsAppProxyProtocolConfig* ContainerConfig::getWhatsAppProxyProtocolConfig() const
|
||||
{
|
||||
return protocolConfig.as<WhatsAppProxyProtocolConfig>();
|
||||
}
|
||||
|
||||
Ikev2ProtocolConfig* ContainerConfig::getIkev2ProtocolConfig()
|
||||
{
|
||||
return protocolConfig.as<Ikev2ProtocolConfig>();
|
||||
|
||||
@@ -66,6 +66,9 @@ struct ContainerConfig {
|
||||
TProxyProtocolConfig* getTProxyProtocolConfig();
|
||||
const TProxyProtocolConfig* getTProxyProtocolConfig() const;
|
||||
|
||||
WhatsAppProxyProtocolConfig* getWhatsAppProxyProtocolConfig();
|
||||
const WhatsAppProxyProtocolConfig* getWhatsAppProxyProtocolConfig() const;
|
||||
|
||||
Ikev2ProtocolConfig* getIkev2ProtocolConfig();
|
||||
const Ikev2ProtocolConfig* getIkev2ProtocolConfig() const;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "core/models/protocols/mtProxyProtocolConfig.h"
|
||||
#include "core/models/protocols/telemtProtocolConfig.h"
|
||||
#include "core/models/protocols/tProxyProtocolConfig.h"
|
||||
#include "core/models/protocols/whatsAppProxyProtocolConfig.h"
|
||||
|
||||
namespace amnezia
|
||||
{
|
||||
@@ -47,6 +48,8 @@ Proto ProtocolConfig::type() const
|
||||
return Proto::Telemt;
|
||||
} else if constexpr (std::is_same_v<T, TProxyProtocolConfig>) {
|
||||
return Proto::TProxy;
|
||||
} else if constexpr (std::is_same_v<T, WhatsAppProxyProtocolConfig>) {
|
||||
return Proto::WhatsAppProxy;
|
||||
}
|
||||
return Proto::Unknown;
|
||||
}, data);
|
||||
@@ -80,6 +83,8 @@ QString ProtocolConfig::port() const
|
||||
return arg.port.isEmpty() ? QString(protocols::telemt::defaultPort) : arg.port;
|
||||
} else if constexpr (std::is_same_v<T, TProxyProtocolConfig>) {
|
||||
return arg.port.isEmpty() ? QString(protocols::tProxy::defaultPort) : arg.port;
|
||||
} else if constexpr (std::is_same_v<T, WhatsAppProxyProtocolConfig>) {
|
||||
return arg.effectivePort();
|
||||
}
|
||||
return QString();
|
||||
}, data);
|
||||
@@ -109,6 +114,8 @@ QString ProtocolConfig::transportProto() const
|
||||
return QStringLiteral("tcp");
|
||||
} else if constexpr (std::is_same_v<T, TProxyProtocolConfig>) {
|
||||
return QStringLiteral("tcp");
|
||||
} else if constexpr (std::is_same_v<T, WhatsAppProxyProtocolConfig>) {
|
||||
return QStringLiteral("tcp");
|
||||
}
|
||||
return QString();
|
||||
}, data);
|
||||
@@ -326,6 +333,8 @@ ProtocolConfig ProtocolConfig::fromJson(const QJsonObject& json, Proto type)
|
||||
return ProtocolConfig{TelemtProtocolConfig::fromJson(json)};
|
||||
case Proto::TProxy:
|
||||
return ProtocolConfig{TProxyProtocolConfig::fromJson(json)};
|
||||
case Proto::WhatsAppProxy:
|
||||
return ProtocolConfig{WhatsAppProxyProtocolConfig::fromJson(json)};
|
||||
default:
|
||||
return ProtocolConfig{AwgProtocolConfig{}};
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "core/models/protocols/mtProxyProtocolConfig.h"
|
||||
#include "core/models/protocols/telemtProtocolConfig.h"
|
||||
#include "core/models/protocols/tProxyProtocolConfig.h"
|
||||
#include "core/models/protocols/whatsAppProxyProtocolConfig.h"
|
||||
|
||||
namespace amnezia
|
||||
{
|
||||
@@ -42,6 +43,7 @@ struct ProtocolConfig {
|
||||
MtProxyProtocolConfig,
|
||||
TelemtProtocolConfig,
|
||||
TProxyProtocolConfig,
|
||||
WhatsAppProxyProtocolConfig,
|
||||
Ikev2ProtocolConfig,
|
||||
TorProtocolConfig,
|
||||
DnsProtocolConfig
|
||||
|
||||
@@ -72,12 +72,6 @@ QJsonObject AwgServerConfig::toJson() const
|
||||
if (!port.isEmpty()) {
|
||||
obj[configKey::port] = this->port;
|
||||
}
|
||||
if (!cascadeEndpoint.isEmpty()) {
|
||||
obj[configKey::cascadeEndpoint] = cascadeEndpoint;
|
||||
}
|
||||
if (!cascadePort.isEmpty()) {
|
||||
obj[configKey::cascadePort] = cascadePort;
|
||||
}
|
||||
if (!transportProto.isEmpty()) {
|
||||
obj[configKey::transportProto] = transportProto;
|
||||
}
|
||||
@@ -172,8 +166,6 @@ AwgServerConfig AwgServerConfig::fromJson(const QJsonObject& json)
|
||||
AwgServerConfig config;
|
||||
|
||||
config.port = json.value(configKey::port).toString();
|
||||
config.cascadeEndpoint = json.value(configKey::cascadeEndpoint).toString();
|
||||
config.cascadePort = json.value(configKey::cascadePort).toString();
|
||||
config.transportProto = json.value(configKey::transportProto).toString();
|
||||
config.protocolVersion = json.value(configKey::protocolVersion).toString();
|
||||
config.subnetAddress = json.value(configKey::subnetAddress).toString();
|
||||
@@ -226,12 +218,6 @@ QJsonObject AwgClientConfig::toJson() const
|
||||
if (port > 0) {
|
||||
obj[configKey::port] = port;
|
||||
}
|
||||
if (!cascadeEndpoint.isEmpty()) {
|
||||
obj[configKey::cascadeEndpoint] = cascadeEndpoint;
|
||||
}
|
||||
if (!cascadePort.isEmpty()) {
|
||||
obj[configKey::cascadePort] = cascadePort;
|
||||
}
|
||||
if (!clientIp.isEmpty()) {
|
||||
obj[configKey::clientIp] = clientIp;
|
||||
}
|
||||
@@ -347,14 +333,6 @@ QJsonObject AwgClientConfig::toJson() const
|
||||
return obj;
|
||||
}
|
||||
|
||||
void AwgClientConfig::setCascade(const QString &newEndpoint, const QString &newPort)
|
||||
{
|
||||
cascadeEndpoint = newEndpoint;
|
||||
cascadePort = newPort;
|
||||
nativeConfig = replaceWireGuardEndpoint(nativeConfig, newEndpoint.isEmpty() ? hostName : newEndpoint,
|
||||
newPort.isEmpty() ? port : newPort.toInt());
|
||||
}
|
||||
|
||||
AwgClientConfig AwgClientConfig::fromJson(const QJsonObject& json)
|
||||
{
|
||||
AwgClientConfig config;
|
||||
@@ -362,8 +340,6 @@ AwgClientConfig AwgClientConfig::fromJson(const QJsonObject& json)
|
||||
config.nativeConfig = json.value(configKey::config).toString();
|
||||
config.hostName = json.value(configKey::hostName).toString();
|
||||
config.port = json.value(configKey::port).toInt(0);
|
||||
config.cascadeEndpoint = json.value(configKey::cascadeEndpoint).toString();
|
||||
config.cascadePort = json.value(configKey::cascadePort).toString();
|
||||
config.clientIp = json.value(configKey::clientIp).toString();
|
||||
config.clientPrivateKey = json.value(configKey::clientPrivKey).toString();
|
||||
config.clientPublicKey = json.value(configKey::clientPubKey).toString();
|
||||
|
||||
@@ -19,8 +19,6 @@ namespace AwgConstant
|
||||
|
||||
struct AwgServerConfig {
|
||||
QString port;
|
||||
QString cascadeEndpoint;
|
||||
QString cascadePort;
|
||||
QString transportProto;
|
||||
QString protocolVersion;
|
||||
QString subnetAddress;
|
||||
@@ -63,8 +61,6 @@ struct AwgClientConfig {
|
||||
QString nativeConfig;
|
||||
QString hostName;
|
||||
int port;
|
||||
QString cascadeEndpoint;
|
||||
QString cascadePort;
|
||||
QString clientIp;
|
||||
QString clientPrivateKey;
|
||||
QString clientPublicKey;
|
||||
@@ -99,9 +95,6 @@ struct AwgClientConfig {
|
||||
QString maxHandshakeAttempts;
|
||||
QString randomTrailers;
|
||||
QString disableCookies;
|
||||
|
||||
void setCascade(const QString &newEndpoint, const QString &newPort);
|
||||
|
||||
QJsonObject toJson() const;
|
||||
static AwgClientConfig fromJson(const QJsonObject& json);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "whatsAppProxyProtocolConfig.h"
|
||||
|
||||
#include "core/utils/constants/configKeys.h"
|
||||
#include "core/utils/constants/protocolConstants.h"
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
QString WhatsAppProxyProtocolConfig::effectivePort() const
|
||||
{
|
||||
return port.isEmpty() ? QString(protocols::whatsAppProxy::defaultPort) : port;
|
||||
}
|
||||
|
||||
QString WhatsAppProxyProtocolConfig::effectiveMediaPort() const
|
||||
{
|
||||
return mediaPort.isEmpty() ? QString(protocols::whatsAppProxy::defaultMediaPort) : mediaPort;
|
||||
}
|
||||
|
||||
QJsonObject WhatsAppProxyProtocolConfig::toJson() const
|
||||
{
|
||||
QJsonObject obj;
|
||||
if (!port.isEmpty()) {
|
||||
obj[QString(configKey::port)] = port;
|
||||
}
|
||||
if (!mediaPort.isEmpty()) {
|
||||
obj[protocols::whatsAppProxy::mediaPortKey] = mediaPort;
|
||||
}
|
||||
if (!publicHost.isEmpty()) {
|
||||
obj[protocols::whatsAppProxy::publicHostKey] = publicHost;
|
||||
}
|
||||
obj[protocols::whatsAppProxy::isEnabledKey] = isEnabled;
|
||||
return obj;
|
||||
}
|
||||
|
||||
WhatsAppProxyProtocolConfig WhatsAppProxyProtocolConfig::fromJson(const QJsonObject &json)
|
||||
{
|
||||
WhatsAppProxyProtocolConfig c;
|
||||
c.port = json.value(QString(configKey::port)).toString();
|
||||
c.mediaPort = json.value(protocols::whatsAppProxy::mediaPortKey).toString();
|
||||
c.publicHost = json.value(protocols::whatsAppProxy::publicHostKey).toString();
|
||||
c.isEnabled = json.value(protocols::whatsAppProxy::isEnabledKey).toBool(true);
|
||||
return c;
|
||||
}
|
||||
|
||||
bool WhatsAppProxyProtocolConfig::equalsDockerDeploymentSettings(const WhatsAppProxyProtocolConfig &other) const
|
||||
{
|
||||
return effectivePort() == other.effectivePort() && effectiveMediaPort() == other.effectiveMediaPort();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef WHATSAPPPROXYPROTOCOLCONFIG_H
|
||||
#define WHATSAPPPROXYPROTOCOLCONFIG_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
|
||||
namespace amnezia
|
||||
{
|
||||
|
||||
struct WhatsAppProxyProtocolConfig
|
||||
{
|
||||
QString port;
|
||||
QString mediaPort;
|
||||
QString publicHost;
|
||||
bool isEnabled = true;
|
||||
|
||||
QString effectivePort() const;
|
||||
QString effectiveMediaPort() const;
|
||||
|
||||
QJsonObject toJson() const;
|
||||
static WhatsAppProxyProtocolConfig fromJson(const QJsonObject &json);
|
||||
bool equalsDockerDeploymentSettings(const WhatsAppProxyProtocolConfig &other) const;
|
||||
};
|
||||
|
||||
} // namespace amnezia
|
||||
|
||||
#endif // WHATSAPPPROXYPROTOCOLCONFIG_H
|
||||
@@ -20,12 +20,6 @@ QJsonObject WireGuardServerConfig::toJson() const
|
||||
if (!port.isEmpty()) {
|
||||
obj[configKey::port] = port;
|
||||
}
|
||||
if (!cascadeEndpoint.isEmpty()) {
|
||||
obj[configKey::cascadeEndpoint] = cascadeEndpoint;
|
||||
}
|
||||
if (!cascadePort.isEmpty()) {
|
||||
obj[configKey::cascadePort] = cascadePort;
|
||||
}
|
||||
if (!transportProto.isEmpty()) {
|
||||
obj[configKey::transportProto] = transportProto;
|
||||
}
|
||||
@@ -51,8 +45,6 @@ WireGuardServerConfig WireGuardServerConfig::fromJson(const QJsonObject& json)
|
||||
WireGuardServerConfig config;
|
||||
|
||||
config.port = json.value(configKey::port).toString();
|
||||
config.cascadeEndpoint = json.value(configKey::cascadeEndpoint).toString();
|
||||
config.cascadePort = json.value(configKey::cascadePort).toString();
|
||||
config.transportProto = json.value(configKey::transportProto).toString();
|
||||
config.subnetAddress = json.value(configKey::subnetAddress).toString();
|
||||
config.subnetMask = json.value(configKey::subnetMask).toString();
|
||||
@@ -81,12 +73,6 @@ QJsonObject WireGuardClientConfig::toJson() const
|
||||
if (port > 0) {
|
||||
obj[configKey::port] = port;
|
||||
}
|
||||
if (!cascadeEndpoint.isEmpty()) {
|
||||
obj[configKey::cascadeEndpoint] = cascadeEndpoint;
|
||||
}
|
||||
if (!cascadePort.isEmpty()) {
|
||||
obj[configKey::cascadePort] = cascadePort;
|
||||
}
|
||||
if (!clientIp.isEmpty()) {
|
||||
obj[configKey::clientIp] = clientIp;
|
||||
}
|
||||
@@ -133,14 +119,6 @@ QJsonObject WireGuardClientConfig::toJson() const
|
||||
return obj;
|
||||
}
|
||||
|
||||
void WireGuardClientConfig::setCascade(const QString &newEndpoint, const QString &newPort)
|
||||
{
|
||||
cascadeEndpoint = newEndpoint;
|
||||
cascadePort = newPort;
|
||||
nativeConfig = replaceWireGuardEndpoint(nativeConfig, newEndpoint.isEmpty() ? hostName : newEndpoint,
|
||||
newPort.isEmpty() ? port : newPort.toInt());
|
||||
}
|
||||
|
||||
WireGuardClientConfig WireGuardClientConfig::fromJson(const QJsonObject& json)
|
||||
{
|
||||
WireGuardClientConfig config;
|
||||
@@ -148,8 +126,6 @@ WireGuardClientConfig WireGuardClientConfig::fromJson(const QJsonObject& json)
|
||||
config.nativeConfig = json.value(configKey::config).toString();
|
||||
config.hostName = json.value(configKey::hostName).toString();
|
||||
config.port = json.value(configKey::port).toInt(0);
|
||||
config.cascadeEndpoint = json.value(configKey::cascadeEndpoint).toString();
|
||||
config.cascadePort = json.value(configKey::cascadePort).toString();
|
||||
config.clientIp = json.value(configKey::clientIp).toString();
|
||||
config.clientPrivateKey = json.value(configKey::clientPrivKey).toString();
|
||||
config.clientPublicKey = json.value(configKey::clientPubKey).toString();
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace amnezia
|
||||
|
||||
struct WireGuardServerConfig {
|
||||
QString port;
|
||||
QString cascadeEndpoint;
|
||||
QString cascadePort;
|
||||
QString transportProto;
|
||||
QString subnetAddress;
|
||||
QString subnetMask;
|
||||
@@ -30,8 +28,6 @@ struct WireGuardClientConfig {
|
||||
QString nativeConfig;
|
||||
QString hostName;
|
||||
int port;
|
||||
QString cascadeEndpoint;
|
||||
QString cascadePort;
|
||||
QString clientIp;
|
||||
QString clientPrivateKey;
|
||||
QString clientPublicKey;
|
||||
@@ -45,8 +41,6 @@ struct WireGuardClientConfig {
|
||||
QMap<QString, QString> awgParams;
|
||||
bool isObfuscationEnabled = false;
|
||||
|
||||
void setCascade(const QString &newEndpoint, const QString &newPort);
|
||||
|
||||
QJsonObject toJson() const;
|
||||
static WireGuardClientConfig fromJson(const QJsonObject& json);
|
||||
};
|
||||
|
||||
@@ -354,6 +354,9 @@ void XrayServerConfig::applyDefaults(bool fillFlowDefault)
|
||||
transportProto = ProtocolUtils::transportProtoToString(ProtocolUtils::defaultTransportProto(Proto::Xray),
|
||||
Proto::Xray);
|
||||
}
|
||||
if (site.isEmpty()) {
|
||||
site = protocols::xray::defaultSite;
|
||||
}
|
||||
if (transport.isEmpty()) {
|
||||
transport = protocols::xray::defaultTransport;
|
||||
}
|
||||
@@ -364,7 +367,7 @@ void XrayServerConfig::applyDefaults(bool fillFlowDefault)
|
||||
flow = protocols::xray::defaultFlow;
|
||||
}
|
||||
if (sni.isEmpty()) {
|
||||
sni = site;
|
||||
sni = site.isEmpty() ? QString::fromLatin1(protocols::xray::defaultSni) : site;
|
||||
}
|
||||
if (alpn.isEmpty()) {
|
||||
alpn = protocols::xray::defaultAlpn;
|
||||
@@ -566,7 +569,7 @@ QJsonObject XrayServerConfig::streamSettingsJson(XrayStreamSide side) const
|
||||
|
||||
if (securityEff == QLatin1String(px::securityTls)) {
|
||||
QJsonObject tlsSettings;
|
||||
tlsSettings[px::serverName] = sni;
|
||||
tlsSettings[px::serverName] = sni.isEmpty() ? QString::fromLatin1(px::defaultSni) : sni;
|
||||
const QString alpnEff = alpn.isEmpty() ? QString::fromLatin1(px::defaultAlpn) : alpn;
|
||||
QJsonArray alpnArray;
|
||||
for (const QString &a : alpnEff.split(QLatin1Char(','))) {
|
||||
@@ -595,7 +598,7 @@ QJsonObject XrayServerConfig::streamSettingsJson(XrayStreamSide side) const
|
||||
if (clientSide && securityEff == QLatin1String(px::securityReality)) {
|
||||
QJsonObject realitySettings;
|
||||
realitySettings[px::fingerprint] = fingerprintEff;
|
||||
realitySettings[px::serverName] = sni;
|
||||
realitySettings[px::serverName] = sni.isEmpty() ? QString::fromLatin1(px::defaultSni) : sni;
|
||||
streamSettings[px::realitySettings] = realitySettings;
|
||||
}
|
||||
|
||||
@@ -1136,10 +1139,11 @@ QJsonObject XrayServerConfig::toServerInboundJson(const XrayServerInboundInputs
|
||||
|
||||
QJsonObject streamSettings = serverStreamSettings();
|
||||
if (xrayEffective::security(*this) == QLatin1String(px::securityReality)) {
|
||||
const QString siteEff = site.isEmpty() ? QString::fromLatin1(px::defaultSite) : site;
|
||||
QJsonObject realitySettings;
|
||||
realitySettings[px::dest] = site + QStringLiteral(":443");
|
||||
realitySettings[px::dest] = siteEff + QStringLiteral(":443");
|
||||
realitySettings[px::privateKey] = inputs.realityPrivateKey;
|
||||
realitySettings[px::serverNames] = QJsonArray { sni.isEmpty() ? site : sni };
|
||||
realitySettings[px::serverNames] = QJsonArray { sni.isEmpty() ? siteEff : sni };
|
||||
realitySettings[px::shortIds] = QJsonArray { inputs.realityShortId };
|
||||
streamSettings[px::realitySettings] = realitySettings;
|
||||
}
|
||||
@@ -1319,9 +1323,10 @@ QJsonObject XrayServerConfig::serverView() const
|
||||
view[px::streamSettings] = serverStreamSettings();
|
||||
|
||||
if (xrayEffective::security(*this) == QLatin1String(px::securityReality)) {
|
||||
const QString siteEff = site.isEmpty() ? QString::fromLatin1(px::defaultSite) : site;
|
||||
QJsonObject reality;
|
||||
reality[px::dest] = site;
|
||||
reality[px::serverName] = sni.isEmpty() ? site : sni;
|
||||
reality[px::dest] = siteEff;
|
||||
reality[px::serverName] = sni.isEmpty() ? siteEff : sni;
|
||||
view[QStringLiteral("reality")] = reality;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "protocolUtils.h"
|
||||
|
||||
#include <QRandomGenerator>
|
||||
#include <QRegularExpression>
|
||||
#include <QJsonObject>
|
||||
#include <QObject>
|
||||
|
||||
@@ -73,6 +72,7 @@ QMap<Proto, QString> ProtocolUtils::protocolHumanNames()
|
||||
{ Proto::MtProxy, QObject::tr("MTProxy (Telegram)") },
|
||||
{ Proto::Telemt, QObject::tr("Telemt (Telegram)") },
|
||||
{ Proto::TProxy, QObject::tr("TProxy (Telegram WEB)") },
|
||||
{ Proto::WhatsAppProxy, QObject::tr("WhatsApp proxy") },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ ServiceType ProtocolUtils::protocolService(Proto p)
|
||||
case Proto::MtProxy: return ServiceType::Other;
|
||||
case Proto::Telemt: return ServiceType::Other;
|
||||
case Proto::TProxy: return ServiceType::Other;
|
||||
case Proto::WhatsAppProxy: return ServiceType::Other;
|
||||
default: return ServiceType::Other;
|
||||
}
|
||||
}
|
||||
@@ -115,6 +116,7 @@ int ProtocolUtils::getPortForInstall(Proto p)
|
||||
case MtProxy:
|
||||
case Telemt:
|
||||
case TProxy:
|
||||
case WhatsAppProxy:
|
||||
default:
|
||||
return defaultPort(p);
|
||||
}
|
||||
@@ -137,6 +139,7 @@ int ProtocolUtils::defaultPort(Proto p)
|
||||
case Proto::MtProxy: return QString(protocols::mtProxy::defaultPort).toInt();
|
||||
case Proto::Telemt: return QString(protocols::telemt::defaultPort).toInt();
|
||||
case Proto::TProxy: return QString(protocols::tProxy::defaultPort).toInt();
|
||||
case Proto::WhatsAppProxy: return QString(protocols::whatsAppProxy::defaultPort).toInt();
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
@@ -158,6 +161,7 @@ bool ProtocolUtils::defaultPortChangeable(Proto p)
|
||||
case Proto::MtProxy: return true;
|
||||
case Proto::Telemt: return true;
|
||||
case Proto::TProxy: return true;
|
||||
case Proto::WhatsAppProxy: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
@@ -181,6 +185,7 @@ TransportProto ProtocolUtils::defaultTransportProto(Proto p)
|
||||
case Proto::MtProxy: return TransportProto::Tcp;
|
||||
case Proto::Telemt: return TransportProto::Tcp;
|
||||
case Proto::TProxy: return TransportProto::Tcp;
|
||||
case Proto::WhatsAppProxy: return TransportProto::Tcp;
|
||||
default: return TransportProto::Udp;
|
||||
}
|
||||
}
|
||||
@@ -203,6 +208,7 @@ bool ProtocolUtils::defaultTransportProtoChangeable(Proto p)
|
||||
case Proto::MtProxy: return false;
|
||||
case Proto::Telemt: return false;
|
||||
case Proto::TProxy: return false;
|
||||
case Proto::WhatsAppProxy: return false;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
@@ -217,10 +223,3 @@ QString ProtocolUtils::key_proto_config_path(Proto p)
|
||||
return protoToString(p) + "_config_path";
|
||||
}
|
||||
|
||||
QString ProtocolUtils::replaceWireGuardEndpoint(QString nativeConfig, const QString &host, int port)
|
||||
{
|
||||
static const QRegularExpression endpointLine(QString(R"(^(\s*%1\s*=\s*).*$)").arg(protocols::wireguard::Endpoint),
|
||||
QRegularExpression::MultilineOption);
|
||||
const QString endpointHost = host.contains(':') ? QString("[%1]").arg(host) : host;
|
||||
return nativeConfig.replace(endpointLine, QString("\\1%1:%2").arg(endpointHost).arg(port));
|
||||
}
|
||||
@@ -39,8 +39,6 @@ namespace amnezia
|
||||
QString key_proto_config_data(Proto p);
|
||||
QString key_proto_config_path(Proto p);
|
||||
|
||||
QString replaceWireGuardEndpoint(QString nativeConfig, const QString &host, int port);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,10 +174,6 @@ ErrorCode XrayProtocol::startTun2Socks()
|
||||
connect(
|
||||
m_tun2socksProcess.data(), &IpcProcessInterfaceReplica::readyReadStandardError, this,
|
||||
[this]() {
|
||||
if (!m_tun2socksProcess) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto readAllStandardError = m_tun2socksProcess->readAllStandardError();
|
||||
if (!readAllStandardError.waitForFinished()) {
|
||||
qWarning() << "Failed to read output from tun2socks";
|
||||
|
||||
@@ -17,12 +17,14 @@
|
||||
using namespace amnezia;
|
||||
|
||||
namespace {
|
||||
constexpr char prodGatewayEndpoint[] = "http://gw.amnezia.org:80/";
|
||||
constexpr char gatewayEndpoint[] = "http://gw.amnezia.org:80/";
|
||||
}
|
||||
|
||||
SecureAppSettingsRepository::SecureAppSettingsRepository(SecureQSettings* settings, QObject *parent)
|
||||
: QObject(parent), m_settings(settings)
|
||||
{
|
||||
QString storedEndpoint = value("Conf/gatewayEndpoint", gatewayEndpoint).toString();
|
||||
m_gatewayEndpoint = storedEndpoint.isEmpty() ? gatewayEndpoint : storedEndpoint;
|
||||
}
|
||||
|
||||
QVariant SecureAppSettingsRepository::value(const QString &key, const QVariant &defaultValue) const
|
||||
@@ -268,46 +270,35 @@ void SecureAppSettingsRepository::setAppsSplitTunnelingEnabled(bool enabled)
|
||||
emit appsSplitTunnelingEnabledChanged(enabled);
|
||||
}
|
||||
|
||||
GatewayEnvironment SecureAppSettingsRepository::gatewayEnvironment(bool isTestPurchase) const
|
||||
QString SecureAppSettingsRepository::getGatewayEndpoint(bool isTestPurchase) const
|
||||
{
|
||||
if (isTestPurchase) {
|
||||
return { SANDBOX_AGW_ENDPOINT, QByteArray::fromBase64(SANDBOX_AGW_PUBLIC_KEY_B64), SANDBOX_S3_ENDPOINT, {}, true };
|
||||
return QString(DEV_AGW_ENDPOINT);
|
||||
}
|
||||
if (isDevGatewayEnv()) {
|
||||
return {
|
||||
devGatewayEndpoint(), QByteArray::fromBase64(devGatewayPublicKey().toUtf8()), devGatewayProxyStorages(), {}, true
|
||||
};
|
||||
}
|
||||
return { prodGatewayEndpoint, QByteArray::fromBase64(PROD_AGW_PUBLIC_KEY_B64), PROD_S3_ENDPOINT,
|
||||
FALLBACK_S3_ENDPOINT, false };
|
||||
return m_gatewayEndpoint;
|
||||
}
|
||||
|
||||
QString SecureAppSettingsRepository::devGatewayEndpoint() const
|
||||
void SecureAppSettingsRepository::setGatewayEndpoint(const QString &endpoint)
|
||||
{
|
||||
return value("Conf/devGatewayEndpoint").toString();
|
||||
m_gatewayEndpoint = endpoint;
|
||||
setValue("Conf/gatewayEndpoint", endpoint);
|
||||
}
|
||||
|
||||
QString SecureAppSettingsRepository::devGatewayProxyStorages() const
|
||||
void SecureAppSettingsRepository::resetGatewayEndpoint()
|
||||
{
|
||||
return value("Conf/devGatewayProxyStorages").toString();
|
||||
m_gatewayEndpoint = gatewayEndpoint;
|
||||
setValue("Conf/gatewayEndpoint", gatewayEndpoint);
|
||||
}
|
||||
|
||||
QString SecureAppSettingsRepository::devGatewayPublicKey() const
|
||||
void SecureAppSettingsRepository::setDevGatewayEndpoint()
|
||||
{
|
||||
return value("Conf/devGatewayPublicKey").toString();
|
||||
m_gatewayEndpoint = QString(DEV_AGW_ENDPOINT);
|
||||
setValue("Conf/gatewayEndpoint", DEV_AGW_ENDPOINT);
|
||||
}
|
||||
|
||||
void SecureAppSettingsRepository::setDevGatewayConfig(const QString &endpoint, const QString &proxyStorages,
|
||||
const QString &publicKey)
|
||||
bool SecureAppSettingsRepository::isDevGatewayEnv(bool isTestPurchase) const
|
||||
{
|
||||
setValue("Conf/devGatewayEndpoint", endpoint);
|
||||
setValue("Conf/devGatewayProxyStorages", proxyStorages);
|
||||
setValue("Conf/devGatewayPublicKey", publicKey);
|
||||
}
|
||||
|
||||
bool SecureAppSettingsRepository::isDevGatewayEnv() const
|
||||
{
|
||||
return value("Conf/devGatewayEnv", false).toBool();
|
||||
return isTestPurchase ? true : value("Conf/devGatewayEnv", false).toBool();
|
||||
}
|
||||
|
||||
void SecureAppSettingsRepository::toggleDevGatewayEnv(bool enabled)
|
||||
|
||||
@@ -57,12 +57,11 @@ public:
|
||||
bool isAppsSplitTunnelingEnabled() const;
|
||||
void setAppsSplitTunnelingEnabled(bool enabled);
|
||||
|
||||
GatewayEnvironment gatewayEnvironment(bool isTestPurchase = false) const;
|
||||
QString devGatewayEndpoint() const;
|
||||
QString devGatewayProxyStorages() const;
|
||||
QString devGatewayPublicKey() const;
|
||||
void setDevGatewayConfig(const QString &endpoint, const QString &proxyStorages, const QString &publicKey);
|
||||
bool isDevGatewayEnv() const;
|
||||
QString getGatewayEndpoint(bool isTestPurchase = false) const;
|
||||
void setGatewayEndpoint(const QString &endpoint);
|
||||
void resetGatewayEndpoint();
|
||||
void setDevGatewayEndpoint();
|
||||
bool isDevGatewayEnv(bool isTestPurchase = false) const;
|
||||
void toggleDevGatewayEnv(bool enabled);
|
||||
QByteArray readGatewayProxyUrls(const QString &cacheKey) const;
|
||||
void writeGatewayProxyUrls(const QString &cacheKey, const QByteArray &proxyUrlsEncrypted);
|
||||
@@ -137,6 +136,7 @@ private:
|
||||
void setValue(const QString &key, const QVariant &value);
|
||||
|
||||
SecureQSettings* m_settings;
|
||||
QString m_gatewayEndpoint;
|
||||
};
|
||||
|
||||
#endif // SECUREAPPSETTINGSREPOSITORY_H
|
||||
@@ -39,15 +39,6 @@ namespace amnezia
|
||||
QString secondaryDns;
|
||||
};
|
||||
|
||||
struct GatewayEnvironment
|
||||
{
|
||||
QString endpoint;
|
||||
QByteArray publicKey;
|
||||
QString primaryProxyStorages;
|
||||
QString fallbackProxyStorages;
|
||||
bool isDev = false;
|
||||
};
|
||||
|
||||
struct SplitTunnelingSettings
|
||||
{
|
||||
bool isSitesSplitTunnelingEnabled;
|
||||
|
||||
@@ -13,8 +13,6 @@ namespace amnezia
|
||||
constexpr QLatin1String password("password");
|
||||
constexpr QLatin1String port("port");
|
||||
constexpr QLatin1String localPort("local_port");
|
||||
constexpr QLatin1String cascadeEndpoint("cascade_endpoint");
|
||||
constexpr QLatin1String cascadePort("cascade_port");
|
||||
|
||||
constexpr QLatin1String dns1("dns1");
|
||||
constexpr QLatin1String dns2("dns2");
|
||||
@@ -146,6 +144,7 @@ namespace amnezia
|
||||
constexpr QLatin1String mtproxy("mtproxy");
|
||||
constexpr QLatin1String telemt("telemt");
|
||||
constexpr QLatin1String tproxy("tproxy");
|
||||
constexpr QLatin1String whatsappproxy("whatsappproxy");
|
||||
|
||||
constexpr QLatin1String splitTunnelSites("splitTunnelSites");
|
||||
constexpr QLatin1String splitTunnelType("splitTunnelType");
|
||||
|
||||
@@ -57,22 +57,7 @@ namespace amnezia
|
||||
constexpr char shortidPath[] = "/opt/amnezia/xray/xray_short_id.key";
|
||||
constexpr char tlsCertPath[] = "/opt/amnezia/xray/tls_cert.pem";
|
||||
constexpr char tlsKeyPath[] = "/opt/amnezia/xray/tls_key.pem";
|
||||
constexpr const char *defaultSites[] = {
|
||||
"www.microsoft.com",
|
||||
"www.apple.com",
|
||||
"www.icloud.com",
|
||||
"dl.google.com",
|
||||
"www.bing.com",
|
||||
"www.samsung.com",
|
||||
"www.nvidia.com",
|
||||
"www.cisco.com",
|
||||
"www.asus.com",
|
||||
"www.logitech.com",
|
||||
"www.dropbox.com",
|
||||
"www.mozilla.org",
|
||||
"addons.mozilla.org",
|
||||
"www.speedtest.net",
|
||||
};
|
||||
constexpr char defaultSite[] = "www.googletagmanager.com";
|
||||
|
||||
constexpr char defaultPort[] = "443";
|
||||
constexpr char defaultLocalProxyPort[] = "10808";
|
||||
@@ -84,7 +69,8 @@ namespace amnezia
|
||||
constexpr char defaultSecurity[] = "reality";
|
||||
constexpr char defaultFlow[] = "xtls-rprx-vision";
|
||||
constexpr char defaultTransport[] = "raw";
|
||||
constexpr char defaultFingerprint[] = "firefox";
|
||||
constexpr char defaultFingerprint[] = "hellochrome_120";
|
||||
constexpr char defaultSni[] = "www.googletagmanager.com";
|
||||
constexpr char defaultAlpn[] = "h2";
|
||||
|
||||
constexpr char defaultXhttpMode[] = "Stream-one";
|
||||
@@ -427,6 +413,16 @@ namespace amnezia
|
||||
constexpr int maxWorkers = 32;
|
||||
}
|
||||
|
||||
namespace whatsAppProxy
|
||||
{
|
||||
constexpr char mediaPortKey[] = "whatsapp_proxy_media_port";
|
||||
constexpr char publicHostKey[] = "whatsapp_proxy_public_host";
|
||||
constexpr char isEnabledKey[] = "whatsapp_proxy_is_enabled";
|
||||
|
||||
constexpr char defaultPort[] = "443";
|
||||
constexpr char defaultMediaPort[] = "587";
|
||||
}
|
||||
|
||||
} // namespace protocols
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace amnezia
|
||||
MtProxy,
|
||||
Telemt,
|
||||
TProxy,
|
||||
WhatsAppProxy,
|
||||
};
|
||||
Q_ENUM_NS(DockerContainer)
|
||||
} // namespace ContainerEnumNS
|
||||
|
||||
@@ -80,6 +80,7 @@ QMap<DockerContainer, QString> ContainerUtils::containerHumanNames()
|
||||
{ DockerContainer::MtProxy, QObject::tr("MTProxy (Telegram)") },
|
||||
{ DockerContainer::Telemt, QObject::tr("Telemt (Telegram)") },
|
||||
{ DockerContainer::TProxy, QObject::tr("TProxy (Telegram WEB)") },
|
||||
{ DockerContainer::WhatsAppProxy, QObject::tr("WhatsApp proxy") },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -120,6 +121,8 @@ QMap<DockerContainer, QString> ContainerUtils::containerDescriptions()
|
||||
QObject::tr("Telegram MTProto proxy (Telemt, Rust)") },
|
||||
{ DockerContainer::TProxy,
|
||||
QObject::tr("Telegram WEB proxy (tproxy-server)") },
|
||||
{ DockerContainer::WhatsAppProxy,
|
||||
QObject::tr("WhatsApp chat and media proxy") },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -203,6 +206,11 @@ QMap<DockerContainer, QString> ContainerUtils::containerDetailedDescriptions()
|
||||
QObject::tr("Telegram WEB proxy. Clients connect over HTTPS to a hostname; "
|
||||
"the server relays traffic to official MTProxy. Requires a domain, "
|
||||
"ports 80 and 443, and a WEB-capable Telegram app.") },
|
||||
{ DockerContainer::WhatsAppProxy,
|
||||
QObject::tr("WhatsApp proxy based on the official Meta implementation. "
|
||||
"Relays chat traffic through the chat port and media through the media port. "
|
||||
"Users enter the server address and both ports in WhatsApp settings. "
|
||||
"Calls are not proxied.") },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -235,6 +243,7 @@ Proto ContainerUtils::defaultProtocol(DockerContainer c)
|
||||
case DockerContainer::MtProxy: return Proto::MtProxy;
|
||||
case DockerContainer::Telemt: return Proto::Telemt;
|
||||
case DockerContainer::TProxy: return Proto::TProxy;
|
||||
case DockerContainer::WhatsAppProxy: return Proto::WhatsAppProxy;
|
||||
default: return Proto::Unknown;
|
||||
}
|
||||
}
|
||||
@@ -265,6 +274,7 @@ bool ContainerUtils::isSupportedByCurrentPlatform(DockerContainer c)
|
||||
case DockerContainer::MtProxy: return true;
|
||||
case DockerContainer::Telemt: return true;
|
||||
case DockerContainer::TProxy: return true;
|
||||
case DockerContainer::WhatsAppProxy: return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -283,6 +293,7 @@ bool ContainerUtils::isSupportedByCurrentPlatform(DockerContainer c)
|
||||
case DockerContainer::MtProxy: return true;
|
||||
case DockerContainer::Telemt: return true;
|
||||
case DockerContainer::TProxy: return true;
|
||||
case DockerContainer::WhatsAppProxy: return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -304,6 +315,7 @@ bool ContainerUtils::isSupportedByCurrentPlatform(DockerContainer c)
|
||||
case DockerContainer::MtProxy: return true;
|
||||
case DockerContainer::Telemt: return true;
|
||||
case DockerContainer::TProxy: return true;
|
||||
case DockerContainer::WhatsAppProxy: return true;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
@@ -373,6 +385,7 @@ bool ContainerUtils::isShareable(DockerContainer container)
|
||||
case DockerContainer::MtProxy: return false;
|
||||
case DockerContainer::Telemt: return false;
|
||||
case DockerContainer::TProxy: return false;
|
||||
case DockerContainer::WhatsAppProxy: return false;
|
||||
default: return true;
|
||||
}
|
||||
}
|
||||
@@ -409,6 +422,7 @@ int ContainerUtils::installPageOrder(DockerContainer container)
|
||||
case DockerContainer::MtProxy:
|
||||
case DockerContainer::Telemt:
|
||||
case DockerContainer::TProxy:
|
||||
case DockerContainer::WhatsAppProxy:
|
||||
return 20;
|
||||
default: return 0;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace amnezia
|
||||
MtProxy,
|
||||
Telemt,
|
||||
TProxy,
|
||||
WhatsAppProxy,
|
||||
};
|
||||
Q_ENUM_NS(Proto)
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "core/models/protocols/mtProxyProtocolConfig.h"
|
||||
#include "core/models/protocols/telemtProtocolConfig.h"
|
||||
#include "core/models/protocols/tProxyProtocolConfig.h"
|
||||
#include "core/models/protocols/whatsAppProxyProtocolConfig.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace ProtocolUtils;
|
||||
@@ -43,6 +44,7 @@ QString amnezia::scriptFolder(amnezia::DockerContainer container)
|
||||
case DockerContainer::MtProxy: return QLatin1String("mtproxy");
|
||||
case DockerContainer::Telemt: return QLatin1String("telemt");
|
||||
case DockerContainer::TProxy: return QLatin1String("tproxy");
|
||||
case DockerContainer::WhatsAppProxy: return QLatin1String("whatsapp_proxy");
|
||||
default: return QString();
|
||||
}
|
||||
}
|
||||
@@ -208,7 +210,7 @@ amnezia::ScriptVars amnezia::genXrayVars(const ContainerConfig &containerConfig)
|
||||
if (auto* xrayProtocolConfig = containerConfig.getXrayProtocolConfig()) {
|
||||
const XrayServerConfig& config = xrayProtocolConfig->serverConfig;
|
||||
|
||||
vars.append({ { "$XRAY_SITE_NAME", config.site } });
|
||||
vars.append({ { "$XRAY_SITE_NAME", config.site.isEmpty() ? protocols::xray::defaultSite : config.site } });
|
||||
vars.append({ { "$XRAY_SERVER_PORT", config.port.isEmpty() ? protocols::xray::defaultPort : config.port } });
|
||||
}
|
||||
|
||||
@@ -428,6 +430,18 @@ amnezia::ScriptVars amnezia::genTProxyVars(const ContainerConfig &containerConfi
|
||||
return vars;
|
||||
}
|
||||
|
||||
amnezia::ScriptVars amnezia::genWhatsAppProxyVars(const ContainerConfig &containerConfig)
|
||||
{
|
||||
ScriptVars vars;
|
||||
|
||||
if (auto *whatsAppProxyConfig = containerConfig.getWhatsAppProxyProtocolConfig()) {
|
||||
vars.append({ { "$WHATSAPP_PROXY_CHAT_PORT", whatsAppProxyConfig->effectivePort() } });
|
||||
vars.append({ { "$WHATSAPP_PROXY_MEDIA_PORT", whatsAppProxyConfig->effectiveMediaPort() } });
|
||||
}
|
||||
|
||||
return vars;
|
||||
}
|
||||
|
||||
amnezia::ScriptVars amnezia::genProtocolVarsForContainer(DockerContainer container, const ContainerConfig &containerConfig)
|
||||
{
|
||||
ScriptVars vars;
|
||||
@@ -461,6 +475,9 @@ amnezia::ScriptVars amnezia::genProtocolVarsForContainer(DockerContainer contain
|
||||
case Proto::TProxy:
|
||||
vars.append(genTProxyVars(containerConfig));
|
||||
break;
|
||||
case Proto::WhatsAppProxy:
|
||||
vars.append(genWhatsAppProxyVars(containerConfig));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ ScriptVars genSocks5ProxyVars(const ContainerConfig &containerConfig);
|
||||
ScriptVars genMtProxyVars(const ContainerConfig &containerConfig);
|
||||
ScriptVars genTelemtVars(const ContainerConfig &containerConfig);
|
||||
ScriptVars genTProxyVars(const ContainerConfig &containerConfig);
|
||||
ScriptVars genWhatsAppProxyVars(const ContainerConfig &containerConfig);
|
||||
|
||||
ScriptVars genProtocolVarsForContainer(DockerContainer container, const ContainerConfig &containerConfig);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,8 @@ ErrorCode SshSession::runContainerScript(const ServerCredentials &credentials, D
|
||||
return e;
|
||||
|
||||
const bool useSh = container == DockerContainer::Socks5Proxy || container == DockerContainer::MtProxy
|
||||
|| container == DockerContainer::Telemt || container == DockerContainer::TProxy;
|
||||
|| container == DockerContainer::Telemt || container == DockerContainer::TProxy
|
||||
|| container == DockerContainer::WhatsAppProxy;
|
||||
QString runner = QString("sudo docker exec -i $CONTAINER_NAME %2 %1 ").arg(fileName, useSh ? "sh" : "bash");
|
||||
e = runScript(credentials, replaceVars(runner, amnezia::genBaseVars(credentials, container, QString(), QString())), cbReadStdOut, cbReadStdErr);
|
||||
|
||||
|
||||
@@ -205,10 +205,10 @@ extension PacketTunnelProvider {
|
||||
}
|
||||
}
|
||||
|
||||
func stopXray(completionHandler: @escaping () -> Void) {
|
||||
func stopXray(completionHandler: () -> Void) {
|
||||
Socks5Tunnel.quit()
|
||||
LibXrayStopXray()
|
||||
hevSocksTunnelGroup.notify(queue: .main, execute: completionHandler)
|
||||
completionHandler()
|
||||
}
|
||||
|
||||
func sockCallback(fd: uintptr_t) {
|
||||
@@ -345,13 +345,10 @@ extension PacketTunnelProvider {
|
||||
return
|
||||
}
|
||||
|
||||
hevSocksTunnelGroup.enter()
|
||||
DispatchQueue.global().async { [hevSocksTunnelGroup] in
|
||||
DispatchQueue.global().async {
|
||||
xrayLog(.info, message: "Hev socks started")
|
||||
completionHandler(nil)
|
||||
let result = Socks5Tunnel.run(withConfig: configurationFilePath)
|
||||
xrayLog(.info, message: "Hev socks stopped: \(result)")
|
||||
hevSocksTunnelGroup.leave()
|
||||
Socks5Tunnel.run(withConfig: configurationFilePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||
var protoType: TunnelProtoType?
|
||||
|
||||
var activeIfaceIdx: UInt32 = 0
|
||||
let hevSocksTunnelGroup = DispatchGroup()
|
||||
|
||||
func openVPNPacketFlow() -> OpenVPNAdapterPacketFlow {
|
||||
openVPNPacketFlowAdapter
|
||||
@@ -317,11 +316,10 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||
updateActiveInterfaceIndex(for: changePath)
|
||||
reasserting = true
|
||||
xrayLog(.info, message: "Applying network change to xray tunnel")
|
||||
stopXray { [weak self] in
|
||||
self?.startXray { [weak self] error in
|
||||
self?.reasserting = false
|
||||
completion(error)
|
||||
}
|
||||
stopXray { }
|
||||
startXray { [weak self] error in
|
||||
self?.reasserting = false
|
||||
completion(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
<file>tproxy/Dockerfile</file>
|
||||
<file>tproxy/run_container.sh</file>
|
||||
<file>tproxy/start.sh</file>
|
||||
<file>whatsapp_proxy/configure_container.sh</file>
|
||||
<file>whatsapp_proxy/Dockerfile</file>
|
||||
<file>whatsapp_proxy/run_container.sh</file>
|
||||
<file>whatsapp_proxy/start.sh</file>
|
||||
<file>openvpn/configure_container.sh</file>
|
||||
<file>openvpn/Dockerfile</file>
|
||||
<file>openvpn/run_container.sh</file>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
FROM haproxy:lts-alpine
|
||||
|
||||
USER root
|
||||
RUN apk add --no-cache openssl
|
||||
|
||||
RUN mkdir -p /opt/amnezia /data
|
||||
RUN printf '#!/bin/sh\ntail -f /dev/null\n' > /opt/amnezia/start.sh && \
|
||||
chmod a+x /opt/amnezia/start.sh
|
||||
|
||||
VOLUME /data
|
||||
ENTRYPOINT ["/bin/sh", "/opt/amnezia/start.sh"]
|
||||
CMD [""]
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
|
||||
mkdir -p /data
|
||||
|
||||
if [ ! -s /data/proxy.pem ]; then
|
||||
openssl req -x509 -newkey rsa:2048 -nodes -days 3650 \
|
||||
-subj "/CN=$(openssl rand -hex 8).net" \
|
||||
-keyout /data/proxy.key -out /data/proxy.crt 2>/dev/null
|
||||
cat /data/proxy.key /data/proxy.crt > /data/proxy.pem
|
||||
rm -f /data/proxy.key /data/proxy.crt
|
||||
chmod 600 /data/proxy.pem
|
||||
fi
|
||||
|
||||
cat > /data/haproxy.cfg << EOF_CFG
|
||||
global
|
||||
tune.bufsize 4096
|
||||
maxconn 27500
|
||||
spread-checks 5
|
||||
ssl-server-verify none
|
||||
|
||||
defaults
|
||||
mode tcp
|
||||
timeout client-fin 1s
|
||||
timeout server-fin 1s
|
||||
timeout connect 5s
|
||||
timeout client 200s
|
||||
timeout server 200s
|
||||
default-server inter 10s fastinter 1s downinter 3s error-limit 50
|
||||
|
||||
frontend chat
|
||||
bind ipv4@*:443 ssl crt /data/proxy.pem
|
||||
default_backend wa_chat
|
||||
|
||||
frontend media
|
||||
bind ipv4@*:587
|
||||
default_backend wa_media
|
||||
|
||||
backend wa_chat
|
||||
default-server check inter 60000 observe layer4 send-proxy
|
||||
server g_whatsapp_net_5222 g.whatsapp.net:5222
|
||||
|
||||
backend wa_media
|
||||
default-server check inter 60000 observe layer4
|
||||
server whatsapp_net_443 whatsapp.net:443
|
||||
EOF_CFG
|
||||
|
||||
echo "[*] WhatsApp proxy configuration"
|
||||
echo "[*] Chat port: $WHATSAPP_PROXY_CHAT_PORT"
|
||||
echo "[*] Media port: $WHATSAPP_PROXY_MEDIA_PORT"
|
||||
@@ -0,0 +1,8 @@
|
||||
sudo docker run -d \
|
||||
--log-driver none \
|
||||
--restart always \
|
||||
-p $WHATSAPP_PROXY_CHAT_PORT:443/tcp \
|
||||
-p $WHATSAPP_PROXY_MEDIA_PORT:587/tcp \
|
||||
-v amnezia-whatsappproxy-data:/data \
|
||||
--name $CONTAINER_NAME \
|
||||
$CONTAINER_NAME
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -f /data/haproxy.cfg ] || [ ! -s /data/proxy.pem ]; then
|
||||
echo "ERROR: /data/haproxy.cfg not found — run configure_container first"
|
||||
tail -f /dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec haproxy -W -db -f /data/haproxy.cfg
|
||||
@@ -176,24 +176,19 @@ private slots:
|
||||
}
|
||||
}
|
||||
|
||||
void testDevGatewaySignals()
|
||||
{
|
||||
QSignalSpy devGatewayConfigChangedSpy(m_coreController->m_settingsUiController,
|
||||
&SettingsUiController::devGatewayConfigChanged);
|
||||
void testGatewayEndpointSignals() {
|
||||
QSignalSpy gatewayEndpointChangedSpy(m_coreController->m_settingsUiController, &SettingsUiController::gatewayEndpointChanged);
|
||||
QSignalSpy devGatewayEnvChangedSpy(m_coreController->m_settingsUiController, &SettingsUiController::devGatewayEnvChanged);
|
||||
|
||||
QString initialEndpoint = m_coreController->m_settingsController->getGatewayEndpoint();
|
||||
QString newEndpoint = "https://test-gateway.example.com";
|
||||
QString newProxyStorages = "https://storage-1.example.com, https://storage-2.example.com";
|
||||
QString newPublicKey = "dGVzdC1rZXk=";
|
||||
|
||||
m_coreController->m_settingsUiController->saveDevGatewayConfig(newEndpoint, newProxyStorages, newPublicKey);
|
||||
QVERIFY2(devGatewayConfigChangedSpy.count() == 1, "devGatewayConfigChanged signal should be emitted");
|
||||
QVERIFY2(m_coreController->m_settingsUiController->getDevGatewayEndpoint() == newEndpoint,
|
||||
"Dev gateway endpoint should be available in SettingsUiController");
|
||||
QVERIFY2(m_coreController->m_settingsUiController->getDevGatewayProxyStorages() == newProxyStorages,
|
||||
"Dev gateway proxy storages should be available in SettingsUiController");
|
||||
QVERIFY2(m_coreController->m_settingsUiController->getDevGatewayPublicKey() == newPublicKey,
|
||||
"Dev gateway public key should be available in SettingsUiController");
|
||||
m_coreController->m_settingsUiController->setGatewayEndpoint(newEndpoint);
|
||||
QVERIFY2(gatewayEndpointChangedSpy.count() == 1, "gatewayEndpointChanged signal should be emitted");
|
||||
QVERIFY2(gatewayEndpointChangedSpy.at(0).at(0).toString() == newEndpoint, "gatewayEndpointChanged should emit correct endpoint");
|
||||
QVERIFY2(m_coreController->m_settingsController->getGatewayEndpoint() == newEndpoint, "Gateway endpoint should be updated in SettingsController");
|
||||
QVERIFY2(m_coreController->m_settingsUiController->getGatewayEndpoint() == newEndpoint, "Gateway endpoint should be available in SettingsUiController");
|
||||
QVERIFY2(m_coreController->m_appSettingsRepository->getGatewayEndpoint() == newEndpoint, "Gateway endpoint should be available in SecureAppSettingsRepository");
|
||||
|
||||
bool initialDevEnv = m_coreController->m_settingsController->isDevGatewayEnv();
|
||||
m_coreController->m_settingsUiController->toggleDevGatewayEnv(!initialDevEnv);
|
||||
|
||||
@@ -75,7 +75,7 @@ void TestXrayConfigModel::isValidSni_data()
|
||||
{
|
||||
QTest::addColumn<QString>("sni");
|
||||
QTest::addColumn<bool>("valid");
|
||||
QTest::newRow("empty") << "" << false;
|
||||
QTest::newRow("empty") << "" << true;
|
||||
QTest::newRow("domain") << "www.example.com" << true;
|
||||
QTest::newRow("ipv4") << "203.0.113.10" << true;
|
||||
QTest::newRow("star") << "*" << false;
|
||||
|
||||
@@ -55,6 +55,7 @@ InstallUiController::InstallUiController(InstallController *installController,
|
||||
MtProxyConfigModel* mtConfigModel,
|
||||
TelemtConfigModel *telemtConfigModel,
|
||||
TProxyConfigModel *tProxyConfigModel,
|
||||
WhatsAppProxyConfigModel *whatsAppProxyConfigModel,
|
||||
ConnectionController *connectionController,
|
||||
QObject *parent)
|
||||
: QObject(parent),
|
||||
@@ -76,6 +77,7 @@ InstallUiController::InstallUiController(InstallController *installController,
|
||||
m_mtProxyConfigModel(mtConfigModel),
|
||||
m_telemtConfigModel(telemtConfigModel),
|
||||
m_tProxyConfigModel(tProxyConfigModel),
|
||||
m_whatsAppProxyConfigModel(whatsAppProxyConfigModel),
|
||||
m_connectionController(connectionController)
|
||||
{
|
||||
connect(m_installController, &InstallController::configValidated, this, &InstallUiController::configValidated);
|
||||
@@ -92,6 +94,9 @@ void InstallUiController::install(DockerContainer container, int port, Transport
|
||||
m_installController->setTProxyInstallHints(m_tProxyConfigModel->getHostname(),
|
||||
m_tProxyConfigModel->getAcmeEmail());
|
||||
}
|
||||
if (container == DockerContainer::WhatsAppProxy && m_whatsAppProxyConfigModel) {
|
||||
m_installController->setWhatsAppProxyInstallHints(m_whatsAppProxyConfigModel->getMediaPort());
|
||||
}
|
||||
|
||||
const bool isNewServer = serverId.isEmpty();
|
||||
|
||||
@@ -269,6 +274,10 @@ bool InstallUiController::buildContainerConfigFromModel(int containerIndex, int
|
||||
containerConfig.protocolConfig = m_tProxyConfigModel->getProtocolConfig();
|
||||
break;
|
||||
}
|
||||
case Proto::WhatsAppProxy: {
|
||||
containerConfig.protocolConfig = m_whatsAppProxyConfigModel->getProtocolConfig();
|
||||
break;
|
||||
}
|
||||
#ifdef Q_OS_WINDOWS
|
||||
case Proto::Ikev2: {
|
||||
containerConfig.protocolConfig = m_ikev2ConfigModel->getProtocolConfig();
|
||||
@@ -325,7 +334,7 @@ void InstallUiController::updateServerConfig(const QString &serverId, int contai
|
||||
ContainerConfig oldContainerConfig = m_serversController->getContainerConfig(serverId, container);
|
||||
|
||||
const bool asyncUpdate = container == DockerContainer::MtProxy || container == DockerContainer::Telemt
|
||||
|| container == DockerContainer::TProxy
|
||||
|| container == DockerContainer::TProxy || container == DockerContainer::WhatsAppProxy
|
||||
|| container == DockerContainer::Xray || container == DockerContainer::SSXray;
|
||||
|
||||
|
||||
@@ -336,7 +345,7 @@ void InstallUiController::updateServerConfig(const QString &serverId, int contai
|
||||
m_serverConfigUpdateInProgress = true;
|
||||
|
||||
const bool emitBusy = container == DockerContainer::MtProxy || container == DockerContainer::Telemt
|
||||
|| container == DockerContainer::TProxy;
|
||||
|| container == DockerContainer::TProxy || container == DockerContainer::WhatsAppProxy;
|
||||
if (emitBusy)
|
||||
emit serverIsBusy(true);
|
||||
auto *watcher = new QFutureWatcher<ErrorCode>(this);
|
||||
@@ -391,7 +400,7 @@ void InstallUiController::setContainerEnabled(const QString &serverId, int conta
|
||||
{
|
||||
const DockerContainer container = static_cast<DockerContainer>(containerIndex);
|
||||
if (container != DockerContainer::MtProxy && container != DockerContainer::Telemt
|
||||
&& container != DockerContainer::TProxy) {
|
||||
&& container != DockerContainer::TProxy && container != DockerContainer::WhatsAppProxy) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -423,7 +432,7 @@ void InstallUiController::refreshContainerStatus(const QString &serverId, int co
|
||||
{
|
||||
const DockerContainer container = static_cast<DockerContainer>(containerIndex);
|
||||
if (container != DockerContainer::MtProxy && container != DockerContainer::Telemt
|
||||
&& container != DockerContainer::TProxy) {
|
||||
&& container != DockerContainer::TProxy && container != DockerContainer::WhatsAppProxy) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -759,6 +768,7 @@ void InstallUiController::updateProtocolConfigModel(const QString &serverId, int
|
||||
case Proto::MtProxy: updateIfPresent(m_mtProxyConfigModel, containerConfig.getMtProxyProtocolConfig()); break;
|
||||
case Proto::Telemt: updateIfPresent(m_telemtConfigModel, containerConfig.getTelemtProtocolConfig()); break;
|
||||
case Proto::TProxy: updateIfPresent(m_tProxyConfigModel, containerConfig.getTProxyProtocolConfig()); break;
|
||||
case Proto::WhatsAppProxy: updateIfPresent(m_whatsAppProxyConfigModel, containerConfig.getWhatsAppProxyProtocolConfig()); break;
|
||||
#ifdef Q_OS_WINDOWS
|
||||
case Proto::Ikev2: updateIfPresent(m_ikev2ConfigModel, containerConfig.getIkev2ProtocolConfig()); break;
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "ui/models/services/mtProxyConfigModel.h"
|
||||
#include "ui/models/services/telemtConfigModel.h"
|
||||
#include "ui/models/services/tProxyConfigModel.h"
|
||||
#include "ui/models/services/whatsAppProxyConfigModel.h"
|
||||
|
||||
class InstallUiController : public QObject
|
||||
{
|
||||
@@ -55,6 +56,7 @@ public:
|
||||
MtProxyConfigModel* mtConfigModel,
|
||||
TelemtConfigModel* telemtConfigModel,
|
||||
TProxyConfigModel* tProxyConfigModel,
|
||||
WhatsAppProxyConfigModel* whatsAppProxyConfigModel,
|
||||
ConnectionController* connectionController,
|
||||
QObject *parent = nullptr);
|
||||
~InstallUiController();
|
||||
@@ -163,6 +165,7 @@ private:
|
||||
MtProxyConfigModel* m_mtProxyConfigModel;
|
||||
TelemtConfigModel* m_telemtConfigModel;
|
||||
TProxyConfigModel* m_tProxyConfigModel;
|
||||
WhatsAppProxyConfigModel* m_whatsAppProxyConfigModel;
|
||||
ConnectionController* m_connectionController;
|
||||
|
||||
ServerCredentials m_processedServerCredentials;
|
||||
|
||||
@@ -576,6 +576,8 @@ QStringList ServersUiController::getAllInstalledServicesName(int serverIndex) co
|
||||
servicesName.append("Telemt");
|
||||
} else if (container == DockerContainer::TProxy) {
|
||||
servicesName.append("TProxy");
|
||||
} else if (container == DockerContainer::WhatsAppProxy) {
|
||||
servicesName.append("WhatsApp");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,26 +296,21 @@ bool SettingsUiController::isDevModeEnabled()
|
||||
return m_settingsController->isDevModeEnabled();
|
||||
}
|
||||
|
||||
QString SettingsUiController::getDevGatewayEndpoint()
|
||||
void SettingsUiController::resetGatewayEndpoint()
|
||||
{
|
||||
return m_settingsController->devGatewayEndpoint();
|
||||
m_settingsController->resetGatewayEndpoint();
|
||||
emit gatewayEndpointChanged(m_settingsController->getGatewayEndpoint());
|
||||
}
|
||||
|
||||
QString SettingsUiController::getDevGatewayProxyStorages()
|
||||
void SettingsUiController::setGatewayEndpoint(const QString &endpoint)
|
||||
{
|
||||
return m_settingsController->devGatewayProxyStorages();
|
||||
m_settingsController->setGatewayEndpoint(endpoint);
|
||||
emit gatewayEndpointChanged(endpoint);
|
||||
}
|
||||
|
||||
QString SettingsUiController::getDevGatewayPublicKey()
|
||||
QString SettingsUiController::getGatewayEndpoint()
|
||||
{
|
||||
return m_settingsController->devGatewayPublicKey();
|
||||
}
|
||||
|
||||
void SettingsUiController::saveDevGatewayConfig(const QString &endpoint, const QString &proxyStorages,
|
||||
const QString &publicKey)
|
||||
{
|
||||
m_settingsController->setDevGatewayConfig(endpoint, proxyStorages, publicKey);
|
||||
emit devGatewayConfigChanged();
|
||||
return m_settingsController->getGatewayEndpoint();
|
||||
}
|
||||
|
||||
bool SettingsUiController::isDevGatewayEnv()
|
||||
@@ -326,6 +321,7 @@ bool SettingsUiController::isDevGatewayEnv()
|
||||
void SettingsUiController::toggleDevGatewayEnv(bool enabled)
|
||||
{
|
||||
m_settingsController->toggleDevGatewayEnv(enabled);
|
||||
emit gatewayEndpointChanged(m_settingsController->getGatewayEndpoint());
|
||||
emit devGatewayEnvChanged(enabled);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@ public:
|
||||
Q_PROPERTY(bool strictKillSwitchEnabled READ isStrictKillSwitchEnabled WRITE toggleStrictKillSwitch NOTIFY strictKillSwitchEnabledChanged)
|
||||
|
||||
Q_PROPERTY(bool isDevModeEnabled READ isDevModeEnabled NOTIFY devModeEnabled)
|
||||
Q_PROPERTY(QString devGatewayEndpoint READ getDevGatewayEndpoint NOTIFY devGatewayConfigChanged)
|
||||
Q_PROPERTY(QString devGatewayProxyStorages READ getDevGatewayProxyStorages NOTIFY devGatewayConfigChanged)
|
||||
Q_PROPERTY(QString devGatewayPublicKey READ getDevGatewayPublicKey NOTIFY devGatewayConfigChanged)
|
||||
Q_PROPERTY(QString gatewayEndpoint READ getGatewayEndpoint WRITE setGatewayEndpoint NOTIFY gatewayEndpointChanged)
|
||||
Q_PROPERTY(bool isDevGatewayEnv READ isDevGatewayEnv WRITE toggleDevGatewayEnv NOTIFY devGatewayEnvChanged)
|
||||
|
||||
Q_PROPERTY(bool isHomeAdLabelVisible READ isHomeAdLabelVisible NOTIFY isHomeAdLabelVisibleChanged)
|
||||
@@ -92,10 +90,9 @@ public slots:
|
||||
void enableDevMode();
|
||||
bool isDevModeEnabled();
|
||||
|
||||
QString getDevGatewayEndpoint();
|
||||
QString getDevGatewayProxyStorages();
|
||||
QString getDevGatewayPublicKey();
|
||||
void saveDevGatewayConfig(const QString &endpoint, const QString &proxyStorages, const QString &publicKey);
|
||||
void resetGatewayEndpoint();
|
||||
void setGatewayEndpoint(const QString &endpoint);
|
||||
QString getGatewayEndpoint();
|
||||
bool isDevGatewayEnv();
|
||||
void toggleDevGatewayEnv(bool enabled);
|
||||
|
||||
@@ -129,7 +126,7 @@ signals:
|
||||
void onNotificationStateChanged();
|
||||
|
||||
void devModeEnabled();
|
||||
void devGatewayConfigChanged();
|
||||
void gatewayEndpointChanged(const QString &endpoint);
|
||||
void devGatewayEnvChanged(bool enabled);
|
||||
|
||||
void activityPaused();
|
||||
|
||||
@@ -78,6 +78,7 @@ QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
||||
case IsMtProxyRole: return container == DockerContainer::MtProxy;
|
||||
case IsTelemtRole: return container == DockerContainer::Telemt;
|
||||
case IsTProxyRole: return container == DockerContainer::TProxy;
|
||||
case IsWhatsAppProxyRole: return container == DockerContainer::WhatsAppProxy;
|
||||
case InstallPageOrderRole: return ContainerUtils::installPageOrder(container);
|
||||
}
|
||||
|
||||
@@ -193,5 +194,6 @@ QHash<int, QByteArray> ContainersModel::roleNames() const
|
||||
roles[IsMtProxyRole] = "isMtProxy";
|
||||
roles[IsTelemtRole] = "isTelemt";
|
||||
roles[IsTProxyRole] = "isTProxy";
|
||||
roles[IsWhatsAppProxyRole] = "isWhatsAppProxy";
|
||||
return roles;
|
||||
}
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
IsMtProxyRole,
|
||||
IsTelemtRole,
|
||||
IsTProxyRole,
|
||||
IsWhatsAppProxyRole,
|
||||
};
|
||||
|
||||
Q_INVOKABLE void openContainerSettings(int containerIndex);
|
||||
|
||||
@@ -58,73 +58,6 @@ void AwgConfigModel::setPort(const QString &value)
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QString AwgConfigModel::cascadeEndpoint() const
|
||||
{
|
||||
return m_protocolConfig.serverConfig.cascadeEndpoint;
|
||||
}
|
||||
|
||||
void AwgConfigModel::setCascadeEndpoint(const QString &value)
|
||||
{
|
||||
if (m_protocolConfig.serverConfig.cascadeEndpoint == value) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.serverConfig.cascadeEndpoint = value;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QString AwgConfigModel::cascadePort() const
|
||||
{
|
||||
return m_protocolConfig.serverConfig.cascadePort;
|
||||
}
|
||||
|
||||
void AwgConfigModel::setCascadePort(const QString &value)
|
||||
{
|
||||
if (m_protocolConfig.serverConfig.cascadePort == value) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.serverConfig.cascadePort = value;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QString AwgConfigModel::clientHostName() const
|
||||
{
|
||||
return m_protocolConfig.clientConfig->hostName;
|
||||
}
|
||||
|
||||
QString AwgConfigModel::clientPort() const
|
||||
{
|
||||
const int port = m_protocolConfig.clientConfig->port;
|
||||
return port > 0 ? QString::number(port) : QString();
|
||||
}
|
||||
|
||||
QString AwgConfigModel::clientCascadeEndpoint() const
|
||||
{
|
||||
return m_protocolConfig.clientConfig->cascadeEndpoint;
|
||||
}
|
||||
|
||||
void AwgConfigModel::setClientCascadeEndpoint(const QString &value)
|
||||
{
|
||||
if (m_protocolConfig.clientConfig->cascadeEndpoint == value) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.clientConfig->setCascade(value, m_protocolConfig.clientConfig->cascadePort);
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QString AwgConfigModel::clientCascadePort() const
|
||||
{
|
||||
return m_protocolConfig.clientConfig->cascadePort;
|
||||
}
|
||||
|
||||
void AwgConfigModel::setClientCascadePort(const QString &value)
|
||||
{
|
||||
if (m_protocolConfig.clientConfig->cascadePort == value) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.clientConfig->setCascade(m_protocolConfig.clientConfig->cascadeEndpoint, value);
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QString AwgConfigModel::clientMtu() const
|
||||
{
|
||||
return m_protocolConfig.clientConfig->mtu;
|
||||
@@ -776,15 +709,8 @@ amnezia::AwgProtocolConfig AwgConfigModel::getProtocolConfig()
|
||||
{
|
||||
bool serverSettingsChanged = !m_protocolConfig.serverConfig.hasEqualServerSettings(m_originalProtocolConfig.serverConfig);
|
||||
|
||||
const auto &serverConfig = m_protocolConfig.serverConfig;
|
||||
const auto &originalServerConfig = m_originalProtocolConfig.serverConfig;
|
||||
const bool cascadeChanged = serverConfig.cascadeEndpoint != originalServerConfig.cascadeEndpoint
|
||||
|| serverConfig.cascadePort != originalServerConfig.cascadePort;
|
||||
|
||||
if (serverSettingsChanged) {
|
||||
m_protocolConfig.clearClientConfig();
|
||||
} else if (cascadeChanged) {
|
||||
m_protocolConfig.clientConfig->setCascade(serverConfig.cascadeEndpoint, serverConfig.cascadePort);
|
||||
}
|
||||
|
||||
return m_protocolConfig;
|
||||
|
||||
@@ -14,13 +14,7 @@ class AwgConfigModel : public QObject
|
||||
|
||||
Q_PROPERTY(QString subnetAddress READ subnetAddress WRITE setSubnetAddress NOTIFY changed)
|
||||
Q_PROPERTY(QString port READ port WRITE setPort NOTIFY changed)
|
||||
Q_PROPERTY(QString cascadeEndpoint READ cascadeEndpoint WRITE setCascadeEndpoint NOTIFY changed)
|
||||
Q_PROPERTY(QString cascadePort READ cascadePort WRITE setCascadePort NOTIFY changed)
|
||||
Q_PROPERTY(QString clientMtu READ clientMtu WRITE setClientMtu NOTIFY changed)
|
||||
Q_PROPERTY(QString clientHostName READ clientHostName NOTIFY changed)
|
||||
Q_PROPERTY(QString clientPort READ clientPort NOTIFY changed)
|
||||
Q_PROPERTY(QString clientCascadeEndpoint READ clientCascadeEndpoint WRITE setClientCascadeEndpoint NOTIFY changed)
|
||||
Q_PROPERTY(QString clientCascadePort READ clientCascadePort WRITE setClientCascadePort NOTIFY changed)
|
||||
Q_PROPERTY(QString clientJunkPacketCount READ clientJunkPacketCount WRITE setClientJunkPacketCount NOTIFY changed)
|
||||
Q_PROPERTY(QString clientJunkPacketMinSize READ clientJunkPacketMinSize WRITE setClientJunkPacketMinSize NOTIFY changed)
|
||||
Q_PROPERTY(QString clientJunkPacketMaxSize READ clientJunkPacketMaxSize WRITE setClientJunkPacketMaxSize NOTIFY changed)
|
||||
@@ -75,21 +69,6 @@ public:
|
||||
QString port() const;
|
||||
void setPort(const QString &value);
|
||||
|
||||
QString cascadeEndpoint() const;
|
||||
void setCascadeEndpoint(const QString &value);
|
||||
|
||||
QString cascadePort() const;
|
||||
void setCascadePort(const QString &value);
|
||||
|
||||
QString clientHostName() const;
|
||||
QString clientPort() const;
|
||||
|
||||
QString clientCascadeEndpoint() const;
|
||||
void setClientCascadeEndpoint(const QString &value);
|
||||
|
||||
QString clientCascadePort() const;
|
||||
void setClientCascadePort(const QString &value);
|
||||
|
||||
QString clientMtu() const;
|
||||
void setClientMtu(const QString &value);
|
||||
|
||||
|
||||
@@ -40,73 +40,6 @@ void WireGuardConfigModel::setPort(const QString &value)
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QString WireGuardConfigModel::cascadeEndpoint() const
|
||||
{
|
||||
return m_protocolConfig.serverConfig.cascadeEndpoint;
|
||||
}
|
||||
|
||||
void WireGuardConfigModel::setCascadeEndpoint(const QString &value)
|
||||
{
|
||||
if (m_protocolConfig.serverConfig.cascadeEndpoint == value) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.serverConfig.cascadeEndpoint = value;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QString WireGuardConfigModel::cascadePort() const
|
||||
{
|
||||
return m_protocolConfig.serverConfig.cascadePort;
|
||||
}
|
||||
|
||||
void WireGuardConfigModel::setCascadePort(const QString &value)
|
||||
{
|
||||
if (m_protocolConfig.serverConfig.cascadePort == value) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.serverConfig.cascadePort = value;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QString WireGuardConfigModel::clientHostName() const
|
||||
{
|
||||
return m_protocolConfig.clientConfig->hostName;
|
||||
}
|
||||
|
||||
QString WireGuardConfigModel::clientPort() const
|
||||
{
|
||||
const int port = m_protocolConfig.clientConfig->port;
|
||||
return port > 0 ? QString::number(port) : QString();
|
||||
}
|
||||
|
||||
QString WireGuardConfigModel::clientCascadeEndpoint() const
|
||||
{
|
||||
return m_protocolConfig.clientConfig->cascadeEndpoint;
|
||||
}
|
||||
|
||||
void WireGuardConfigModel::setClientCascadeEndpoint(const QString &value)
|
||||
{
|
||||
if (m_protocolConfig.clientConfig->cascadeEndpoint == value) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.clientConfig->setCascade(value, m_protocolConfig.clientConfig->cascadePort);
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QString WireGuardConfigModel::clientCascadePort() const
|
||||
{
|
||||
return m_protocolConfig.clientConfig->cascadePort;
|
||||
}
|
||||
|
||||
void WireGuardConfigModel::setClientCascadePort(const QString &value)
|
||||
{
|
||||
if (m_protocolConfig.clientConfig->cascadePort == value) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.clientConfig->setCascade(m_protocolConfig.clientConfig->cascadeEndpoint, value);
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QString WireGuardConfigModel::clientMtu() const
|
||||
{
|
||||
if (m_protocolConfig.clientConfig.has_value()) {
|
||||
@@ -163,15 +96,8 @@ amnezia::WireGuardProtocolConfig WireGuardConfigModel::getProtocolConfig()
|
||||
{
|
||||
bool serverSettingsChanged = !m_protocolConfig.serverConfig.hasEqualServerSettings(m_originalProtocolConfig.serverConfig);
|
||||
|
||||
const auto &serverConfig = m_protocolConfig.serverConfig;
|
||||
const auto &originalServerConfig = m_originalProtocolConfig.serverConfig;
|
||||
const bool cascadeChanged = serverConfig.cascadeEndpoint != originalServerConfig.cascadeEndpoint
|
||||
|| serverConfig.cascadePort != originalServerConfig.cascadePort;
|
||||
|
||||
if (serverSettingsChanged) {
|
||||
m_protocolConfig.clearClientConfig();
|
||||
} else if (cascadeChanged) {
|
||||
m_protocolConfig.clientConfig->setCascade(serverConfig.cascadeEndpoint, serverConfig.cascadePort);
|
||||
}
|
||||
|
||||
return m_protocolConfig;
|
||||
|
||||
@@ -14,13 +14,7 @@ class WireGuardConfigModel : public QObject
|
||||
|
||||
Q_PROPERTY(QString subnetAddress READ subnetAddress WRITE setSubnetAddress NOTIFY changed)
|
||||
Q_PROPERTY(QString port READ port WRITE setPort NOTIFY changed)
|
||||
Q_PROPERTY(QString cascadeEndpoint READ cascadeEndpoint WRITE setCascadeEndpoint NOTIFY changed)
|
||||
Q_PROPERTY(QString cascadePort READ cascadePort WRITE setCascadePort NOTIFY changed)
|
||||
Q_PROPERTY(QString clientMtu READ clientMtu WRITE setClientMtu NOTIFY changed)
|
||||
Q_PROPERTY(QString clientHostName READ clientHostName NOTIFY changed)
|
||||
Q_PROPERTY(QString clientPort READ clientPort NOTIFY changed)
|
||||
Q_PROPERTY(QString clientCascadeEndpoint READ clientCascadeEndpoint WRITE setClientCascadeEndpoint NOTIFY changed)
|
||||
Q_PROPERTY(QString clientCascadePort READ clientCascadePort WRITE setClientCascadePort NOTIFY changed)
|
||||
|
||||
public:
|
||||
explicit WireGuardConfigModel(QObject *parent = nullptr);
|
||||
@@ -31,21 +25,6 @@ public:
|
||||
QString port() const;
|
||||
void setPort(const QString &value);
|
||||
|
||||
QString cascadeEndpoint() const;
|
||||
void setCascadeEndpoint(const QString &value);
|
||||
|
||||
QString cascadePort() const;
|
||||
void setCascadePort(const QString &value);
|
||||
|
||||
QString clientHostName() const;
|
||||
QString clientPort() const;
|
||||
|
||||
QString clientCascadeEndpoint() const;
|
||||
void setClientCascadeEndpoint(const QString &value);
|
||||
|
||||
QString clientCascadePort() const;
|
||||
void setClientCascadePort(const QString &value);
|
||||
|
||||
QString clientMtu() const;
|
||||
void setClientMtu(const QString &value);
|
||||
|
||||
|
||||
@@ -759,7 +759,7 @@ QStringList XrayConfigModel::transportOptions()
|
||||
|
||||
QStringList XrayConfigModel::fingerprintOptions()
|
||||
{
|
||||
return { "chrome", "firefox", "safari", "ios", "android", "edge", "360", "qq", "random" };
|
||||
return { "hellochrome_120", "chrome", "firefox", "safari", "ios", "android", "edge", "360", "qq", "random" };
|
||||
}
|
||||
|
||||
QStringList XrayConfigModel::alpnOptions()
|
||||
@@ -833,6 +833,11 @@ QString XrayConfigModel::portDefault()
|
||||
return QString::fromLatin1(protocols::xray::defaultPort);
|
||||
}
|
||||
|
||||
QString XrayConfigModel::sniDefault()
|
||||
{
|
||||
return QString::fromLatin1(protocols::xray::defaultSni);
|
||||
}
|
||||
|
||||
QString XrayConfigModel::xhttpHostDefault()
|
||||
{
|
||||
return QString::fromLatin1(protocols::xray::defaultXhttpHost);
|
||||
@@ -928,7 +933,10 @@ bool XrayConfigModel::isValidHost(const QString &host)
|
||||
bool XrayConfigModel::isValidSni(const QString &sni)
|
||||
{
|
||||
const QString t = sni.trimmed();
|
||||
if (t.isEmpty() || t.contains(QLatin1Char('*'))) {
|
||||
if (t.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (t.contains(QLatin1Char('*'))) {
|
||||
return false;
|
||||
}
|
||||
return isValidSingleHost(t);
|
||||
|
||||
@@ -251,6 +251,7 @@ public:
|
||||
Q_INVOKABLE static QString mkcpDefaultCwndMultiplier();
|
||||
|
||||
Q_INVOKABLE static QString portDefault();
|
||||
Q_INVOKABLE static QString sniDefault();
|
||||
Q_INVOKABLE static QString xhttpHostDefault();
|
||||
Q_INVOKABLE static QString xhttpUplinkChunkSizeDefault();
|
||||
Q_INVOKABLE static QString scMaxEachPostBytesMinDefault();
|
||||
|
||||
@@ -45,6 +45,7 @@ QHash<int, QByteArray> ProtocolsModel::roleNames() const
|
||||
roles[IsMtProxyRole] = "isMtProxy";
|
||||
roles[IsTelemtRole] = "isTelemt";
|
||||
roles[IsTProxyRole] = "isTProxy";
|
||||
roles[IsWhatsAppProxyRole] = "isWhatsAppProxy";
|
||||
|
||||
return roles;
|
||||
}
|
||||
@@ -77,6 +78,7 @@ QVariant ProtocolsModel::data(const QModelIndex &index, int role) const
|
||||
case IsMtProxyRole: return proto == Proto::MtProxy;
|
||||
case IsTelemtRole: return proto == Proto::Telemt;
|
||||
case IsTProxyRole: return proto == Proto::TProxy;
|
||||
case IsWhatsAppProxyRole: return proto == Proto::WhatsAppProxy;
|
||||
case RawConfigRole:
|
||||
return getRawConfig();
|
||||
case IsClientProtocolExistsRole:
|
||||
@@ -133,6 +135,7 @@ PageLoader::PageEnum ProtocolsModel::serverProtocolPage(Proto protocol) const
|
||||
case Proto::MtProxy: return PageLoader::PageEnum::PageServiceMtProxySettings;
|
||||
case Proto::Telemt: return PageLoader::PageEnum::PageServiceTelemtSettings;
|
||||
case Proto::TProxy: return PageLoader::PageEnum::PageServiceTProxySettings;
|
||||
case Proto::WhatsAppProxy: return PageLoader::PageEnum::PageServiceWhatsAppProxySettings;
|
||||
default: return PageLoader::PageEnum::PageProtocolOpenVpnSettings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
IsMtProxyRole,
|
||||
IsTelemtRole,
|
||||
IsTProxyRole,
|
||||
IsWhatsAppProxyRole,
|
||||
};
|
||||
|
||||
explicit ProtocolsModel(QObject *parent = nullptr);
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
#include "whatsAppProxyConfigModel.h"
|
||||
|
||||
#include "core/utils/constants/configKeys.h"
|
||||
#include "core/utils/constants/protocolConstants.h"
|
||||
#include "core/utils/networkUtilities.h"
|
||||
|
||||
#include <QHostAddress>
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
namespace
|
||||
{
|
||||
const QRegularExpression kHostnameRe(
|
||||
QStringLiteral("^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)+$"));
|
||||
}
|
||||
|
||||
WhatsAppProxyConfigModel::WhatsAppProxyConfigModel(QObject *parent) : QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool WhatsAppProxyConfigModel::isEnabled() const
|
||||
{
|
||||
return m_protocolConfig.isEnabled;
|
||||
}
|
||||
|
||||
void WhatsAppProxyConfigModel::updateModel(DockerContainer container, const WhatsAppProxyProtocolConfig &protocolConfig)
|
||||
{
|
||||
m_container = container;
|
||||
m_protocolConfig = protocolConfig;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void WhatsAppProxyConfigModel::updateModel(const QJsonObject &config)
|
||||
{
|
||||
m_fullConfig = config;
|
||||
m_protocolConfig = WhatsAppProxyProtocolConfig::fromJson(config.value(configKey::whatsappproxy).toObject());
|
||||
m_protocolConfig.port = m_protocolConfig.effectivePort();
|
||||
m_protocolConfig.mediaPort = m_protocolConfig.effectiveMediaPort();
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QJsonObject WhatsAppProxyConfigModel::getConfig()
|
||||
{
|
||||
m_fullConfig.insert(configKey::whatsappproxy, m_protocolConfig.toJson());
|
||||
return m_fullConfig;
|
||||
}
|
||||
|
||||
WhatsAppProxyProtocolConfig WhatsAppProxyConfigModel::getProtocolConfig()
|
||||
{
|
||||
return m_protocolConfig;
|
||||
}
|
||||
|
||||
void WhatsAppProxyConfigModel::setPort(const QString &port)
|
||||
{
|
||||
const QString p = sanitizePortFieldText(port);
|
||||
if (m_protocolConfig.port == p) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.port = p;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void WhatsAppProxyConfigModel::setMediaPort(const QString &port)
|
||||
{
|
||||
const QString p = sanitizePortFieldText(port);
|
||||
if (m_protocolConfig.mediaPort == p) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.mediaPort = p;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void WhatsAppProxyConfigModel::setPublicHost(const QString &host)
|
||||
{
|
||||
const QString h = host.trimmed();
|
||||
if (!isValidPublicHost(h) || m_protocolConfig.publicHost == h) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.publicHost = h;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void WhatsAppProxyConfigModel::setEnabled(bool enabled)
|
||||
{
|
||||
if (m_protocolConfig.isEnabled == enabled) {
|
||||
return;
|
||||
}
|
||||
m_protocolConfig.isEnabled = enabled;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
QString WhatsAppProxyConfigModel::getPort() const
|
||||
{
|
||||
return m_protocolConfig.effectivePort();
|
||||
}
|
||||
|
||||
QString WhatsAppProxyConfigModel::getMediaPort() const
|
||||
{
|
||||
return m_protocolConfig.effectiveMediaPort();
|
||||
}
|
||||
|
||||
QString WhatsAppProxyConfigModel::getPublicHost() const
|
||||
{
|
||||
return m_protocolConfig.publicHost;
|
||||
}
|
||||
|
||||
QString WhatsAppProxyConfigModel::defaultPort() const
|
||||
{
|
||||
return QString(protocols::whatsAppProxy::defaultPort);
|
||||
}
|
||||
|
||||
QString WhatsAppProxyConfigModel::defaultMediaPort() const
|
||||
{
|
||||
return QString(protocols::whatsAppProxy::defaultMediaPort);
|
||||
}
|
||||
|
||||
bool WhatsAppProxyConfigModel::isValidPort(const QString &port) const
|
||||
{
|
||||
bool ok = false;
|
||||
const int n = port.toInt(&ok);
|
||||
return ok && n >= 1 && n <= 65535;
|
||||
}
|
||||
|
||||
bool WhatsAppProxyConfigModel::isValidPublicHost(const QString &host) const
|
||||
{
|
||||
const QString t = host.trimmed();
|
||||
if (t.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (t.length() > 253) {
|
||||
return false;
|
||||
}
|
||||
const QHostAddress address(t);
|
||||
if (address.protocol() == QHostAddress::IPv4Protocol) {
|
||||
return NetworkUtilities::checkIPv4Format(t);
|
||||
}
|
||||
if (address.protocol() == QHostAddress::IPv6Protocol) {
|
||||
return !address.isNull() && !address.isLoopback();
|
||||
}
|
||||
return kHostnameRe.match(t).hasMatch();
|
||||
}
|
||||
|
||||
QString WhatsAppProxyConfigModel::sanitizePortFieldText(const QString &input) const
|
||||
{
|
||||
QString out;
|
||||
out.reserve(qMin(input.size(), 5));
|
||||
for (const QChar &c : input) {
|
||||
const ushort u = c.unicode();
|
||||
if (u >= '0' && u <= '9' && out.size() < 5) {
|
||||
out.append(c);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef WHATSAPPPROXYCONFIGMODEL_H
|
||||
#define WHATSAPPPROXYCONFIGMODEL_H
|
||||
|
||||
#include "core/models/protocols/whatsAppProxyProtocolConfig.h"
|
||||
#include "core/utils/containerEnum.h"
|
||||
#include <QJsonObject>
|
||||
#include <QObject>
|
||||
|
||||
class WhatsAppProxyConfigModel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString port READ getPort WRITE setPort NOTIFY changed)
|
||||
Q_PROPERTY(QString mediaPort READ getMediaPort WRITE setMediaPort NOTIFY changed)
|
||||
Q_PROPERTY(QString publicHost READ getPublicHost WRITE setPublicHost NOTIFY changed)
|
||||
Q_PROPERTY(bool isEnabled READ isEnabled WRITE setEnabled NOTIFY changed)
|
||||
|
||||
public:
|
||||
explicit WhatsAppProxyConfigModel(QObject *parent = nullptr);
|
||||
|
||||
bool isEnabled() const;
|
||||
|
||||
public slots:
|
||||
void updateModel(amnezia::DockerContainer container, const amnezia::WhatsAppProxyProtocolConfig &protocolConfig);
|
||||
void updateModel(const QJsonObject &config);
|
||||
|
||||
QJsonObject getConfig();
|
||||
amnezia::WhatsAppProxyProtocolConfig getProtocolConfig();
|
||||
|
||||
Q_INVOKABLE void setPort(const QString &port);
|
||||
Q_INVOKABLE void setMediaPort(const QString &port);
|
||||
Q_INVOKABLE void setPublicHost(const QString &host);
|
||||
Q_INVOKABLE void setEnabled(bool enabled);
|
||||
|
||||
Q_INVOKABLE QString getPort() const;
|
||||
Q_INVOKABLE QString getMediaPort() const;
|
||||
Q_INVOKABLE QString getPublicHost() const;
|
||||
|
||||
Q_INVOKABLE QString defaultPort() const;
|
||||
Q_INVOKABLE QString defaultMediaPort() const;
|
||||
|
||||
Q_INVOKABLE bool isValidPort(const QString &port) const;
|
||||
Q_INVOKABLE bool isValidPublicHost(const QString &host) const;
|
||||
Q_INVOKABLE QString sanitizePortFieldText(const QString &input) const;
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
private:
|
||||
amnezia::DockerContainer m_container;
|
||||
QJsonObject m_fullConfig;
|
||||
amnezia::WhatsAppProxyProtocolConfig m_protocolConfig;
|
||||
};
|
||||
|
||||
#endif // WHATSAPPPROXYCONFIGMODEL_H
|
||||
@@ -1,87 +0,0 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
import MtProxyConfig 1.0
|
||||
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
|
||||
property string endpoint
|
||||
property string port
|
||||
property string endpointPlaceholder
|
||||
property string portPlaceholder
|
||||
property bool warningVisible: false
|
||||
property var scroller: null
|
||||
|
||||
signal endpointEdited(string text)
|
||||
signal portEdited(string text)
|
||||
|
||||
spacing: 12
|
||||
|
||||
H2TextType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 28
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
text: qsTr("Cascade connection")
|
||||
}
|
||||
|
||||
NotificationType {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
visible: root.warningVisible
|
||||
|
||||
variant: NotificationType.Warning
|
||||
text: qsTr("Cascade endpoint and port are the address and port of the entry server that forwards traffic to this server. New client configs will connect to them instead of this server's address and port. Existing configs are not changed")
|
||||
}
|
||||
|
||||
TextFieldType {
|
||||
id: endpointTextField
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
headerText: qsTr("Cascade endpoint")
|
||||
textField.placeholderText: root.endpointPlaceholder
|
||||
textField.text: root.endpoint
|
||||
textField.maximumLength: 253
|
||||
textField.validator: PublicHostInputValidator {}
|
||||
|
||||
textField.onTextEdited: root.endpointEdited(textField.text.trim())
|
||||
|
||||
textField.onActiveFocusChanged: {
|
||||
if (textField.activeFocus && root.scroller) {
|
||||
root.scroller.scrollToItem(endpointTextField)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextFieldType {
|
||||
id: portTextField
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
headerText: qsTr("Cascade port")
|
||||
textField.placeholderText: root.portPlaceholder
|
||||
textField.text: root.port
|
||||
textField.maximumLength: 5
|
||||
textField.validator: IntValidator { bottom: 1; top: 65535 }
|
||||
|
||||
textField.onTextEdited: root.portEdited(textField.text)
|
||||
|
||||
textField.onActiveFocusChanged: {
|
||||
if (textField.activeFocus && root.scroller) {
|
||||
root.scroller.scrollToItem(portTextField)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,9 @@ ListViewType {
|
||||
} else if (isTProxy) {
|
||||
TProxyConfigModel.updateModel(config)
|
||||
PageController.goToPage(PageEnum.PageServiceTProxySettings, false)
|
||||
} else if (isWhatsAppProxy) {
|
||||
WhatsAppProxyConfigModel.updateModel(config)
|
||||
PageController.goToPage(PageEnum.PageServiceWhatsAppProxySettings, false)
|
||||
} else {
|
||||
InstallController.updateProtocols(ServersUiController.processedServerId, containerIndex)
|
||||
PageController.goToPage(PageEnum.PageSettingsServerProtocol)
|
||||
|
||||
@@ -118,7 +118,6 @@ Item {
|
||||
|
||||
enabled: d.scrolled > 0
|
||||
acceptedButtons: Qt.AllButtons
|
||||
hoverEnabled: true
|
||||
}
|
||||
|
||||
IconButtonType {
|
||||
|
||||
@@ -15,6 +15,16 @@ TabButton {
|
||||
readonly property int maximumHorizontalPadding: root.size === TabButtonType.Large ? 24 : 10
|
||||
|
||||
implicitWidth: implicitContentWidth + 2 * root.maximumHorizontalPadding
|
||||
width: {
|
||||
if (!root.visible) {
|
||||
return 0
|
||||
}
|
||||
const tabBar = root.TabBar.tabBar
|
||||
if (!tabBar || tabBar.visibleTabCount === undefined) {
|
||||
return implicitWidth
|
||||
}
|
||||
return tabBar.availableWidth / Math.max(1, tabBar.visibleTabCount)
|
||||
}
|
||||
implicitHeight: root.size === TabButtonType.Large ? 48 : 36
|
||||
|
||||
horizontalPadding: Math.max(4, Math.min(root.maximumHorizontalPadding, (root.width - implicitContentWidth) / 2))
|
||||
|
||||
@@ -4,6 +4,17 @@ import QtQuick.Controls
|
||||
TabBar {
|
||||
id: root
|
||||
|
||||
readonly property int visibleTabCount: {
|
||||
let visibleCount = 0
|
||||
for (let i = 0; i < root.count; ++i) {
|
||||
const tab = root.itemAt(i)
|
||||
if (tab && tab.visible) {
|
||||
++visibleCount
|
||||
}
|
||||
}
|
||||
return visibleCount
|
||||
}
|
||||
|
||||
spacing: 0
|
||||
background: null
|
||||
}
|
||||
@@ -54,25 +54,14 @@ PageType {
|
||||
Layout.fillWidth: true
|
||||
|
||||
headerText: qsTr("Gateway endpoint")
|
||||
textField.text: SettingsController.devGatewayEndpoint
|
||||
}
|
||||
textField.text: SettingsController.gatewayEndpoint
|
||||
|
||||
TextFieldType {
|
||||
id: gatewayProxyStoragesField
|
||||
buttonImageSource: textField.text !== "" ? "qrc:/images/controls/refresh-cw.svg" : ""
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
headerText: qsTr("Gateway proxy storages")
|
||||
textField.text: SettingsController.devGatewayProxyStorages
|
||||
}
|
||||
|
||||
TextFieldType {
|
||||
id: gatewayPublicKeyField
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
headerText: qsTr("Gateway public key")
|
||||
textField.text: SettingsController.devGatewayPublicKey
|
||||
clickedFunc: function() {
|
||||
SettingsController.resetGatewayEndpoint()
|
||||
gatewayEndpointField.textField.text = SettingsController.gatewayEndpoint
|
||||
}
|
||||
}
|
||||
|
||||
ButtonType {
|
||||
@@ -83,12 +72,11 @@ PageType {
|
||||
text: qsTr("Save")
|
||||
|
||||
onClicked: {
|
||||
SettingsController.saveDevGatewayConfig(gatewayEndpointField.textField.text.trim(),
|
||||
gatewayProxyStoragesField.textField.text.trim(),
|
||||
gatewayPublicKeyField.textField.text.trim())
|
||||
gatewayEndpointField.textField.text = SettingsController.devGatewayEndpoint
|
||||
gatewayProxyStoragesField.textField.text = SettingsController.devGatewayProxyStorages
|
||||
gatewayPublicKeyField.textField.text = SettingsController.devGatewayPublicKey
|
||||
var trimmed = gatewayEndpointField.textField.text.replace(/^\s+|\s+$/g, '')
|
||||
gatewayEndpointField.textField.text = trimmed
|
||||
if (trimmed !== SettingsController.gatewayEndpoint) {
|
||||
SettingsController.gatewayEndpoint = trimmed
|
||||
}
|
||||
PageController.showNotificationMessage(qsTr("Settings saved"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,20 +271,6 @@ PageType {
|
||||
}
|
||||
}
|
||||
|
||||
CascadeSettings {
|
||||
Layout.fillWidth: true
|
||||
|
||||
scroller: smartScroll
|
||||
|
||||
endpoint: AwgConfigModel.clientCascadeEndpoint
|
||||
port: AwgConfigModel.clientCascadePort
|
||||
endpointPlaceholder: AwgConfigModel.clientHostName
|
||||
portPlaceholder: AwgConfigModel.clientPort
|
||||
|
||||
onEndpointEdited: (text) => { AwgConfigModel.clientCascadeEndpoint = text }
|
||||
onPortEdited: (text) => { AwgConfigModel.clientCascadePort = text }
|
||||
}
|
||||
|
||||
H2TextType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 28
|
||||
|
||||
@@ -464,23 +464,6 @@ PageType {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CascadeSettings {
|
||||
Layout.fillWidth: true
|
||||
|
||||
enabled: root.isEnabled
|
||||
|
||||
warningVisible: true
|
||||
scroller: smartScroll
|
||||
|
||||
endpoint: AwgConfigModel.cascadeEndpoint
|
||||
port: AwgConfigModel.cascadePort
|
||||
endpointPlaceholder: ServersUiController.serverHostName(ServersUiController.processedServerId)
|
||||
portPlaceholder: AwgConfigModel.port
|
||||
|
||||
onEndpointEdited: (text) => { AwgConfigModel.cascadeEndpoint = text }
|
||||
onPortEdited: (text) => { AwgConfigModel.cascadePort = text }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,18 +60,6 @@ PageType {
|
||||
checkEmptyText: true
|
||||
}
|
||||
|
||||
CascadeSettings {
|
||||
Layout.fillWidth: true
|
||||
|
||||
endpoint: WireGuardConfigModel.clientCascadeEndpoint
|
||||
port: WireGuardConfigModel.clientCascadePort
|
||||
endpointPlaceholder: WireGuardConfigModel.clientHostName
|
||||
portPlaceholder: WireGuardConfigModel.clientPort
|
||||
|
||||
onEndpointEdited: (text) => { WireGuardConfigModel.clientCascadeEndpoint = text }
|
||||
onPortEdited: (text) => { WireGuardConfigModel.clientCascadePort = text }
|
||||
}
|
||||
|
||||
H2TextType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 40
|
||||
|
||||
@@ -77,20 +77,6 @@ PageType {
|
||||
|
||||
checkEmptyText: true
|
||||
}
|
||||
|
||||
CascadeSettings {
|
||||
Layout.fillWidth: true
|
||||
|
||||
warningVisible: true
|
||||
|
||||
endpoint: WireGuardConfigModel.cascadeEndpoint
|
||||
port: WireGuardConfigModel.cascadePort
|
||||
endpointPlaceholder: ServersUiController.serverHostName(ServersUiController.processedServerId)
|
||||
portPlaceholder: WireGuardConfigModel.port
|
||||
|
||||
onEndpointEdited: (text) => { WireGuardConfigModel.cascadeEndpoint = text }
|
||||
onPortEdited: (text) => { WireGuardConfigModel.cascadePort = text }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +159,7 @@ PageType {
|
||||
id: sniFieldTls
|
||||
Layout.fillWidth: true
|
||||
headerText: qsTr("Server Name (SNI)")
|
||||
placeholderText: XrayConfigModel.sniDefault()
|
||||
textField.text: XrayConfigModel.sni
|
||||
textField.validator: RegularExpressionValidator { regularExpression: /^[A-Za-z0-9._-]*$/ }
|
||||
textField.onTextEdited: XrayConfigModel.sni = textField.text
|
||||
@@ -215,6 +216,7 @@ PageType {
|
||||
id: sniFieldReality
|
||||
Layout.fillWidth: true
|
||||
headerText: qsTr("Server Name (SNI)")
|
||||
placeholderText: XrayConfigModel.sniDefault()
|
||||
textField.text: XrayConfigModel.sni
|
||||
textField.validator: RegularExpressionValidator { regularExpression: /^[A-Za-z0-9._-]*$/ }
|
||||
textField.onTextEdited: XrayConfigModel.sni = textField.text
|
||||
|
||||
@@ -0,0 +1,567 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import PageEnum 1.0
|
||||
import ProtocolEnum 1.0
|
||||
import Style 1.0
|
||||
import MtProxyConfig 1.0
|
||||
|
||||
import "./"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
import "../Components"
|
||||
|
||||
PageType {
|
||||
id: root
|
||||
|
||||
property int containerStatus: 1
|
||||
property int statusErrorCode: 0
|
||||
property bool isUpdating: false
|
||||
property bool isCheckingStatus: false
|
||||
property bool previousEnabled: true
|
||||
property int previousContainerStatus: 1
|
||||
property string savedPublicHost: ""
|
||||
property string savedPort: ""
|
||||
property string savedMediaPort: ""
|
||||
property bool pendingUpdateAfterEnable: false
|
||||
property bool remoteOperationBusy: false
|
||||
|
||||
readonly property bool networkBlocked: !NetworkReachabilityController.hasInternetAccess
|
||||
readonly property bool pageBusy: isCheckingStatus || isUpdating || remoteOperationBusy
|
||||
readonly property bool navigationBlockedWhileBusy: pageBusy
|
||||
|
||||
property bool pageOpenHandled: false
|
||||
property bool busyIndicatorShown: false
|
||||
property bool containerStatusRefreshCallPending: false
|
||||
|
||||
readonly property bool fieldsEditable: WhatsAppProxyConfigModel.isEnabled && containerStatus === 1 && !root.pageBusy
|
||||
|
||||
function effectiveHost() {
|
||||
return root.savedPublicHost !== "" ? root.savedPublicHost : ServersUiController.serverHostName(ServersUiController.processedServerId)
|
||||
}
|
||||
|
||||
function shareText() {
|
||||
return qsTr("WhatsApp proxy") + "\n"
|
||||
+ qsTr("Proxy address: %1").arg(root.effectiveHost()) + "\n"
|
||||
+ qsTr("Chat port: %1 (TLS on)").arg(root.savedPort) + "\n"
|
||||
+ qsTr("Media port: %1").arg(root.savedMediaPort) + "\n"
|
||||
+ qsTr("WhatsApp: Settings > Storage and data > Proxy")
|
||||
}
|
||||
|
||||
function saveCurrentValues() {
|
||||
savedPublicHost = WhatsAppProxyConfigModel.getPublicHost()
|
||||
savedPort = WhatsAppProxyConfigModel.getPort()
|
||||
savedMediaPort = WhatsAppProxyConfigModel.getMediaPort()
|
||||
}
|
||||
|
||||
function syncPageBusyIndicator() {
|
||||
if (!root.pageOpenHandled) {
|
||||
return
|
||||
}
|
||||
var wantBusy = root.pageBusy
|
||||
if (wantBusy === root.busyIndicatorShown) {
|
||||
return
|
||||
}
|
||||
root.busyIndicatorShown = wantBusy
|
||||
PageController.showBusyIndicator(wantBusy)
|
||||
}
|
||||
|
||||
onPageBusyChanged: syncPageBusyIndicator()
|
||||
|
||||
function requestContainerStatusRefresh() {
|
||||
if (!NetworkReachabilityController.hasInternetAccess) {
|
||||
isCheckingStatus = false
|
||||
syncPageBusyIndicator()
|
||||
return
|
||||
}
|
||||
isCheckingStatus = true
|
||||
syncPageBusyIndicator()
|
||||
InstallController.refreshContainerStatus(ServersUiController.processedServerId,
|
||||
ServersUiController.processedContainerIndex)
|
||||
}
|
||||
|
||||
function scheduleContainerStatusRefresh() {
|
||||
if (containerStatusRefreshCallPending) {
|
||||
return
|
||||
}
|
||||
containerStatusRefreshCallPending = true
|
||||
Qt.callLater(function () {
|
||||
containerStatusRefreshCallPending = false
|
||||
root.requestContainerStatusRefresh()
|
||||
})
|
||||
}
|
||||
|
||||
function onPageShown() {
|
||||
if (root.pageOpenHandled) {
|
||||
return
|
||||
}
|
||||
root.pageOpenHandled = true
|
||||
|
||||
PageController.disableControls(navigationBlockedWhileBusy)
|
||||
|
||||
isCheckingStatus = NetworkReachabilityController.hasInternetAccess
|
||||
syncPageBusyIndicator()
|
||||
root.scheduleContainerStatusRefresh()
|
||||
}
|
||||
|
||||
function scheduleUpdate() {
|
||||
Qt.callLater(function () {
|
||||
InstallController.updateServerConfig(ServersUiController.processedServerId,
|
||||
ServersUiController.processedContainerIndex, ProtocolEnum.WhatsAppProxy, false)
|
||||
})
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: InstallController
|
||||
|
||||
function onUpdateContainerFinished(message, closePage) {
|
||||
if (!root.visible) {
|
||||
isUpdating = false
|
||||
isCheckingStatus = false
|
||||
return
|
||||
}
|
||||
isUpdating = false
|
||||
containerStatus = 1
|
||||
root.saveCurrentValues()
|
||||
PageController.showNotificationMessage(message)
|
||||
}
|
||||
function onInstallationErrorOccurred() {
|
||||
if (!root.visible) {
|
||||
isUpdating = false
|
||||
isCheckingStatus = false
|
||||
return
|
||||
}
|
||||
isUpdating = false
|
||||
containerStatus = previousContainerStatus
|
||||
WhatsAppProxyConfigModel.setEnabled(previousEnabled)
|
||||
WhatsAppProxyConfigModel.setPublicHost(savedPublicHost)
|
||||
WhatsAppProxyConfigModel.setPort(savedPort)
|
||||
WhatsAppProxyConfigModel.setMediaPort(savedMediaPort)
|
||||
}
|
||||
function onSetContainerEnabledFinished(enabled) {
|
||||
if (!root.visible) {
|
||||
isUpdating = false
|
||||
return
|
||||
}
|
||||
if (enabled && root.pendingUpdateAfterEnable) {
|
||||
root.pendingUpdateAfterEnable = false
|
||||
isUpdating = true
|
||||
root.scheduleUpdate()
|
||||
return
|
||||
}
|
||||
isUpdating = false
|
||||
containerStatus = enabled ? 1 : 2
|
||||
PageController.showNotificationMessage(enabled ? qsTr("WhatsApp proxy started") : qsTr("WhatsApp proxy stopped"))
|
||||
}
|
||||
function onServerIsBusy(busy) {
|
||||
root.remoteOperationBusy = busy
|
||||
}
|
||||
function onContainerStatusRefreshed(status, errorCode) {
|
||||
if (!root.visible) {
|
||||
isCheckingStatus = false
|
||||
return
|
||||
}
|
||||
containerStatus = status
|
||||
root.statusErrorCode = errorCode
|
||||
if (status === 3 && errorCode !== 0) {
|
||||
PageController.showNotificationMessage(
|
||||
qsTr("Settings locked: connection timed out (error code %1). Re-open the page to retry.").arg(errorCode))
|
||||
}
|
||||
|
||||
root.saveCurrentValues()
|
||||
if (status === 1) {
|
||||
WhatsAppProxyConfigModel.setEnabled(true)
|
||||
} else if (status === 2) {
|
||||
WhatsAppProxyConfigModel.setEnabled(false)
|
||||
}
|
||||
isCheckingStatus = false
|
||||
syncPageBusyIndicator()
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
root.saveCurrentValues()
|
||||
Qt.callLater(root.onPageShown)
|
||||
}
|
||||
|
||||
onNavigationBlockedWhileBusyChanged: {
|
||||
if (root.visible) {
|
||||
PageController.disableControls(navigationBlockedWhileBusy)
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (!visible) {
|
||||
root.pageOpenHandled = false
|
||||
containerStatusRefreshCallPending = false
|
||||
isCheckingStatus = false
|
||||
busyIndicatorShown = false
|
||||
statusErrorCode = 0
|
||||
PageController.disableControls(false)
|
||||
PageController.showBusyIndicator(false)
|
||||
} else {
|
||||
root.onPageShown()
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: NetworkReachabilityController
|
||||
|
||||
function onHasInternetAccessChanged() {
|
||||
if (!root.visible) {
|
||||
return
|
||||
}
|
||||
if (NetworkReachabilityController.hasInternetAccess) {
|
||||
root.scheduleContainerStatusRefresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: contentLayer
|
||||
anchors.fill: parent
|
||||
enabled: !root.pageBusy
|
||||
|
||||
ColumnLayout {
|
||||
id: pageHeader
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
spacing: 0
|
||||
|
||||
NavigationBarType {
|
||||
Layout.fillWidth: true
|
||||
|
||||
title: qsTr("WhatsApp proxy settings")
|
||||
}
|
||||
|
||||
LinkButtonType {
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
size: LinkButtonType.Medium
|
||||
horizontalPadding: 14
|
||||
verticalPadding: 8
|
||||
|
||||
text: qsTr("Read more about WhatsApp proxy")
|
||||
|
||||
onClicked: Qt.openUrlExternally("https://github.com/WhatsApp/proxy")
|
||||
}
|
||||
|
||||
SmallTextType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 12
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
visible: root.networkBlocked
|
||||
text: qsTr("No internet connection. Connect to the internet to change WhatsApp proxy settings.")
|
||||
}
|
||||
}
|
||||
|
||||
TabsType {
|
||||
id: mainTabBar
|
||||
|
||||
anchors.top: pageHeader.bottom
|
||||
anchors.topMargin: 24
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 16
|
||||
anchors.rightMargin: 16
|
||||
|
||||
TabButtonType {
|
||||
text: qsTr("Connection")
|
||||
}
|
||||
TabButtonType {
|
||||
text: qsTr("Settings")
|
||||
}
|
||||
}
|
||||
|
||||
StackLayout {
|
||||
anchors.top: mainTabBar.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
currentIndex: mainTabBar.currentIndex
|
||||
|
||||
Item {
|
||||
FlickableType {
|
||||
id: connectionFlickable
|
||||
|
||||
anchors.top: parent.top
|
||||
|
||||
contentHeight: connectionContent.implicitHeight
|
||||
|
||||
ColumnLayout {
|
||||
id: connectionContent
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
spacing: 0
|
||||
|
||||
SmallTextType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 24
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
text: qsTr("Enter these values in WhatsApp: Settings > Storage and data > Proxy")
|
||||
}
|
||||
|
||||
ListGroupType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 12
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
CopyableValueRow {
|
||||
Layout.fillWidth: true
|
||||
|
||||
copiedText: qsTr("Copied")
|
||||
label: qsTr("Proxy address")
|
||||
value: root.effectiveHost()
|
||||
}
|
||||
|
||||
CopyableValueRow {
|
||||
Layout.fillWidth: true
|
||||
|
||||
copiedText: qsTr("Copied")
|
||||
label: qsTr("Chat port (TLS on)")
|
||||
value: root.savedPort
|
||||
}
|
||||
|
||||
CopyableValueRow {
|
||||
Layout.fillWidth: true
|
||||
|
||||
copiedText: qsTr("Copied")
|
||||
label: qsTr("Media port")
|
||||
value: root.savedMediaPort
|
||||
showSeparator: false
|
||||
}
|
||||
}
|
||||
|
||||
ButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 24
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
text: qsTr("Share")
|
||||
|
||||
onClicked: {
|
||||
ExportController.generateQrFromStringRaw(root.shareText())
|
||||
PageController.goToShareConnectionPage(qsTr("WhatsApp proxy"),
|
||||
qsTr("WhatsApp proxy settings"), "", ".txt", "whatsapp_proxy")
|
||||
}
|
||||
}
|
||||
|
||||
CaptionTextType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 12
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
text: qsTr("Anyone who knows the address and ports can use the proxy. Calls are not proxied.")
|
||||
}
|
||||
|
||||
ButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 24
|
||||
Layout.bottomMargin: 16 + PageController.safeAreaBottomMargin
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
visible: ServersUiController.isProcessedServerHasWriteAccess()
|
||||
variant: ButtonType.Destructive
|
||||
text: qsTr("Delete WhatsApp proxy")
|
||||
|
||||
onClicked: {
|
||||
var headerText = qsTr("Remove %1 from server?").arg(ContainersModel.getProcessedContainerName())
|
||||
var yesButtonFunction = function () {
|
||||
PageController.goToPage(PageEnum.PageDeinstalling)
|
||||
InstallController.removeContainer(ServersUiController.processedServerId,
|
||||
ServersUiController.processedContainerIndex)
|
||||
}
|
||||
Dialogs.askQuestion(headerText,
|
||||
qsTr("The proxy will be stopped and all users will lose access."),
|
||||
qsTr("Continue"), qsTr("Cancel"), yesButtonFunction, function () {})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
FlickableType {
|
||||
id: settingsFlickable
|
||||
|
||||
anchors.top: parent.top
|
||||
|
||||
contentHeight: settingsContent.implicitHeight
|
||||
|
||||
ColumnLayout {
|
||||
id: settingsContent
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
spacing: 12
|
||||
|
||||
SwitchRowType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 24
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
text: qsTr("Enable WhatsApp proxy")
|
||||
checked: WhatsAppProxyConfigModel.isEnabled
|
||||
enabled: containerStatus !== 0 && containerStatus !== 3 && !root.pageBusy && !root.networkBlocked
|
||||
onToggled: function () {
|
||||
if (checked !== WhatsAppProxyConfigModel.isEnabled) {
|
||||
previousEnabled = WhatsAppProxyConfigModel.isEnabled
|
||||
previousContainerStatus = containerStatus
|
||||
WhatsAppProxyConfigModel.isEnabled = checked
|
||||
isUpdating = true
|
||||
if (checked) {
|
||||
root.pendingUpdateAfterEnable = true
|
||||
}
|
||||
InstallController.setContainerEnabled(ServersUiController.processedServerId,
|
||||
ServersUiController.processedContainerIndex, checked)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SmallTextType {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
visible: !root.fieldsEditable && !root.pageBusy
|
||||
text: (containerStatus === 1 || containerStatus === 2)
|
||||
? qsTr("Enable WhatsApp proxy to edit settings")
|
||||
: (statusErrorCode !== 0
|
||||
? qsTr("Settings locked: connection timed out (error code %1). Re-open the page to retry.").arg(statusErrorCode)
|
||||
: qsTr("Cannot reach the server — settings are unavailable"))
|
||||
}
|
||||
|
||||
TextFieldType {
|
||||
id: publicHostTextField
|
||||
Layout.topMargin: 12
|
||||
enabled: root.fieldsEditable
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
headerText: qsTr("Public host / IP")
|
||||
textField.placeholderText: ServersUiController.serverHostName(ServersUiController.processedServerId)
|
||||
textField.text: WhatsAppProxyConfigModel.publicHost
|
||||
textField.maximumLength: 253
|
||||
textField.validator: PublicHostInputValidator {
|
||||
}
|
||||
textField.onEditingFinished: {
|
||||
textField.text = textField.text.trim()
|
||||
if (!WhatsAppProxyConfigModel.isValidPublicHost(textField.text)) {
|
||||
publicHostTextField.errorText = qsTr("Enter a valid IP address or domain name")
|
||||
return
|
||||
}
|
||||
publicHostTextField.errorText = ""
|
||||
}
|
||||
}
|
||||
|
||||
CaptionTextType {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
text: qsTr("Leave empty to use server IP automatically")
|
||||
}
|
||||
|
||||
TextFieldType {
|
||||
id: portTextField
|
||||
enabled: root.fieldsEditable
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
headerText: qsTr("Chat port")
|
||||
textField.placeholderText: WhatsAppProxyConfigModel.defaultPort()
|
||||
textField.text: WhatsAppProxyConfigModel.port
|
||||
textField.maximumLength: 5
|
||||
textField.inputMethodHints: Qt.ImhDigitsOnly
|
||||
textField.validator: IntValidator { bottom: 1; top: 65535 }
|
||||
}
|
||||
|
||||
TextFieldType {
|
||||
id: mediaPortTextField
|
||||
enabled: root.fieldsEditable
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
headerText: qsTr("Media port")
|
||||
textField.placeholderText: WhatsAppProxyConfigModel.defaultMediaPort()
|
||||
textField.text: WhatsAppProxyConfigModel.mediaPort
|
||||
textField.maximumLength: 5
|
||||
textField.inputMethodHints: Qt.ImhDigitsOnly
|
||||
textField.validator: IntValidator { bottom: 1; top: 65535 }
|
||||
}
|
||||
|
||||
CaptionTextType {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
text: qsTr("Changing a port reinstalls the container. WhatsApp uses 443 and 587 by default; with other ports users enter them manually and enable TLS for the chat port.")
|
||||
}
|
||||
|
||||
ButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 12
|
||||
Layout.bottomMargin: 16 + PageController.safeAreaBottomMargin
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
text: qsTr("Save")
|
||||
enabled: root.fieldsEditable && !root.networkBlocked
|
||||
onClicked: {
|
||||
publicHostTextField.errorText = ""
|
||||
portTextField.errorText = ""
|
||||
mediaPortTextField.errorText = ""
|
||||
|
||||
var host = publicHostTextField.textField.text.trim()
|
||||
var chatPort = WhatsAppProxyConfigModel.sanitizePortFieldText(portTextField.textField.text)
|
||||
var mediaPort = WhatsAppProxyConfigModel.sanitizePortFieldText(mediaPortTextField.textField.text)
|
||||
|
||||
var hasError = false
|
||||
if (!WhatsAppProxyConfigModel.isValidPublicHost(host)) {
|
||||
publicHostTextField.errorText = qsTr("Enter a valid IP address or domain name")
|
||||
hasError = true
|
||||
}
|
||||
if (!WhatsAppProxyConfigModel.isValidPort(chatPort)) {
|
||||
portTextField.errorText = qsTr("The port must be in the range of 1 to 65535")
|
||||
hasError = true
|
||||
}
|
||||
if (!WhatsAppProxyConfigModel.isValidPort(mediaPort)) {
|
||||
mediaPortTextField.errorText = qsTr("The port must be in the range of 1 to 65535")
|
||||
hasError = true
|
||||
} else if (mediaPort === chatPort) {
|
||||
mediaPortTextField.errorText = qsTr("The media port must differ from the chat port")
|
||||
hasError = true
|
||||
}
|
||||
if (hasError) {
|
||||
return
|
||||
}
|
||||
|
||||
previousContainerStatus = containerStatus
|
||||
WhatsAppProxyConfigModel.setPublicHost(host)
|
||||
WhatsAppProxyConfigModel.setPort(chatPort)
|
||||
WhatsAppProxyConfigModel.setMediaPort(mediaPort)
|
||||
isUpdating = true
|
||||
root.scheduleUpdate()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,8 +160,6 @@ PageType {
|
||||
width: listView.width
|
||||
implicitHeight: appItem.implicitHeight
|
||||
|
||||
enabled: root.pageEnabled
|
||||
|
||||
ListItemType {
|
||||
id: appItem
|
||||
|
||||
|
||||
@@ -21,30 +21,13 @@ PageType {
|
||||
readonly property int pageSettingsServerServices: 1
|
||||
readonly property int pageSettingsServerData: 2
|
||||
|
||||
readonly property var tabTitles: [qsTr("Protocols"), qsTr("Services"), qsTr("Management")]
|
||||
readonly property var availableTabs: {
|
||||
const tabs = []
|
||||
if (protocolsPage.installedProtocolsCount > 0) {
|
||||
tabs.push(root.pageSettingsServerProtocols)
|
||||
}
|
||||
if (servicesPage.installedServicesCount > 0) {
|
||||
tabs.push(root.pageSettingsServerServices)
|
||||
}
|
||||
tabs.push(root.pageSettingsServerData)
|
||||
return tabs
|
||||
}
|
||||
|
||||
property int currentTab: (ServersUiController.isServerFromApi(ServersUiController.processedServerId)
|
||||
&& !ServersUiController.serverHasInstalledContainers(ServersUiController.processedServerId)) ?
|
||||
root.pageSettingsServerData : root.pageSettingsServerProtocols
|
||||
|
||||
property var processedServer
|
||||
|
||||
Connections {
|
||||
target: PageController
|
||||
|
||||
function onGoToPageSettingsServerServices() {
|
||||
root.currentTab = root.pageSettingsServerServices
|
||||
tabBar.setCurrentIndex(root.pageSettingsServerServices)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,18 +111,25 @@ PageType {
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
currentIndex: root.availableTabs.indexOf(root.currentTab)
|
||||
currentIndex: (ServersUiController.isServerFromApi(ServersUiController.processedServerId)
|
||||
&& !ServersUiController.serverHasInstalledContainers(ServersUiController.processedServerId)) ?
|
||||
root.pageSettingsServerData : root.pageSettingsServerProtocols
|
||||
|
||||
Repeater {
|
||||
model: root.availableTabs
|
||||
TabButtonType {
|
||||
id: protocolsTab
|
||||
visible: protocolsPage.installedProtocolsCount > 0
|
||||
text: qsTr("Protocols")
|
||||
}
|
||||
|
||||
TabButtonType {
|
||||
required property int modelData
|
||||
TabButtonType {
|
||||
id: servicesTab
|
||||
visible: servicesPage.installedServicesCount > 0
|
||||
text: qsTr("Services")
|
||||
}
|
||||
|
||||
text: root.tabTitles[modelData]
|
||||
|
||||
onClicked: root.currentTab = modelData
|
||||
}
|
||||
TabButtonType {
|
||||
id: dataTab
|
||||
text: qsTr("Management")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +140,7 @@ PageType {
|
||||
Layout.fillHeight: true
|
||||
Layout.topMargin: 24
|
||||
|
||||
currentIndex: root.currentTab
|
||||
currentIndex: tabBar.currentIndex
|
||||
|
||||
PageSettingsServerProtocols {
|
||||
id: protocolsPage
|
||||
|
||||
@@ -59,6 +59,7 @@ PageType {
|
||||
required property string detailedDescription
|
||||
required property int dockerContainer
|
||||
required property bool isTProxy
|
||||
required property bool isWhatsAppProxy
|
||||
|
||||
function install() {
|
||||
if (isTProxy) {
|
||||
@@ -96,6 +97,20 @@ PageType {
|
||||
return
|
||||
}
|
||||
|
||||
if (isWhatsAppProxy) {
|
||||
mediaPort.errorText = ""
|
||||
if (!mediaPort.textField.acceptableInput) {
|
||||
mediaPort.errorText = qsTr("The port must be in the range of 1 to 65535")
|
||||
return
|
||||
}
|
||||
if (mediaPort.textField.text === port.textField.text) {
|
||||
mediaPort.errorText = qsTr("The media port must differ from the chat port")
|
||||
return
|
||||
}
|
||||
WhatsAppProxyConfigModel.setPort(port.textField.text)
|
||||
WhatsAppProxyConfigModel.setMediaPort(mediaPort.textField.text)
|
||||
}
|
||||
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||
InstallController.install(dockerContainer, port.textField.text, transportProtoSelector.currentIndex, ServersUiController.processedServerId)
|
||||
}
|
||||
@@ -155,11 +170,33 @@ PageType {
|
||||
|
||||
visible: !delegateRoot.isTProxy
|
||||
|
||||
headerText: qsTr("Port")
|
||||
headerText: delegateRoot.isWhatsAppProxy ? qsTr("Chat port") : qsTr("Port")
|
||||
textField.maximumLength: 5
|
||||
textField.validator: IntValidator { bottom: 1; top: 65535 }
|
||||
}
|
||||
|
||||
TextFieldType {
|
||||
id: mediaPort
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
visible: delegateRoot.isWhatsAppProxy
|
||||
|
||||
headerText: qsTr("Media port")
|
||||
textField.text: WhatsAppProxyConfigModel.defaultMediaPort()
|
||||
textField.maximumLength: 5
|
||||
textField.validator: IntValidator { bottom: 1; top: 65535 }
|
||||
}
|
||||
|
||||
CaptionTextType {
|
||||
Layout.fillWidth: true
|
||||
|
||||
visible: delegateRoot.isWhatsAppProxy
|
||||
|
||||
text: qsTr("WhatsApp uses chat port 443 and media port 587 by default. With other ports, users must enter them in WhatsApp proxy settings and enable TLS for the chat port. Calls are not proxied.")
|
||||
color: AmneziaStyle.color.textAccent
|
||||
}
|
||||
|
||||
TextFieldType {
|
||||
id: tproxyHostname
|
||||
|
||||
|
||||
@@ -244,9 +244,6 @@ PageType {
|
||||
}
|
||||
|
||||
function onBackgroundPurchaseCompleted(message) {
|
||||
if (!root.isTabBarShown) {
|
||||
PageController.goToPageHome()
|
||||
}
|
||||
PageController.showNotificationMessage(message)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/ui/qml">
|
||||
<file>Components/CopyableValueRow.qml</file>
|
||||
<file>Components/CascadeSettings.qml</file>
|
||||
<file>Components/ConfigContentSheet.qml</file>
|
||||
<file>Components/QrCodeCard.qml</file>
|
||||
<file>Components/ShareClientInfoSheet.qml</file>
|
||||
@@ -134,6 +133,7 @@
|
||||
<file>Pages2/PageServiceMtProxySettings.qml</file>
|
||||
<file>Pages2/PageServiceTelemtSettings.qml</file>
|
||||
<file>Pages2/PageServiceTProxySettings.qml</file>
|
||||
<file>Pages2/PageServiceWhatsAppProxySettings.qml</file>
|
||||
<file>Pages2/PageServiceSftpSettings.qml</file>
|
||||
<file>Pages2/PageServiceSocksProxySettings.qml</file>
|
||||
<file>Pages2/PageServiceTorWebsiteSettings.qml</file>
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace PageLoader
|
||||
PageServiceMtProxySettings,
|
||||
PageServiceTelemtSettings,
|
||||
PageServiceTProxySettings,
|
||||
PageServiceWhatsAppProxySettings,
|
||||
|
||||
PageSetupWizardStart,
|
||||
PageSetupWizardCredentials,
|
||||
|
||||
Loaded 100 of 104 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user