lc-core/src/main/scala/lc/Main.scala
vinceh121 b5a33d2e42
Listen address in config
Signed-off-by: vinceh121 <contact@vinceh121.me>
2021-05-19 14:32:02 +02:00

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
}
}
}