mirror of
https://github.com/openlibrecommunity/olcng.git
synced 2026-07-03 14:05:17 +02:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b92a6cdfac | |||
| 45da2479dd | |||
| 1c936b2b31 | |||
| dbe109eedb | |||
| 7705aded77 |
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.
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)
|
||||
|
||||
Reference in New Issue
Block a user