Compare commits

...

14 Commits

Author SHA1 Message Date
Aravinth Manivannan
9922c23322
Merge pull request #162 from lorenzleutgeb/patch-1
fix: SPDX identifier for license in package.json
2024-04-17 23:47:51 +05:30
Lorenz Leutgeb
2a92e8f672
fix: SPDX identifier for license in package.json 2024-04-17 19:04:09 +02:00
Aravinth Manivannan
581e6f9440
Merge pull request #157 from mCaptcha/fix-154
fix: exit loop when paginated DB query in easy PoW auto-enhance loop returns empty array
2024-03-24 08:53:08 +05:30
Aravinth Manivannan
3a7e71b499
fix: exit loop when paginated DB query returns empty array
fixes: https://github.com/mCaptcha/mCaptcha/issues/154
2024-03-24 08:40:52 +05:30
Aravinth Manivannan
91955501e2
feat: enable easy PoW configuration auto-enhance by default 2024-03-24 08:37:26 +05:30
Aravinth Manivannan
cb72b0adfa
Merge pull request #152 from mCaptcha/fix-151
fix: difficulty factor for "broke my site" should be greater than peak sustainable traffic"
2024-03-23 13:55:28 +05:30
Aravinth Manivannan
c1fe45d409
fix: difficulty factor for "broke my site" should be greater than "peak sustainable traffic"
fixes: #151
2024-03-23 13:31:49 +05:30
Aravinth Manivannan
59e339f287
Merge pull request #150 from mCaptcha/fix-144
feat: add curl to the final image to aid in healthchecks
2024-03-15 18:01:12 +05:30
Aravinth Manivannan
ddcde9cf18
Merge pull request #146 from 15aura35/master
Update .env.docker-compose to use port 7000 instead of 7001
2024-03-15 18:00:17 +05:30
Aravinth Manivannan
65c92ee96e
feat: add curl to the final image to aid in healthchecks
closes: https://github.com/mCaptcha/mCaptcha/issues/144
2024-03-14 20:52:37 +05:30
Aravinth Manivannan
40766ff44f
Merge pull request #147 from mitallast/master
Fix: ensuring worker is ready
2024-03-12 19:41:49 +05:30
mitallast
ddc3008009 await worker is ready 2024-03-05 13:42:10 +03:00
mitallast
cba056aba6 fix wasm bigint progress handler 2024-03-05 13:13:47 +03:00
15aura35
16c975d2ec
Update .env.docker-compose 2024-03-01 21:53:32 +00:00
10 changed files with 43 additions and 14 deletions

View File

@ -13,7 +13,7 @@ MCAPTCHA_redis_URL=redis://mcaptcha_redis
MCAPTCHA_redis_POOL=4
# server
PORT=7001
PORT=7000
MCAPTCHA_server_DOMAIN=localhost
MCAPTCHA__server_COOKIE_SECRET=pleasereplacethiswithrandomstring # PLEASE SET RANDOM STRING. MIN LENGTH=32
MCAPTCHA__server_IP= 0.0.0.0
@ -26,8 +26,8 @@ MCAPTCHA_captcha_RUNNERS=4
MCAPTCHA_captcha_QUEUE_LENGTH=2000
MCAPTCHA_captcha_ENABLE_STATS=true
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_avg_traffic_difficulty=50000 # almost instant solution
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_broke_my_site_traffic_difficulty=3000000 # roughly 1.5s
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_peak_sustainable_traffic_difficulty=5000000 # greater than 3.5s
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_peak_sustainable_traffic_difficulty=3000000 # greater than 3.5s
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_broke_my_site_traffic_difficulty=5000000 # roughly 1.5s
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_duration=30 # cooldown period in seconds
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_avg_traffic_time=1 # almost instant solution
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_peak_sustainable_traffic_time=3

View File

@ -31,6 +31,10 @@ RUN cargo build --release
FROM debian:bookworm as mCaptcha
LABEL org.opencontainers.image.source https://github.com/mCaptcha/mCaptcha
RUN set -ex; \
apt-get update; \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends curl
RUN useradd -ms /bin/bash -u 1001 mcaptcha
WORKDIR /home/mcaptcha
COPY --from=rust /src/target/release/mcaptcha /usr/local/bin/

View File

