Commit 8aa2c951 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Move cronet to Nebulo instead of the tunnel library, prepare to remove it in a build flavor

parent 52d9d079
...@@ -148,10 +148,12 @@ dependencies { ...@@ -148,10 +148,12 @@ dependencies {
implementation 'com.frostnerd.utilskt:lifecycle:1.2.2' implementation 'com.frostnerd.utilskt:lifecycle:1.2.2'
implementation 'com.frostnerd.utilskt:preferences:1.5.31' // https://git.frostnerd.com/AndroidUtils/preferenceskt implementation 'com.frostnerd.utilskt:preferences:1.5.31' // https://git.frostnerd.com/AndroidUtils/preferenceskt
implementation 'com.frostnerd.utilskt:navigationdraweractivity:1.4.3' // https://git.frostnerd.com/AndroidUtils/navigationdraweractivity implementation 'com.frostnerd.utilskt:navigationdraweractivity:1.4.3' // https://git.frostnerd.com/AndroidUtils/navigationdraweractivity
implementation 'com.frostnerd.utilskt:encrypteddnstunnelproxy:2.1.30' // https://git.frostnerd.com/AndroidUtils/encrypteddnstunnelproxy implementation 'com.frostnerd.utilskt:encrypteddnstunnelproxy:2.1.31' // https://git.frostnerd.com/AndroidUtils/encrypteddnstunnelproxy
implementation 'com.frostnerd.utilskt:general:1.0.26' // https://git.frostnerd.com/AndroidUtils/generalkt implementation 'com.frostnerd.utilskt:general:1.0.26' // https://git.frostnerd.com/AndroidUtils/generalkt
implementation 'com.frostnerd.utilskt:adapters:1.3.5' // https://git.frostnerd.com/AndroidUtils/Adapters implementation 'com.frostnerd.utilskt:adapters:1.3.5' // https://git.frostnerd.com/AndroidUtils/Adapters
implementation 'com.google.android.gms:play-services-cronet:17.0.0'
implementation 'androidx.work:work-runtime:2.5.0' implementation 'androidx.work:work-runtime:2.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0-rc01' implementation 'androidx.appcompat:appcompat:1.3.0-rc01'
implementation "androidx.preference:preference:1.1.1" implementation "androidx.preference:preference:1.1.1"
......
...@@ -16,13 +16,12 @@ import androidx.annotation.ColorInt ...@@ -16,13 +16,12 @@ import androidx.annotation.ColorInt
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import com.frostnerd.dnstunnelproxy.KnownDnsServers import com.frostnerd.dnstunnelproxy.KnownDnsServers
import com.frostnerd.encrypteddnstunnelproxy.AbstractHttpsDNSHandle import com.frostnerd.encrypteddnstunnelproxy.AbstractHttpsDNSHandle
import com.frostnerd.encrypteddnstunnelproxy.QuicEngine
import com.frostnerd.encrypteddnstunnelproxy.quic.AbstractQuicDnsHandle import com.frostnerd.encrypteddnstunnelproxy.quic.AbstractQuicDnsHandle
import com.frostnerd.encrypteddnstunnelproxy.quic.QuicUpstreamAddress import com.frostnerd.encrypteddnstunnelproxy.quic.QuicUpstreamAddress
import com.frostnerd.encrypteddnstunnelproxy.tls.AbstractTLSDnsHandle import com.frostnerd.encrypteddnstunnelproxy.tls.AbstractTLSDnsHandle
import com.google.android.gms.net.CronetProviderInstaller
import kotlinx.android.synthetic.main.dialog_privacypolicy.view.* import kotlinx.android.synthetic.main.dialog_privacypolicy.view.*
import okhttp3.internal.toHexString import okhttp3.internal.toHexString
import org.chromium.net.CronetEngine
import java.util.* import java.util.*
...@@ -135,23 +134,8 @@ fun loadKnownDNSServers() { ...@@ -135,23 +134,8 @@ fun loadKnownDNSServers() {
KnownDnsServers KnownDnsServers
} }
fun createQuicCronetEngineIfInstalled(context: Context, vararg addresses: QuicUpstreamAddress): CronetEngine? { fun createQuicEngineIfInstalled(context: Context, quicOnly:Boolean, vararg addresses: QuicUpstreamAddress): QuicEngine? {
return if(CronetProviderInstaller.isInstalled()) try { return if (QuicEngineImpl.providerInstalled) {
AbstractQuicDnsHandle.createEngine(context, *addresses) QuicEngineImpl(context, quicOnly, *addresses)
} catch (ex:Throwable) { null } } else null
else null
}
fun createHttpCronetEngineIfInstalled(context: Context): CronetEngine? {
return if(CronetProviderInstaller.isInstalled()) try {
val cacheDir = context.cacheDir.resolve("cronetcachehttp")
cacheDir.mkdir()
return CronetEngine.Builder(context)
.enableHttp2(true)
.enableBrotli(true)
.enableQuic(true)
.setStoragePath(cacheDir.path)
.build()
} catch (ex:Throwable) { null }
else null
} }
\ No newline at end of file
package com.frostnerd.smokescreen
import android.content.Context
import com.frostnerd.encrypteddnstunnelproxy.QuicEngine
import com.frostnerd.encrypteddnstunnelproxy.quic.QuicUpstreamAddress
import com.google.android.gms.net.CronetProviderInstaller
import org.chromium.net.CronetEngine
import java.net.URL
import java.net.URLConnection
/*
* Copyright (C) 2021 Daniel Wolf (Ch4t4r)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You can contact the developer at daniel.wolf@frostnerd.com.
*/
class QuicEngineImpl(context: Context, private val quicOnly:Boolean, vararg addresses:QuicUpstreamAddress):QuicEngine(context, *addresses) {
companion object {
var providerInstalled:Boolean = false
private set
fun installNetworkEngine(context: Context, onSuccess:(() -> Unit)? = null) {
try {
if(CronetProviderInstaller.isInstalled()) {
providerInstalled = true
onSuccess?.invoke()
} else {
CronetProviderInstaller.installProvider(context).addOnCompleteListener {
providerInstalled = true
onSuccess?.invoke()
}
}
} catch (ex:Throwable) {
ex.printStackTrace()
}
}
}
private var engine: CronetEngine? = null
init {
installNetworkEngine(context) {
engine = createEngine(context, *addresses)
}
}
private fun createEngine(context: Context, vararg addresses:QuicUpstreamAddress): CronetEngine {
val cacheDir = context.cacheDir.resolve("cronetcache")
cacheDir.mkdir()
return CronetEngine.Builder(context)
.apply {
addresses.forEach {
addQuicHint(it.host, it.port, 443)
}
}.enableHttp2(!quicOnly)
.enableBrotli(true)
.enableQuic(true)
.setStoragePath(cacheDir.path)
.build()
}
override fun openConnection(url: URL): URLConnection {
return engine!!.openConnection(url)
}
override fun shutdown() {
engine?.shutdown()
}
fun usable():Boolean {
return providerInstalled && engine != null
}
}
\ No newline at end of file
...@@ -144,7 +144,7 @@ class SmokeScreen : Application() { ...@@ -144,7 +144,7 @@ class SmokeScreen : Application() {
log("Application created.") log("Application created.")
handleFallbackDns() handleFallbackDns()
loadKnownDNSServers() loadKnownDNSServers()
AbstractQuicDnsHandle.installProvider(this) {} QuicEngineImpl.installNetworkEngine(this)
} }
private fun handleFallbackDns() { private fun handleFallbackDns() {
......
...@@ -68,7 +68,8 @@ class NebuloAppIntro:AppIntro() { ...@@ -68,7 +68,8 @@ class NebuloAppIntro:AppIntro() {
scope.launch { scope.launch {
for(server in chunks[i]) { for(server in chunks[i]) {
if(!isActive) break if(!isActive) break
val testResult = DnsSpeedTest(this@NebuloAppIntro, server, log = {}, cronetEngine = createQuicCronetEngineIfInstalled(this@NebuloAppIntro)).runTest(3) val testResult = DnsSpeedTest(this@NebuloAppIntro, server, log = {},
quicOnlyEngine = createQuicEngineIfInstalled(this@NebuloAppIntro, true)).runTest(3)
synchronized(speedTestResults) { synchronized(speedTestResults) {
speedTestResults[server] = testResult speedTestResults[server] = testResult
} }
......
...@@ -195,8 +195,8 @@ class SpeedTestActivity : BaseActivity() { ...@@ -195,8 +195,8 @@ class SpeedTestActivity : BaseActivity() {
if(wasStartedBefore) prepareList() if(wasStartedBefore) prepareList()
testJob = launchWithLifecycle { testJob = launchWithLifecycle {
prepareListJob?.join() prepareListJob?.join()
val engine = if(BuildConfig.SHOW_DOQ) createQuicCronetEngineIfInstalled(this@SpeedTestActivity) else null val engine = if(BuildConfig.SHOW_DOQ) createQuicEngineIfInstalled(this@SpeedTestActivity, true) else null
val httpsEngine = createHttpCronetEngineIfInstalled(this@SpeedTestActivity) val httpsEngine = createQuicEngineIfInstalled(this@SpeedTestActivity, false)
testRunning = true testRunning = true
wasStartedBefore = true wasStartedBefore = true
val testsLeft = testResults!!.shuffled() val testsLeft = testResults!!.shuffled()
......
...@@ -377,7 +377,7 @@ class MainFragment : Fragment() { ...@@ -377,7 +377,7 @@ class MainFragment : Fragment() {
if(!context.getPreferences().compareDnsSpeedsAtLaunch) return if(!context.getPreferences().compareDnsSpeedsAtLaunch) return
launchWithLifecycle { launchWithLifecycle {
val httpsEngine = createHttpCronetEngineIfInstalled(context) val httpsEngine = createQuicEngineIfInstalled(context, false)
val fastServerAverage = (AbstractHttpsDNSHandle.suspendUntilKnownServersArePopulated( val fastServerAverage = (AbstractHttpsDNSHandle.suspendUntilKnownServersArePopulated(
1500 1500
) { ) {
...@@ -389,8 +389,8 @@ class MainFragment : Fragment() { ...@@ -389,8 +389,8 @@ class MainFragment : Fragment() {
context, context,
it as DnsServerInformation<*>, it as DnsServerInformation<*>,
log = {}, log = {},
cronetEngine = null, /* We do not need quic here*/ quicOnlyEngine = null, /* We do not need quic here*/
httpsCronetEngine = httpsEngine httpsQuicEngine = httpsEngine
).runTest(4) ).runTest(4)
}.takeIf { }.takeIf {
it.isNotEmpty() it.isNotEmpty()
......
...@@ -1246,7 +1246,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope { ...@@ -1246,7 +1246,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
var forwardingMode = VPNTunnelProxy.ForwardingMode.MIXED var forwardingMode = VPNTunnelProxy.ForwardingMode.MIXED
val httpCronetEngine = createHttpCronetEngineIfInstalled(this) val httpQuicEngine = createQuicEngineIfInstalled(this, false)
serverConfig.httpsConfiguration?.forEach { serverConfig.httpsConfiguration?.forEach {
forwardingMode = VPNTunnelProxy.ForwardingMode.NO_POLLABLE forwardingMode = VPNTunnelProxy.ForwardingMode.NO_POLLABLE
val addresses = serverConfig.getIpAddressesFor(ipv4Enabled, ipv6Enabled, it) val addresses = serverConfig.getIpAddressesFor(ipv4Enabled, ipv6Enabled, it)
...@@ -1264,7 +1264,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope { ...@@ -1264,7 +1264,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
} }
}, },
mapQueryRefusedToHostBlock = getPreferences().mapQueryRefusedToHostBlock, mapQueryRefusedToHostBlock = getPreferences().mapQueryRefusedToHostBlock,
cronetEngine = httpCronetEngine quicEngine = httpQuicEngine
) )
handle.ipv4Enabled = ipv4Enabled handle.ipv4Enabled = ipv4Enabled
handle.ipv6Enabled = ipv6Enabled handle.ipv6Enabled = ipv6Enabled
...@@ -1294,8 +1294,8 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope { ...@@ -1294,8 +1294,8 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
if (defaultHandle == null) defaultHandle = handle if (defaultHandle == null) defaultHandle = handle
else handles.add(handle) else handles.add(handle)
} }
val cronetEngine = serverConfig.quicConfiguration?.let { createQuicCronetEngineIfInstalled(this, *it.toTypedArray()) } val quicEngine = serverConfig.quicConfiguration?.let { createQuicEngineIfInstalled(this, true, *it.toTypedArray()) }
if(serverConfig.quicConfiguration != null && cronetEngine == null) { if(serverConfig.quicConfiguration != null && quicEngine == null) {
showCronetErrorNotification() showCronetErrorNotification()
destroy(true) destroy(true)
return return
...@@ -1315,7 +1315,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope { ...@@ -1315,7 +1315,7 @@ class DnsVpnService : VpnService(), Runnable, CoroutineScope {
} }
} }
}, mapQueryRefusedToHostBlock = getPreferences().mapQueryRefusedToHostBlock, }, mapQueryRefusedToHostBlock = getPreferences().mapQueryRefusedToHostBlock,
cronetEngine!! quicEngine!!
) )
handle.ipv4Enabled = ipv4Enabled handle.ipv4Enabled = ipv4Enabled
handle.ipv6Enabled = ipv6Enabled handle.ipv6Enabled = ipv6Enabled
......
...@@ -3,9 +3,9 @@ package com.frostnerd.smokescreen.util.proxy ...@@ -3,9 +3,9 @@ package com.frostnerd.smokescreen.util.proxy
import com.frostnerd.dnstunnelproxy.AddressCreator import com.frostnerd.dnstunnelproxy.AddressCreator
import com.frostnerd.dnstunnelproxy.UpstreamAddress import com.frostnerd.dnstunnelproxy.UpstreamAddress
import com.frostnerd.encrypteddnstunnelproxy.AbstractHttpsDNSHandle import com.frostnerd.encrypteddnstunnelproxy.AbstractHttpsDNSHandle
import com.frostnerd.encrypteddnstunnelproxy.QuicEngine
import com.frostnerd.encrypteddnstunnelproxy.ServerConfiguration import com.frostnerd.encrypteddnstunnelproxy.ServerConfiguration
import com.frostnerd.vpntunnelproxy.FutureAnswer import com.frostnerd.vpntunnelproxy.FutureAnswer
import org.chromium.net.CronetEngine
import org.minidns.dnsmessage.DnsMessage import org.minidns.dnsmessage.DnsMessage
import java.net.InetAddress import java.net.InetAddress
...@@ -33,9 +33,9 @@ class ProxyHttpsHandler( ...@@ -33,9 +33,9 @@ class ProxyHttpsHandler(
connectTimeout: Long, connectTimeout: Long,
val queryCountCallback: (() -> Unit)? = null, val queryCountCallback: (() -> Unit)? = null,
val mapQueryRefusedToHostBlock:Boolean, val mapQueryRefusedToHostBlock:Boolean,
cronetEngine: CronetEngine? = null quicEngine: QuicEngine? = null
) : ) :
AbstractHttpsDNSHandle(serverConfigurations, connectTimeout, cronetEngine) { AbstractHttpsDNSHandle(serverConfigurations, connectTimeout, quicEngine) {
override val handlesSpecificRequests: Boolean = ProxyBypassHandler.knownSearchDomains.isNotEmpty() override val handlesSpecificRequests: Boolean = ProxyBypassHandler.knownSearchDomains.isNotEmpty()
private val dummyUpstreamAddress = UpstreamAddress(AddressCreator.fromHostAddress("0.0.0.0"), 1) private val dummyUpstreamAddress = UpstreamAddress(AddressCreator.fromHostAddress("0.0.0.0"), 1)
......
...@@ -2,10 +2,10 @@ package com.frostnerd.smokescreen.util.proxy ...@@ -2,10 +2,10 @@ package com.frostnerd.smokescreen.util.proxy
import com.frostnerd.dnstunnelproxy.AddressCreator import com.frostnerd.dnstunnelproxy.AddressCreator
import com.frostnerd.dnstunnelproxy.UpstreamAddress import com.frostnerd.dnstunnelproxy.UpstreamAddress
import com.frostnerd.encrypteddnstunnelproxy.QuicEngine
import com.frostnerd.encrypteddnstunnelproxy.quic.AbstractQuicDnsHandle import com.frostnerd.encrypteddnstunnelproxy.quic.AbstractQuicDnsHandle
import com.frostnerd.encrypteddnstunnelproxy.quic.QuicUpstreamAddress import com.frostnerd.encrypteddnstunnelproxy.quic.QuicUpstreamAddress
import com.frostnerd.vpntunnelproxy.FutureAnswer import com.frostnerd.vpntunnelproxy.FutureAnswer
import org.chromium.net.CronetEngine
import org.minidns.dnsmessage.DnsMessage import org.minidns.dnsmessage.DnsMessage
import org.minidns.record.A import org.minidns.record.A
import org.minidns.record.AAAA import org.minidns.record.AAAA
...@@ -36,7 +36,7 @@ class ProxyQuicHandler( ...@@ -36,7 +36,7 @@ class ProxyQuicHandler(
connectTimeout: Int, connectTimeout: Int,
val queryCountCallback: (() -> Unit)? = null, val queryCountCallback: (() -> Unit)? = null,
val mapQueryRefusedToHostBlock:Boolean, val mapQueryRefusedToHostBlock:Boolean,
engine:CronetEngine engine: QuicEngine
):AbstractQuicDnsHandle(upstreamAddresses, connectTimeout, engine) { ):AbstractQuicDnsHandle(upstreamAddresses, connectTimeout, engine) {
override val handlesSpecificRequests: Boolean = ProxyBypassHandler.knownSearchDomains.isNotEmpty() override val handlesSpecificRequests: Boolean = ProxyBypassHandler.knownSearchDomains.isNotEmpty()
private val dummyUpstreamAddress = UpstreamAddress(AddressCreator.fromHostAddress("0.0.0.0"), 1) private val dummyUpstreamAddress = UpstreamAddress(AddressCreator.fromHostAddress("0.0.0.0"), 1)
......
...@@ -5,18 +5,19 @@ import androidx.annotation.IntRange ...@@ -5,18 +5,19 @@ import androidx.annotation.IntRange
import com.frostnerd.dnstunnelproxy.DnsServerInformation import com.frostnerd.dnstunnelproxy.DnsServerInformation
import com.frostnerd.dnstunnelproxy.UpstreamAddress import com.frostnerd.dnstunnelproxy.UpstreamAddress
import com.frostnerd.encrypteddnstunnelproxy.HttpsDnsServerInformation import com.frostnerd.encrypteddnstunnelproxy.HttpsDnsServerInformation
import com.frostnerd.encrypteddnstunnelproxy.QuicEngine
import com.frostnerd.encrypteddnstunnelproxy.ServerConfiguration import com.frostnerd.encrypteddnstunnelproxy.ServerConfiguration
import com.frostnerd.encrypteddnstunnelproxy.closeSilently import com.frostnerd.encrypteddnstunnelproxy.closeSilently
import com.frostnerd.encrypteddnstunnelproxy.quic.QuicUpstreamAddress import com.frostnerd.encrypteddnstunnelproxy.quic.QuicUpstreamAddress
import com.frostnerd.encrypteddnstunnelproxy.tls.TLSUpstreamAddress import com.frostnerd.encrypteddnstunnelproxy.tls.TLSUpstreamAddress
import com.frostnerd.smokescreen.createHttpCronetEngineIfInstalled import com.frostnerd.smokescreen.QuicEngineImpl
import com.frostnerd.smokescreen.createQuicEngineIfInstalled
import com.frostnerd.smokescreen.type import com.frostnerd.smokescreen.type
import com.frostnerd.smokescreen.util.ServerType import com.frostnerd.smokescreen.util.ServerType
import okhttp3.* import okhttp3.*
import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.RequestBody.Companion.toRequestBody
import org.chromium.net.CronetEngine
import org.minidns.dnsmessage.DnsMessage import org.minidns.dnsmessage.DnsMessage
import org.minidns.dnsmessage.Question import org.minidns.dnsmessage.Question
import org.minidns.record.Record import org.minidns.record.Record
...@@ -50,8 +51,8 @@ class DnsSpeedTest(context:Context, ...@@ -50,8 +51,8 @@ class DnsSpeedTest(context:Context,
val server: DnsServerInformation<*>, val server: DnsServerInformation<*>,
private val connectTimeout: Int = 2500, private val connectTimeout: Int = 2500,
private val readTimeout:Int = 1500, private val readTimeout:Int = 1500,
private val cronetEngine: CronetEngine?, private val quicOnlyEngine: QuicEngine?,
httpsCronetEngine: CronetEngine? = null, httpsQuicEngine: QuicEngine? = null,
val log:(line:String) -> Unit) { val log:(line:String) -> Unit) {
private val httpClient by lazy(LazyThreadSafetyMode.NONE) { private val httpClient by lazy(LazyThreadSafetyMode.NONE) {
OkHttpClient.Builder() OkHttpClient.Builder()
...@@ -65,8 +66,8 @@ class DnsSpeedTest(context:Context, ...@@ -65,8 +66,8 @@ class DnsSpeedTest(context:Context,
it.urlCreator.address it.urlCreator.address
}) })
} }
private val _httpsCronetEngine by lazy(LazyThreadSafetyMode.NONE) { private val _quicEngine by lazy(LazyThreadSafetyMode.NONE) {
httpsCronetEngine ?: createHttpCronetEngineIfInstalled(context) httpsQuicEngine ?: createQuicEngineIfInstalled(context, false)
} }
companion object { companion object {
...@@ -94,7 +95,7 @@ class DnsSpeedTest(context:Context, ...@@ -94,7 +95,7 @@ class DnsSpeedTest(context:Context,
ServerType.DOH -> { ServerType.DOH -> {
server as HttpsDnsServerInformation server as HttpsDnsServerInformation
server.serverConfigurations.values.forEach { server.serverConfigurations.values.forEach {
latencies += if(_httpsCronetEngine == null) { latencies += if(_quicEngine == null) {
if(firstPass) testHttps(it) if(firstPass) testHttps(it)
testHttps(it) ?: 0 testHttps(it) ?: 0
} else { } else {
...@@ -107,7 +108,7 @@ class DnsSpeedTest(context:Context, ...@@ -107,7 +108,7 @@ class DnsSpeedTest(context:Context,
ServerType.DOQ -> { ServerType.DOQ -> {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
(server as DnsServerInformation<QuicUpstreamAddress>).servers.forEach { (server as DnsServerInformation<QuicUpstreamAddress>).servers.forEach {
if(cronetEngine != null) { if(quicOnlyEngine != null) {
if(firstPass) testQuic(it.address) if(firstPass) testQuic(it.address)
latencies += testQuic(it.address) ?: 0 latencies += testQuic(it.address) ?: 0
} }
...@@ -117,7 +118,7 @@ class DnsSpeedTest(context:Context, ...@@ -117,7 +118,7 @@ class DnsSpeedTest(context:Context,
firstPass = false firstPass = false
} }
if(server.type == ServerType.DOH) { if(server.type == ServerType.DOH) {
if(_httpsCronetEngine == null) httpClient.connectionPool.evictAll() if(_quicEngine == null) httpClient.connectionPool.evictAll()
} }
return when (strategy) { return when (strategy) {
Strategy.BEST_CASE -> { Strategy.BEST_CASE -> {
...@@ -213,7 +214,7 @@ class DnsSpeedTest(context:Context, ...@@ -213,7 +214,7 @@ class DnsSpeedTest(context:Context,
var connection:HttpURLConnection? = null var connection:HttpURLConnection? = null
var wasEstablished = false var wasEstablished = false
try { try {
connection = _httpsCronetEngine!!.openConnection(url) as HttpURLConnection connection = _quicEngine!!.openConnection(url) as HttpURLConnection
connection.connectTimeout = connectTimeout connection.connectTimeout = connectTimeout
if(config.requestHasBody) { if(config.requestHasBody) {
val body = config.bodyCreator?.createBody(msg, config.urlCreator.address) ?: return null val body = config.bodyCreator?.createBody(msg, config.urlCreator.address) ?: return null
...@@ -307,7 +308,7 @@ class DnsSpeedTest(context:Context, ...@@ -307,7 +308,7 @@ class DnsSpeedTest(context:Context,
val msg = createTestDnsPacket() val msg = createTestDnsPacket()
try { try {
val start = System.currentTimeMillis() val start = System.currentTimeMillis()
connection = cronetEngine!!.openConnection(url) as HttpURLConnection connection = quicOnlyEngine!!.openConnection(url) as HttpURLConnection
connection.connectTimeout = connectTimeout connection.connectTimeout = connectTimeout
connection.requestMethod = "POST" connection.requestMethod = "POST"
connection.setRequestProperty("Content-Type", "application/dns-message") connection.setRequestProperty("Content-Type", "application/dns-message")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment