mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 11:24:35 -05:00
make it compile
This commit is contained in:
@@ -17,4 +17,4 @@ class PersistentCookieJar(context: Context) : CookieJar {
|
|||||||
override fun loadForRequest(url: HttpUrl): List<Cookie> {
|
override fun loadForRequest(url: HttpUrl): List<Cookie> {
|
||||||
return store.get(url)
|
return store.get(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,5 +76,4 @@ class PersistentCookieStore(context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun Cookie.hasExpired() = System.currentTimeMillis() >= expiresAt
|
private fun Cookie.hasExpired() = System.currentTimeMillis() >= expiresAt
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.gargoylesoftware.htmlunit.BrowserVersion
|
|||||||
import com.gargoylesoftware.htmlunit.WebClient
|
import com.gargoylesoftware.htmlunit.WebClient
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlPage
|
import com.gargoylesoftware.htmlunit.html.HtmlPage
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
|
import mu.KotlinLogging
|
||||||
import okhttp3.Cookie
|
import okhttp3.Cookie
|
||||||
import okhttp3.HttpUrl
|
import okhttp3.HttpUrl
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
@@ -14,6 +15,8 @@ import java.io.IOException
|
|||||||
|
|
||||||
// from TachiWeb-Server
|
// from TachiWeb-Server
|
||||||
class CloudflareInterceptor : Interceptor {
|
class CloudflareInterceptor : Interceptor {
|
||||||
|
private val logger = KotlinLogging.logger {}
|
||||||
|
|
||||||
private val network: NetworkHelper by injectLazy()
|
private val network: NetworkHelper by injectLazy()
|
||||||
|
|
||||||
private val `serverCheck` = arrayOf("cloudflare-nginx", "cloudflare")
|
private val `serverCheck` = arrayOf("cloudflare-nginx", "cloudflare")
|
||||||
@@ -24,6 +27,7 @@ class CloudflareInterceptor : Interceptor {
|
|||||||
|
|
||||||
// Check if Cloudflare anti-bot is on
|
// Check if Cloudflare anti-bot is on
|
||||||
if (response.code == 503 && response.header("Server") in serverCheck) {
|
if (response.code == 503 && response.header("Server") in serverCheck) {
|
||||||
|
logger.debug { "CloudflareInterceptor is kicking in..." }
|
||||||
return try {
|
return try {
|
||||||
chain.proceed(resolveChallenge(response))
|
chain.proceed(resolveChallenge(response))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -92,4 +96,4 @@ class CloudflareInterceptor : Interceptor {
|
|||||||
.header("Cookie", newCookies.map { it.toString() }.joinToString("; "))
|
.header("Cookie", newCookies.map { it.toString() }.joinToString("; "))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
* Headers builder for requests. Implementations can override this method for custom headers.
|
* Headers builder for requests. Implementations can override this method for custom headers.
|
||||||
*/
|
*/
|
||||||
protected open fun headersBuilder() = Headers.Builder().apply {
|
protected open fun headersBuilder() = Headers.Builder().apply {
|
||||||
add("User-Agent", DEFAULT_USERAGENT)
|
add("User-Agent", DEFAULT_USER_AGENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user