5 Commits

Author SHA1 Message Date
zarazaex69 b92a6cdfac fix(speedtest): improve connection test with IP validation 2026-04-10 18:36:36 +03:00
zarazaex69 45da2479dd fix(v2ray): remove unused VPN DNS server retrieval 2026-04-10 18:14:58 +03:00
zarazaex69 1c936b2b31 fix(v2ray): simplify DNS server configuration logic 2026-04-10 17:50:56 +03:00
zarazaex69 dbe109eedb chore(mmkv): update database files and checksums 2026-04-10 17:41:59 +03:00
zarazaex69 7705aded77 fix(settings): validate VPN DNS servers with IP address check 2026-04-10 17:28:56 +03:00
13 changed files with 16 additions and 18 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -346,7 +346,7 @@ object SettingsManager {
*/
fun getVpnDnsServers(): List<String> {
val vpnDns = MmkvManager.decodeSettingsString(AppConfig.PREF_VPN_DNS) ?: AppConfig.DNS_VPN
return vpnDns.split(",").filter { it.isNotBlank() }
return vpnDns.split(",").filter { it.isNotBlank() && Utils.isPureIpAddress(it) }
}
/**
@@ -94,18 +94,23 @@ object SpeedtestManager {
var result: String
var elapsed = -1L
val conn = HttpUtil.createProxyConnection(SettingsManager.getDelayTestUrl(), port, 15000, 15000) ?: return Pair(elapsed, "")
val testUrl = "https://icanhazip.com"
val conn = HttpUtil.createProxyConnection(testUrl, port, 15000, 15000) ?: return Pair(elapsed, "")
try {
val start = SystemClock.elapsedRealtime()
val code = conn.responseCode
if (code != 200) {
throw IOException(context.getString(R.string.connection_test_error_status_code, code))
}
val responseBody = conn.inputStream.bufferedReader().readText().trim()
elapsed = SystemClock.elapsedRealtime() - start
result = when (code) {
204 -> context.getString(R.string.connection_test_available, elapsed)
200 if conn.contentLengthLong == 0L -> context.getString(R.string.connection_test_available, elapsed)
else -> throw IOException(
context.getString(R.string.connection_test_error_status_code, code)
)
if (xyz.zarazaex.olc.util.Utils.isPureIpAddress(responseBody)) {
result = context.getString(R.string.connection_test_available, elapsed)
} else {
throw IOException("Invalid IP response: $responseBody")
}
} catch (e: IOException) {
Log.e(AppConfig.TAG, "Connection test IOException", e)
@@ -594,7 +594,6 @@ object V2rayConfigManager {
val remoteDns = SettingsManager.getRemoteDnsServers()
val domesticDns = SettingsManager.getDomesticDnsServers()
val vpnDns = if (SettingsManager.isVpnMode()) SettingsManager.getVpnDnsServers() else emptyList()
val proxyDomain = getUserRule2Domain(AppConfig.TAG_PROXY)
val directDomain = getUserRule2Domain(AppConfig.TAG_DIRECT)
val isCnRoutingMode = directDomain.contains(AppConfig.GEOSITE_CN)
@@ -621,14 +620,8 @@ object V2rayConfigManager {
)
}
if (vpnDns.isNotEmpty()) {
vpnDns.forEach {
servers.add(it)
}
} else {
remoteDns.forEach {
servers.add(it)
}
remoteDns.forEach {
servers.add(it)
}
val blkDomain = getUserRule2Domain(AppConfig.TAG_BLOCKED)