mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-02-13 03:38:06 -05:00
Add config option for maxAttempts field
Signed-off-by: Rahul Rudragoudar <rr83019@gmail.com>
This commit is contained in:
parent
72cbbcde1f
commit
632eb49fd3
@ -3,6 +3,7 @@ package lc
|
||||
import lc.core.{CaptchaProviders, Captcha, Config}
|
||||
import lc.server.Server
|
||||
import lc.background.BackgroundTask
|
||||
import lc.database.Statements
|
||||
|
||||
object LCFramework {
|
||||
def main(args: scala.Array[String]): Unit = {
|
||||
@ -12,6 +13,7 @@ object LCFramework {
|
||||
"data/config.json"
|
||||
}
|
||||
val config = new Config(configFilePath)
|
||||
Statements.maxAttempts = config.maxAttempts
|
||||
val captchaProviders = new CaptchaProviders(config = config)
|
||||
val captcha = new Captcha(config = config, captchaProviders = captchaProviders)
|
||||
val backgroundTask = new BackgroundTask(config = config, captcha = captcha)
|
||||
|
@ -26,6 +26,7 @@ object AttributesEnum extends Enumeration {
|
||||
val PLAYGROUND_ENABLED: Value = Value("playgroundEnabled")
|
||||
val CORS_HEADER: Value = Value("corsHeader")
|
||||
val CONFIG: Value = Value("config")
|
||||
val MAX_ATTEMPTS: Value = Value("maxAttempts")
|
||||
}
|
||||
|
||||
object ResultEnum extends Enumeration {
|
||||
|
@ -47,6 +47,7 @@ class Config(configFilePath: String) {
|
||||
val threadDelay: Int = (configJson \ AttributesEnum.THREAD_DELAY.toString).extract[Int]
|
||||
val playgroundEnabled: Boolean = (configJson \ AttributesEnum.PLAYGROUND_ENABLED.toString).extract[Boolean]
|
||||
val corsHeader: String = (configJson \ AttributesEnum.CORS_HEADER.toString).extract[String]
|
||||
val maxAttempts: Int = (configJson \ AttributesEnum.MAX_ATTEMPTS.toString).extract[Int]
|
||||
|
||||
private val captchaConfigJson = (configJson \ "captchas")
|
||||
val captchaConfigTransform: JValue = captchaConfigJson transformField { case JField("config", JObject(config)) =>
|
||||
@ -69,6 +70,7 @@ class Config(configFilePath: String) {
|
||||
(AttributesEnum.THREAD_DELAY.toString -> 2) ~
|
||||
(AttributesEnum.PLAYGROUND_ENABLED.toString -> true) ~
|
||||
(AttributesEnum.CORS_HEADER.toString -> "") ~
|
||||
(AttributesEnum.MAX_ATTEMPTS.toString -> 10) ~
|
||||
("captchas" -> List(
|
||||
(
|
||||
(AttributesEnum.NAME.toString -> "FilterChallenge") ~
|
||||
|
@ -118,6 +118,6 @@ object Statements {
|
||||
```
|
||||
*/
|
||||
private val dbConn: DBConn = new DBConn()
|
||||
private val maxAttempts = 10
|
||||
var maxAttempts: Int = 10
|
||||
val tlStmts: ThreadLocal[Statements] = ThreadLocal.withInitial(() => new Statements(dbConn, maxAttempts))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user