mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-12 22:43:20 -05:00
commit
ab9c0e6247
@ -16,7 +16,7 @@ object LCFramework {
|
||||
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(port = config.port, captcha = captcha)
|
||||
val server = new Server(address = config.address, port = config.port, captcha = captcha)
|
||||
server.start()
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ object AttributesEnum extends Enumeration {
|
||||
val NAME: Value = Value("name")
|
||||
val RANDOM_SEED: Value = Value("randomSeed")
|
||||
val PORT: Value = Value("port")
|
||||
val ADDRESS: Value = Value("address")
|
||||
val CAPTCHA_EXPIRY_TIME_LIMIT: Value = Value("captchaExpiryTimeLimit")
|
||||
val THROTTLE: Value = Value("throttle")
|
||||
val THREAD_DELAY: Value = Value("threadDelay")
|
||||
|
@ -40,6 +40,7 @@ class Config(configFilePath: String) {
|
||||
private val configJson = parse(configString)
|
||||
|
||||
val port: Int = (configJson \ AttributesEnum.PORT.toString).extract[Int]
|
||||
val address: String = (configJson \ AttributesEnum.ADDRESS.toString).extract[String]
|
||||
val throttle: Int = (configJson \ AttributesEnum.THROTTLE.toString).extract[Int]
|
||||
val seed: Int = (configJson \ AttributesEnum.RANDOM_SEED.toString).extract[Int]
|
||||
val captchaExpiryTimeLimit: Int = (configJson \ AttributesEnum.CAPTCHA_EXPIRY_TIME_LIMIT.toString).extract[Int]
|
||||
@ -60,6 +61,7 @@ class Config(configFilePath: String) {
|
||||
val defaultConfigMap =
|
||||
(AttributesEnum.RANDOM_SEED.toString -> new ju.Random().nextInt()) ~
|
||||
(AttributesEnum.PORT.toString -> 8888) ~
|
||||
(AttributesEnum.ADDRESS.toString -> "0.0.0.0") ~
|
||||
(AttributesEnum.CAPTCHA_EXPIRY_TIME_LIMIT.toString -> 5) ~
|
||||
(AttributesEnum.THROTTLE.toString -> 1000) ~
|
||||
(AttributesEnum.THREAD_DELAY.toString -> 2) ~
|
||||
|
@ -9,11 +9,12 @@ import org.limium.picoserve
|
||||
import org.limium.picoserve.Server.ByteResponse
|
||||
import scala.io.Source
|
||||
import org.limium.picoserve.Server.StringResponse
|
||||
import java.net.InetSocketAddress
|
||||
|
||||
class Server(port: Int, captcha: Captcha) {
|
||||
class Server(address: String, port: Int, captcha: Captcha) {
|
||||
val server: picoserve.Server = picoserve.Server
|
||||
.builder()
|
||||
.port(port)
|
||||
.address(new InetSocketAddress(address, port))
|
||||
.backlog(32)
|
||||
.POST(
|
||||
"/v1/captcha",
|
||||
@ -69,7 +70,7 @@ class Server(port: Int, captcha: Captcha) {
|
||||
}
|
||||
|
||||
def start(): Unit = {
|
||||
println("Starting server on port:" + port)
|
||||
println("Starting server on " + address + ":" + port)
|
||||
server.start()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user