From 2c8fcc75aa91b2fcd5e460c406ca9862a4863f86 Mon Sep 17 00:00:00 2001 From: therealaleph Date: Sun, 26 Apr 2026 00:28:46 +0300 Subject: [PATCH] v1.6.3: fix Android notification SOCKS5 port mismatch (#211) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit buildNotif() hardcoded `proxyPort + 1` for the SOCKS5 line, ignoring cfg.socks5Port entirely. With the default Android config (listenPort=8080, socks5Port=1081) the foreground notification read "Routing via SOCKS5 127.0.0.1:8081" but the real listener was on 1081 — so users configuring per-app SOCKS5 (Telegram, etc.) against the notification value silently failed. Use the same `cfg.socks5Port ?: (cfg.listenPort + 1)` elvis fallback the real listener uses, and surface both ports in the notification: HTTP 127.0.0.1:8080 · SOCKS5 127.0.0.1:1081 Reported by vpnineh and l3est (with netstat screenshots showing the exact mismatch). Co-Authored-By: Claude Opus 4.7 (1M context) --- Cargo.lock | 2 +- Cargo.toml | 2 +- android/app/build.gradle.kts | 4 ++-- .../java/com/therealaleph/mhrv/MhrvVpnService.kt | 16 +++++++++++++--- docs/changelog/v1.6.3.md | 4 ++++ 5 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 docs/changelog/v1.6.3.md diff --git a/Cargo.lock b/Cargo.lock index 432bb32..5a91881 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2186,7 +2186,7 @@ dependencies = [ [[package]] name = "mhrv-rs" -version = "1.6.2" +version = "1.6.3" dependencies = [ "base64 0.22.1", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 01af7c4..34b3930 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mhrv-rs" -version = "1.6.2" +version = "1.6.3" edition = "2021" description = "Rust port of MasterHttpRelayVPN -- DPI bypass via Google Apps Script relay with domain fronting" license = "MIT" diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 206bada..ae9b7df 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -14,8 +14,8 @@ android { applicationId = "com.therealaleph.mhrv" minSdk = 24 // Android 7.0 — covers 99%+ of live devices. targetSdk = 34 - versionCode = 141 - versionName = "1.6.2" + versionCode = 142 + versionName = "1.6.3" // Ship all four mainstream Android ABIs: // - arm64-v8a — 95%+ of real-world Android phones since 2019 diff --git a/android/app/src/main/java/com/therealaleph/mhrv/MhrvVpnService.kt b/android/app/src/main/java/com/therealaleph/mhrv/MhrvVpnService.kt index 121b9af..91f6672 100644 --- a/android/app/src/main/java/com/therealaleph/mhrv/MhrvVpnService.kt +++ b/android/app/src/main/java/com/therealaleph/mhrv/MhrvVpnService.kt @@ -91,7 +91,17 @@ class MhrvVpnService : VpnService() { // path below MUST therefore happen after a `startForeground()` // call — otherwise the user-visible symptom is "the app crashes // the instant I tap Start". See issue #73. - startForeground(NOTIF_ID, buildNotif(cfg.listenPort)) + // Issue #211: notification used to display + // `127.0.0.1:${listenPort + 1}` for the SOCKS5 port, which is + // wrong whenever socks5Port doesn't equal listenPort+1. With the + // default Android config (listenPort=8080, socks5Port=1081) + // users saw "Routing via SOCKS5 127.0.0.1:8081" but the real + // listener was on 1081 — so per-app SOCKS5 setup against the + // notification value silently failed. Pass the actual socks5Port + // (after the same elvis fallback used elsewhere) so the + // notification matches reality. + val notifSocks5Port = cfg.socks5Port ?: (cfg.listenPort + 1) + startForeground(NOTIF_ID, buildNotif(cfg.listenPort, notifSocks5Port)) // Deployment ID + auth key are required for apps_script and full // modes — both talk to Apps Script. Only google_only (bootstrap) @@ -424,7 +434,7 @@ class MhrvVpnService : VpnService() { Log.i(TAG, "onDestroy done") } - private fun buildNotif(proxyPort: Int): Notification { + private fun buildNotif(httpPort: Int, socks5Port: Int): Notification { val mgr = getSystemService(NotificationManager::class.java) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val ch = NotificationChannel( @@ -451,7 +461,7 @@ class MhrvVpnService : VpnService() { ) return NotificationCompat.Builder(this, CHANNEL_ID) .setContentTitle("mhrv-rs VPN is active") - .setContentText("Routing via SOCKS5 127.0.0.1:${proxyPort + 1}") + .setContentText("HTTP 127.0.0.1:$httpPort · SOCKS5 127.0.0.1:$socks5Port") .setSmallIcon(android.R.drawable.presence_online) .setContentIntent(openIntent) .addAction(android.R.drawable.ic_menu_close_clear_cancel, "Stop", stopIntent) diff --git a/docs/changelog/v1.6.3.md b/docs/changelog/v1.6.3.md new file mode 100644 index 0000000..7be78d2 --- /dev/null +++ b/docs/changelog/v1.6.3.md @@ -0,0 +1,4 @@ + +• رفع باگ "نوتیفیکیشن سرور اندروید پورت اشتباه SOCKS5 رو نشون می‌داد" ([#211](https://github.com/therealaleph/MasterHttpRelayVPN-RUST/issues/211)): با تنظیمات پیش‌فرض اندروید (`listenPort=8080`, `socks5Port=1081`)، نوتیفیکیشن می‌نوشت `Routing via SOCKS5 127.0.0.1:8081` که اشتباه بود — listener واقعی روی `1081` اجرا می‌شد. هر کاربری که پروکسی تلگرام رو روی پورت نوتیفیکیشن (8081) ست می‌کرد، در سکوت fail می‌شد. علت: تابع `buildNotif` به‌جای خوندن `cfg.socks5Port`، hardcode می‌کرد `proxyPort + 1`. حالا متن نوتیفیکیشن همون منطق elvis fallback `cfg.socks5Port ?: (cfg.listenPort + 1)` رو که در تنظیم listener واقعی استفاده می‌شه می‌خونه و علاوه بر SOCKS5، پورت HTTP رو هم نشون می‌ده: `HTTP 127.0.0.1:8080 · SOCKS5 127.0.0.1:1081`. ۲ کاربر مستقل ریپورت کردن (vpnineh، l3est) +--- +• Fix "Android server notification showed wrong SOCKS5 port" bug ([#211](https://github.com/therealaleph/MasterHttpRelayVPN-RUST/issues/211)): with the default Android config (`listenPort=8080`, `socks5Port=1081`), the foreground-service notification read `Routing via SOCKS5 127.0.0.1:8081` — wrong, since the real listener was on `1081`. Anyone configuring Telegram (or any per-app SOCKS5 client) against the notification value silently failed. Cause: `buildNotif` hardcoded `proxyPort + 1` instead of reading `cfg.socks5Port`. The notification now uses the same elvis fallback `cfg.socks5Port ?: (cfg.listenPort + 1)` that the actual listener uses, and shows both ports for clarity: `HTTP 127.0.0.1:8080 · SOCKS5 127.0.0.1:1081`. Two independent users (vpnineh, l3est) reported this