Добавь ручной и автоматический режимы VPN

This commit is contained in:
2026-05-20 12:10:49 +03:00
parent 1385364265
commit 7c625e840e
6 changed files with 185 additions and 32 deletions

View File

@@ -35,10 +35,19 @@ printf '%s\n' "$status_json" | grep -q '"app":'
grep -q 'LemanaVPN-openconnect-lite.log' "$ROOT/bin/vpn-lemanapro.sh"
grep -q '"event":"waiting"' "$ROOT/bin/vpn-lemanapro.sh"
grep -q -- '--patch-only' "$ROOT/bin/vpn-lemanapro.sh"
grep -q -- '--auto' "$ROOT/bin/vpn-lemanapro.sh"
grep -q -- '--manual' "$ROOT/bin/vpn-lemanapro.sh"
grep -q -- '--manual-sso' "$ROOT/bin/vpn-lemanapro.sh"
grep -q 'LEMANA_VPN_AUTOFILL_DISABLE' "$ROOT/bin/vpn-lemanapro.sh"
grep -q 'LEMANA_VPN_AUTOFILL_CLICK' "$ROOT/bin/vpn-lemanapro.sh"
grep -q 'vpn-auto' "$ROOT/install.sh"
grep -q 'vpn-manual' "$ROOT/install.sh"
grep -q 'connect(mode: .auto)' "$ROOT/app/Sources/LemanaVPN/LemanaVPNApp.swift"
grep -q 'connect(mode: .manual)' "$ROOT/app/Sources/LemanaVPN/LemanaVPNApp.swift"
grep -q 'enum VPNLaunchMode' "$ROOT/app/Sources/LemanaVPN/VPNManager.swift"
fake_webengine="$TMP_DIR/webengine_process.py"
fake_authenticator="$TMP_DIR/authenticator.py"
cat > "$fake_webengine" <<'PY'
import json
import sys
@@ -97,7 +106,27 @@ def get_selectors(rules, credentials):
return "\n".join(statements)
PY
cat > "$fake_authenticator" <<'PY'
import requests
import structlog
logger = structlog.get_logger()
class Authenticator:
def _detect_authentication_target_url(self):
# Follow possible redirects in a GET request
# Authentication will occur using a POST request on the final URL
response = requests.get(self.host.vpn_url)
response.raise_for_status()
self.host.address = response.url
logger.debug("Auth target url", url=self.host.vpn_url)
def _start_authentication(self):
pass
PY
LEMANA_VPN_WEBENGINE_PROCESS="$fake_webengine" \
LEMANA_VPN_AUTHENTICATOR="$fake_authenticator" \
LEMANA_VPN_OC_PYTHON=python3 \
LEMANA_VPN_PATCH_BACKUP_DIR="$TMP_DIR/patch-backups" \
bash "$ROOT/bin/vpn-lemanapro.sh" --patch-only >/dev/null
@@ -107,6 +136,8 @@ grep -q 'LEMANA_VPN_AUTOFILL_DISABLE' "$fake_webengine"
grep -q 'new RegExp' "$fake_webengine"
grep -q 'script.setWorldId(QWebEngineScript.ScriptWorldId.ApplicationWorld)' "$fake_webengine"
grep -q 'new Event("input", {{bubbles: true}})' "$fake_webengine"
grep -q 'LEMANA_VPN_AUTOFILL_CLICK' "$fake_webengine"
grep -q 'os.environ.get("LEMANA_VPN_AUTOFILL_CLICK", "1") != "0"' "$fake_webengine"
if grep -q 'ScriptWorldId.MainWorld' "$fake_webengine"; then
echo "patched auto-fill should keep the original ApplicationWorld behavior" >&2
exit 1
@@ -119,6 +150,13 @@ if grep -q 'valueSetter' "$fake_webengine"; then
echo "patched auto-fill should use the original direct value assignment with input/change events" >&2
exit 1
fi
grep -q 'from urllib.parse import urljoin' "$fake_authenticator"
grep -q 'self.session.get(self.host.vpn_url, allow_redirects=False)' "$fake_authenticator"
grep -q 'response.headers.get("Location")' "$fake_authenticator"
if grep -q 'requests.get(self.host.vpn_url)' "$fake_authenticator"; then
echo "auth target detection must not follow redirects with bare requests.get" >&2
exit 1
fi
status_text="$(bash "$ROOT/bin/vpn-lemanapro.sh" --status)"
printf '%s\n' "$status_text" | grep -q 'Modules:'