mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-04-15 08:35:44 -04:00
45 lines
1.4 KiB
Scala
45 lines
1.4 KiB
Scala
package lc
|
|
|
|
import lc.core.{CaptchaProviders, Captcha, Config}
|
|
import lc.server.Server
|
|
import lc.background.BackgroundTask
|
|
|
|
object LCFramework {
|
|
def main(args: scala.Array[String]): Unit = {
|
|
val configFilePath = if (args.length > 0){
|
|
args(0)
|
|
} else {
|
|
"data/config.json"
|
|
}
|
|
val config = new Config(configFilePath)
|
|
val captchaProviders = new CaptchaProviders(config = config)
|
|
val captcha = new Captcha(config = config, captchaProviders = captchaProviders)
|
|
val backgroundTask = new BackgroundTask(config = config, captcha = captcha)
|
|
backgroundTask.beginThread(delay = config.threadDelay)
|
|
val server = new Server(address = config.address, port = config.port, captcha = captcha)
|
|
server.start()
|
|
}
|
|
}
|
|
|
|
object MakeSamples {
|
|
def main(args: scala.Array[String]): Unit = {
|
|
val configFilePath = if (args.length > 0){
|
|
args(0)
|
|
} else {
|
|
"data/config.json"
|
|
}
|
|
val config = new Config(configFilePath)
|
|
val captchaProviders = new CaptchaProviders(config = config)
|
|
val samples = captchaProviders.generateChallengeSamples()
|
|
samples.foreach {
|
|
case (key, sample) =>
|
|
val extensionMap = Map("image/png" -> "png", "image/gif" -> "gif")
|
|
println(key + ": " + sample)
|
|
|
|
val outStream = new java.io.FileOutputStream("samples/" + key + "." + extensionMap(sample.contentType))
|
|
outStream.write(sample.content)
|
|
outStream.close
|
|
}
|
|
}
|
|
}
|