vpn/docs/building.md

2.7 KiB

Сборка и запуск

Development

uv sync
uv run pytest
uv run flet run app/main.py

uv уже был установлен в рабочем окружении. Flet current build creates a Flutter shell and packages the Python app; the native Android bridge is registered as a local Flet extension from native/android/flet_vpn_bridge.

Backend

Generate a Fernet key and configure the operator token:

export VPNAPP_ADMIN_TOKEN="$(python -c 'import secrets; print(secrets.token_urlsafe(32))')"
export VPNAPP_SECRET_KEY="$(uv run --project backend python -c 'from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())')"
export VPNAPP_BASE_URL=http://127.0.0.1:8080
./scripts/run-backend.sh

Open http://127.0.0.1:8080/admin. The page is one self-contained HTML file with no frontend build. It asks for the configured token, lists users/devices, creates/deletes them and generates enrollment/subscription links. Deploy behind HTTPS and do not put the admin token in a public URL.

Android

The Flet shell can be built without a native core artifact; runtime connections then return UNSUPPORTED honestly. A release build pins and enforces libbox:

./scripts/fetch-engine-artifacts.sh
REQUIRE_NATIVE_ARTIFACTS=1 ./scripts/build-android.sh

For a native-bridge/permissions smoke APK without cores, run ./scripts/build-android.sh. The script targets arm64-v8a.

Build prerequisites are current JDK/Android SDK/Flutter as required by Flet. Use a device/emulator with API 26+ for LocalOnlyHotspot; API 33+ needs runtime NEARBY_WIFI_DEVICES. Android VPN consent must be granted interactively by the user.

FreeTurn AAR:

git clone --depth 1 --branch <pinned-ref> https://github.com/samosvalishe/free-turn-proxy.git /tmp/free-turn-proxy
cd /tmp/free-turn-proxy
task build:android
cp dist/freeturn.aar /path/to/repo/native/android/libs/

scripts/fetch-engine-artifacts.sh downloads Leadaxe/sing-box-lx at the version in native/android/libbox.version, verifies release SHA256SUMS, and installs it locally. To upgrade, change that version, run the fetch script, inspect the AAR API with javap, update THIRD_PARTY_NOTICES.md, rebuild, and execute the Android manual test matrix.

The FreeTurn AAR is intentionally not packaged in the same APK yet: both artifacts own different global gomobile runtime classes. It requires a namespaced binding or another device-proven isolation solution, not a duplicate-class exclusion workaround.

Desktop

SIGNBOX_BIN=/absolute/path/to/sign-box ./scripts/build-desktop.sh linux
SIGNBOX_BIN=/absolute/path/to/sign-box.exe ./scripts/build-desktop.sh windows

Desktop SignBox proxy mode is process based. System proxy changes are not performed.