mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-27 21:05:58 -05:00
WIP: Add config case class to avoid type change
Signed-off-by: Rahul Rudragoudar <rr83019@gmail.com>
This commit is contained in:
parent
e1505a7573
commit
8e66f3fa8e
@ -11,6 +11,18 @@ import java.io.{FileNotFoundException, File, PrintWriter}
|
|||||||
import java.{util => ju}
|
import java.{util => ju}
|
||||||
import lc.misc.HelperFunctions
|
import lc.misc.HelperFunctions
|
||||||
|
|
||||||
|
case class ConfigField(
|
||||||
|
port: Option[Int],
|
||||||
|
address: Option[String],
|
||||||
|
throttle: Option[Int],
|
||||||
|
seed: Option[Int],
|
||||||
|
captchaExpiryTimeLimit: Option[Int],
|
||||||
|
threadDelay: Option[Int],
|
||||||
|
playgroundEnabled: Option[String],
|
||||||
|
corsHeader: Option[String],
|
||||||
|
maxAttempts: Option[Int]
|
||||||
|
)
|
||||||
|
|
||||||
class Config(configFilePath: String) {
|
class Config(configFilePath: String) {
|
||||||
|
|
||||||
import Config.formats
|
import Config.formats
|
||||||
@ -42,6 +54,14 @@ class Config(configFilePath: String) {
|
|||||||
|
|
||||||
private val configJson = parse(configString)
|
private val configJson = parse(configString)
|
||||||
|
|
||||||
|
val fields = configJson.extract[ConfigField]
|
||||||
|
|
||||||
|
val port1: Int = fields.port.getOrElse(8888)
|
||||||
|
val address1: String = fields.address.getOrElse("0.0.0.0")
|
||||||
|
|
||||||
|
println(port1)
|
||||||
|
println(address1)
|
||||||
|
|
||||||
val port: Int = getOptionalConfigParam(AttributesEnum.PORT.toString, "8888").toInt
|
val port: Int = getOptionalConfigParam(AttributesEnum.PORT.toString, "8888").toInt
|
||||||
val address: String = getOptionalConfigParam(AttributesEnum.ADDRESS.toString, "0.0.0.0")
|
val address: String = getOptionalConfigParam(AttributesEnum.ADDRESS.toString, "0.0.0.0")
|
||||||
val throttle: Int = getOptionalConfigParam(AttributesEnum.THROTTLE.toString, "1000").toInt
|
val throttle: Int = getOptionalConfigParam(AttributesEnum.THROTTLE.toString, "1000").toInt
|
||||||
@ -84,7 +104,7 @@ class Config(configFilePath: String) {
|
|||||||
(AttributesEnum.CAPTCHA_EXPIRY_TIME_LIMIT.toString -> 5) ~
|
(AttributesEnum.CAPTCHA_EXPIRY_TIME_LIMIT.toString -> 5) ~
|
||||||
(AttributesEnum.THROTTLE.toString -> 1000) ~
|
(AttributesEnum.THROTTLE.toString -> 1000) ~
|
||||||
(AttributesEnum.THREAD_DELAY.toString -> 2) ~
|
(AttributesEnum.THREAD_DELAY.toString -> 2) ~
|
||||||
(AttributesEnum.PLAYGROUND_ENABLED.toString -> true) ~
|
(AttributesEnum.PLAYGROUND_ENABLED.toString -> "true") ~
|
||||||
(AttributesEnum.CORS_HEADER.toString -> "") ~
|
(AttributesEnum.CORS_HEADER.toString -> "") ~
|
||||||
(AttributesEnum.MAX_ATTEMPTS.toString -> 10) ~
|
(AttributesEnum.MAX_ATTEMPTS.toString -> 10) ~
|
||||||
("captchas" -> List(
|
("captchas" -> List(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user