Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

### Performance & Censorship Resistance
- **MASQUE over HTTP/1.1, HTTP/2, and HTTP/3 (QUIC)**
- **Control-Plane Edge Relayer & Automatic Failover**
- **Dynamic Remote Configuration & Endpoint Sync**
- **TLS Fragmentation (Record & Packet)**
- **uTLS Fingerprint Emulation**
- **Upstream Proxy Chaining**
Expand All @@ -41,6 +43,7 @@
- **Automatic Connection Recovery**

### User Experience & System Integration
- **Light, Dark & System Adaptive Themes**
- **Real-Time Traffic & Latency Diagnostics**
- **Public & Exit IP Detection**
- **Global Server Locations**
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ android {
applicationId = "com.vauth.foxyvpn"
minSdk = 26
targetSdk = 35
versionCode = 49
versionName = "2.0.3"
versionCode = 50
versionName = "2.0.4"
}

splits {
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@
android:name=".widget.QuickConnectWidgetProvider"
android:label="@string/quick_connect"
android:icon="@drawable/widget_preview"
android:exported="false">
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/quick_connect_widget_info" />
</receiver>

<receiver
android:name=".widget.QuickConnectWidgetProvider$ToggleReceiver"
android:exported="false" />

<provider
android:name="androidx.core.content.FileProvider"
Expand Down
38 changes: 25 additions & 13 deletions app/src/main/java/com/vauth/foxyvpn/data/FastlyChallengeSolver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.vauth.foxyvpn.data
import java.net.URLEncoder
import java.security.MessageDigest
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
Expand Down Expand Up @@ -85,12 +86,7 @@ class FastlyChallengeSolver(private val cookieJar: SimpleCookieJar) {
"Untrusted challenge origin"
}
val base = "https://${origin.host}"
if (!challengedBody.isNullOrEmpty() && isChallengePage(challengedBody)) {
val solverJar = SimpleCookieJar()
val solver = newSolverClient(solverJar)
solveChallengePage(challengedBody, base, userAgent, solver, solverJar)
return@withContext
}
val solverConfigUA = FoxyRemoteConfig.current.solver.headers["User-Agent"]
val defaultBase =
runCatching { FoxyRemoteConfig.current.endpoints.controlPlane.oauthToken.toHttpUrl() }
.getOrNull()?.let { "https://${it.host}" } ?: "https://api.accounts.firefox.com"
Expand All @@ -102,12 +98,20 @@ class FastlyChallengeSolver(private val cookieJar: SimpleCookieJar) {
"https://accounts.firefox.com",
).distinct()
var lastError: FastlyChallengeError? = null
val candidateUAs =
listOfNotNull(
solverConfigUA,
FirefoxAccountHeaders.browserUserAgent,
userAgent.takeIf { it.isNotBlank() },
).distinct()
for (candidateBase in bases) {
for (candidateUA in listOf(userAgent, FirefoxAccountHeaders.browserUserAgent, FirefoxAccountHeaders.desktopUserAgent).distinct()) {
for (candidateUA in candidateUAs) {
try {
if (solveChallengeOnHost(candidateBase, candidateUA)) {
return@withContext
}
} catch (cancellation: CancellationException) {
throw cancellation
} catch (error: FastlyChallengeError) {
lastError = error
} catch (e: Exception) {
Expand Down Expand Up @@ -153,12 +157,14 @@ class FastlyChallengeSolver(private val cookieJar: SimpleCookieJar) {
allowChallenge: Boolean = false,
): String {
val builder = Request.Builder().url(url)
for ((key, value) in FoxyRemoteConfig.current.solver.headers) {
val solverHeaders = FoxyRemoteConfig.current.solver.headers
for ((key, value) in solverHeaders) {
builder.header(key, value)
}
val effectiveUA = solverHeaders["User-Agent"] ?: userAgent
val request =
builder
.header("User-Agent", userAgent)
.header("User-Agent", effectiveUA)
.header("Accept", accept)
.build()
client.newCall(request).awaitResponse().use { response ->
Expand Down Expand Up @@ -225,14 +231,16 @@ class FastlyChallengeSolver(private val cookieJar: SimpleCookieJar) {
): String {
val patUrl = "$prefixUrl/pat?token=${URLEncoder.encode(token, "UTF-8")}"
val builder = Request.Builder().url(patUrl)
for ((key, value) in FoxyRemoteConfig.current.solver.headers) {
val solverHeaders = FoxyRemoteConfig.current.solver.headers
for ((key, value) in solverHeaders) {
builder.header(key, value)
}
val effectiveUA = solverHeaders["User-Agent"] ?: userAgent
val request =
builder
.header("Accept", "text/plain")
.header("Content-Type", "application/json")
.header("User-Agent", userAgent)
.header("User-Agent", effectiveUA)
.header("Origin", baseOrigin(prefixUrl))
.post(ByteArray(0).toRequestBody(null))
.build()
Expand Down Expand Up @@ -398,6 +406,8 @@ class FastlyChallengeSolver(private val cookieJar: SimpleCookieJar) {
val page =
try {
fetchText(solver, pageUrl, userAgent = userAgent, allowChallenge = true)
} catch (cancellation: CancellationException) {
throw cancellation
} catch (_: Exception) {
return false
}
Expand Down Expand Up @@ -447,14 +457,16 @@ class FastlyChallengeSolver(private val cookieJar: SimpleCookieJar) {
.toString()
.toRequestBody("application/json".toMediaType())
val builder = Request.Builder().url("$prefixUrl/fst-post-back")
for ((key, value) in FoxyRemoteConfig.current.solver.headers) {
val solverHeaders = FoxyRemoteConfig.current.solver.headers
for ((key, value) in solverHeaders) {
builder.header(key, value)
}
val effectiveUA = solverHeaders["User-Agent"] ?: userAgent
val request =
builder
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("User-Agent", userAgent)
.header("User-Agent", effectiveUA)
.header("Origin", baseOrigin(prefixUrl))
.post(postBody)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ internal object FirefoxAccountHeaders {
get() = FoxyRemoteConfig.current.browser.headers["User-Agent"]
?: resolvePlaceholders("Mozilla/5.0 (Android {android_version}; Mobile; rv:$major.0) Gecko/$major.0 Firefox/$major.0")

val desktopUserAgent: String
get() = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:$major.0) Gecko/20100101 Firefox/$major.0"

val userAgent: String
get() = controlPlaneUserAgent

fun apply(builder: Request.Builder): Request.Builder {
val headers = FoxyRemoteConfig.current.controlPlane.headers
for ((key, value) in headers) {
Expand All @@ -36,6 +30,8 @@ internal object FirefoxAccountHeaders {
return builder
}

fun applyOAuth(builder: Request.Builder): Request.Builder = apply(builder)

suspend fun refresh(client: OkHttpClient) {
mutex.withLock {
nextRefreshNanos?.let { if (System.nanoTime() - it < 0L) return }
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/com/vauth/foxyvpn/data/FoxyRemoteConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ data class EndpointsConfig(
)

val DEFAULT_RELAYERS: Map<String, String> = emptyMap()
val DEFAULT_RELAYER_ROUTES: Set<String> = setOf("guardian")
val DEFAULT_FAILOVER_CODES: Set<Int> = setOf(451)
val DEFAULT_RELAYER_ROUTES: Set<String> = setOf("guardian", "fxa", "config", "server_list")
val DEFAULT_FAILOVER_CODES: Set<Int> = setOf(406, 451)

data class RemoteConfig(
val version: Int,
Expand Down Expand Up @@ -104,7 +104,10 @@ private val DEFAULT_SOLVER =
ComponentConfig(
headers =
mapOf(
"User-Agent" to resolvePlaceholders("MozillaVPN/2.24.0 (sys:android {android_version})"),
"User-Agent" to
resolvePlaceholders(
"Mozilla/5.0 (Android {android_version}; Mobile; rv:159.0) Gecko/159.0 Firefox/159.0"
),
"Accept-Encoding" to "identity",
),
)
Expand Down
Loading
Loading