Compare commits
59 commits
update-dep
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
8bed3cb352 | ||
|
8e03290fda | ||
|
321fd2e89b | ||
|
36600e2f13 | ||
|
606d22cc9d | ||
|
4426057fbc | ||
|
1f23999c10 | ||
|
0a3d93453e | ||
|
939fb5f8b9 | ||
|
3a787a6592 | ||
|
9dfb0713ad | ||
|
ad4582cc16 | ||
|
77e4a9c473 | ||
|
b6497882d7 | ||
|
49a8757ead | ||
|
1107d3fc05 | ||
|
072a997ff0 | ||
|
d30b53f4ee | ||
|
b3021c500e | ||
|
79006f1e64 | ||
|
a45840d259 | ||
|
960283324d | ||
|
74364c4e17 | ||
|
3d02f55241 | ||
|
eab146b121 | ||
|
d4534c1c43 | ||
|
d5617c7ec7 | ||
|
f933a30e7e | ||
|
87785b38be | ||
|
52c2c6e598 | ||
|
b6a6705449 | ||
|
c56b04fa5a | ||
|
ccb9278d67 | ||
|
eb69e9aedc | ||
|
1310c22bed | ||
|
b300d2caac | ||
|
5d03682c45 | ||
|
61729c5fae | ||
|
8ec5122f87 | ||
|
6bd66e6d00 | ||
|
8e3fb9d8ec | ||
|
c67b7ac686 | ||
|
cb7245d577 | ||
|
4739c697b7 | ||
|
561a847bd7 | ||
|
9e77eec657 | ||
|
30dc51e8e1 | ||
|
4e2758f415 | ||
|
0e75a22beb | ||
|
0d2c02348b | ||
|
98efe3ae56 | ||
|
060291d174 | ||
|
65c3b9ad67 | ||
|
d3e08ff49e | ||
|
431463a397 | ||
|
342d03b58b | ||
|
765be413c4 | ||
|
e0203c660d | ||
|
ce73d29792 |
193 changed files with 8332 additions and 9186 deletions
|
@ -12,3 +12,4 @@ src/cache_buster_data.json
|
|||
browser/target
|
||||
browser/cobertura.xml
|
||||
browser/docs
|
||||
**/target
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
export POSTGRES_DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"
|
||||
export MARIA_DATABASE_URL="mysql://maria:password@localhost:3306/maria"
|
||||
export MARIA_DATABASE_URL="mysql://root:password@localhost:3306/maria"
|
||||
|
|
56
.github/workflows/clippy-fmt.yml
vendored
56
.github/workflows/clippy-fmt.yml
vendored
|
@ -12,64 +12,28 @@ jobs:
|
|||
fmt:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: ⚡ Cache
|
||||
uses: actions/cache@v2
|
||||
- uses: actions/checkout@v4
|
||||
# Ensure rustfmt is installed and setup problem matcher
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
node_modules
|
||||
./docs/openapi/node_modules
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
components: rustfmt
|
||||
- name: Check with rustfmt
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
- name: Rustfmt Check
|
||||
uses: actions-rust-lang/rustfmt@v1
|
||||
|
||||
clippy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: ⚡ Cache
|
||||
uses: actions/cache@v2
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
node_modules
|
||||
./docs/openapi/node_modules
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
components: clippy
|
||||
override: true
|
||||
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "18.0.0"
|
||||
node-version: "20.0.0"
|
||||
|
||||
- name: Build frontend
|
||||
run: make frontend
|
||||
|
||||
- name: Check with Clippy
|
||||
uses: actions-rs/clippy-check@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --workspace --tests --all-features
|
||||
- name: clippy Check
|
||||
run: cargo clippy --workspace --tests --all-features
|
||||
|
|
254
.github/workflows/coverage.yml
vendored
254
.github/workflows/coverage.yml
vendored
|
@ -1,135 +1,119 @@
|
|||
name: Coverage
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- db-abstract
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version:
|
||||
- stable
|
||||
#- 1.51.0
|
||||
|
||||
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres
|
||||
env:
|
||||
POSTGRES_PASSWORD: password
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_DB: postgres
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
mcaptcha-redis:
|
||||
image: mcaptcha/cache
|
||||
ports:
|
||||
- 6379:6379
|
||||
|
||||
mcaptcha-smtp:
|
||||
image: maildev/maildev
|
||||
env:
|
||||
MAILDEV_WEB_PORT: "1080"
|
||||
MAILDEV_INCOMING_USER: "admin"
|
||||
MAILDEV_INCOMING_PASS: "password"
|
||||
ports:
|
||||
- 1080:1080
|
||||
- 10025:1025
|
||||
|
||||
|
||||
maria:
|
||||
image: mariadb:10
|
||||
env:
|
||||
MARIADB_USER: "maria"
|
||||
MARIADB_PASSWORD: "password"
|
||||
MARIADB_ROOT_PASSWORD: "password"
|
||||
MARIADB_DATABASE: "maria"
|
||||
options: >-
|
||||
--health-cmd="mysqladmin ping"
|
||||
--health-interval=10s
|
||||
--health-timeout=5s
|
||||
--health-retries=10
|
||||
ports:
|
||||
- 3306:3306
|
||||
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: ⚡ Cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
node_modules
|
||||
./docs/openapi/node_modules
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
|
||||
- name: load env
|
||||
run: |
|
||||
source .env_sample \
|
||||
&& echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV \
|
||||
&& echo "MARIA_DATABASE_URL=$MARIA_DATABASE_URL" >> $GITHUB_ENV
|
||||
|
||||
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "18.0.0"
|
||||
|
||||
- name: Install ${{ matrix.version }}
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Build frontend
|
||||
run: make frontend
|
||||
|
||||
- name: Run the frontend tests
|
||||
run: make test.frontend
|
||||
|
||||
- name: Run migrations
|
||||
run: make migrate
|
||||
env:
|
||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||
MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}"
|
||||
|
||||
- name: build frontend
|
||||
run: make frontend
|
||||
|
||||
- name: Generate coverage file
|
||||
if: github.event_name == 'pull_request'
|
||||
#if: (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||
uses: actions-rs/tarpaulin@v0.1
|
||||
with:
|
||||
args: "-t 1200"
|
||||
env:
|
||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||
MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}"
|
||||
# GIT_HASH is dummy value. I guess build.rs is skipped in tarpaulin
|
||||
# execution so this value is required for preventing meta tests from
|
||||
# panicking
|
||||
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61
|
||||
CACHE_BUSTER_FILE_MAP: '{"map":{"./static/bundle/main.js":"./prod/bundle/main.1417115E59909BE0A01040A45A398ADB09D928DF89CCF038FA44B14850442096.js"},"base_dir":"./prod"}'
|
||||
COMPILED_DATE: "2021-07-21"
|
||||
|
||||
- name: Upload to Codecov
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: codecov/codecov-action@v2
|
||||
#name: Coverage
|
||||
#
|
||||
#on:
|
||||
# pull_request:
|
||||
# types: [opened, synchronize, reopened]
|
||||
# push:
|
||||
# branches:
|
||||
# - master
|
||||
# - db-abstract
|
||||
#
|
||||
#jobs:
|
||||
# build_and_test:
|
||||
# strategy:
|
||||
# fail-fast: false
|
||||
# matrix:
|
||||
# version:
|
||||
# - stable
|
||||
# #- 1.51.0
|
||||
#
|
||||
# name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||
# runs-on: ubuntu-latest
|
||||
#
|
||||
# services:
|
||||
# postgres:
|
||||
# image: postgres
|
||||
# env:
|
||||
# POSTGRES_PASSWORD: password
|
||||
# POSTGRES_USER: postgres
|
||||
# POSTGRES_DB: postgres
|
||||
# options: >-
|
||||
# --health-cmd pg_isready
|
||||
# --health-interval 10s
|
||||
# --health-timeout 5s
|
||||
# --health-retries 5
|
||||
# ports:
|
||||
# - 5432:5432
|
||||
#
|
||||
# mcaptcha-redis:
|
||||
# image: mcaptcha/cache
|
||||
# ports:
|
||||
# - 6379:6379
|
||||
#
|
||||
# mcaptcha-smtp:
|
||||
# image: maildev/maildev
|
||||
# env:
|
||||
# MAILDEV_WEB_PORT: "1080"
|
||||
# MAILDEV_INCOMING_USER: "admin"
|
||||
# MAILDEV_INCOMING_PASS: "password"
|
||||
# ports:
|
||||
# - 1080:1080
|
||||
# - 10025:1025
|
||||
#
|
||||
#
|
||||
# maria:
|
||||
# image: mariadb:10
|
||||
# env:
|
||||
# MARIADB_USER: "maria"
|
||||
# MARIADB_PASSWORD: "password"
|
||||
# MARIADB_ROOT_PASSWORD: "password"
|
||||
# MARIADB_DATABASE: "maria"
|
||||
# options: >-
|
||||
# --health-cmd="mysqladmin ping"
|
||||
# --health-interval=10s
|
||||
# --health-timeout=5s
|
||||
# --health-retries=10
|
||||
# ports:
|
||||
# - 3306:3306
|
||||
#
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
#
|
||||
# - name: load env
|
||||
# run: |
|
||||
# source .env_sample \
|
||||
# && echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV \
|
||||
# && echo "MARIA_DATABASE_URL=$MARIA_DATABASE_URL" >> $GITHUB_ENV
|
||||
#
|
||||
#
|
||||
# - uses: actions/setup-node@v2
|
||||
# with:
|
||||
# node-version: "18.0.0"
|
||||
#
|
||||
# - uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
#
|
||||
# - name: Build frontend
|
||||
# run: make frontend
|
||||
#
|
||||
# - name: Run the frontend tests
|
||||
# run: make test.frontend
|
||||
#
|
||||
# - name: Run migrations
|
||||
# run: make migrate
|
||||
# env:
|
||||
# POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||
# MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}"
|
||||
#
|
||||
# - name: build frontend
|
||||
# run: make frontend
|
||||
#
|
||||
# - name: Generate coverage file
|
||||
# if: github.event_name == 'pull_request'
|
||||
# #if: (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||
# uses: actions-rs/tarpaulin@v0.1
|
||||
# with:
|
||||
# args: "-t 1200"
|
||||
# env:
|
||||
# POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||
# MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}"
|
||||
# # GIT_HASH is dummy value. I guess build.rs is skipped in tarpaulin
|
||||
# # execution so this value is required for preventing meta tests from
|
||||
# # panicking
|
||||
# GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61
|
||||
# CACHE_BUSTER_FILE_MAP: '{"map":{"./static/bundle/main.js":"./prod/bundle/main.1417115E59909BE0A01040A45A398ADB09D928DF89CCF038FA44B14850442096.js"},"base_dir":"./prod"}'
|
||||
# COMPILED_DATE: "2021-07-21"
|
||||
#
|
||||
# - name: Upload to Codecov
|
||||
# if: github.event_name == 'pull_request'
|
||||
# uses: codecov/codecov-action@v2
|
||||
|
|
30
.github/workflows/linux.yml
vendored
30
.github/workflows/linux.yml
vendored
|
@ -9,7 +9,7 @@ on:
|
|||
branches:
|
||||
- master
|
||||
- "*"
|
||||
- '!gh-pages'
|
||||
- "!gh-pages"
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
|
@ -17,9 +17,7 @@ jobs:
|
|||
fail-fast: false
|
||||
matrix:
|
||||
version:
|
||||
#- 1.51.0
|
||||
- stable
|
||||
# - nightly
|
||||
|
||||
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -55,7 +53,7 @@ jobs:
|
|||
|
||||
maria:
|
||||
image: mariadb:10
|
||||
env:
|
||||
env:
|
||||
MARIADB_USER: "maria"
|
||||
MARIADB_PASSWORD: "password"
|
||||
MARIADB_ROOT_PASSWORD: "password"
|
||||
|
@ -69,17 +67,8 @@ jobs:
|
|||
- 3306:3306
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: ⚡ Cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
node_modules
|
||||
./docs/openapi/node_modules
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
||||
- name: configure GPG key
|
||||
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/mCaptcha'
|
||||
|
@ -95,14 +84,9 @@ jobs:
|
|||
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "18.0.0"
|
||||
node-version: "20.0.0"
|
||||
|
||||
- name: Install ${{ matrix.version }}
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu
|
||||
profile: minimal
|
||||
override: true
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
|
||||
- name: install nightwatch dep
|
||||
run: sudo apt-get install xvfb
|
||||
|
@ -135,7 +119,7 @@ jobs:
|
|||
run: make test.integration
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/mCaptcha'
|
||||
if: github.ref == 'refs/heads/master' && github.event_name == 'push' && github.repository == 'mCaptcha/mCaptcha'
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: mcaptcha
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -16,3 +16,5 @@ assets
|
|||
yarn-error.log
|
||||
src/cache_buster_data.json.license
|
||||
**/**/target
|
||||
src/libcachebust_data.json
|
||||
utils/cache-bust/src/libcachebust_data.json
|
||||
|
|
1
.nvmrc
Normal file
1
.nvmrc
Normal file
|
@ -0,0 +1 @@
|
|||
20
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
### Changed
|
||||
|
||||
- 2023-10-18: Environment variable names have changed, please see
|
||||
[CONFIGURATION.md](docs/CONFIGURATION.md) for the names of environment
|
||||
variables.
|
||||
- ([`7d0e4c6`](https://github.com/mCaptcha/mCaptcha/commit/7d0e4c6be4b0769921cda7681858ebe16ec9a07b)) Add `secret` parameter to token verification request payload(`/api/v1/pow/siteverify`) to mitigate a security issue that @gusted found:
|
||||
> ...A malicious user could grab the sitekey
|
||||
> and use that sitekey with mcaptcha to use it for their own server.
|
||||
|
|
1505
Cargo.lock
generated
1505
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
17
Cargo.toml
17
Cargo.toml
|
@ -33,15 +33,15 @@ actix-service = "2.0.0"
|
|||
async-trait = "0.1.51"
|
||||
mime_guess = "2.0.3"
|
||||
rust-embed = "6.4.0"
|
||||
cache-buster = { git = "https://github.com/realaravinth/cache-buster" }
|
||||
libcachebust = "0.3.0"
|
||||
|
||||
futures = "0.3.15"
|
||||
tokio = { version = "1.14", features = ["sync"]}
|
||||
|
||||
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline", "mysql"] }
|
||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "postgres", "time", "mysql"] }
|
||||
argon2-creds = { branch = "master", git = "https://github.com/realaravinth/argon2-creds"}
|
||||
#argon2-creds = { version="*", path = "../../argon2-creds/" }
|
||||
config = "0.11"
|
||||
config = "0.13"
|
||||
validator = { version = "0.15", features = ["derive"]}
|
||||
|
||||
derive_builder = "0.11"
|
||||
|
@ -59,13 +59,11 @@ log = "0.4"
|
|||
lazy_static = "1.4"
|
||||
|
||||
|
||||
libmcaptcha = { version = "0.2.3", git = "https://github.com/mCaptcha/libmcaptcha", features = ["full"], tag ="0.2.3" }
|
||||
#libmcaptcha = { branch = "master", git = "https://github.com/mCaptcha/libmcaptcha", features = ["full"] }
|
||||
#libmcaptcha = { path = "../libmcaptcha", features = ["full"]}
|
||||
libmcaptcha = "0.2.4"
|
||||
|
||||
rand = "0.8"
|
||||
|
||||
sailfish = "0.4.0"
|
||||
sailfish = "0.7.0"
|
||||
|
||||
mime = "0.3.16"
|
||||
|
||||
|
@ -80,6 +78,7 @@ lettre = { version = "0.10.0-rc.3", features = [
|
|||
|
||||
openssl = { version = "0.10.48", features = ["vendored"] }
|
||||
uuid = { version = "1.4.0", features = ["v4", "serde"] }
|
||||
reqwest = { version = "0.11.18", features = ["json", "gzip"] }
|
||||
|
||||
|
||||
[dependencies.db-core]
|
||||
|
@ -102,10 +101,10 @@ features = ["actix_identity_backend"]
|
|||
|
||||
[build-dependencies]
|
||||
serde_json = "1"
|
||||
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline", "mysql" ] }
|
||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "postgres", "time", "mysql" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
pow_sha256 = { version = "0.3.1", git = "https://github.com/mcaptcha/pow_sha256", tag="0.3.1" }
|
||||
mcaptcha_pow_sha256 = "0.4"
|
||||
awc = "3.0.0"
|
||||
|
||||
|
||||
|
|
22
Dockerfile
22
Dockerfile
|
@ -1,8 +1,7 @@
|
|||
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
FROM node:18.0.0 as frontend
|
||||
FROM node:20 as frontend
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
|
@ -21,33 +20,16 @@ COPY Makefile /src/
|
|||
COPY scripts /src/scripts
|
||||
RUN make frontend
|
||||
|
||||
FROM rust:latest as planner
|
||||
RUN cargo install cargo-chef
|
||||
WORKDIR /src
|
||||
COPY . /src/
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
FROM rust:latest as cacher
|
||||
WORKDIR /src/
|
||||
RUN cargo install cargo-chef
|
||||
COPY --from=planner /src/recipe.json recipe.json
|
||||
RUN cargo chef cook --release --recipe-path recipe.json
|
||||
|
||||
FROM rust:latest as rust
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
COPY --from=cacher /src/target target
|
||||
#COPY --from=cacher /src/db/db-core/target /src/db/db-core/target
|
||||
#COPY --from=cacher /src/db/db-sqlx-postgres/target /src/db/db-sqlx-postgres/target
|
||||
#COPY --from=cacher /src/db/db-migrations/target /src/db/db-migrations/target
|
||||
#COPY --from=cacher /src/utils/cache-bust/target /src/utils/cache-bust/target
|
||||
COPY --from=frontend /src/static/cache/bundle/ /src/static/cache/bundle/
|
||||
COPY --from=frontend /src/docs/openapi/dist/ /src/docs/openapi/dist/
|
||||
RUN cargo --version
|
||||
RUN make cache-bust
|
||||
RUN cargo build --release
|
||||
|
||||
FROM debian:bullseye as mCaptcha
|
||||
FROM debian:bookworm as mCaptcha
|
||||
LABEL org.opencontainers.image.source https://github.com/mCaptcha/mCaptcha
|
||||
RUN useradd -ms /bin/bash -u 1001 mcaptcha
|
||||
WORKDIR /home/mcaptcha
|
||||
|
|
9
Makefile
9
Makefile
|
@ -4,7 +4,7 @@
|
|||
|
||||
BUNDLE = static/cache/bundle
|
||||
OPENAPI = docs/openapi
|
||||
CLEAN_UP = $(BUNDLE) src/cache_buster_data.json assets
|
||||
CLEAN_UP = $(BUNDLE) src/libcachebust_data.json assets
|
||||
|
||||
define deploy_dependencies ## deploy dependencies
|
||||
@-docker create --name ${db} \
|
||||
|
@ -34,8 +34,7 @@ endef
|
|||
|
||||
define run_dev_migrations ## run database migrations
|
||||
cd db/db-sqlx-maria/ && \
|
||||
DATABASE_URL=${MARIA_DATABASE_URL} sqlx migrate run
|
||||
cd db/db-sqlx-postgres/ && \
|
||||
DATABASE_URL=${MARIA_DATABASE_URL} sqlx migrate run cd db/db-sqlx-postgres/ && \
|
||||
DATABASE_URL=${POSTGRES_DATABASE_URL} sqlx migrate run
|
||||
endef
|
||||
|
||||
|
@ -67,11 +66,9 @@ define test_db_sqlx_maria
|
|||
endef
|
||||
|
||||
define test_core
|
||||
cargo test --no-fail-fast
|
||||
cargo test --no-fail-fast --jobs=4
|
||||
endef
|
||||
|
||||
|
||||
|
||||
default: frontend ## Build app in debug mode
|
||||
$(call cache_bust)
|
||||
cargo build
|
||||
|
|
3
build.rs
3
build.rs
|
@ -16,6 +16,7 @@ fn main() {
|
|||
let git_hash = String::from_utf8(output.stdout).unwrap();
|
||||
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
|
||||
|
||||
let now = OffsetDateTime::now_utc().format("%y-%m-%d");
|
||||
let now = OffsetDateTime::now_utc();
|
||||
let now = format!("{}{}{}", now.year(), now.month(), now.date());
|
||||
println!("cargo:rustc-env=COMPILED_DATE={}", &now);
|
||||
}
|
||||
|
|
|
@ -42,17 +42,11 @@ duration = 30 # cooldown period in seconds
|
|||
# This section deals with the database location and how to access it
|
||||
# Please note that at the moment, we have support for only postgresqa.
|
||||
# Example, if you are Batman, your config would be:
|
||||
# hostname = "batcave.org"
|
||||
# port = "5432"
|
||||
# username = "batman"
|
||||
# password = "somereallycomplicatedBatmanpassword"
|
||||
hostname = "localhost"
|
||||
port = "5432"
|
||||
username = "postgres"
|
||||
password = "password"
|
||||
name = "postgres"
|
||||
# url = "postgres://batman:password@batcave.org:5432/batcave"
|
||||
# database_type = "postgres"
|
||||
# pool = 4
|
||||
url = "postgres://example.org" # hack for tests to run successfully
|
||||
pool = 4
|
||||
database_type="postgres" # "postgres", "maria"
|
||||
|
||||
[redis]
|
||||
# This section deals with the database location and how to access it
|
||||
|
@ -72,3 +66,8 @@ url = "127.0.0.1"
|
|||
port = 10025
|
||||
username = "admin"
|
||||
password = "password"
|
||||
|
||||
#[survey]
|
||||
#nodes = ["http://localhost:7001"]
|
||||
#rate_limit = 10 # upload every hour
|
||||
#instance_root_url = "http://localhost:7000"
|
||||
|
|
|
@ -13,8 +13,7 @@ async-trait = "0.1.51"
|
|||
thiserror = "1.0.30"
|
||||
serde = { version = "1", features = ["derive"]}
|
||||
url = { version = "2.2.2", features = ["serde"] }
|
||||
libmcaptcha = { version = "0.2.3", git = "https://github.com/mCaptcha/libmcaptcha", features = ["minimal"], default-features = false, tag = "0.2.3"}
|
||||
#libmcaptcha = { branch = "master", git = "https://github.com/mCaptcha/libmcaptcha", features = ["full"] }
|
||||
libmcaptcha = "0.2.4"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
|
@ -289,6 +289,35 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
|||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get all psuedo IDs
|
||||
async fn analytics_get_all_psuedo_ids(&self, page: usize) -> DBResult<Vec<String>>;
|
||||
|
||||
/// Track maximum nonce received against captcha levels
|
||||
async fn update_max_nonce_for_level(
|
||||
&self,
|
||||
captcha_key: &str,
|
||||
difficulty_factor: u32,
|
||||
latest_nonce: u32,
|
||||
) -> DBResult<()>;
|
||||
|
||||
/// Get maximum nonce tracked so far for captcha levels
|
||||
async fn get_max_nonce_for_level(
|
||||
&self,
|
||||
captcha_key: &str,
|
||||
difficulty_factor: u32,
|
||||
) -> DBResult<u32>;
|
||||
|
||||
/// Get number of analytics entries that are under a certain duration
|
||||
async fn stats_get_num_logs_under_time(&self, duration: u32) -> DBResult<usize>;
|
||||
|
||||
/// Get the entry at a location in the list of analytics entires under a certain time limit
|
||||
/// and sorted in ascending order
|
||||
async fn stats_get_entry_at_location_for_time_limit_asc(
|
||||
&self,
|
||||
duration: u32,
|
||||
location: u32,
|
||||
) -> DBResult<Option<usize>>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq)]
|
||||
|
|
|
@ -7,6 +7,29 @@
|
|||
use crate::errors::*;
|
||||
use crate::prelude::*;
|
||||
|
||||
/// easy traffic pattern
|
||||
pub const TRAFFIC_PATTERN: TrafficPattern = TrafficPattern {
|
||||
avg_traffic: 500,
|
||||
peak_sustainable_traffic: 5_000,
|
||||
broke_my_site_traffic: Some(10_000),
|
||||
};
|
||||
|
||||
/// levels for complex captcha config
|
||||
pub const LEVELS: [Level; 3] = [
|
||||
Level {
|
||||
difficulty_factor: 1,
|
||||
visitor_threshold: 1,
|
||||
},
|
||||
Level {
|
||||
difficulty_factor: 2,
|
||||
visitor_threshold: 2,
|
||||
},
|
||||
Level {
|
||||
difficulty_factor: 3,
|
||||
visitor_threshold: 3,
|
||||
},
|
||||
];
|
||||
|
||||
/// test all database functions
|
||||
pub async fn database_works<'a, T: MCDatabase>(
|
||||
db: &T,
|
||||
|
@ -250,7 +273,6 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
db.record_confirm(c.key).await.unwrap();
|
||||
|
||||
// analytics start
|
||||
|
||||
db.analytics_create_psuedo_id_if_not_exists(c.key)
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -258,6 +280,12 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
.analytics_get_psuedo_id_from_capmaign_id(c.key)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
vec![psuedo_id.clone()],
|
||||
db.analytics_get_all_psuedo_ids(0).await.unwrap()
|
||||
);
|
||||
assert!(db.analytics_get_all_psuedo_ids(1).await.unwrap().is_empty());
|
||||
|
||||
db.analytics_create_psuedo_id_if_not_exists(c.key)
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -267,6 +295,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
.await
|
||||
.unwrap()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
c.key,
|
||||
db.analytics_get_capmaign_id_from_psuedo_id(&psuedo_id)
|
||||
|
@ -275,11 +304,31 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
);
|
||||
|
||||
let analytics = CreatePerformanceAnalytics {
|
||||
time: 0,
|
||||
difficulty_factor: 0,
|
||||
time: 1,
|
||||
difficulty_factor: 1,
|
||||
worker_type: "wasm".into(),
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
db.stats_get_num_logs_under_time(analytics.time)
|
||||
.await
|
||||
.unwrap(),
|
||||
0
|
||||
);
|
||||
|
||||
db.analysis_save(c.key, &analytics).await.unwrap();
|
||||
assert_eq!(
|
||||
db.stats_get_num_logs_under_time(analytics.time)
|
||||
.await
|
||||
.unwrap(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
db.stats_get_num_logs_under_time(analytics.time - 1)
|
||||
.await
|
||||
.unwrap(),
|
||||
0
|
||||
);
|
||||
let limit = 50;
|
||||
let mut offset = 0;
|
||||
let a = db.analytics_fetch(c.key, limit, offset).await.unwrap();
|
||||
|
@ -298,11 +347,82 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
.unwrap();
|
||||
assert_eq!(db.analytics_fetch(c.key, 1000, 0).await.unwrap().len(), 0);
|
||||
assert!(!db.analytics_captcha_is_published(c.key).await.unwrap());
|
||||
|
||||
let rest_analytics = [
|
||||
CreatePerformanceAnalytics {
|
||||
time: 2,
|
||||
difficulty_factor: 2,
|
||||
worker_type: "wasm".into(),
|
||||
},
|
||||
CreatePerformanceAnalytics {
|
||||
time: 3,
|
||||
difficulty_factor: 3,
|
||||
worker_type: "wasm".into(),
|
||||
},
|
||||
CreatePerformanceAnalytics {
|
||||
time: 4,
|
||||
difficulty_factor: 4,
|
||||
worker_type: "wasm".into(),
|
||||
},
|
||||
CreatePerformanceAnalytics {
|
||||
time: 5,
|
||||
difficulty_factor: 5,
|
||||
worker_type: "wasm".into(),
|
||||
},
|
||||
];
|
||||
for a in rest_analytics.iter() {
|
||||
db.analysis_save(c.key, &a).await.unwrap();
|
||||
}
|
||||
assert!(db
|
||||
.stats_get_entry_at_location_for_time_limit_asc(1, 2)
|
||||
.await
|
||||
.unwrap()
|
||||
.is_none());
|
||||
assert_eq!(
|
||||
db.stats_get_entry_at_location_for_time_limit_asc(2, 1)
|
||||
.await
|
||||
.unwrap(),
|
||||
Some(2)
|
||||
);
|
||||
assert_eq!(
|
||||
db.stats_get_entry_at_location_for_time_limit_asc(3, 2)
|
||||
.await
|
||||
.unwrap(),
|
||||
Some(3)
|
||||
);
|
||||
|
||||
db.analytics_delete_all_records_for_campaign(c.key)
|
||||
.await
|
||||
.unwrap();
|
||||
// analytics end
|
||||
|
||||
// nonce tracking start
|
||||
assert_eq!(
|
||||
db.get_max_nonce_for_level(c.key, l[0].difficulty_factor)
|
||||
.await
|
||||
.unwrap(),
|
||||
0
|
||||
);
|
||||
db.update_max_nonce_for_level(c.key, l[0].difficulty_factor, 1000)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
db.get_max_nonce_for_level(c.key, l[0].difficulty_factor)
|
||||
.await
|
||||
.unwrap(),
|
||||
1000
|
||||
);
|
||||
db.update_max_nonce_for_level(c.key, l[0].difficulty_factor, 10_000)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
db.get_max_nonce_for_level(c.key, l[0].difficulty_factor)
|
||||
.await
|
||||
.unwrap(),
|
||||
10_000
|
||||
);
|
||||
// nonce tracking end
|
||||
|
||||
assert_eq!(db.fetch_solve(p.username, c.key).await.unwrap().len(), 1);
|
||||
assert_eq!(
|
||||
db.fetch_config_fetched(p.username, c.key)
|
||||
|
|
|
@ -10,4 +10,4 @@ authors = ["realaravinth <realaravinth@batsense.net>"]
|
|||
|
||||
[dependencies]
|
||||
actix-rt = "2"
|
||||
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline", "mysql" ] }
|
||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "postgres", "time", "mysql" ] }
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT time FROM mcaptcha_pow_confirmed_stats \n WHERE \n config_id = (\n SELECT config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?))\n ORDER BY time DESC",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "time",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "NOT_NULL | UNSIGNED | BINARY | TIMESTAMP",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "1367dceb151a766a901b5dd771d0b75d0bc61d2fef17a94a90c8ffa0065e2c44"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT\n captcha_key\n FROM\n mcaptcha_config\n WHERE\n config_id = (\n SELECT\n config_id\n FROM\n mcaptcha_psuedo_campaign_id\n WHERE\n psuedo_id = ?\n );",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "captcha_key",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "14dc89b2988b221fd24e4f319b1d48f5e6c65c760c30d11c9c29087f09cee23a"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "INSERT INTO\n mcaptcha_track_nonce (level_id, nonce)\n VALUES ((\n SELECT\n level_id\n FROM\n mcaptcha_levels\n WHERE\n config_id = (SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?)\n AND\n difficulty_factor = ?\n AND\n visitor_threshold = ?\n ), ?);",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 4
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "216478d53870d7785cd0be43f030883ab79eaafb558d9197d09aea3adbd7b0bc"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "INSERT INTO mcaptcha_sitekey_user_provided_avg_traffic (\n config_id,\n avg_traffic,\n peak_sustainable_traffic,\n broke_my_site_traffic\n ) VALUES ( \n (SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n ), ?, ?, ?)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 5
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "22e697114c3ed5b0156cdceab11a398f1ef3a804f482e1cd948bc615ef95fc92"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "UPDATE mcaptcha_track_nonce SET nonce = ?\n WHERE level_id = (\n SELECT\n level_id\n FROM\n mcaptcha_levels\n WHERE\n config_id = (SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?)\n AND\n difficulty_factor = ?\n )\n AND nonce <= ?;",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 4
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "349ba17ff197aca7ee9fbd43e227d181c27ae04702fd6bdb6ddc32aab3bcb1ea"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "INSERT INTO mcaptcha_pow_confirmed_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "34b29417f9ff3f4d5987df0ce81023b1985eb84e560602b36182f55de6cd9d83"
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT captcha_key, name, config_id, duration FROM mcaptcha_config WHERE\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "captcha_key",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "name",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "config_id",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | PRIMARY_KEY | AUTO_INCREMENT",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "duration",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "3812693a9ae4402d900bcbf680981e6194073bd1937af11a77daa3776fb4c873"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "UPDATE mcaptcha_config SET name = ?, duration = ?\n WHERE user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n AND captcha_key = ?",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 4
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "3a8381eb0f0542a492d9dd51368e769e2b313e0576a1873e5c7630011e463daf"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT email FROM mcaptcha_users WHERE name = ?",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "email",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "UNIQUE_KEY",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "413ea53cea8b8f114fc009bad527b054a68a94477dfcc50d860d45bbd864d4f1"
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "-- SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>\n--\n-- SPDX-License-Identifier: AGPL-3.0-or-later\n\n-- gets all unread notifications a user has\nSELECT \n mcaptcha_notifications.id,\n mcaptcha_notifications.heading,\n mcaptcha_notifications.message,\n mcaptcha_notifications.received,\n mcaptcha_users.name\nFROM\n mcaptcha_notifications \nINNER JOIN \n mcaptcha_users \nON \n mcaptcha_notifications.tx = mcaptcha_users.id\nWHERE \n mcaptcha_notifications.rx = (\n SELECT \n id \n FROM \n mcaptcha_users\n WHERE\n name = ?\n )\nAND \n mcaptcha_notifications.read_notification IS NULL;\n",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | PRIMARY_KEY | AUTO_INCREMENT",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "heading",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "message",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 1000
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "received",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "NOT_NULL | UNSIGNED | BINARY | TIMESTAMP",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "name",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "42d967d6e080efd3cff8d4df13ea4d2ff38f3093da5c97000349dfc23c4d4eb3"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "INSERT INTO mcaptcha_pow_fetched_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "598a8202942771eff460faa6f09bd3fb1fc910d5fab7edb07c49dadbbaeb1cb8"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT psuedo_id FROM\n mcaptcha_psuedo_campaign_id\n WHERE\n config_id = (SELECT config_id FROM mcaptcha_config WHERE captcha_key = (?));\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "psuedo_id",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "5ad1ef722a961183228d851813b9f50284520bf8cc8118c765b72c108daaf6fb"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "INSERT INTO mcaptcha_users \n (name , password, secret) VALUES (?, ?, ?)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 3
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "5d5a106981345e9f62bc2239c00cdc683d3aaaa820d63da300dc51e3f6f363d3"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "\n DELETE FROM\n mcaptcha_pow_analytics\n WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?\n ) ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "6094468b7fa20043b0da90e366b7f1fa29a8c748e163b6712725440b25ae9361"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT config_id FROM mcaptcha_config\n WHERE\n captcha_key = ? \n AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "config_id",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | PRIMARY_KEY | AUTO_INCREMENT",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "66ec7df10484f8e0206f3c97afc9136021589556c38dbbed341d6574487f79f2"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "UPDATE mcaptcha_users set name = ?\n WHERE name = ?",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "676a9f1761c3b63cf16d7d4dd6261507cc7707feb32d458f4b946ed9caa53721"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "DELETE FROM mcaptcha_users WHERE name = (?)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "6d1b6e5e58ca2ba285cab7b050bbdc43de1f3e46cf7d420bc95c124a1c7c9d1f"
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT difficulty_factor, visitor_threshold FROM mcaptcha_levels WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n ) ORDER BY difficulty_factor ASC;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "difficulty_factor",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "visitor_threshold",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "6d43e6ceb54a0ff8a803bd96dd9134b15da01d48776ac0cf3d66a2997dadce5e"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "INSERT INTO mcaptcha_levels (\n difficulty_factor, \n visitor_threshold,\n config_id) VALUES (\n ?, ?, (\n SELECT config_id FROM mcaptcha_config WHERE\n captcha_key = (?) AND user_id = (\n SELECT ID FROM mcaptcha_users WHERE name = ?\n )));",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 4
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "74d68a86f852d3d85957e94ed04e8acd8e6144744f7b13e383ebcb2bcf3360ae"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "UPDATE mcaptcha_users set secret = ?\n WHERE name = ?",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "7838ade4a48068e25c6f117ee8e38f088b867b1ab08a7dd0269b76891266ace6"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "DELETE FROM mcaptcha_levels \n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?) \n AND user_id = (\n SELECT ID from mcaptcha_users WHERE name = ?\n )\n )",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "7894dda54cd65559fe3b81bab7df8cc848e21ed5c7f5e88951bf1c98c78ed820"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "INSERT INTO mcaptcha_notifications (\n heading, message, tx, rx, received)\n VALUES (\n ?, ?,\n (SELECT ID FROM mcaptcha_users WHERE name = ?),\n (SELECT ID FROM mcaptcha_users WHERE name = ?),\n ?\n );",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 5
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "89386c46668a2653a54687e65958af5cf7a8da268339a1f5a379ede47b3c6d2a"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT duration FROM mcaptcha_config \n where captcha_key= ?",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "duration",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "8acbf84d4801e86221d8f6324ae50488a0986182d66b20ad414bce4e2ac18eca"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "UPDATE mcaptcha_config SET captcha_key = ? \n WHERE captcha_key = ? AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 3
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "8e6026abf7c0e8ab90ee8eb7ada9f66962ab6999d3127944b058d6f96346e72f"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "insert into mcaptcha_users \n (name , password, email, secret) values (?, ?, ?, ?)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 4
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "8ec8bbde0c02a99f74d12e6778f123a973283e6d56b6861b30f559768617848a"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT\n COUNT(difficulty_factor) AS count\n FROM\n mcaptcha_pow_analytics\n WHERE time <= ?;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "count",
|
||||
"type_info": {
|
||||
"type": "LongLong",
|
||||
"flags": "NOT_NULL | BINARY",
|
||||
"char_set": 63,
|
||||
"max_size": 21
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "9bae79667a8cc631541879321e72a40f20cf812584aaf44418089bc7a51e07c4"
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT `config_id`, `duration`, `name`, `captcha_key` from mcaptcha_config WHERE\n `captcha_key` = ? AND\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?) ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "config_id",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | PRIMARY_KEY | AUTO_INCREMENT",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "duration",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "name",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "captcha_key",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "9c435148ed5655e79dd1e73e3566ce23b7c6d38edcedbb988c95813c5da893ed"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "UPDATE mcaptcha_users set email = ?\n WHERE name = ?",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "9cb416de904872d66af90baa0024f382ce6f8344464c607fe6e6c2572816dfc2"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "INSERT INTO\n mcaptcha_track_nonce (level_id, nonce)\n VALUES ((\n SELECT\n level_id\n FROM\n mcaptcha_levels\n WHERE\n config_id = (SELECT config_id FROM mcaptcha_config WHERE captcha_key =?)\n AND\n difficulty_factor = ?\n ), ?);",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 3
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "9def82dcec9c8d477824182bb2f71044cc264cf2073ab4f60a0000b435ed0f0b"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "\n INSERT INTO\n mcaptcha_psuedo_campaign_id (config_id, psuedo_id)\n VALUES (\n (SELECT config_id FROM mcaptcha_config WHERE captcha_key = (?)),\n ?\n );",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "9e45969a0f79eab8caba41b0d91e5e3b85a1a68a49136f89fc90793c38f00041"
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT\n id, time, difficulty_factor, worker_type\n FROM\n mcaptcha_pow_analytics\n WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?\n ) \n ORDER BY ID\n LIMIT ? OFFSET ?",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | PRIMARY_KEY | AUTO_INCREMENT",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "time",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "difficulty_factor",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "worker_type",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 3
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "9f10afb0f242f11c58389803c5e85e244cc59102b8929a21e3fcaa852d57a52c"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT config_id from mcaptcha_config WHERE captcha_key = ?",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "config_id",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | PRIMARY_KEY | AUTO_INCREMENT",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "a89c066db044cddfdebee6a0fd0d80a5a26dcb7ecc00a9899f5634b72ea0a952"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT nonce FROM mcaptcha_track_nonce\n WHERE level_id = (\n SELECT\n level_id\n FROM\n mcaptcha_levels\n WHERE\n config_id = (SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?)\n AND\n difficulty_factor = ?\n );",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "nonce",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "b739ec4cfab1ec60947106c8112e931510c3a50a1606facdde0c0ebb540d5beb"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT secret FROM mcaptcha_users WHERE ID = (\n SELECT user_id FROM mcaptcha_config WHERE captcha_key = ?\n )",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "secret",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 200
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "b9258c2494d95701d19703cf5cd05a222057a0ccad943192138b1a4a94bf823b"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "DELETE FROM mcaptcha_config where captcha_key= (?)\n AND\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "b95e5a60a202cb646d5e76df8c7395e4bf881a6dd14e28e6f2e8b93e0536b331"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT\n difficulty_factor\n FROM\n mcaptcha_pow_analytics\n WHERE\n time <= ?\n ORDER BY difficulty_factor ASC LIMIT 1 OFFSET ?;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "difficulty_factor",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "c4d6ad934e38218931e74ae1c31c6712cbadb40f31bb12e160c9d333c7e3835c"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT name from mcaptcha_users WHERE email = ?",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "name",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "caa1638ee510ef62b86817e5d2baeaca8dfa432c23d7630c0e70737211a4680b"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "UPDATE mcaptcha_users set password = ?\n WHERE name = ?",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "cad5b403470f26c565e74a1dca19b7dee066141dec0f708070067e34d5bf72cc"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "INSERT INTO mcaptcha_config\n (`captcha_key`, `user_id`, `duration`, `name`)\n VALUES (?, (SELECT ID FROM mcaptcha_users WHERE name = ?), ?, ?)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 4
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "d05b84966f4e70c53789221f961bf3637f404f3ba45e880115e97ed1ba5a2809"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT time FROM mcaptcha_pow_solved_stats \n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?)) \n ORDER BY time DESC",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "time",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "NOT_NULL | UNSIGNED | BINARY | TIMESTAMP",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "d4b92e8099cd29cfdb99aadeeada739bb6858667fc65f528ec484e98a9da21bc"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT time FROM mcaptcha_pow_fetched_stats\n WHERE \n config_id = (\n SELECT \n config_id FROM mcaptcha_config \n WHERE \n captcha_key = ?\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = ?))\n ORDER BY time DESC",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "time",
|
||||
"type_info": {
|
||||
"type": "Timestamp",
|
||||
"flags": "NOT_NULL | UNSIGNED | BINARY | TIMESTAMP",
|
||||
"char_set": 63,
|
||||
"max_size": 19
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "daac5e937aeac2f106eb89154b431fa8bd1bd7baa95e51704fdcdf50bd970a1d"
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT name, password FROM mcaptcha_users WHERE name = ?",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "name",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "password",
|
||||
"type_info": {
|
||||
"type": "Blob",
|
||||
"flags": "NOT_NULL | BLOB | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 262140
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "dd5ff10b88fa6f374e105b6bed9e34e0870ac8dd7ce36dfb09d13a1b7005b2eb"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT secret FROM mcaptcha_users WHERE name = ?",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "secret",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 200
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "dd9b4dec39405ff19af21faabb6a7c3bb3207e7e785fe15357146b88c6c27f01"
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT difficulty_factor, visitor_threshold FROM mcaptcha_levels WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config where captcha_key= (?)\n AND user_id = (SELECT ID from mcaptcha_users WHERE name = ?)\n )\n ORDER BY difficulty_factor ASC;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "difficulty_factor",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "visitor_threshold",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "df6de3b96afcfb7f364f98954995e506b19e80e7f88204405d970c360ad5e1a0"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "INSERT INTO mcaptcha_pow_solved_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "e2b0b85f2afac1cbca43ce684641bf75ef070e44ce3d00404fc6151d2f4d7bcf"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "\n SELECT\n psuedo_id\n FROM\n mcaptcha_psuedo_campaign_id\n ORDER BY ID ASC LIMIT ? OFFSET ?;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "psuedo_id",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "e2c30dafa790b388a193ad8785c0a7d88d8e7a7558775e238fe009f478003e46"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "\n DELETE FROM\n mcaptcha_psuedo_campaign_id\n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?\n );",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "e4d9bf156a368dcee1433dd5ced9f1991aa15f84e0ade916433aada40f68f0aa"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT name from mcaptcha_users WHERE name = ?",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "name",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "e6569a6064d0e07abea4c0bd4686cdfdaac64f0109ac40efaed06a744a2eaf5e"
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT \n avg_traffic, \n peak_sustainable_traffic, \n broke_my_site_traffic \n FROM \n mcaptcha_sitekey_user_provided_avg_traffic \n WHERE \n config_id = (\n SELECT \n config_id \n FROM \n mcaptcha_config \n WHERE \n captcha_key = ? \n AND user_id = (\n SELECT \n id \n FROM \n mcaptcha_users \n WHERE \n NAME = ?\n )\n )\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "avg_traffic",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "peak_sustainable_traffic",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "NOT_NULL | NO_DEFAULT_VALUE",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "broke_my_site_traffic",
|
||||
"type_info": {
|
||||
"type": "Long",
|
||||
"flags": "",
|
||||
"char_set": 63,
|
||||
"max_size": 11
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "e91116ebce127833488130cf1060e0817e5677f39588632452b8d621688c405a"
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "SELECT name, password FROM mcaptcha_users WHERE email = ?",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "name",
|
||||
"type_info": {
|
||||
"type": "VarString",
|
||||
"flags": "NOT_NULL | UNIQUE_KEY | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 400
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "password",
|
||||
"type_info": {
|
||||
"type": "Blob",
|
||||
"flags": "NOT_NULL | BLOB | NO_DEFAULT_VALUE",
|
||||
"char_set": 224,
|
||||
"max_size": 262140
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "ed943cbf7e16536d81010255ce2f5beb207b2b9d44cb859fa9f2233405b80ae0"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "INSERT INTO mcaptcha_pow_analytics \n (config_id, time, difficulty_factor, worker_type)\n VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?, ?, ?)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 4
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "f987c4568ab28271d87af47f473b18cf41130a483333e81d5f50199758cbb98b"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "-- SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>\n--\n-- SPDX-License-Identifier: AGPL-3.0-or-later\n\n-- mark a notification as read\nUPDATE mcaptcha_notifications\n SET read_notification = TRUE\nWHERE \n mcaptcha_notifications.id = ?\nAND\n mcaptcha_notifications.rx = (\n SELECT\n id\n FROM\n mcaptcha_users\n WHERE\n name = ?\n );\n",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "f9f2ed1b2f47828d5d976d2e470e106d54b8a2357f9d525ef0cdb1f7965aa61c"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "MySQL",
|
||||
"query": "DELETE FROM mcaptcha_sitekey_user_provided_avg_traffic\n WHERE config_id = (\n SELECT config_id \n FROM \n mcaptcha_config \n WHERE\n captcha_key = ?\n AND \n user_id = (SELECT ID FROM mcaptcha_users WHERE name = ?)\n );",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "fc717ff0827ccfaa1cc61a71cc7f71c348ebb03d35895c54b011c03121ad2385"
|
||||
}
|
|
@ -12,11 +12,11 @@ authors = ["realaravinth <realaravinth@batsense.net>"]
|
|||
async-trait = "0.1.51"
|
||||
db-core = {path = "../db-core"}
|
||||
futures = "0.3.15"
|
||||
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "mysql", "time", "offline" ] }
|
||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "mysql", "time"] }
|
||||
uuid = { version = "1.4.0", features = ["v4", "serde"] }
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "2"
|
||||
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "mysql", "time", "offline" ] }
|
||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "mysql", "time" ] }
|
||||
db-core = {path = "../db-core", features = ["test"]}
|
||||
url = { version = "2.2.2", features = ["serde"] }
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
-- Add migration script here
|
||||
CREATE TABLE IF NOT EXISTS mcaptcha_track_nonce (
|
||||
level_id INTEGER NOT NULL,
|
||||
nonce INTEGER NOT NULL DEFAULT 0,
|
||||
ID INT auto_increment,
|
||||
PRIMARY KEY(ID),
|
||||
CONSTRAINT `fk_mcaptcha_track_nonce_level_id`
|
||||
FOREIGN KEY (level_id)
|
||||
REFERENCES mcaptcha_levels (level_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE
|
||||
);
|
|
@ -49,7 +49,6 @@ pub mod dev {
|
|||
|
||||
pub mod prelude {
|
||||
pub use super::*;
|
||||
pub use db_core::prelude::*;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
@ -61,7 +60,7 @@ impl Connect for ConnectionOptions {
|
|||
let mut connect_options =
|
||||
sqlx::mysql::MySqlConnectOptions::from_str(&fresh.url).unwrap();
|
||||
if fresh.disable_logging {
|
||||
connect_options.disable_statement_logging();
|
||||
connect_options = connect_options.disable_statement_logging();
|
||||
}
|
||||
fresh
|
||||
.pool_options
|
||||
|
@ -434,6 +433,39 @@ impl MCDatabase for Database {
|
|||
futs.push(fut);
|
||||
}
|
||||
|
||||
try_join_all(futs)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
|
||||
let mut futs = Vec::with_capacity(levels.len());
|
||||
|
||||
for level in levels.iter() {
|
||||
let difficulty_factor = level.difficulty_factor as i32;
|
||||
let visitor_threshold = level.visitor_threshold as i32;
|
||||
let fut = sqlx::query!(
|
||||
"INSERT INTO
|
||||
mcaptcha_track_nonce (level_id, nonce)
|
||||
VALUES ((
|
||||
SELECT
|
||||
level_id
|
||||
FROM
|
||||
mcaptcha_levels
|
||||
WHERE
|
||||
config_id = (SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?)
|
||||
AND
|
||||
difficulty_factor = ?
|
||||
AND
|
||||
visitor_threshold = ?
|
||||
), ?);",
|
||||
&captcha_key,
|
||||
difficulty_factor,
|
||||
visitor_threshold,
|
||||
0,
|
||||
)
|
||||
.execute(&self.pool);
|
||||
futs.push(fut);
|
||||
}
|
||||
|
||||
try_join_all(futs)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
|
@ -988,12 +1020,8 @@ impl MCDatabase for Database {
|
|||
&self,
|
||||
captcha_id: &str,
|
||||
) -> DBResult<String> {
|
||||
struct ID {
|
||||
psuedo_id: String,
|
||||
}
|
||||
|
||||
let res = sqlx::query_as!(
|
||||
ID,
|
||||
PsuedoID,
|
||||
"SELECT psuedo_id FROM
|
||||
mcaptcha_psuedo_campaign_id
|
||||
WHERE
|
||||
|
@ -1070,6 +1098,182 @@ impl MCDatabase for Database {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
/// Get all psuedo IDs
|
||||
async fn analytics_get_all_psuedo_ids(&self, page: usize) -> DBResult<Vec<String>> {
|
||||
const LIMIT: usize = 50;
|
||||
let offset = LIMIT * page;
|
||||
|
||||
let mut res = sqlx::query_as!(
|
||||
PsuedoID,
|
||||
"
|
||||
SELECT
|
||||
psuedo_id
|
||||
FROM
|
||||
mcaptcha_psuedo_campaign_id
|
||||
ORDER BY ID ASC LIMIT ? OFFSET ?;",
|
||||
LIMIT as i64,
|
||||
offset as i64
|
||||
)
|
||||
.fetch_all(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
|
||||
Ok(res.drain(0..).map(|r| r.psuedo_id).collect())
|
||||
}
|
||||
|
||||
/// Track maximum nonce received against captcha levels
|
||||
async fn update_max_nonce_for_level(
|
||||
&self,
|
||||
captcha_key: &str,
|
||||
difficulty_factor: u32,
|
||||
latest_nonce: u32,
|
||||
) -> DBResult<()> {
|
||||
let latest_nonce = latest_nonce as i64;
|
||||
sqlx::query!(
|
||||
"UPDATE mcaptcha_track_nonce SET nonce = ?
|
||||
WHERE level_id = (
|
||||
SELECT
|
||||
level_id
|
||||
FROM
|
||||
mcaptcha_levels
|
||||
WHERE
|
||||
config_id = (SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?)
|
||||
AND
|
||||
difficulty_factor = ?
|
||||
)
|
||||
AND nonce <= ?;",
|
||||
latest_nonce,
|
||||
&captcha_key,
|
||||
difficulty_factor as i64,
|
||||
latest_nonce
|
||||
)
|
||||
.execute(&self.pool).await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get maximum nonce tracked so far for captcha levels
|
||||
async fn get_max_nonce_for_level(
|
||||
&self,
|
||||
captcha_key: &str,
|
||||
difficulty_factor: u32,
|
||||
) -> DBResult<u32> {
|
||||
struct X {
|
||||
nonce: i32,
|
||||
}
|
||||
|
||||
async fn inner_get_max_nonce(
|
||||
pool: &MySqlPool,
|
||||
captcha_key: &str,
|
||||
difficulty_factor: u32,
|
||||
) -> DBResult<X> {
|
||||
sqlx::query_as!(
|
||||
X,
|
||||
"SELECT nonce FROM mcaptcha_track_nonce
|
||||
WHERE level_id = (
|
||||
SELECT
|
||||
level_id
|
||||
FROM
|
||||
mcaptcha_levels
|
||||
WHERE
|
||||
config_id = (SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?)
|
||||
AND
|
||||
difficulty_factor = ?
|
||||
);",
|
||||
&captcha_key,
|
||||
difficulty_factor as i32,
|
||||
)
|
||||
.fetch_one(pool).await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))
|
||||
}
|
||||
|
||||
let res = inner_get_max_nonce(&self.pool, captcha_key, difficulty_factor).await;
|
||||
if let Err(DBError::CaptchaNotFound) = res {
|
||||
sqlx::query!(
|
||||
"INSERT INTO
|
||||
mcaptcha_track_nonce (level_id, nonce)
|
||||
VALUES ((
|
||||
SELECT
|
||||
level_id
|
||||
FROM
|
||||
mcaptcha_levels
|
||||
WHERE
|
||||
config_id = (SELECT config_id FROM mcaptcha_config WHERE captcha_key =?)
|
||||
AND
|
||||
difficulty_factor = ?
|
||||
), ?);",
|
||||
&captcha_key,
|
||||
difficulty_factor as i32,
|
||||
0,
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
|
||||
let res =
|
||||
inner_get_max_nonce(&self.pool, captcha_key, difficulty_factor).await?;
|
||||
Ok(res.nonce as u32)
|
||||
} else {
|
||||
let res = res?;
|
||||
Ok(res.nonce as u32)
|
||||
}
|
||||
}
|
||||
|
||||
/// Get number of analytics entries that are under a certain duration
|
||||
async fn stats_get_num_logs_under_time(&self, duration: u32) -> DBResult<usize> {
|
||||
struct Count {
|
||||
count: Option<i64>,
|
||||
}
|
||||
|
||||
//"SELECT COUNT(*) FROM (SELECT difficulty_factor FROM mcaptcha_pow_analytics WHERE time <= ?) as count",
|
||||
let count = sqlx::query_as!(
|
||||
Count,
|
||||
"SELECT
|
||||
COUNT(difficulty_factor) AS count
|
||||
FROM
|
||||
mcaptcha_pow_analytics
|
||||
WHERE time <= ?;",
|
||||
duration as i32,
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
|
||||
Ok(count.count.unwrap_or_else(|| 0) as usize)
|
||||
}
|
||||
|
||||
/// Get the entry at a location in the list of analytics entires under a certain time limited
|
||||
/// and sorted in ascending order
|
||||
async fn stats_get_entry_at_location_for_time_limit_asc(
|
||||
&self,
|
||||
duration: u32,
|
||||
location: u32,
|
||||
) -> DBResult<Option<usize>> {
|
||||
struct Difficulty {
|
||||
difficulty_factor: Option<i32>,
|
||||
}
|
||||
|
||||
match sqlx::query_as!(
|
||||
Difficulty,
|
||||
"SELECT
|
||||
difficulty_factor
|
||||
FROM
|
||||
mcaptcha_pow_analytics
|
||||
WHERE
|
||||
time <= ?
|
||||
ORDER BY difficulty_factor ASC LIMIT 1 OFFSET ?;",
|
||||
duration as i32,
|
||||
location as i64 - 1,
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
{
|
||||
Ok(res) => Ok(Some(res.difficulty_factor.unwrap() as usize)),
|
||||
Err(sqlx::Error::RowNotFound) => Ok(None),
|
||||
Err(e) => Err(map_row_not_found_err(e, DBError::CaptchaNotFound)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -1135,3 +1339,7 @@ impl From<InternaleCaptchaConfig> for Captcha {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct PsuedoID {
|
||||
psuedo_id: String,
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
|
||||
#![cfg(test)]
|
||||
|
||||
use sqlx::mysql::MySqlPoolOptions;
|
||||
use std::env;
|
||||
|
||||
use sqlx::{migrate::MigrateDatabase, mysql::MySqlPoolOptions};
|
||||
use url::Url;
|
||||
|
||||
use crate::*;
|
||||
|
||||
use db_core::tests::*;
|
||||
|
@ -26,28 +28,6 @@ async fn everyting_works() {
|
|||
const HEADING: &str = "testing notifications get db mariadb";
|
||||
const MESSAGE: &str = "testing notifications get message db mariadb";
|
||||
|
||||
// easy traffic pattern
|
||||
const TRAFFIC_PATTERN: TrafficPattern = TrafficPattern {
|
||||
avg_traffic: 500,
|
||||
peak_sustainable_traffic: 5_000,
|
||||
broke_my_site_traffic: Some(10_000),
|
||||
};
|
||||
|
||||
const LEVELS: [Level; 3] = [
|
||||
Level {
|
||||
difficulty_factor: 1,
|
||||
visitor_threshold: 1,
|
||||
},
|
||||
Level {
|
||||
difficulty_factor: 2,
|
||||
visitor_threshold: 2,
|
||||
},
|
||||
Level {
|
||||
difficulty_factor: 3,
|
||||
visitor_threshold: 3,
|
||||
},
|
||||
];
|
||||
|
||||
const ADD_NOTIFICATION: AddNotification = AddNotification {
|
||||
from: NAME,
|
||||
to: NAME,
|
||||
|
@ -56,10 +36,20 @@ async fn everyting_works() {
|
|||
};
|
||||
|
||||
let url = env::var("MARIA_DATABASE_URL").unwrap();
|
||||
|
||||
let mut parsed = Url::parse(&url).unwrap();
|
||||
parsed.set_path("db_maria_test");
|
||||
let url = parsed.to_string();
|
||||
|
||||
if sqlx::MySql::database_exists(&url).await.unwrap() {
|
||||
sqlx::MySql::drop_database(&url).await.unwrap();
|
||||
}
|
||||
sqlx::MySql::create_database(&url).await.unwrap();
|
||||
|
||||
let pool_options = MySqlPoolOptions::new().max_connections(2);
|
||||
let connection_options = ConnectionOptions::Fresh(Fresh {
|
||||
pool_options,
|
||||
url,
|
||||
url: url.clone(),
|
||||
disable_logging: false,
|
||||
});
|
||||
let db = connection_options.connect().await.unwrap();
|
||||
|
@ -78,4 +68,6 @@ async fn everyting_works() {
|
|||
description: CAPTCHA_DESCRIPTION,
|
||||
};
|
||||
database_works(&db, &p, &c, &LEVELS, &TRAFFIC_PATTERN, &ADD_NOTIFICATION).await;
|
||||
drop(db);
|
||||
sqlx::MySql::drop_database(&url).await.unwrap();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT id, time, difficulty_factor, worker_type FROM mcaptcha_pow_analytics\n WHERE \n config_id = (\n SELECT \n config_id FROM mcaptcha_config \n WHERE \n key = $1\n )\n ORDER BY ID\n OFFSET $2 LIMIT $3\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "time",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "difficulty_factor",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "worker_type",
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Int8",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "017576128f1c63aee062799a33f872457fe19f5d6429d0af312dc00c244b31cb"
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT config_id, duration, name, key from mcaptcha_config WHERE\n key = $1 AND\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = $2) ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "config_id",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "duration",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "name",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "key",
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "02deb524bb12632af9b7883975f75fdc30d6775d836aff647add1dffd1a4bc00"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO mcaptcha_pow_confirmed_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config WHERE key = $1), $2)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Timestamptz"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "044e2036a518de2ccac9318ccba07f7ce10e4a1c1d51d0128ea5e8cb94358ac5"
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO mcaptcha_sitekey_user_provided_avg_traffic (\n config_id,\n avg_traffic,\n peak_sustainable_traffic,\n broke_my_site_traffic\n ) VALUES ( \n (SELECT config_id FROM mcaptcha_config WHERE key = ($1)\n AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = $2)\n ), $3, $4, $5)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Int4",
|
||||
"Int4",
|
||||
"Int4"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "0840af95cc17c8ea6fc994e53696d4dec39ef9b4b6dd6c58c21cc44ccbb4bd09"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "DELETE FROM mcaptcha_sitekey_user_provided_avg_traffic\n WHERE config_id = (\n SELECT config_id \n FROM \n mcaptcha_config \n WHERE\n key = ($1) \n AND \n user_id = (SELECT ID FROM mcaptcha_users WHERE name = $2)\n );",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "0e7a1a38019c5e88ebd096fc5f6031aaa7f337fe735aa44c4e31bd6e51163749"
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO\n mcaptcha_track_nonce (level_id, nonce)\n VALUES ((\n SELECT\n level_id\n FROM\n mcaptcha_levels\n WHERE\n config_id = (SELECT config_id FROM mcaptcha_config WHERE key = ($1))\n AND\n difficulty_factor = $2\n AND\n visitor_threshold = $3\n ), $4);",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Int4",
|
||||
"Int4",
|
||||
"Int4"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "133ee23ab5ac7c664a86b6edfaa8da79281b6d1f5ba33c642a6ea1b0682fe0b0"
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT key, name, config_id, duration FROM mcaptcha_config WHERE\n user_id = (SELECT ID FROM mcaptcha_users WHERE name = $1) ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "key",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "name",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "config_id",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "duration",
|
||||
"type_info": "Int4"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "16864df9cf9a69c299d9ab68bac559c48f4fc433541a10f7c1b60717df2b820e"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE mcaptcha_users set name = $1\n WHERE name = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "1e9fe69b23e4bfa7bb369455753100307e334e8dbaf02ff37cda08992fe95910"
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "-- SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>\n--\n-- SPDX-License-Identifier: AGPL-3.0-or-later\n\n-- gets all unread notifications a user has\nSELECT \n mcaptcha_notifications.id,\n mcaptcha_notifications.heading,\n mcaptcha_notifications.message,\n mcaptcha_notifications.received,\n mcaptcha_users.name\nFROM\n mcaptcha_notifications \nINNER JOIN \n mcaptcha_users \nON \n mcaptcha_notifications.tx = mcaptcha_users.id\nWHERE \n mcaptcha_notifications.rx = (\n SELECT \n id \n FROM \n mcaptcha_users\n WHERE\n name = $1\n )\nAND \n mcaptcha_notifications.read IS NULL;\n",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "heading",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "message",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "received",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "name",
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "213ac909efb60f7f5e095fe2d3d1ec4f98fde7d84de011272c788aaf825b6ae2"
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT\n key\n FROM\n mcaptcha_config\n WHERE\n config_id = (\n SELECT\n config_id\n FROM\n mcaptcha_psuedo_campaign_id\n WHERE\n psuedo_id = $1\n );",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "key",
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "21cdf28d8962389d22c8ddefdad82780f5316737e3d833623512aa12a54a026a"
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO mcaptcha_config\n (key, user_id, duration, name)\n VALUES ($1, (SELECT ID FROM mcaptcha_users WHERE name = $2), $3, $4)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text",
|
||||
"Int4",
|
||||
"Varchar"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "307245aaf5b0d692448b80358d6916aa50c507b35e724d66c9b16a16b60e1b38"
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT email FROM mcaptcha_users WHERE name = $1",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "email",
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "30ba202b601dd07f41798775c7c59fde7deeae759ec959df46734a66ffd78df7"
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n DELETE FROM\n mcaptcha_psuedo_campaign_id\n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config WHERE key = ($1)\n );",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "30d8945806b4c68b6da800395f61c1e480839093bfcda9c693bf1972a65c7d79"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE mcaptcha_users set secret = $1\n WHERE name = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "3b1c8128fc48b16d8e8ea6957dd4fbc0eb19ae64748fd7824e9f5e1901dd1726"
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT EXISTS (\n SELECT 1 from mcaptcha_config WHERE key = $1 \n AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = $2)\n )",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "exists",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "3eb1c43ffd2378c4dd59975568c3a180b72d13008f294a91f3e76b785dba295b"
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT time FROM mcaptcha_pow_confirmed_stats \n WHERE \n config_id = (\n SELECT config_id FROM mcaptcha_config \n WHERE \n key = $1\n AND\n user_id = (\n SELECT \n ID FROM mcaptcha_users WHERE name = $2))\n ORDER BY time DESC",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "time",
|
||||
"type_info": "Timestamptz"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "4303f5c6ef98e0de9d8d3c2d781d3ffaa3dee5f7d27db831d327b26f03ba9d68"
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "insert into mcaptcha_users \n (name , password, email, secret) values ($1, $2, $3, $4)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text",
|
||||
"Varchar",
|
||||
"Varchar"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "45d9e9fb6344fe3a18c2529d50c935d3837bfe25c96595beb6970d6067720578"
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT EXISTS (SELECT 1 from mcaptcha_users WHERE email = $1)",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "exists",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "47fa50aecfb1499b0a18fa9299643017a1a8d69d4e9980032e0d8f745465d14f"
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT secret FROM mcaptcha_users WHERE ID = (\n SELECT user_id FROM mcaptcha_config WHERE key = $1\n )",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "secret",
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "494d2aed281e1408aeda3606b0814db75aea2878783a2e2f11a4feb6fc48e938"
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT EXISTS (SELECT 1 from mcaptcha_config WHERE key = $1)",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "exists",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "4a5dfbc5aeb2bab290a09640cc25223d484fbc7549e5bc54f33bab8616725031"
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE mcaptcha_config SET key = $1 \n WHERE key = $2 AND user_id = (SELECT ID FROM mcaptcha_users WHERE name = $3)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "507bea10c7f8417c5b1430211d0137299cd561333bf47f7b4887d0ef801d1ea4"
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE mcaptcha_config SET name = $1, duration = $2\n WHERE user_id = (SELECT ID FROM mcaptcha_users WHERE name = $3)\n AND key = $4",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Int4",
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "570c22f19fe0b97d78086038c8ef82509dce0bae704d80f9f031c1c47e6a6572"
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT difficulty_factor, visitor_threshold FROM mcaptcha_levels WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config WHERE key = ($1)\n AND user_id = (SELECT ID from mcaptcha_users WHERE name = $2)\n )\n ORDER BY difficulty_factor ASC;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "difficulty_factor",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "visitor_threshold",
|
||||
"type_info": "Int4"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "717771c42737feb3f4ca13f2ab11361073ea17b55562a103f660149bf049c5c6"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO mcaptcha_pow_fetched_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config WHERE key = $1), $2)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Timestamptz"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "726a794f7599b78ab749d9f887f5c28db38f072b41f691bde35d23ba0dd72409"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "DELETE FROM mcaptcha_levels \n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config where key = ($1) \n AND user_id = (\n SELECT ID from mcaptcha_users WHERE name = $2\n )\n )",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "7c96ae73dd73c1b0e073e3ac78f87f4cba23fdb2cdbed9ba9b0d55f33655582e"
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue