mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-03-30 15:08:29 +00:00
Compare commits
14 Commits
v0.1.0-rc1
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9922c23322 | ||
![]() |
2a92e8f672 | ||
![]() |
581e6f9440 | ||
![]() |
3a7e71b499 | ||
![]() |
91955501e2 | ||
![]() |
cb72b0adfa | ||
![]() |
c1fe45d409 | ||
![]() |
59e339f287 | ||
![]() |
ddcde9cf18 | ||
![]() |
65c92ee96e | ||
![]() |
40766ff44f | ||
![]() |
ddc3008009 | ||
![]() |
cba056aba6 | ||
![]() |
16c975d2ec |
@ -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
|
||||
|
@ -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/
|
||||
|
@ -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]
|
||||
|
@ -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",
|
||||
|
@ -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 {
|
||||
|
@ -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"
|
||||
|
@ -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}`);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -40,5 +40,6 @@ export type Token = {
|
||||
};
|
||||
|
||||
export type ServiceWorkerMessage =
|
||||
| { type: "ready" }
|
||||
| { type: "work"; value: ServiceWorkerWork }
|
||||
| { type: "progress"; nonce: number };
|
||||
|
Loading…
x
Reference in New Issue
Block a user