Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make flaresolverr session options configurable #854

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ object CFClearance {
FlareSolverRequest(
"request.get",
originalRequest.url.toString(),
session = "suwayomi",
sessionTtlMinutes = 15,
session = serverConfig.flareSolverrSessionName.value,
sessionTtlMinutes = serverConfig.flareSolverrSessionTtl.value,
cookies =
network.cookieStore.get(originalRequest.url).map {
FlareSolverCookie(it.name, it.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class SettingsMutation {
updateSetting(settings.flareSolverrEnabled, serverConfig.flareSolverrEnabled)
updateSetting(settings.flareSolverrUrl, serverConfig.flareSolverrUrl)
updateSetting(settings.flareSolverrTimeout, serverConfig.flareSolverrTimeout)
updateSetting(settings.flareSolverrSessionName, serverConfig.flareSolverrSessionName)
updateSetting(settings.flareSolverrSessionTtl, serverConfig.flareSolverrSessionTtl)
}

fun setSettings(input: SetSettingsInput): SetSettingsPayload {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ interface Settings : Node {
val flareSolverrEnabled: Boolean?
val flareSolverrUrl: String?
val flareSolverrTimeout: Int?
val flareSolverrSessionName: String?
val flareSolverrSessionTtl: Int?
}

data class PartialSettingsType(
Expand Down Expand Up @@ -127,6 +129,8 @@ data class PartialSettingsType(
override val flareSolverrEnabled: Boolean?,
override val flareSolverrUrl: String?,
override val flareSolverrTimeout: Int?,
override val flareSolverrSessionName: String?,
override val flareSolverrSessionTtl: Int?,
) : Settings

class SettingsType(
Expand Down Expand Up @@ -178,6 +182,8 @@ class SettingsType(
override val flareSolverrEnabled: Boolean,
override val flareSolverrUrl: String,
override val flareSolverrTimeout: Int,
override val flareSolverrSessionName: String,
override val flareSolverrSessionTtl: Int,
) : Settings {
constructor(config: ServerConfig = serverConfig) : this(
config.ip.value,
Expand Down Expand Up @@ -228,5 +234,7 @@ class SettingsType(
config.flareSolverrEnabled.value,
config.flareSolverrUrl.value,
config.flareSolverrTimeout.value,
config.flareSolverrSessionName.value,
config.flareSolverrSessionTtl.value,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class ServerConfig(getConfig: () -> Config, val moduleName: String = SERVER_CONF
val flareSolverrEnabled: MutableStateFlow<Boolean> by OverrideConfigValue(BooleanConfigAdapter)
val flareSolverrUrl: MutableStateFlow<String> by OverrideConfigValue(StringConfigAdapter)
val flareSolverrTimeout: MutableStateFlow<Int> by OverrideConfigValue(IntConfigAdapter)
val flareSolverrSessionName: MutableStateFlow<String> by OverrideConfigValue(StringConfigAdapter)
val flareSolverrSessionTtl: MutableStateFlow<Int> by OverrideConfigValue(IntConfigAdapter)

@OptIn(ExperimentalCoroutinesApi::class)
fun <T> subscribeTo(
Expand Down
4 changes: 3 additions & 1 deletion server/src/main/resources/server-reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ server.localSourcePath = ""
# Cloudflare bypass
server.flareSolverrEnabled = false
server.flareSolverrUrl = "http://localhost:8191"
server.flareSolverrTimeout = 60 # time in seconds
server.flareSolverrTimeout = 60 # time in seconds
server.flareSolverrSessionName = "suwayomi"
server.flareSolverrSessionTtl = 15 # time in minutes
Loading