diff --git a/README.md b/README.md index b8644b4b..3f1fd416 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,8 @@ - **TLS Fragmentation (Record & Packet)** - **uTLS Fingerprint Emulation** - **Upstream Proxy Chaining** -- **Custom Edge Override** +- **Custom Edge Override/Scanner** +- **Custom SNI** - **Multiplexing & Concurrency Controls** - **Custom Tunnel MTU** - **Automatic Connection Recovery** diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 71b47f4a..50c42df8 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -23,8 +23,8 @@ android { applicationId = "com.vauth.foxyvpn" minSdk = 26 targetSdk = 35 - versionCode = 50 - versionName = "2.0.4" + versionCode = 51 + versionName = "2.0.5" } splits { diff --git a/app/src/main/java/com/vauth/foxyvpn/FoxyVpnApp.kt b/app/src/main/java/com/vauth/foxyvpn/FoxyVpnApp.kt index acd375f8..373b4cab 100644 --- a/app/src/main/java/com/vauth/foxyvpn/FoxyVpnApp.kt +++ b/app/src/main/java/com/vauth/foxyvpn/FoxyVpnApp.kt @@ -6,6 +6,7 @@ import android.app.NotificationManager import android.content.res.Configuration import com.vauth.foxyvpn.data.ControlPlaneHttp import com.vauth.foxyvpn.data.CrashReporter +import com.vauth.foxyvpn.data.EdgeScanner import com.vauth.foxyvpn.data.FoxyRemoteConfig import com.vauth.foxyvpn.data.FxaAuthRepository import com.vauth.foxyvpn.data.GuardianClient @@ -68,6 +69,8 @@ class FoxyVpnApp : Application(), AppContainer { ) } else null } + EdgeScanner.upstreamProxyProvider = ControlPlaneHttp.upstreamProxyProvider + EdgeScanner.bootstrapDnsConfigProvider = ControlPlaneHttp.bootstrapDnsConfigProvider ControlPlaneHttp.relayerConfigProvider = { RelayerConfig( provider = settingsStore.relayerProvider, diff --git a/app/src/main/java/com/vauth/foxyvpn/data/ControlPlaneHttp.kt b/app/src/main/java/com/vauth/foxyvpn/data/ControlPlaneHttp.kt index da619f9d..c24393ae 100644 --- a/app/src/main/java/com/vauth/foxyvpn/data/ControlPlaneHttp.kt +++ b/app/src/main/java/com/vauth/foxyvpn/data/ControlPlaneHttp.kt @@ -222,7 +222,7 @@ object ControlPlaneHttp { @Volatile private var cachedDnsOverHttps: DnsOverHttps? = null private val dohLock = Any() - private fun getOrCreateDoh(dohUrl: String): DnsOverHttps? { + internal fun getOrCreateDoh(dohUrl: String): DnsOverHttps? { if (cachedDohUrl == dohUrl) { val cached = cachedDnsOverHttps if (cached != null) return cached diff --git a/app/src/main/java/com/vauth/foxyvpn/data/EdgeScanner.kt b/app/src/main/java/com/vauth/foxyvpn/data/EdgeScanner.kt new file mode 100644 index 00000000..27443022 --- /dev/null +++ b/app/src/main/java/com/vauth/foxyvpn/data/EdgeScanner.kt @@ -0,0 +1,137 @@ +package com.vauth.foxyvpn.data + +import java.net.InetAddress +import java.net.InetSocketAddress +import java.net.Proxy +import java.net.Socket +import java.util.concurrent.atomic.AtomicInteger +import javax.net.ssl.HttpsURLConnection +import javax.net.ssl.SNIHostName +import javax.net.ssl.SSLContext +import javax.net.ssl.SSLSocket +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.sync.Semaphore +import kotlinx.coroutines.sync.withPermit +import kotlinx.coroutines.withContext +import okhttp3.Dns + +object EdgeScanner { + const val MASQUE_HOST = "p.m1.fastly-masque.net" + const val MASQUE_PORT = 2499 + const val RANGE_BASE = "23.235.42" + const val HOST_COUNT = 254 + + private const val CONNECT_TIMEOUT_MS = 1500 + private const val TLS_TIMEOUT_MS = 3000 + private const val MAX_CONCURRENT = 20 + + @Volatile var upstreamProxyProvider: (() -> UpstreamProxyConfig?)? = null + + @Volatile var bootstrapDnsConfigProvider: (() -> Pair)? = null + + @Volatile var networkProvider: (() -> android.net.Network?)? = null + + @Volatile var socketProtector: ((Socket) -> Boolean)? = null + + data class EdgeScanResult(val address: String, val ms: Int) + + private data class ProbeOutcome(val address: String, val tlsMs: Int, val httpMs: Int?) + + suspend fun scanBestEdge(onProgress: suspend (tested: Int, total: Int) -> Unit): EdgeScanResult? = + withContext(Dispatchers.IO) { + val proxy = proxyForScan() ?: return@withContext null + val hosts = (1..HOST_COUNT).map { "$RANGE_BASE.$it" } + val tested = AtomicInteger(0) + val semaphore = Semaphore(MAX_CONCURRENT) + val sslContext = SSLContext.getInstance("TLS").apply { init(null, null, null) } + val outcomes = hosts.map { host -> + async { + val result = semaphore.withPermit { probeEdge(host, sslContext, proxy) } + onProgress(tested.incrementAndGet(), hosts.size) + result + } + }.awaitAll().filterNotNull() + val httpBest = outcomes.mapNotNull { outcome -> + outcome.httpMs?.let { EdgeScanResult(outcome.address, it) } + }.minByOrNull { it.ms } + if (httpBest != null) return@withContext httpBest + outcomes.minByOrNull { it.tlsMs }?.let { EdgeScanResult(it.address, it.tlsMs) } + } + + private fun proxyForScan(): Proxy? { + val config = upstreamProxyProvider?.invoke() ?: return Proxy.NO_PROXY + if (config.host.isBlank() || config.port !in 1..65535) return Proxy.NO_PROXY + val proxyType = if (config.type == SettingsStore.UpstreamProxyType.HTTP) Proxy.Type.HTTP else Proxy.Type.SOCKS + val address = resolveProxyHost(config.host) ?: return null + return Proxy(proxyType, InetSocketAddress(address, config.port)) + } + + private fun resolveProxyHost(host: String): InetAddress? { + if (SettingsStore.isValidIpAddress(host)) { + return runCatching { InetAddress.getByName(host) }.getOrNull() + } + val config = bootstrapDnsConfigProvider?.invoke() + val provider = config?.first ?: SettingsStore.DnsProvider.DIRECT_SYSTEM + val dohUrl = config?.second.orEmpty() + if (provider != SettingsStore.DnsProvider.DIRECT_SYSTEM && dohUrl.isNotBlank()) { + val doh = ControlPlaneHttp.getOrCreateDoh(dohUrl) + if (doh != null) { + return runCatching { doh.lookup(host).firstOrNull() }.getOrNull() + } + } + val network = runCatching { networkProvider?.invoke() }.getOrNull() + val fromNetwork = if (network != null) { + runCatching { network.getAllByName(host).toList() }.getOrNull() + } else { + null + } + if (!fromNetwork.isNullOrEmpty()) return fromNetwork.first() + return runCatching { Dns.SYSTEM.lookup(host).firstOrNull() }.getOrNull() + } + + private fun probeEdge(host: String, sslContext: SSLContext, proxy: Proxy): ProbeOutcome? { + val start = System.nanoTime() + val plain = Socket(proxy) + try { + val protector = socketProtector + if (protector != null && !protector(plain)) return null + plain.connect(InetSocketAddress(host, MASQUE_PORT), CONNECT_TIMEOUT_MS) + val sslSocket = sslContext.socketFactory.createSocket(plain, host, MASQUE_PORT, true) as SSLSocket + sslSocket.soTimeout = TLS_TIMEOUT_MS + return sslSocket.use { + val params = it.sslParameters + params.serverNames = listOf(SNIHostName(MASQUE_HOST)) + it.sslParameters = params + it.startHandshake() + if (!HttpsURLConnection.getDefaultHostnameVerifier().verify(MASQUE_HOST, it.session)) return@use null + val tlsMs = ((System.nanoTime() - start) / 1_000_000L).coerceAtLeast(1L).toInt() + val httpMs = try { + val request = "GET / HTTP/1.1\r\nHost: $MASQUE_HOST\r\nConnection: close\r\n\r\n" + it.outputStream.write(request.toByteArray(Charsets.US_ASCII)) + it.outputStream.flush() + val buffer = ByteArray(5) + var read = 0 + while (read < 5) { + val n = it.inputStream.read(buffer, read, 5 - read) + if (n == -1) return@use ProbeOutcome(host, tlsMs, null) + read += n + } + if (!String(buffer, Charsets.US_ASCII).startsWith("HTTP/")) return@use ProbeOutcome(host, tlsMs, null) + ((System.nanoTime() - start) / 1_000_000L).coerceAtLeast(1L).toInt() + } catch (_: Exception) { + null + } + ProbeOutcome(host, tlsMs, httpMs) + } + } catch (_: Exception) { + return null + } finally { + try { + plain.close() + } catch (_: Exception) { + } + } + } +} diff --git a/app/src/main/java/com/vauth/foxyvpn/data/SettingsStore.kt b/app/src/main/java/com/vauth/foxyvpn/data/SettingsStore.kt index 85107c0d..6eb23609 100644 --- a/app/src/main/java/com/vauth/foxyvpn/data/SettingsStore.kt +++ b/app/src/main/java/com/vauth/foxyvpn/data/SettingsStore.kt @@ -382,7 +382,7 @@ class SettingsStore(context: Context) { var customEdgeAddress: String get() = prefs.getString(KEY_CUSTOM_EDGE_ADDRESS, "") ?: "" set(value) { - val normalized = value.trim().lowercase() + val normalized = value.trim().lowercase().removeSuffix(".") if (normalized.isNotEmpty() && !isValidEdgeHost(normalized)) return prefs.edit().putString(KEY_CUSTOM_EDGE_ADDRESS, normalized).apply() } @@ -390,6 +390,17 @@ class SettingsStore(context: Context) { val effectiveCustomEdgeAddress: String? get() = customEdgeAddress.takeIf { isValidEdgeHost(it) } + var customSni: String + get() = prefs.getString(KEY_CUSTOM_SNI, "") ?: "" + set(value) { + val normalized = value.trim().lowercase().removeSuffix(".") + if (normalized.isNotEmpty() && !isValidHostname(normalized)) return + prefs.edit().putString(KEY_CUSTOM_SNI, normalized).apply() + } + + val effectiveCustomSni: String? + get() = customSni.takeIf { isValidHostname(it) } + val localProxyAuthEnabled: Boolean get() = prefs.getBoolean("local_proxy_auth_enabled", false) @@ -702,6 +713,7 @@ class SettingsStore(context: Context) { const val DEFAULT_MAX_CONCURRENT_STREAMS = 32 private const val KEY_PROXY_ONLY_MODE = "proxy_only_mode" private const val KEY_CUSTOM_EDGE_ADDRESS = "custom_edge_address" + private const val KEY_CUSTOM_SNI = "custom_sni" private const val KEY_UPSTREAM_PROXY_ENABLED = "upstream_proxy_enabled" private const val KEY_UPSTREAM_PROXY_TYPE = "upstream_proxy_type" private const val KEY_UPSTREAM_PROXY_HOST = "upstream_proxy_host" diff --git a/app/src/main/java/com/vauth/foxyvpn/data/TunnelSettings.kt b/app/src/main/java/com/vauth/foxyvpn/data/TunnelSettings.kt index 3e48dd59..0eee5ce0 100644 --- a/app/src/main/java/com/vauth/foxyvpn/data/TunnelSettings.kt +++ b/app/src/main/java/com/vauth/foxyvpn/data/TunnelSettings.kt @@ -5,6 +5,7 @@ data class TunnelSettings( val dnsProvider: SettingsStore.DnsProvider, val bootstrapDnsProvider: SettingsStore.DnsProvider, val effectiveCustomEdgeAddress: String?, + val effectiveCustomSni: String?, val effectiveDohUrl: String, val effectiveBootstrapDohUrl: String, val excludedApps: Set, @@ -46,6 +47,7 @@ fun SettingsStore.tunnelSnapshot(): TunnelSettings = dnsProvider = dnsProvider, bootstrapDnsProvider = bootstrapDnsProvider, effectiveCustomEdgeAddress = effectiveCustomEdgeAddress, + effectiveCustomSni = effectiveCustomSni, effectiveDohUrl = effectiveDohUrl, effectiveBootstrapDohUrl = effectiveBootstrapDohUrl, excludedApps = excludedApps.toSet(), diff --git a/app/src/main/java/com/vauth/foxyvpn/ui/screens/SettingsScreen.kt b/app/src/main/java/com/vauth/foxyvpn/ui/screens/SettingsScreen.kt index 4ba315d5..cad61de6 100644 --- a/app/src/main/java/com/vauth/foxyvpn/ui/screens/SettingsScreen.kt +++ b/app/src/main/java/com/vauth/foxyvpn/ui/screens/SettingsScreen.kt @@ -56,6 +56,7 @@ import com.vauth.foxyvpn.ui.ProxyEditor import com.vauth.foxyvpn.ui.ProxySettingsViewModel import com.vauth.foxyvpn.ui.settings.ConcurrencyPickerDialog import com.vauth.foxyvpn.ui.settings.CustomEdgeAddressDialog +import com.vauth.foxyvpn.ui.settings.CustomSniDialog import com.vauth.foxyvpn.ui.settings.DnsProviderPickerDialog import com.vauth.foxyvpn.ui.settings.HttpVersionPickerDialog import com.vauth.foxyvpn.ui.settings.IpModePickerDialog @@ -84,6 +85,7 @@ private enum class SettingsDialog { DNS_PROVIDER, BOOTSTRAP_DNS_PROVIDER, EDGE_ADDRESS, + CUSTOM_SNI, SPLIT_TUNNEL, HTTP_VERSION, IP_MODE, @@ -114,6 +116,7 @@ fun SettingsScreen( var customBootstrapDohUrl by remember { mutableStateOf(settingsStore.customBootstrapDohUrl) } var proxyOnlyMode by remember { mutableStateOf(settingsStore.proxyOnlyMode) } var customEdgeAddress by remember { mutableStateOf(settingsStore.customEdgeAddress) } + var customSni by remember { mutableStateOf(settingsStore.customSni) } var excludedApps by remember { mutableStateOf(settingsStore.excludedApps) } var includedApps by remember { mutableStateOf(settingsStore.includedApps) } var bypassLocalNetwork by remember { mutableStateOf(settingsStore.bypassLocalNetwork) } @@ -269,6 +272,15 @@ fun SettingsScreen( activeDialog = SettingsDialog.NONE }, ) + SettingsDialog.CUSTOM_SNI -> CustomSniDialog( + current = customSni, + onDismiss = { activeDialog = SettingsDialog.NONE }, + onConfirm = { + customSni = it + settingsStore.customSni = it + activeDialog = SettingsDialog.NONE + }, + ) SettingsDialog.SPLIT_TUNNEL -> SplitTunnelDialog( currentMode = splitTunnelMode, currentExcluded = excludedApps, @@ -559,6 +571,14 @@ fun SettingsScreen( }, modifier = Modifier.clickable { activeDialog = SettingsDialog.EDGE_ADDRESS }, ) + ListItem( + headlineContent = { Text(stringResource(R.string.settings_custom_sni)) }, + supportingContent = { Text(customSni.ifBlank { stringResource(R.string.not_set) }) }, + trailingContent = { + Icon(Icons.AutoMirrored.Filled.KeyboardArrowRight, contentDescription = null) + }, + modifier = Modifier.clickable { activeDialog = SettingsDialog.CUSTOM_SNI }, + ) ListItem( headlineContent = { Text(stringResource(R.string.settings_transport_protocol)) }, supportingContent = { Text(httpVersion.label) }, diff --git a/app/src/main/java/com/vauth/foxyvpn/ui/settings/ConnectionDialogs.kt b/app/src/main/java/com/vauth/foxyvpn/ui/settings/ConnectionDialogs.kt index 59f6f4aa..ef6db9fc 100644 --- a/app/src/main/java/com/vauth/foxyvpn/ui/settings/ConnectionDialogs.kt +++ b/app/src/main/java/com/vauth/foxyvpn/ui/settings/ConnectionDialogs.kt @@ -14,15 +14,19 @@ import androidx.compose.foundation.selection.selectableGroup import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll import androidx.compose.material3.AlertDialog +import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.RadioButton import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.Saver import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue @@ -34,7 +38,13 @@ import androidx.compose.ui.semantics.Role import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.dp import com.vauth.foxyvpn.R +import com.vauth.foxyvpn.data.EdgeScanner import com.vauth.foxyvpn.data.SettingsStore +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext private const val MAX_SAVED_NETWORK_DRAFT_CHARS = 4096 @@ -135,6 +145,13 @@ internal fun DnsProviderPickerDialog( ) } +private sealed interface EdgeScanState { + data object Idle : EdgeScanState + data class Scanning(val tested: Int, val total: Int) : EdgeScanState + data class Success(val result: EdgeScanner.EdgeScanResult) : EdgeScanState + data object NotFound : EdgeScanState +} + @Composable internal fun CustomEdgeAddressDialog( current: String, @@ -144,6 +161,37 @@ internal fun CustomEdgeAddressDialog( var value by rememberSaveable(stateSaver = NetworkDraftSaver) { mutableStateOf(current) } val trimmed = value.trim() val isValid = trimmed.isEmpty() || SettingsStore.isValidEdgeHost(trimmed) + val scope = rememberCoroutineScope() + var scanJob by remember { mutableStateOf(null) } + var scanState by remember { mutableStateOf(EdgeScanState.Idle) } + DisposableEffect(Unit) { + onDispose { scanJob?.cancel() } + } + val isScanning = scanState is EdgeScanState.Scanning + val startScan: () -> Unit = { + scanJob?.cancel() + scanState = EdgeScanState.Scanning(0, EdgeScanner.HOST_COUNT) + scanJob = scope.launch { + val result = try { + EdgeScanner.scanBestEdge { tested, total -> + withContext(Dispatchers.Main) { + val currentState = scanState + val prev = if (currentState is EdgeScanState.Scanning) currentState.tested else 0 + scanState = EdgeScanState.Scanning(maxOf(prev, tested), total) + } + } + } catch (_: CancellationException) { + scanState = EdgeScanState.Idle + return@launch + } + if (result != null) { + value = result.address + scanState = EdgeScanState.Success(result) + } else { + scanState = EdgeScanState.NotFound + } + } + } AlertDialog( onDismissRequest = onDismiss, @@ -169,6 +217,97 @@ internal fun CustomEdgeAddressDialog( color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(top = 8.dp), ) + when (val state = scanState) { + is EdgeScanState.Success -> Text( + stringResource(R.string.edge_scan_best, state.result.address, state.result.ms), + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(top = 8.dp), + ) + EdgeScanState.NotFound -> Text( + stringResource(R.string.edge_scan_not_found), + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier.padding(top = 8.dp), + ) + else -> {} + } + if (isScanning) { + val scanning = scanState as EdgeScanState.Scanning + LinearProgressIndicator( + progress = { scanning.tested.toFloat() / scanning.total.coerceAtLeast(1).toFloat() }, + modifier = Modifier.fillMaxWidth().padding(top = 12.dp), + ) + Text( + stringResource(R.string.edge_scan_scanning, scanning.tested, scanning.total), + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(top = 8.dp), + ) + TextButton( + onClick = { + scanJob?.cancel() + scanState = EdgeScanState.Idle + }, + modifier = Modifier.padding(top = 4.dp), + ) { + Text(stringResource(R.string.cancel)) + } + } else { + TextButton( + onClick = startScan, + modifier = Modifier.padding(top = 4.dp), + ) { + Text(stringResource(R.string.edge_scan)) + } + } + } + }, + confirmButton = { + TextButton(onClick = { onConfirm(trimmed) }, enabled = isValid) { + Text(stringResource(R.string.save)) + } + }, + dismissButton = { + TextButton(onClick = onDismiss) { Text(stringResource(R.string.cancel)) } + }, + ) +} + +@Composable +internal fun CustomSniDialog( + current: String, + onDismiss: () -> Unit, + onConfirm: (String) -> Unit, +) { + var value by rememberSaveable(stateSaver = NetworkDraftSaver) { mutableStateOf(current) } + val trimmed = value.trim() + val isValid = trimmed.isEmpty() || SettingsStore.isValidHostname(trimmed) + + AlertDialog( + onDismissRequest = onDismiss, + title = { Text(stringResource(R.string.settings_custom_sni)) }, + text = { + Column(Modifier.verticalScroll(rememberScrollState())) { + OutlinedTextField( + value = value, + onValueChange = { value = it }, + label = { Text(stringResource(R.string.settings_domain)) }, + keyboardOptions = + KeyboardOptions( + keyboardType = KeyboardType.Ascii, + autoCorrectEnabled = false, + ), + modifier = Modifier.fillMaxWidth(), + singleLine = true, + isError = !isValid, + ) + Text( + stringResource(R.string.dialog_custom_sni_help), + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(top = 8.dp), + ) } }, confirmButton = { diff --git a/app/src/main/java/com/vauth/foxyvpn/vpn/FoxyVpnService.kt b/app/src/main/java/com/vauth/foxyvpn/vpn/FoxyVpnService.kt index b9cc0b68..912a0bba 100644 --- a/app/src/main/java/com/vauth/foxyvpn/vpn/FoxyVpnService.kt +++ b/app/src/main/java/com/vauth/foxyvpn/vpn/FoxyVpnService.kt @@ -22,6 +22,7 @@ import com.vauth.foxyvpn.FoxyVpnApp import com.vauth.foxyvpn.MainActivity import com.vauth.foxyvpn.data.AppLogger import com.vauth.foxyvpn.data.ControlPlaneHttp +import com.vauth.foxyvpn.data.EdgeScanner import com.vauth.foxyvpn.data.FoxyRemoteConfig import com.vauth.foxyvpn.data.FxaRefreshFailure import com.vauth.foxyvpn.data.GUARDIAN_ENDPOINT_DEFAULT @@ -649,11 +650,14 @@ class FoxyVpnService : VpnService() { if (proxyOnlyMode) { ControlPlaneHttp.socketProtector = null + EdgeScanner.socketProtector = null } else { ControlPlaneHttp.socketProtector = { socket -> protect(socket) } + EdgeScanner.socketProtector = { socket -> protect(socket) } } ControlPlaneHttp.networkProvider = { firstUsableNetwork() } + EdgeScanner.networkProvider = { firstUsableNetwork() } suspend fun mintProxyPass(): ProxyPass { var auth = app.authRepository.ensureFreshAccessToken() @@ -982,7 +986,9 @@ class FoxyVpnService : VpnService() { releaseResources(detachResources()) if (!ownsCore) return ControlPlaneHttp.socketProtector = null + EdgeScanner.socketProtector = null ControlPlaneHttp.networkProvider = null + EdgeScanner.networkProvider = null _state.value = ConnectionState.DISCONNECTED _vpnLiveStats.value = VpnLiveStats() _connectedAtElapsedMs.value = null diff --git a/app/src/main/java/com/vauth/foxyvpn/vpn/SingBoxConfigBuilder.kt b/app/src/main/java/com/vauth/foxyvpn/vpn/SingBoxConfigBuilder.kt index c788b91c..2b1a8639 100644 --- a/app/src/main/java/com/vauth/foxyvpn/vpn/SingBoxConfigBuilder.kt +++ b/app/src/main/java/com/vauth/foxyvpn/vpn/SingBoxConfigBuilder.kt @@ -352,7 +352,8 @@ object SingBoxConfigBuilder { val tls = JSONObject().apply { put("enabled", true) - put("server_name", candidate.host) + val customSni = settings.effectiveCustomSni + put("server_name", customSni ?: candidate.host) if (targetVersion != 3) { put( "utls", diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3b3a9032..128f3863 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -44,6 +44,9 @@ Proxy-only mode Run local proxy servers without VPN Custom edge address + Custom SNI + Domain + Sets the TLS server name to this hostname instead of the MASQUE hostname. Use a hostname under *.m1.fastly-masque.net; leave blank for the default. Transport protocol TLS fragmentation Browser TLS fingerprint @@ -181,6 +184,10 @@ Direct via local network HTTPS DoH endpoint Leave empty to resolve the server hostname normally. + Scan + Scanning… %1$d/%2$d + Best edge: %1$s (%2$d ms) + No working edge found HTTP protocol version used to tunnel traffic. Maximum packet size for the tunnel interface. Fragments TLS packets to bypass censorship.