@ -34,11 +34,11 @@ enable_stats = true
[captcha.default_difficulty_strategy]
avg_traffic_difficulty = 50000 # almost instant solution
#avg_traffic_time = 1 # almost instant solution
avg_traffic_time = 1 # almost instant solution
peak_sustainable_traffic_difficulty = 3000000 # roughly 1.5s
#peak_sustainable_traffic_time = 3
peak_sustainable_traffic_time = 3
broke_my_site_traffic_difficulty = 5000000 # greater than 3.5s
#broke_my_site_traffic_time = 5
broke_my_site_traffic_time = 5
duration = 30 # cooldown period in seconds
[database]

View File

@ -2,7 +2,7 @@
"name": "vanilla",
"main": "index.js",
"version": "1.0.0",
"license": "AGPL-3.0",
"license": "AGPL-3.0-or-later",
"scripts": {
"build": "webpack --mode production",
"lint": "yarn run eslint templates",

View File

@ -55,6 +55,9 @@ impl UpdateEasyCaptcha {
}
let mut patterns = data.db.get_all_easy_captchas(limit, offset).await?;
if patterns.is_empty() {
break;
}
for pattern in patterns.drain(0..) {
if !Self::can_run(rx) {
return Ok(());
@ -85,6 +88,7 @@ impl UpdateEasyCaptcha {
}
page += 1;
}
Ok(())
}
fn can_run(rx: &mut Receiver<()>) -> bool {

View File

@ -21,7 +21,7 @@ SPDX-License-Identifier: MIT OR Apache-2.0
<label class="widget__verification-container" for="widget__verification-checkbox">
<span id="widget__verification-text"
>I'm not a robot</span>
<input
<input disabled
id="widget__verification-checkbox"
aria-valuenow="I'm not a robot"
aria-checked="false"

View File

@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: MIT OR Apache-2.0
import { Work, ServiceWorkerMessage } from "./types";
import {Work, ServiceWorkerMessage} from "./types";
import fetchPoWConfig from "./fetchPoWConfig";
import sendWork from "./sendWork";
import sendToParent from "./sendToParent";
@ -12,7 +12,17 @@ import * as CONST from "./const";
import "./main.scss";
let LOCK = false;
const worker = new Worker("/bench.js");
const workerPromise = new Promise<Worker>((res) => {
const worker = new Worker("/bench.js");
worker.onmessage = (event: MessageEvent) => {
const message: ServiceWorkerMessage = event.data;
if(message.type === "ready") {
console.log("worker ready");
res(worker);
}
};
});
/** add mcaptcha widget element to DOM */
export const registerVerificationEventHandler = (): void => {
@ -20,10 +30,14 @@ export const registerVerificationEventHandler = (): void => {
document.querySelector(".widget__verification-container")
);
verificationContainer.style.display = "flex";
CONST.btn().addEventListener("click", (e) => solveCaptchaRunner(e));
workerPromise.then((worker: Worker) => {
const btn = CONST.btn();
btn.disabled = false;
btn.addEventListener("click", (e) => solveCaptchaRunner(worker, e));
});
};
export const solveCaptchaRunner = async (e: Event): Promise<void> => {
export const solveCaptchaRunner = async (worker: Worker, e: Event): Promise<void> => {
const PROGRESS_FILL = <HTMLElement>document.querySelector(".progress__fill");
const setWidth = (width: number) => {
@ -94,7 +108,7 @@ export const solveCaptchaRunner = async (e: Event): Promise<void> => {
}
if (resp.type === "progress") {
if (width < 80) {
width = Number(resp.nonce / max_recorded_nonce) * 100;
width = resp.nonce / max_recorded_nonce * 100;
setWidth(width);
}
console.log(`received nonce ${resp.nonce}`);

View File

@ -30,7 +30,7 @@ const prove = async (
config.string,
config.difficulty_factor,
STEPS,
progress
(nonce: BigInt | number) => progress(Number(nonce))
);
const t1 = performance.now();
time = t1 - t0;

View File

@ -9,6 +9,12 @@ import prove from "./prove";
import { PoWConfig, ServiceWorkerMessage, ServiceWorkerWork } from "./types";
log.log("worker registered");
const ready: ServiceWorkerMessage = {
type: "ready",
};
postMessage(ready);
onmessage = async (e) => {
console.debug("message received at worker");
const config: PoWConfig = e.data;

View File

@ -40,5 +40,6 @@ export type Token = {
};
export type ServiceWorkerMessage =
| { type: "ready" }
| { type: "work"; value: ServiceWorkerWork }
| { type: "progress"; nonce: number };