feat(komga): ignore dns over https (#6335)

This commit is contained in:
Gauthier 2021-03-29 19:04:40 +08:00 committed by GitHub
parent 21cf5dac2d
commit 7655bf6483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 112 additions and 101 deletions

View File

@ -1,3 +1,11 @@
## 1.2.23
Minimum Komga version required: `0.75.0`
### Features
* ignore DNS over HTTPS so it can reach IP addresses
## 1.2.22 ## 1.2.22
Minimum Komga version required: `0.75.0` Minimum Komga version required: `0.75.0`

View File

@ -5,13 +5,13 @@ ext {
extName = 'Komga' extName = 'Komga'
pkgNameSuffix = 'all.komga' pkgNameSuffix = 'all.komga'
extClass = '.KomgaFactory' extClass = '.KomgaFactory'
extVersionCode = 22 extVersionCode = 23
libVersion = '1.2' libVersion = '1.2'
} }
dependencies { dependencies {
implementation 'io.reactivex:rxandroid:1.2.1' implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.3.6' implementation 'io.reactivex:rxjava:1.3.8'
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -28,6 +28,7 @@ import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import okhttp3.Credentials import okhttp3.Credentials
import okhttp3.Dns
import okhttp3.Headers import okhttp3.Headers
import okhttp3.HttpUrl import okhttp3.HttpUrl
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
@ -336,6 +337,7 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
override val name = "Komga${if (suffix.isNotBlank()) " ($suffix)" else ""}" override val name = "Komga${if (suffix.isNotBlank()) " ($suffix)" else ""}"
override val lang = "en" override val lang = "en"
override val supportsLatest = true override val supportsLatest = true
private val LOG_TAG = "extension.all.komga${if (suffix.isNotBlank()) ".$suffix" else ""}"
override val baseUrl by lazy { getPrefBaseUrl() } override val baseUrl by lazy { getPrefBaseUrl() }
private val username by lazy { getPrefUsername() } private val username by lazy { getPrefUsername() }
@ -361,6 +363,7 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
.build() .build()
} }
} }
.dns(Dns.SYSTEM) // don't use DNS over HTTPS as it breaks IP addressing
.build() .build()
override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) { override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) {
@ -428,114 +431,116 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
private fun getPrefPassword(): String = preferences.getString(PASSWORD_TITLE, PASSWORD_DEFAULT)!! private fun getPrefPassword(): String = preferences.getString(PASSWORD_TITLE, PASSWORD_DEFAULT)!!
init { init {
Single.fromCallable { if (baseUrl.isNotBlank()) {
client.newCall(GET("$baseUrl/api/v1/libraries", headers)).execute() Single.fromCallable {
} client.newCall(GET("$baseUrl/api/v1/libraries", headers)).execute()
.subscribeOn(Schedulers.io()) }
.observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io())
.subscribe( .observeOn(AndroidSchedulers.mainThread())
{ response -> .subscribe(
libraries = try { { response ->
gson.fromJson(response.body()?.charStream()!!) libraries = try {
} catch (e: Exception) { gson.fromJson(response.body()?.charStream()!!)
emptyList() } catch (e: Exception) {
emptyList()
}
},
{ tr ->
Log.e(LOG_TAG, "error while loading libraries for filters", tr)
} }
}, )
{ tr ->
Log.e(LOG_TAG, "error while loading libraries for filters", tr)
}
)
Single.fromCallable { Single.fromCallable {
client.newCall(GET("$baseUrl/api/v1/collections?unpaged=true", headers)).execute() client.newCall(GET("$baseUrl/api/v1/collections?unpaged=true", headers)).execute()
} }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe( .subscribe(
{ response -> { response ->
collections = try { collections = try {
gson.fromJson<PageWrapperDto<CollectionDto>>(response.body()?.charStream()!!).content gson.fromJson<PageWrapperDto<CollectionDto>>(response.body()?.charStream()!!).content
} catch (e: Exception) { } catch (e: Exception) {
emptyList() emptyList()
}
},
{ tr ->
Log.e(LOG_TAG, "error while loading collections for filters", tr)
} }
}, )
{ tr ->
Log.e(LOG_TAG, "error while loading collections for filters", tr)
}
)
Single.fromCallable { Single.fromCallable {
client.newCall(GET("$baseUrl/api/v1/genres", headers)).execute() client.newCall(GET("$baseUrl/api/v1/genres", headers)).execute()
} }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe( .subscribe(
{ response -> { response ->
genres = try { genres = try {
gson.fromJson(response.body()?.charStream()!!) gson.fromJson(response.body()?.charStream()!!)
} catch (e: Exception) { } catch (e: Exception) {
emptySet() emptySet()
}
},
{ tr ->
Log.e(LOG_TAG, "error while loading genres for filters", tr)
} }
}, )
{ tr ->
Log.e(LOG_TAG, "error while loading genres for filters", tr)
}
)
Single.fromCallable { Single.fromCallable {
client.newCall(GET("$baseUrl/api/v1/tags", headers)).execute() client.newCall(GET("$baseUrl/api/v1/tags", headers)).execute()
} }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe( .subscribe(
{ response -> { response ->
tags = try { tags = try {
gson.fromJson(response.body()?.charStream()!!) gson.fromJson(response.body()?.charStream()!!)
} catch (e: Exception) { } catch (e: Exception) {
emptySet() emptySet()
}
},
{ tr ->
Log.e(LOG_TAG, "error while loading tags for filters", tr)
} }
}, )
{ tr ->
Log.e(LOG_TAG, "error while loading tags for filters", tr)
}
)
Single.fromCallable { Single.fromCallable {
client.newCall(GET("$baseUrl/api/v1/publishers", headers)).execute() client.newCall(GET("$baseUrl/api/v1/publishers", headers)).execute()
} }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe( .subscribe(
{ response -> { response ->
publishers = try { publishers = try {
gson.fromJson(response.body()?.charStream()!!) gson.fromJson(response.body()?.charStream()!!)
} catch (e: Exception) { } catch (e: Exception) {
emptySet() emptySet()
}
},
{ tr ->
Log.e(LOG_TAG, "error while loading publishers for filters", tr)
} }
}, )
{ tr ->
Log.e(LOG_TAG, "error while loading publishers for filters", tr)
}
)
Single.fromCallable { Single.fromCallable {
client.newCall(GET("$baseUrl/api/v1/authors", headers)).execute() client.newCall(GET("$baseUrl/api/v1/authors", headers)).execute()
} }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe( .subscribe(
{ response -> { response ->
authors = try { authors = try {
val list: List<AuthorDto> = gson.fromJson(response.body()?.charStream()!!) val list: List<AuthorDto> = gson.fromJson(response.body()?.charStream()!!)
list.groupBy { it.role } list.groupBy { it.role }
} catch (e: Exception) { } catch (e: Exception) {
emptyMap() emptyMap()
}
},
{ tr ->
Log.e(LOG_TAG, "error while loading authors for filters", tr)
} }
}, )
{ tr -> }
Log.e(LOG_TAG, "error while loading authors for filters", tr)
}
)
} }
companion object { companion object {
@ -550,7 +555,5 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() {
private const val TYPE_SERIES = "Series" private const val TYPE_SERIES = "Series"
private const val TYPE_READLISTS = "Read lists" private const val TYPE_READLISTS = "Read lists"
private const val LOG_TAG = "extension.all.komga"
} }
} }