[RU]LibGroup ratelimits hosts (#12275)

This commit is contained in:
Ejan 2022-06-22 14:41:35 +05:00 committed by GitHub
parent c2574260d2
commit 11436ac598
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 11 deletions

View File

@ -1,12 +1,12 @@
package eu.kanade.tachiyomi.extension.ru.hentailib package eu.kanade.tachiyomi.extension.ru.hentailib
import eu.kanade.tachiyomi.multisrc.libgroup.LibGroup import eu.kanade.tachiyomi.multisrc.libgroup.LibGroup
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.network.interceptor.rateLimitHost
import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
import java.io.IOException
import okhttp3.Headers import okhttp3.Headers
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
@ -15,6 +15,10 @@ class HentaiLib : LibGroup("HentaiLib", "https://hentailib.me", "ru") {
override val id: Long = 6425650164840473547 override val id: Long = 6425650164840473547
override val client: OkHttpClient = super.client.newBuilder() override val client: OkHttpClient = super.client.newBuilder()
.rateLimitHost(baseUrl.toHttpUrl(),10) //source
.rateLimitHost("https://img2.hentailib.org".toHttpUrl(),1) //secondary
.rateLimitHost("https://img4.hentailib.org".toHttpUrl(),1) //fourth
.rateLimitHost("https://img3.hentailib.org".toHttpUrl(),1) //compress
.addInterceptor(::imageContentTypeIntercept) .addInterceptor(::imageContentTypeIntercept)
.build() .build()

View File

@ -6,16 +6,16 @@ import android.widget.Toast
import androidx.preference.ListPreference import androidx.preference.ListPreference
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.multisrc.libgroup.LibGroup import eu.kanade.tachiyomi.multisrc.libgroup.LibGroup
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.network.interceptor.rateLimitHost
import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
import okhttp3.Headers import okhttp3.Headers
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import java.io.IOException
class MangaLib : LibGroup("MangaLib", "https://mangalib.me", "ru") { class MangaLib : LibGroup("MangaLib", "https://mangalib.me", "ru") {
@ -25,7 +25,16 @@ class MangaLib : LibGroup("MangaLib", "https://mangalib.me", "ru") {
Injekt.get<Application>().getSharedPreferences("source_${id}_2", 0x0000) Injekt.get<Application>().getSharedPreferences("source_${id}_2", 0x0000)
} }
private val baseOrig: String = "https://mangalib.me"
private val baseMirr: String = "https://mangalib.org"
private var domain: String? = preferences.getString(DOMAIN_PREF, baseOrig)
override val baseUrl: String = domain.toString()
override val client: OkHttpClient = super.client.newBuilder() override val client: OkHttpClient = super.client.newBuilder()
.rateLimitHost(baseUrl.toHttpUrl(),10) //source
.rateLimitHost("https://img2.mixlib.me".toHttpUrl(),1) //secondary
.rateLimitHost("https://img4.imgslib.link".toHttpUrl(),1) //fourth
.rateLimitHost("https://img3.cdnlib.link".toHttpUrl(),1) //compress
.addInterceptor(::imageContentTypeIntercept) .addInterceptor(::imageContentTypeIntercept)
.build() .build()
@ -39,11 +48,6 @@ class MangaLib : LibGroup("MangaLib", "https://mangalib.me", "ru") {
} }
.build() .build()
private val baseOrig: String = "https://mangalib.me"
private val baseMirr: String = "https://mangalib.org"
private var domain: String? = preferences.getString(DOMAIN_PREF, baseOrig)
override val baseUrl: String = domain.toString()
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
if (csrfToken.isEmpty()) { if (csrfToken.isEmpty()) {
val tokenResponse = client.newCall(popularMangaRequest(page)).execute() val tokenResponse = client.newCall(popularMangaRequest(page)).execute()

View File

@ -9,7 +9,7 @@ class LibGenerator: ThemeSourceGenerator {
override val themeClass = "LibGroup" override val themeClass = "LibGroup"
override val baseVersionCode: Int = 5 override val baseVersionCode: Int = 6
override val sources = listOf( override val sources = listOf(
SingleLang("MangaLib", "https://mangalib.me", "ru", overrideVersionCode = 74), SingleLang("MangaLib", "https://mangalib.me", "ru", overrideVersionCode = 74),

View File

@ -79,7 +79,6 @@ abstract class LibGroup(
override val client: OkHttpClient = network.cloudflareClient.newBuilder() override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.connectTimeout(30, TimeUnit.SECONDS) .connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(1, TimeUnit.MINUTES) .readTimeout(1, TimeUnit.MINUTES)
.rateLimit(2)
.addInterceptor { chain -> .addInterceptor { chain ->
val response = chain.proceed(chain.request()) val response = chain.proceed(chain.request())
if (response.code == 419) if (response.code == 419)