Skip to content

Commit

Permalink
added doh
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Jan 3, 2024
1 parent c0d7442 commit 3da0231
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ kotlin {

api(libs.coil.gif)
api(libs.coil.svg)

api(libs.okhttp.doh)
}
}
val desktopMain by getting {
Expand All @@ -122,6 +124,8 @@ kotlin {
api(libs.appdirs)
api(libs.vlcj)
api(libs.webview.desktop)

api(libs.okhttp.doh)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ import io.ktor.serialization.kotlinx.json.*
import io.realm.kotlin.mongodb.App
import io.realm.kotlin.mongodb.AppConfiguration
import kotlinx.serialization.json.Json
import okhttp3.Dns
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.dnsoverhttps.DnsOverHttps
import okio.FileSystem
import org.kodein.di.DI
import org.kodein.di.bindEagerSingleton
import org.kodein.di.bindSingleton
import org.kodein.di.instance
import java.net.InetAddress
import java.util.concurrent.TimeUnit

actual object PlatformModule {
Expand All @@ -46,6 +51,22 @@ actual object PlatformModule {
isLenient = true
}
}
bindSingleton {
OkHttpClient.Builder()
.followRedirects(true)
.followSslRedirects(true)
.connectTimeout(3, TimeUnit.MINUTES)
.readTimeout(3, TimeUnit.MINUTES)
.writeTimeout(3, TimeUnit.MINUTES)
.build()
}
bindSingleton {
DnsOverHttps.Builder()
.client(instance())
.url("https://dns.google/dns-query".toHttpUrl())
.bootstrapDnsHosts(InetAddress.getByName("8.8.4.4"), InetAddress.getByName("8.8.8.8"))
.build()
}
bindSingleton {
HttpClient(OkHttp) {
engine {
Expand All @@ -54,6 +75,7 @@ actual object PlatformModule {
connectTimeout(3, TimeUnit.MINUTES)
readTimeout(3, TimeUnit.MINUTES)
writeTimeout(3, TimeUnit.MINUTES)
dns(instance())
}
}
install(ContentNegotiation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ import io.ktor.http.*
import io.ktor.serialization.kotlinx.json.*
import io.realm.kotlin.mongodb.AppConfiguration
import kotlinx.serialization.json.Json
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.dnsoverhttps.DnsOverHttps
import okio.FileSystem
import org.kodein.di.DI
import org.kodein.di.bindEagerSingleton
import org.kodein.di.bindSingleton
import org.kodein.di.instance
import java.net.InetAddress
import java.util.concurrent.TimeUnit

actual object PlatformModule {
Expand All @@ -44,6 +48,22 @@ actual object PlatformModule {
isLenient = true
}
}
bindSingleton {
OkHttpClient.Builder()
.followRedirects(true)
.followSslRedirects(true)
.connectTimeout(3, TimeUnit.MINUTES)
.readTimeout(3, TimeUnit.MINUTES)
.writeTimeout(3, TimeUnit.MINUTES)
.build()
}
bindSingleton {
DnsOverHttps.Builder()
.client(instance())
.url("https://dns.google/dns-query".toHttpUrl())
.bootstrapDnsHosts(InetAddress.getByName("8.8.4.4"), InetAddress.getByName("8.8.8.8"))
.build()
}
bindSingleton {
HttpClient(OkHttp) {
engine {
Expand All @@ -52,6 +72,7 @@ actual object PlatformModule {
connectTimeout(3, TimeUnit.MINUTES)
readTimeout(3, TimeUnit.MINUTES)
writeTimeout(3, TimeUnit.MINUTES)
dns(instance())
}
}
install(ContentNegotiation) {
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ moko-resources = "0.23.0"
multidex = "2.0.1"
nanoid = "1.0.1"
napier = "2.6.1"
okhttp = "4.12.0"
osdetector = "1.7.3"
protobuf = "0.9.4"
protoc = "3.24.4"
Expand Down Expand Up @@ -125,6 +126,7 @@ moko-resources-generator = { group = "dev.icerock.moko", name = "resources-gener
multidex = { group = "androidx.multidex", name = "multidex", version.ref = "multidex" }
nanoid = { group = "dev.datlag.nanoid", name = "nanoid", version.ref = "nanoid" }
napier = { group = "io.github.aakira", name = "napier", version.ref = "napier" }
okhttp-doh = { group = "com.squareup.okhttp3", name = "okhttp-dnsoverhttps", version.ref = "okhttp" }
permission = { group = "com.google.accompanist", name = "accompanist-permissions", version.ref = "accompanist" }
protobuf = { group = "com.google.protobuf", name = "protobuf-kotlin", version.ref = "protoc" }
protoc = { group = "com.google.protobuf", name = "protoc", version.ref = "protoc" }
Expand Down

0 comments on commit 3da0231

Please sign in to comment.