Merge remote-tracking branch 'origin/master' into fix98SizeParam
This commit is contained in:
commit
c809872b8d
|
@ -1,3 +1,3 @@
|
|||
version="3.4.3"
|
||||
version="3.5.0"
|
||||
maxColumn = 120
|
||||
runner.dialect = scala3
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
FROM adoptopenjdk/openjdk16:alpine AS base-builder
|
||||
ARG SBT_VERSION=1.3.13
|
||||
ARG SBT_VERSION=1.6.2
|
||||
RUN apk add --no-cache bash
|
||||
ENV JAVA_HOME="/usr/lib/jvm/default-jvm/"
|
||||
ENV PATH=$PATH:${JAVA_HOME}/bin
|
||||
RUN \
|
||||
wget -O sbt-$SBT_VERSION.tgz https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz && \
|
||||
tar -xzvf sbt-$SBT_VERSION.tgz && \
|
||||
rm sbt-$SBT_VERSION.tgz
|
||||
tar -xzvf sbt-$SBT_VERSION.tgz && \
|
||||
rm sbt-$SBT_VERSION.tgz
|
||||
|
||||
ENV PATH=$PATH:/sbt/bin/
|
||||
|
||||
|
@ -30,7 +30,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin
|
|||
|
||||
FROM base-core
|
||||
WORKDIR /lc-core
|
||||
COPY --from=builder /build/target/scala-2.13/LibreCaptcha.jar .
|
||||
COPY --from=builder /build/target/scala-3.1.1/LibreCaptcha.jar .
|
||||
RUN mkdir data/
|
||||
|
||||
EXPOSE 8888
|
||||
|
|
|
@ -3,7 +3,9 @@ version: "3.6"
|
|||
services:
|
||||
lc-core:
|
||||
container_name: "libre-captcha"
|
||||
image: librecaptcha/lc-core:1.0.0-stable
|
||||
image: librecaptcha/lc-core:latest
|
||||
# Comment "image" & uncomment "build" if you intend to build from source
|
||||
#build: .
|
||||
volumes:
|
||||
- "./docker-data:/lc-core/data"
|
||||
ports:
|
||||
|
|
|
@ -26,13 +26,12 @@ object LCFramework {
|
|||
corsHeader = config.corsHeader
|
||||
)
|
||||
|
||||
Runtime.getRuntime.addShutdownHook( new Thread {
|
||||
override def run(): Unit = {
|
||||
println("Shutting down gracefully...")
|
||||
backgroundTask.shutdown()
|
||||
}
|
||||
Runtime.getRuntime.addShutdownHook(new Thread {
|
||||
override def run(): Unit = {
|
||||
println("Shutting down gracefully...")
|
||||
backgroundTask.shutdown()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
server.start()
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class BackgroundTask(config: Config, captchaManager: CaptchaManager) {
|
|||
val countExisting = captchaManager.getCount(param).getOrElse(0)
|
||||
val countRequired = requiredCountPerCombination - countExisting
|
||||
if (countRequired > 0) {
|
||||
val countCreate = Math.min(1.0 + requiredCountPerCombination/10.0, countRequired).toInt
|
||||
val countCreate = Math.min(1.0 + requiredCountPerCombination / 10.0, countRequired).toInt
|
||||
println(s"Creating $countCreate of $countRequired captchas for $param")
|
||||
|
||||
for (i <- 0 until countCreate) {
|
||||
|
@ -42,10 +42,10 @@ class BackgroundTask(config: Config, captchaManager: CaptchaManager) {
|
|||
}
|
||||
|
||||
private def allParameterCombinations(): List[Parameters] = {
|
||||
(config.captchaConfig).flatMap {captcha =>
|
||||
(captcha.allowedLevels).flatMap {level =>
|
||||
(captcha.allowedMedia).flatMap {media =>
|
||||
(captcha.allowedInputType).flatMap {inputType =>
|
||||
(config.captchaConfig).flatMap { captcha =>
|
||||
(captcha.allowedLevels).flatMap { level =>
|
||||
(captcha.allowedMedia).flatMap { media =>
|
||||
(captcha.allowedInputType).flatMap { inputType =>
|
||||
(captcha.allowedSizes).map {size =>
|
||||
Parameters(level, media, inputType, size)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@ package lc.database
|
|||
import java.sql.{Connection, DriverManager, Statement}
|
||||
|
||||
class DBConn() {
|
||||
val con: Connection = DriverManager.getConnection("jdbc:h2:./data/H2/captcha3;MAX_COMPACT_TIME=8000;DB_CLOSE_ON_EXIT=FALSE", "sa", "")
|
||||
val con: Connection =
|
||||
DriverManager.getConnection("jdbc:h2:./data/H2/captcha3;MAX_COMPACT_TIME=8000;DB_CLOSE_ON_EXIT=FALSE", "sa", "")
|
||||
|
||||
def getStatement(): Statement = {
|
||||
con.createStatement()
|
||||
|
|
|
@ -13,7 +13,13 @@ import java.net.InetSocketAddress
|
|||
import java.util
|
||||
import scala.jdk.CollectionConverters._
|
||||
|
||||
class Server(address: String, port: Int, captchaManager: CaptchaManager, playgroundEnabled: Boolean, corsHeader: String) {
|
||||
class Server(
|
||||
address: String,
|
||||
port: Int,
|
||||
captchaManager: CaptchaManager,
|
||||
playgroundEnabled: Boolean,
|
||||
corsHeader: String
|
||||
) {
|
||||
var headerMap: util.Map[String, util.List[String]] = _
|
||||
if (corsHeader.nonEmpty) {
|
||||
headerMap = Map("Access-Control-Allow-Origin" -> List(corsHeader).asJava).asJava
|
||||
|
|
Loading…
Reference in New Issue