mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
Compare commits
108 Commits
fix-siteke
...
pow-live-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32762cf6b5 | ||
|
|
43024f1940 | ||
|
|
1e0aedad61 | ||
|
|
1b05cdc391 | ||
|
|
3e5936cb83 | ||
|
|
2ca49cffe4 | ||
|
|
468752f691 | ||
|
|
22edb04ce2 | ||
|
|
6834e555d8 | ||
|
|
3c6b13f947 | ||
|
|
99db889867 | ||
|
|
56dba7b77f | ||
|
|
1c4ee5b622 | ||
|
|
d8a145cf87 | ||
|
|
8ca48d85ff | ||
|
|
2b82af9a0c | ||
|
|
2cf5e48d8e | ||
|
|
679a35216c | ||
|
|
68b59ade8c | ||
|
|
8af09939ff | ||
|
|
dc380adfcf | ||
|
|
f8e3b720de | ||
|
|
5ae3b1f26e | ||
|
|
2a1bda653d | ||
|
|
b0db04f26a | ||
|
|
78de0b266f | ||
|
|
6ede578ad5 | ||
|
|
efed5f5f93 | ||
|
|
4a6850631a | ||
|
|
0adbb0aa2f | ||
|
|
8f3faaa279 | ||
|
|
5324969bd2 | ||
|
|
43dab030df | ||
|
|
9cc667851c | ||
|
|
9fc7c31083 | ||
|
|
90e60b0486 | ||
|
|
58f93cb602 | ||
|
|
fae50b19f8 | ||
|
|
e890ba0f57 | ||
|
|
744d94cf8d | ||
|
|
31d12206aa | ||
|
|
7764eda05d | ||
|
|
f78669955c | ||
|
|
cadc15a7a1 | ||
|
|
c1f6ce3ae2 | ||
|
|
864549cb4c | ||
|
|
5713d4b1ae | ||
|
|
ac502b7c08 | ||
|
|
8dc690ca01 | ||
|
|
a4f9c92b32 | ||
|
|
8826f6df8f | ||
|
|
af35fdb48e | ||
|
|
9fd8ffd666 | ||
|
|
521abd82d6 | ||
|
|
021f2fe5b4 | ||
|
|
b3e0ff6769 | ||
|
|
97abca2520 | ||
|
|
96a6c98c10 | ||
|
|
9d285573d7 | ||
|
|
d506d291c3 | ||
|
|
223e8fb8c2 | ||
|
|
2abf57d16b | ||
|
|
b3ee57d042 | ||
|
|
8c65edd257 | ||
|
|
9f521fe199 | ||
|
|
8ac1e2b81e | ||
|
|
5db58d477b | ||
|
|
db03cd3b1f | ||
|
|
e5e89bd8a0 | ||
|
|
2dd6f063c5 | ||
|
|
bb81e7fb9b | ||
|
|
b3d00c89a6 | ||
|
|
8c9587ad65 | ||
|
|
21825582e5 | ||
|
|
f8e6bdf229 | ||
|
|
8c576d2b07 | ||
|
|
c377cf431e | ||
|
|
ce1b3b0856 | ||
|
|
cd6cecfe4a | ||
|
|
a66d75c3c3 | ||
|
|
3d9056e968 | ||
|
|
bb42841a66 | ||
|
|
961bb6c5f4 | ||
|
|
f56bc6d9e4 | ||
|
|
a040b39558 | ||
|
|
80214b776c | ||
|
|
6de9129cd0 | ||
|
|
1fded38ee8 | ||
|
|
96119fdc71 | ||
|
|
337a378b08 | ||
|
|
d5b17ac00e | ||
|
|
a50763f520 | ||
|
|
6f5c09185f | ||
|
|
249b6461ee | ||
|
|
912b342e0e | ||
|
|
f9efb062e0 | ||
|
|
b8d3b1449a | ||
|
|
9b5b34a1f8 | ||
|
|
0b2af2f900 | ||
|
|
9371416398 | ||
|
|
9a687f99ee | ||
|
|
b6afe79a81 | ||
|
|
b12c30e956 | ||
|
|
c5dc72a83c | ||
|
|
3c3982bad5 | ||
|
|
c92a35a01f | ||
|
|
8a667ad71f | ||
|
|
72cff2a470 |
@@ -1 +1,2 @@
|
|||||||
export POSTGRES_DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"
|
export POSTGRES_DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"
|
||||||
|
export MARIA_DATABASE_URL="mysql://maria:password@localhost:3306/maria"
|
||||||
|
|||||||
39
.github/workflows/coverage.yml
vendored
39
.github/workflows/coverage.yml
vendored
@@ -34,11 +34,39 @@ jobs:
|
|||||||
--health-retries 5
|
--health-retries 5
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
|
|
||||||
mcaptcha-redis:
|
mcaptcha-redis:
|
||||||
image: mcaptcha/cache
|
image: mcaptcha/cache
|
||||||
ports:
|
ports:
|
||||||
- 6379:6379
|
- 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:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: ⚡ Cache
|
- name: ⚡ Cache
|
||||||
@@ -56,15 +84,14 @@ jobs:
|
|||||||
- name: load env
|
- name: load env
|
||||||
run: |
|
run: |
|
||||||
source .env_sample \
|
source .env_sample \
|
||||||
&& echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV
|
&& echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV \
|
||||||
|
&& echo "MARIA_DATABASE_URL=$MARIA_DATABASE_URL" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: "16.x"
|
node-version: "16.x"
|
||||||
|
|
||||||
- name: start smtp server
|
|
||||||
run: docker run -d -p 1080:1080 -p 10025:1025 maildev/maildev --incoming-user admin --incoming-pass password
|
|
||||||
|
|
||||||
- name: Install ${{ matrix.version }}
|
- name: Install ${{ matrix.version }}
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
@@ -76,12 +103,13 @@ jobs:
|
|||||||
run: make frontend
|
run: make frontend
|
||||||
|
|
||||||
- name: Run the frontend tests
|
- name: Run the frontend tests
|
||||||
run: make frontend-test
|
run: make test.frontend
|
||||||
|
|
||||||
- name: Run migrations
|
- name: Run migrations
|
||||||
run: make migrate
|
run: make migrate
|
||||||
env:
|
env:
|
||||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}"
|
||||||
|
|
||||||
- name: build frontend
|
- name: build frontend
|
||||||
run: make frontend
|
run: make frontend
|
||||||
@@ -94,6 +122,7 @@ jobs:
|
|||||||
args: "-t 1200"
|
args: "-t 1200"
|
||||||
env:
|
env:
|
||||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
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
|
# GIT_HASH is dummy value. I guess build.rs is skipped in tarpaulin
|
||||||
# execution so this value is required for preventing meta tests from
|
# execution so this value is required for preventing meta tests from
|
||||||
# panicking
|
# panicking
|
||||||
|
|||||||
69
.github/workflows/linux.yml
vendored
69
.github/workflows/linux.yml
vendored
@@ -8,7 +8,8 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- db-abstract
|
- "*"
|
||||||
|
- '!gh-pages'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_and_test:
|
build_and_test:
|
||||||
@@ -37,10 +38,35 @@ jobs:
|
|||||||
--health-retries 5
|
--health-retries 5
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
|
|
||||||
mcaptcha-redis:
|
mcaptcha-redis:
|
||||||
image: mcaptcha/cache
|
image: mcaptcha/cache
|
||||||
ports:
|
ports:
|
||||||
- 6379:6379
|
- 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:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -55,18 +81,21 @@ jobs:
|
|||||||
target
|
target
|
||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: configure GPG key
|
||||||
|
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/mCaptcha'
|
||||||
|
run: echo -n "$RELEASE_BOT_GPG_SIGNING_KEY" | gpg --batch --import --pinentry-mode loopback
|
||||||
|
env:
|
||||||
|
RELEASE_BOT_GPG_SIGNING_KEY: ${{ secrets.RELEASE_BOT_GPG_SIGNING_KEY }}
|
||||||
|
|
||||||
- name: load env
|
- name: load env
|
||||||
run: |
|
run: |
|
||||||
source .env_sample \
|
source .env_sample \
|
||||||
&& echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV
|
&& echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV \
|
||||||
|
&& echo "MARIA_DATABASE_URL=$MARIA_DATABASE_URL" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: '16.x'
|
node-version: "16.x"
|
||||||
|
|
||||||
- name: start smtp server
|
|
||||||
run: docker run -d -p 1080:1080 -p 10025:1025 maildev/maildev --incoming-user admin --incoming-pass password
|
|
||||||
|
|
||||||
- name: Install ${{ matrix.version }}
|
- name: Install ${{ matrix.version }}
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
@@ -75,15 +104,20 @@ jobs:
|
|||||||
profile: minimal
|
profile: minimal
|
||||||
override: true
|
override: true
|
||||||
|
|
||||||
|
- name: install nightwatch dep
|
||||||
|
run: sudo apt-get install xvfb
|
||||||
|
|
||||||
- name: Run migrations
|
- name: Run migrations
|
||||||
run: make migrate
|
run: make migrate
|
||||||
env:
|
env:
|
||||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}"
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
run: make
|
run: make
|
||||||
env:
|
env:
|
||||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}"
|
||||||
|
|
||||||
# - name: build frontend
|
# - name: build frontend
|
||||||
# run: make frontend
|
# run: make frontend
|
||||||
@@ -95,12 +129,35 @@ jobs:
|
|||||||
run: make test
|
run: make test
|
||||||
env:
|
env:
|
||||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}"
|
||||||
|
|
||||||
|
- name: run integration tests
|
||||||
|
run: make test.integration
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/mCaptcha'
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: mcaptcha
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: publish docker images
|
||||||
|
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/mCaptcha'
|
||||||
|
run: make docker-publish
|
||||||
|
|
||||||
|
- name: publish bins
|
||||||
|
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/mCaptcha'
|
||||||
|
run: ./scripts/publish.sh publish master latest $DUMBSERVE_PASSWORD
|
||||||
|
env:
|
||||||
|
DUMBSERVE_PASSWORD: ${{ secrets.DUMBSERVE_PASSWORD }}
|
||||||
|
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
|
||||||
|
|
||||||
- name: generate documentation
|
- name: generate documentation
|
||||||
if: matrix.version == 'stable' && (github.repository == 'mCaptcha/mCaptcha')
|
if: matrix.version == 'stable' && (github.repository == 'mCaptcha/mCaptcha')
|
||||||
run: make doc
|
run: make doc
|
||||||
env:
|
env:
|
||||||
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}"
|
||||||
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
COMPILED_DATE: "2021-07-21"
|
COMPILED_DATE: "2021-07-21"
|
||||||
|
|
||||||
|
|||||||
32
.github/workflows/tagged-release.yml
vendored
Normal file
32
.github/workflows/tagged-release.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: Create binary for release
|
||||||
|
|
||||||
|
# Only on tags that start with a "v"
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- target: x86_64-pc-windows-gnu
|
||||||
|
archive: zip
|
||||||
|
- target: x86_64-unknown-linux-musl
|
||||||
|
archive: tar.gz tar.xz
|
||||||
|
- target: x86_64-apple-darwin
|
||||||
|
archive: zip
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Compile and release
|
||||||
|
uses: rust-build/rust-build.action@v1.3.2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
RUSTTARGET: ${{ matrix.target }}
|
||||||
|
ARCHIVE_TYPES: ${{ matrix.archive }}
|
||||||
571
Cargo.lock
generated
571
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
19
Cargo.toml
19
Cargo.toml
@@ -16,7 +16,7 @@ build = "build.rs"
|
|||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
exclude = ["db/db-migrations", "utils/cache-bust"]
|
exclude = ["db/db-migrations", "utils/cache-bust"]
|
||||||
memebers = [".", "db/db-core", "db/db-sqlx-postgres"]
|
memebers = [".", "db/db-core", "db/db-sqlx-postgres", "db/db-sqlx-maria"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "mcaptcha"
|
name = "mcaptcha"
|
||||||
@@ -38,7 +38,7 @@ cache-buster = { git = "https://github.com/realaravinth/cache-buster" }
|
|||||||
futures = "0.3.15"
|
futures = "0.3.15"
|
||||||
tokio = { version = "1.14", features = ["sync"]}
|
tokio = { version = "1.14", features = ["sync"]}
|
||||||
|
|
||||||
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] }
|
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline", "mysql"] }
|
||||||
argon2-creds = { branch = "master", git = "https://github.com/realaravinth/argon2-creds"}
|
argon2-creds = { branch = "master", git = "https://github.com/realaravinth/argon2-creds"}
|
||||||
#argon2-creds = { version="*", path = "../../argon2-creds/" }
|
#argon2-creds = { version="*", path = "../../argon2-creds/" }
|
||||||
config = "0.11"
|
config = "0.11"
|
||||||
@@ -59,7 +59,8 @@ log = "0.4"
|
|||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
|
|
||||||
|
|
||||||
libmcaptcha = { branch = "master", git = "https://github.com/mCaptcha/libmcaptcha", features = ["full"] }
|
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 = { path = "../libmcaptcha", features = ["full"]}
|
||||||
|
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
@@ -68,6 +69,8 @@ sailfish = "0.4.0"
|
|||||||
|
|
||||||
mime = "0.3.16"
|
mime = "0.3.16"
|
||||||
|
|
||||||
|
num_cpus = "1.13.1"
|
||||||
|
|
||||||
lettre = { version = "0.10.0-rc.3", features = [
|
lettre = { version = "0.10.0-rc.3", features = [
|
||||||
"builder",
|
"builder",
|
||||||
"tokio1",
|
"tokio1",
|
||||||
@@ -75,7 +78,8 @@ lettre = { version = "0.10.0-rc.3", features = [
|
|||||||
"smtp-transport"
|
"smtp-transport"
|
||||||
]}
|
]}
|
||||||
|
|
||||||
openssl = { version = "0.10.29", features = ["vendored"] }
|
openssl = { version = "0.10.48", features = ["vendored"] }
|
||||||
|
uuid = { version = "1.4.0", features = ["v4", "serde"] }
|
||||||
|
|
||||||
|
|
||||||
[dependencies.db-core]
|
[dependencies.db-core]
|
||||||
@@ -84,6 +88,9 @@ path = "./db/db-core"
|
|||||||
[dependencies.db-sqlx-postgres]
|
[dependencies.db-sqlx-postgres]
|
||||||
path = "./db/db-sqlx-postgres"
|
path = "./db/db-sqlx-postgres"
|
||||||
|
|
||||||
|
[dependencies.db-sqlx-maria]
|
||||||
|
path = "./db/db-sqlx-maria"
|
||||||
|
|
||||||
[dependencies.my-codegen]
|
[dependencies.my-codegen]
|
||||||
git = "https://github.com/realaravinth/actix-web"
|
git = "https://github.com/realaravinth/actix-web"
|
||||||
package = "actix-web-codegen"
|
package = "actix-web-codegen"
|
||||||
@@ -95,10 +102,10 @@ features = ["actix_identity_backend"]
|
|||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] }
|
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline", "mysql" ] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pow_sha256 = { version = "0.2.1", git = "https://github.com/mcaptcha/pow_sha256" }
|
pow_sha256 = { version = "0.3.1", git = "https://github.com/mcaptcha/pow_sha256", tag="0.3.1" }
|
||||||
awc = "3.0.0"
|
awc = "3.0.0"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ COPY --from=cacher /src/target target
|
|||||||
#COPY --from=cacher /src/db/db-migrations/target /src/db/db-migrations/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=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/static/cache/bundle/ /src/static/cache/bundle/
|
||||||
|
COPY --from=frontend /src/docs/openapi/dist/ /src/docs/openapi/dist/
|
||||||
RUN cargo --version
|
RUN cargo --version
|
||||||
RUN make cache-bust
|
RUN make cache-bust
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
|
|||||||
142
Makefile
142
Makefile
@@ -2,6 +2,39 @@ BUNDLE = static/cache/bundle
|
|||||||
OPENAPI = docs/openapi
|
OPENAPI = docs/openapi
|
||||||
CLEAN_UP = $(BUNDLE) src/cache_buster_data.json assets
|
CLEAN_UP = $(BUNDLE) src/cache_buster_data.json assets
|
||||||
|
|
||||||
|
define deploy_dependencies ## deploy dependencies
|
||||||
|
@-docker create --name ${db} \
|
||||||
|
-e POSTGRES_PASSWORD=password \
|
||||||
|
-p 5432:5432 \
|
||||||
|
postgres
|
||||||
|
@-docker create \
|
||||||
|
-p 3306:3306 \
|
||||||
|
--name ${mdb} \
|
||||||
|
--env MARIADB_USER=maria \
|
||||||
|
--env MARIADB_PASSWORD=password \
|
||||||
|
--env MARIADB_ROOT_PASSWORD=password \
|
||||||
|
--env MARIADB_DATABASE=maria \
|
||||||
|
mariadb:latest
|
||||||
|
@-docker create \
|
||||||
|
-p 6379:6379 \
|
||||||
|
--name mcaptcha-cache \
|
||||||
|
mcaptcha/cache:latest
|
||||||
|
docker start ${db}
|
||||||
|
docker start ${mdb}
|
||||||
|
docker start mcaptcha-cache
|
||||||
|
endef
|
||||||
|
|
||||||
|
define run_migrations ## run database migrations
|
||||||
|
cd db/db-migrations/ && cargo run
|
||||||
|
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=${POSTGRES_DATABASE_URL} sqlx migrate run
|
||||||
|
endef
|
||||||
|
|
||||||
define frontend_env ## install frontend deps
|
define frontend_env ## install frontend deps
|
||||||
yarn install
|
yarn install
|
||||||
cd docs/openapi && yarn install
|
cd docs/openapi && yarn install
|
||||||
@@ -11,6 +44,30 @@ define cache_bust ## run cache_busting program
|
|||||||
cd utils/cache-bust && cargo run
|
cd utils/cache-bust && cargo run
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
||||||
|
define test_frontend ## run frontend tests
|
||||||
|
cd $(OPENAPI)&& yarn test
|
||||||
|
yarn test
|
||||||
|
endef
|
||||||
|
|
||||||
|
define test_db_sqlx_postgres
|
||||||
|
cd db/db-sqlx-postgres &&\
|
||||||
|
DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
||||||
|
cargo test --no-fail-fast
|
||||||
|
endef
|
||||||
|
|
||||||
|
define test_db_sqlx_maria
|
||||||
|
cd db/db-sqlx-maria &&\
|
||||||
|
DATABASE_URL=${MARIA_DATABASE_URL}\
|
||||||
|
cargo test --no-fail-fast
|
||||||
|
endef
|
||||||
|
|
||||||
|
define test_core
|
||||||
|
cargo test --no-fail-fast
|
||||||
|
endef
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
default: frontend ## Build app in debug mode
|
default: frontend ## Build app in debug mode
|
||||||
$(call cache_bust)
|
$(call cache_bust)
|
||||||
cargo build
|
cargo build
|
||||||
@@ -22,6 +79,9 @@ check: ## Check for syntax errors on all workspaces
|
|||||||
cd db/db-sqlx-postgres &&\
|
cd db/db-sqlx-postgres &&\
|
||||||
DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
||||||
cargo check
|
cargo check
|
||||||
|
cd db/db-sqlx-maria &&\
|
||||||
|
DATABASE_URL=${MARIA_DATABASE_URL}\
|
||||||
|
cargo check
|
||||||
cd db/db-core/ && cargo check
|
cd db/db-core/ && cargo check
|
||||||
|
|
||||||
cache-bust: ## Run cache buster on static assets
|
cache-bust: ## Run cache buster on static assets
|
||||||
@@ -32,10 +92,6 @@ clean: ## Delete build artifacts
|
|||||||
@yarn cache clean
|
@yarn cache clean
|
||||||
@-rm $(CLEAN_UP)
|
@-rm $(CLEAN_UP)
|
||||||
|
|
||||||
coverage: migrate ## Generate code coverage report in HTML format
|
|
||||||
$(call cache_bust)
|
|
||||||
cargo tarpaulin -t 1200 --out Html
|
|
||||||
|
|
||||||
doc: ## Generate documentation
|
doc: ## Generate documentation
|
||||||
#yarn doc
|
#yarn doc
|
||||||
cargo doc --no-deps --workspace --all-features
|
cargo doc --no-deps --workspace --all-features
|
||||||
@@ -51,6 +107,19 @@ env: ## Setup development environtment
|
|||||||
cargo fetch
|
cargo fetch
|
||||||
$(call frontend_env)
|
$(call frontend_env)
|
||||||
|
|
||||||
|
env.db: ## Deploy dependencies
|
||||||
|
$(call deploy_dependencies)
|
||||||
|
sleep 5
|
||||||
|
$(call run_migrations)
|
||||||
|
|
||||||
|
env.db.recreate: ## Deploy dependencies from scratch
|
||||||
|
@-docker rm -f ${db}
|
||||||
|
@-docker rm -f ${mdb}
|
||||||
|
@-docker rm -f mcaptcha-cache
|
||||||
|
$(call deploy_dependencies)
|
||||||
|
sleep 5
|
||||||
|
$(call run_migrations)
|
||||||
|
|
||||||
frontend-env: ## Install frontend deps
|
frontend-env: ## Install frontend deps
|
||||||
$(call frontend_env)
|
$(call frontend_env)
|
||||||
|
|
||||||
@@ -73,10 +142,6 @@ frontend: ## Build frontend
|
|||||||
@./scripts/librejs.sh
|
@./scripts/librejs.sh
|
||||||
@./scripts/cachebust.sh
|
@./scripts/cachebust.sh
|
||||||
|
|
||||||
frontend-test: ## Run frontend tests
|
|
||||||
cd $(OPENAPI)&& yarn test
|
|
||||||
yarn test
|
|
||||||
|
|
||||||
lint: ## Lint codebase
|
lint: ## Lint codebase
|
||||||
cargo fmt -v --all -- --emit files
|
cargo fmt -v --all -- --emit files
|
||||||
cargo clippy --workspace --tests --all-features
|
cargo clippy --workspace --tests --all-features
|
||||||
@@ -84,44 +149,63 @@ lint: ## Lint codebase
|
|||||||
cd $(OPENAPI)&& yarn test
|
cd $(OPENAPI)&& yarn test
|
||||||
|
|
||||||
migrate: ## Run database migrations
|
migrate: ## Run database migrations
|
||||||
cd db/db-migrations/ && \
|
$(call run_migrations)
|
||||||
DATABASE_URL=${POSTGRES_DATABASE_URL} cargo run
|
|
||||||
|
migrate.dev: ## Run database migrations during development
|
||||||
|
$(call run_dev_migrations)
|
||||||
|
|
||||||
release: frontend ## Build app with release optimizations
|
release: frontend ## Build app with release optimizations
|
||||||
$(call cache_bust)
|
$(call cache_bust)
|
||||||
cargo build --release
|
cargo build --release
|
||||||
|
|
||||||
run: frontend ## Run app in debug mode
|
run: frontend ## Run app in debug mode
|
||||||
|
$(call cache_bust)
|
||||||
cargo run
|
cargo run
|
||||||
|
|
||||||
|
|
||||||
sqlx-offline-data: ## prepare sqlx offline data
|
db.sqlx.offline: ## prepare sqlx offline data
|
||||||
cargo sqlx prepare --database-url=${POSTGRES_DATABASE_URL} -- --bin mcaptcha \
|
|
||||||
--all-features
|
|
||||||
cd db/db-migrations && cargo sqlx prepare \
|
|
||||||
--database-url=${POSTGRES_DATABASE_URL} -- --bin db-migrations \
|
|
||||||
--all-features
|
|
||||||
cd db/db-sqlx-postgres && cargo sqlx prepare \
|
cd db/db-sqlx-postgres && cargo sqlx prepare \
|
||||||
--database-url=${POSTGRES_DATABASE_URL} -- \
|
--database-url=${POSTGRES_DATABASE_URL} -- \
|
||||||
--all-features
|
--all-features
|
||||||
# cd db/db-sqlx-sqlite/ \
|
cd db/db-sqlx-maria && cargo sqlx prepare \
|
||||||
# && DATABASE_URL=${SQLITE_DATABASE_URL} cargo sqlx prepare
|
--database-url=${MARIA_DATABASE_URL} -- \
|
||||||
|
--all-features
|
||||||
|
|
||||||
test-db: ## run tests on database
|
test: frontend ## Run all available tests
|
||||||
cd db/db-sqlx-postgres &&\
|
$(call test_frontend)
|
||||||
DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
|
||||||
cargo test --no-fail-fast
|
|
||||||
test: frontend-test frontend ## Run all available tests
|
|
||||||
$(call cache_bust)
|
$(call cache_bust)
|
||||||
cd db/db-sqlx-postgres &&\
|
$(call test_db_sqlx_postgres)
|
||||||
DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
$(call test_db_sqlx_maria)
|
||||||
cargo test --no-fail-fast
|
$(call test_core)
|
||||||
cargo test --all-features --no-fail-fast
|
|
||||||
# ./scripts/tests.sh
|
# ./scripts/tests.sh
|
||||||
|
|
||||||
xml-test-coverage: migrate ## Generate code coverage report in XML format
|
test.cov.html: migrate ## Generate code coverage report in HTML format
|
||||||
|
$(call cache_bust)
|
||||||
|
cargo tarpaulin -t 1200 --out Html
|
||||||
|
|
||||||
|
test.cov.xml: migrate ## Generate code coverage report in XML format
|
||||||
$(call cache_bust)
|
$(call cache_bust)
|
||||||
cargo tarpaulin -t 1200 --out Xml
|
cargo tarpaulin -t 1200 --out Xml
|
||||||
|
|
||||||
|
|
||||||
|
test.core: ## Run all core tests
|
||||||
|
$(call test_core)
|
||||||
|
|
||||||
|
test.db: ## Run all database driver tests
|
||||||
|
$(call test_db_sqlx_postgres)
|
||||||
|
$(call test_db_sqlx_maria)
|
||||||
|
|
||||||
|
test.db.pg: ## Run Postgres database driver tests
|
||||||
|
$(call test_db_sqlx_postgres)
|
||||||
|
|
||||||
|
test.db.maria: ## Run Maria database driver tests
|
||||||
|
$(call test_db_sqlx_maria)
|
||||||
|
|
||||||
|
test.frontend: ## Run frontend tests
|
||||||
|
$(call test_frontend)
|
||||||
|
|
||||||
|
test.integration: ## run integration tests with nightwatch.js
|
||||||
|
./scripts/integration.sh
|
||||||
|
|
||||||
help: ## Prints help for targets with comments
|
help: ## Prints help for targets with comments
|
||||||
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-].+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -34,7 +34,7 @@ yourself!](https://demo.mcaptcha.org/widget/?sitekey=pHy0AktWyOKuxZDzFfoaewncWec
|
|||||||
|
|
||||||
mCaptcha uses SHA256 based proof-of-work (PoW) to rate limit users.
|
mCaptcha uses SHA256 based proof-of-work (PoW) to rate limit users.
|
||||||
|
|
||||||
When a user wants to do something on an mCaptcha-protected website,
|
When a user wants to do something on a mCaptcha-protected website,
|
||||||
|
|
||||||
1. they will have to generate proof-of-work (a bunch of math that will takes
|
1. they will have to generate proof-of-work (a bunch of math that will takes
|
||||||
time to compute) and submit it to mCaptcha.
|
time to compute) and submit it to mCaptcha.
|
||||||
@@ -112,7 +112,6 @@ After the containers are up, visit [http://localhost:7000](http://localhost:7000
|
|||||||
- username: aaronsw
|
- username: aaronsw
|
||||||
- password: password
|
- password: password
|
||||||
|
|
||||||
|
|
||||||
It takes a while to build the image so please be patient :)
|
It takes a while to build the image so please be patient :)
|
||||||
|
|
||||||
See [DEPLOYMENT.md](./docs/DEPLOYMENT.md) detailed alternate deployment
|
See [DEPLOYMENT.md](./docs/DEPLOYMENT.md) detailed alternate deployment
|
||||||
@@ -129,3 +128,21 @@ See [DEPLOYMENT.md](./docs/DEPLOYMENT.md)
|
|||||||
## Configuration:
|
## Configuration:
|
||||||
|
|
||||||
See [CONFIGURATION.md](./docs/CONFIGURATION.md)
|
See [CONFIGURATION.md](./docs/CONFIGURATION.md)
|
||||||
|
|
||||||
|
## Funding
|
||||||
|
|
||||||
|
### NLnet
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<img
|
||||||
|
height="150px"
|
||||||
|
alt="NLnet NGIZero logo"
|
||||||
|
src="./docs/third-party/NGIZero-green.hex.svg"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
2023 development is funded through the [NGI0 Entrust
|
||||||
|
Fund](https://nlnet.nl/entrust), via [NLnet](https://nlnet.nl/). Please
|
||||||
|
see [here](https://nlnet.nl/project/mCaptcha/) for more details.
|
||||||
|
|||||||
2
build.rs
2
build.rs
@@ -21,7 +21,7 @@ use sqlx::types::time::OffsetDateTime;
|
|||||||
fn main() {
|
fn main() {
|
||||||
// note: add error checking yourself.
|
// note: add error checking yourself.
|
||||||
let output = Command::new("git")
|
let output = Command::new("git")
|
||||||
.args(&["rev-parse", "HEAD"])
|
.args(["rev-parse", "HEAD"])
|
||||||
.output()
|
.output()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let git_hash = String::from_utf8(output.stdout).unwrap();
|
let git_hash = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ cookie_secret = "Zae0OOxf^bOJ#zN^&k7VozgW&QAx%n02TQFXpRMG4cCU0xMzgu3dna@tQ9dvc&T
|
|||||||
# The port at which you want authentication to listen to
|
# The port at which you want authentication to listen to
|
||||||
# takes a number, choose from 1000-10000 if you dont know what you are doing
|
# takes a number, choose from 1000-10000 if you dont know what you are doing
|
||||||
port = 7000
|
port = 7000
|
||||||
#IP address. Enter 0.0.0.0 to listen on all availale addresses
|
#IP address. Enter 0.0.0.0 to listen on all available addresses
|
||||||
ip= "0.0.0.0"
|
ip= "0.0.0.0"
|
||||||
# enter your hostname, eg: example.com
|
# enter your hostname, eg: example.com
|
||||||
domain = "localhost"
|
domain = "localhost"
|
||||||
@@ -28,6 +28,8 @@ salt = "asdl;kjfhjawehfpa;osdkjasdvjaksndfpoanjdfainsdfaijdsfajlkjdsaf;ajsdfwero
|
|||||||
# garbage collection period to manage mCaptcha system
|
# garbage collection period to manage mCaptcha system
|
||||||
# leave untouched if you don't know what you are doing
|
# leave untouched if you don't know what you are doing
|
||||||
gc = 30
|
gc = 30
|
||||||
|
runners = 4
|
||||||
|
queue_length = 2000
|
||||||
enable_stats = true
|
enable_stats = true
|
||||||
|
|
||||||
[captcha.default_difficulty_strategy]
|
[captcha.default_difficulty_strategy]
|
||||||
@@ -50,6 +52,7 @@ username = "postgres"
|
|||||||
password = "password"
|
password = "password"
|
||||||
name = "postgres"
|
name = "postgres"
|
||||||
pool = 4
|
pool = 4
|
||||||
|
database_type="postgres" # "postgres", "maria"
|
||||||
|
|
||||||
[redis]
|
[redis]
|
||||||
# This section deals with the database location and how to access it
|
# This section deals with the database location and how to access it
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ async-trait = "0.1.51"
|
|||||||
thiserror = "1.0.30"
|
thiserror = "1.0.30"
|
||||||
serde = { version = "1", features = ["derive"]}
|
serde = { version = "1", features = ["derive"]}
|
||||||
url = { version = "2.2.2", features = ["serde"] }
|
url = { version = "2.2.2", features = ["serde"] }
|
||||||
libmcaptcha = { branch = "master", git = "https://github.com/mCaptcha/libmcaptcha", features = ["minimal"], default-features = false }
|
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"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
//!
|
//!
|
||||||
//! ## Organisation
|
//! ## Organisation
|
||||||
//!
|
//!
|
||||||
//! Database functionallity is divided accross various modules:
|
//! Database functionality is divided across various modules:
|
||||||
//!
|
//!
|
||||||
//! - [errors](crate::auth): error data structures used in this crate
|
//! - [errors](crate::auth): error data structures used in this crate
|
||||||
//! - [ops](crate::ops): meta operations like connection pool creation, migrations and getting
|
//! - [ops](crate::ops): meta operations like connection pool creation, migrations and getting
|
||||||
@@ -242,14 +242,89 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
|||||||
/// record PoWConfig confirms
|
/// record PoWConfig confirms
|
||||||
async fn record_confirm(&self, key: &str) -> DBResult<()>;
|
async fn record_confirm(&self, key: &str) -> DBResult<()>;
|
||||||
|
|
||||||
/// featch PoWConfig fetches
|
/// fetch PoWConfig fetches
|
||||||
async fn fetch_config_fetched(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
async fn fetch_config_fetched(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
||||||
|
|
||||||
/// featch PoWConfig solves
|
/// fetch PoWConfig solves
|
||||||
async fn fetch_solve(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
async fn fetch_solve(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
||||||
|
|
||||||
/// featch PoWConfig confirms
|
/// fetch PoWConfig confirms
|
||||||
async fn fetch_confirm(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
async fn fetch_confirm(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
||||||
|
|
||||||
|
/// record PoW timing
|
||||||
|
async fn analysis_save(
|
||||||
|
&self,
|
||||||
|
captcha_id: &str,
|
||||||
|
d: &CreatePerformanceAnalytics,
|
||||||
|
) -> DBResult<()>;
|
||||||
|
|
||||||
|
/// fetch PoW analytics
|
||||||
|
async fn analytics_fetch(
|
||||||
|
&self,
|
||||||
|
captcha_id: &str,
|
||||||
|
limit: usize,
|
||||||
|
offset: usize,
|
||||||
|
) -> DBResult<Vec<PerformanceAnalytics>>;
|
||||||
|
|
||||||
|
/// Create psuedo ID against campaign ID to publish analytics
|
||||||
|
async fn analytics_create_psuedo_id_if_not_exists(
|
||||||
|
&self,
|
||||||
|
captcha_id: &str,
|
||||||
|
) -> DBResult<()>;
|
||||||
|
|
||||||
|
/// Get psuedo ID from campaign ID
|
||||||
|
async fn analytics_get_psuedo_id_from_capmaign_id(
|
||||||
|
&self,
|
||||||
|
captcha_id: &str,
|
||||||
|
) -> DBResult<String>;
|
||||||
|
|
||||||
|
/// Get campaign ID from psuedo ID
|
||||||
|
async fn analytics_get_capmaign_id_from_psuedo_id(
|
||||||
|
&self,
|
||||||
|
psuedo_id: &str,
|
||||||
|
) -> DBResult<String>;
|
||||||
|
|
||||||
|
/// Delete all records for campaign
|
||||||
|
async fn analytics_delete_all_records_for_campaign(
|
||||||
|
&self,
|
||||||
|
campaign_id: &str,
|
||||||
|
) -> DBResult<()>;
|
||||||
|
|
||||||
|
/// Get publishing status of pow analytics for captcha ID/ campaign ID
|
||||||
|
async fn analytics_captcha_is_published(&self, campaign_id: &str) -> DBResult<bool> {
|
||||||
|
match self
|
||||||
|
.analytics_get_psuedo_id_from_capmaign_id(campaign_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(_) => Ok(true),
|
||||||
|
Err(errors::DBError::CaptchaNotFound) => Ok(false),
|
||||||
|
Err(e) => Err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq)]
|
||||||
|
/// Log Proof-of-Work CAPTCHA performance analytics
|
||||||
|
pub struct CreatePerformanceAnalytics {
|
||||||
|
/// time taken to generate proof
|
||||||
|
pub time: u32,
|
||||||
|
/// difficulty factor for which the proof was generated
|
||||||
|
pub difficulty_factor: u32,
|
||||||
|
/// worker/client type: wasm, javascript, python, etc.
|
||||||
|
pub worker_type: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq)]
|
||||||
|
/// Proof-of-Work CAPTCHA performance analytics
|
||||||
|
pub struct PerformanceAnalytics {
|
||||||
|
/// log ID
|
||||||
|
pub id: usize,
|
||||||
|
/// time taken to generate proof
|
||||||
|
pub time: u32,
|
||||||
|
/// difficulty factor for which the proof was generated
|
||||||
|
pub difficulty_factor: u32,
|
||||||
|
/// worker/client type: wasm, javascript, python, etc.
|
||||||
|
pub worker_type: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq)]
|
||||||
@@ -287,7 +362,7 @@ pub struct AddNotification<'a> {
|
|||||||
pub from: &'a str,
|
pub from: &'a str,
|
||||||
/// heading of the notification
|
/// heading of the notification
|
||||||
pub heading: &'a str,
|
pub heading: &'a str,
|
||||||
/// mesage of the notification
|
/// message of the notification
|
||||||
pub message: &'a str,
|
pub message: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,12 +373,12 @@ pub struct TrafficPattern {
|
|||||||
pub avg_traffic: u32,
|
pub avg_traffic: u32,
|
||||||
/// the peak traffic that the user's website can handle
|
/// the peak traffic that the user's website can handle
|
||||||
pub peak_sustainable_traffic: u32,
|
pub peak_sustainable_traffic: u32,
|
||||||
/// trafic that bought the user's website down; optional
|
/// traffic that bought the user's website down; optional
|
||||||
pub broke_my_site_traffic: Option<u32>,
|
pub broke_my_site_traffic: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
|
||||||
/// data requried to create new captcha
|
/// data required to create new captcha
|
||||||
pub struct CreateCaptcha<'a> {
|
pub struct CreateCaptcha<'a> {
|
||||||
/// cool down duration
|
/// cool down duration
|
||||||
pub duration: i32,
|
pub duration: i32,
|
||||||
@@ -332,7 +407,6 @@ pub struct Secret {
|
|||||||
/// user's secret
|
/// user's secret
|
||||||
pub secret: String,
|
pub secret: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trait to clone MCDatabase
|
/// Trait to clone MCDatabase
|
||||||
pub trait CloneSPDatabase {
|
pub trait CloneSPDatabase {
|
||||||
/// clone DB
|
/// clone DB
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ pub trait GetConnection {
|
|||||||
async fn get_conn(&self) -> DBResult<Self::Conn>;
|
async fn get_conn(&self) -> DBResult<Self::Conn>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create databse connection
|
/// Create database connection
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Connect {
|
pub trait Connect {
|
||||||
/// database specific pool-type
|
/// database specific pool-type
|
||||||
|
|||||||
@@ -28,21 +28,31 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
an: &AddNotification<'a>,
|
an: &AddNotification<'a>,
|
||||||
) {
|
) {
|
||||||
assert!(db.ping().await, "ping test");
|
assert!(db.ping().await, "ping test");
|
||||||
|
|
||||||
if db.username_exists(p.username).await.unwrap() {
|
if db.username_exists(p.username).await.unwrap() {
|
||||||
db.delete_user(p.username).await.unwrap();
|
db.delete_user(p.username).await.unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
!db.username_exists(p.username).await.unwrap(),
|
!db.username_exists(p.username).await.unwrap(),
|
||||||
"user is deleted so username shouldn't exsit"
|
"user is deleted so username shouldn't exist"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert!(matches!(
|
||||||
|
db.get_secret(&p.username).await,
|
||||||
|
Err(DBError::AccountNotFound)
|
||||||
|
));
|
||||||
|
|
||||||
db.register(p).await.unwrap();
|
db.register(p).await.unwrap();
|
||||||
|
|
||||||
|
assert!(matches!(db.register(&p).await, Err(DBError::UsernameTaken)));
|
||||||
|
|
||||||
// testing get secret
|
// testing get secret
|
||||||
let secret = db.get_secret(p.username).await.unwrap();
|
let secret = db.get_secret(p.username).await.unwrap();
|
||||||
assert_eq!(secret.secret, p.secret, "user secret matches");
|
assert_eq!(secret.secret, p.secret, "user secret matches");
|
||||||
|
|
||||||
// testing update secret: setting secret = username
|
// testing update secret: setting secret = username
|
||||||
db.update_secret(p.username, p.username).await.unwrap();
|
db.update_secret(p.username, p.username).await.unwrap();
|
||||||
|
|
||||||
let secret = db.get_secret(p.username).await.unwrap();
|
let secret = db.get_secret(p.username).await.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
secret.secret, p.username,
|
secret.secret, p.username,
|
||||||
@@ -79,11 +89,11 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
// testing email exists
|
// testing email exists
|
||||||
assert!(
|
assert!(
|
||||||
db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
||||||
"user is registered so email should exsit"
|
"user is registered so email should exist"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
db.username_exists(p.username).await.unwrap(),
|
db.username_exists(p.username).await.unwrap(),
|
||||||
"user is registered so username should exsit"
|
"user is registered so username should exist"
|
||||||
);
|
);
|
||||||
|
|
||||||
// update password test. setting password = username
|
// update password test. setting password = username
|
||||||
@@ -114,7 +124,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
db.delete_user(p.email.as_ref().unwrap()).await.unwrap();
|
db.delete_user(p.email.as_ref().unwrap()).await.unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
!db.username_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
!db.username_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
||||||
"user is deleted so username shouldn't exsit"
|
"user is deleted so username shouldn't exist"
|
||||||
);
|
);
|
||||||
|
|
||||||
// register with email = None
|
// register with email = None
|
||||||
@@ -123,11 +133,11 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
db.register(&p2).await.unwrap();
|
db.register(&p2).await.unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
db.username_exists(p2.username).await.unwrap(),
|
db.username_exists(p2.username).await.unwrap(),
|
||||||
"user is registered so username should exsit"
|
"user is registered so username should exist"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
!db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
||||||
"user registration with email is deleted; so email shouldn't exsit"
|
"user registration with email is deleted; so email shouldn't exist"
|
||||||
);
|
);
|
||||||
|
|
||||||
// testing get_email = None
|
// testing get_email = None
|
||||||
@@ -145,7 +155,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
||||||
"user was with empty email but email is set; so email should exsit"
|
"user was with empty email but email is set; so email should exist"
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -250,6 +260,60 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
db.record_solve(c.key).await.unwrap();
|
db.record_solve(c.key).await.unwrap();
|
||||||
db.record_confirm(c.key).await.unwrap();
|
db.record_confirm(c.key).await.unwrap();
|
||||||
|
|
||||||
|
// analytics start
|
||||||
|
|
||||||
|
db.analytics_create_psuedo_id_if_not_exists(c.key)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let psuedo_id = db
|
||||||
|
.analytics_get_psuedo_id_from_capmaign_id(c.key)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
db.analytics_create_psuedo_id_if_not_exists(c.key)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
psuedo_id,
|
||||||
|
db.analytics_get_psuedo_id_from_capmaign_id(c.key)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
c.key,
|
||||||
|
db.analytics_get_capmaign_id_from_psuedo_id(&psuedo_id)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
|
let analytics = CreatePerformanceAnalytics {
|
||||||
|
time: 0,
|
||||||
|
difficulty_factor: 0,
|
||||||
|
worker_type: "wasm".into(),
|
||||||
|
};
|
||||||
|
db.analysis_save(c.key, &analytics).await.unwrap();
|
||||||
|
let limit = 50;
|
||||||
|
let mut offset = 0;
|
||||||
|
let a = db.analytics_fetch(c.key, limit, offset).await.unwrap();
|
||||||
|
assert_eq!(a[0].time, analytics.time);
|
||||||
|
assert_eq!(a[0].difficulty_factor, analytics.difficulty_factor);
|
||||||
|
assert_eq!(a[0].worker_type, analytics.worker_type);
|
||||||
|
offset += 1;
|
||||||
|
assert!(db
|
||||||
|
.analytics_fetch(c.key, limit, offset)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.is_empty());
|
||||||
|
|
||||||
|
db.analytics_delete_all_records_for_campaign(c.key)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(db.analytics_fetch(c.key, 1000, 0).await.unwrap().len(), 0);
|
||||||
|
assert!(!db.analytics_captcha_is_published(c.key).await.unwrap());
|
||||||
|
db.analytics_delete_all_records_for_campaign(c.key)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
// analytics end
|
||||||
|
|
||||||
assert_eq!(db.fetch_solve(p.username, c.key).await.unwrap().len(), 1);
|
assert_eq!(db.fetch_solve(p.username, c.key).await.unwrap().len(), 1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
db.fetch_config_fetched(p.username, c.key)
|
db.fetch_config_fetched(p.username, c.key)
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ authors = ["realaravinth <realaravinth@batsense.net>"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-rt = "2"
|
actix-rt = "2"
|
||||||
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] }
|
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline", "mysql" ] }
|
||||||
|
|||||||
@@ -17,12 +17,14 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use sqlx::postgres::PgPoolOptions;
|
use sqlx::postgres::PgPoolOptions;
|
||||||
|
use sqlx::mysql::MySqlPoolOptions;
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
#[cfg(not(tarpaulin_include))]
|
||||||
#[actix_rt::main]
|
#[actix_rt::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
//TODO featuregate sqlite and postgres
|
//TODO featuregate sqlite and postgres
|
||||||
postgres_migrate().await;
|
postgres_migrate().await;
|
||||||
|
maria_migrate().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn postgres_migrate() {
|
async fn postgres_migrate() {
|
||||||
@@ -38,3 +40,17 @@ async fn postgres_migrate() {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn maria_migrate() {
|
||||||
|
let db_url = env::var("MARIA_DATABASE_URL").expect("set POSTGRES_DATABASE_URL env var");
|
||||||
|
let db = MySqlPoolOptions::new()
|
||||||
|
.max_connections(2)
|
||||||
|
.connect(&db_url)
|
||||||
|
.await
|
||||||
|
.expect("Unable to form database pool");
|
||||||
|
|
||||||
|
sqlx::migrate!("../db-sqlx-maria/migrations/")
|
||||||
|
.run(&db)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|||||||
16
db/db-sqlx-maria/.gitignore
vendored
Normal file
16
db/db-sqlx-maria/.gitignore
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/target
|
||||||
|
tarpaulin-report.html
|
||||||
|
.env
|
||||||
|
.env
|
||||||
|
cobertura.xml
|
||||||
|
prod/
|
||||||
|
node_modules/
|
||||||
|
/static-assets/bundle
|
||||||
|
static/cache/bundle
|
||||||
|
./templates/**/*.js
|
||||||
|
/static-assets/bundle/*
|
||||||
|
src/cache_buster_data.json
|
||||||
|
coverage
|
||||||
|
dist
|
||||||
|
assets
|
||||||
|
yarn-error.log
|
||||||
22
db/db-sqlx-maria/Cargo.toml
Normal file
22
db/db-sqlx-maria/Cargo.toml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
[package]
|
||||||
|
name = "db-sqlx-maria"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
homepage = "https://mcaptcha.org"
|
||||||
|
repository = "https://github.com/mCaptcha/mCaptcha"
|
||||||
|
documentation = "https://mcaptcha.org/docs/"
|
||||||
|
license = "AGPLv3 or later version"
|
||||||
|
authors = ["realaravinth <realaravinth@batsense.net>"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
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" ] }
|
||||||
|
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" ] }
|
||||||
|
db-core = {path = "../db-core", features = ["test"]}
|
||||||
|
url = { version = "2.2.2", features = ["serde"] }
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS mcaptcha_users (
|
||||||
|
name VARCHAR(100) NOT NULL UNIQUE,
|
||||||
|
email VARCHAR(100) UNIQUE DEFAULT NULL,
|
||||||
|
email_verified BOOLEAN DEFAULT NULL,
|
||||||
|
secret varchar(50) NOT NULL UNIQUE,
|
||||||
|
password TEXT NOT NULL,
|
||||||
|
ID INT auto_increment,
|
||||||
|
PRIMARY KEY(ID)
|
||||||
|
);
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
-- TODO: changed key -> captcha_key
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS mcaptcha_config (
|
||||||
|
config_id INT auto_increment,
|
||||||
|
PRIMARY KEY(config_id),
|
||||||
|
user_id INT NOT NULL,
|
||||||
|
captcha_key varchar(100) NOT NULL UNIQUE,
|
||||||
|
name varchar(100) NOT NULL,
|
||||||
|
duration integer NOT NULL DEFAULT 30,
|
||||||
|
|
||||||
|
CONSTRAINT `fk_mcaptcha_user`
|
||||||
|
FOREIGN KEY (user_id)
|
||||||
|
REFERENCES mcaptcha_users (ID)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
);
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS mcaptcha_levels (
|
||||||
|
config_id INTEGER NOT NULL,
|
||||||
|
difficulty_factor INTEGER NOT NULL,
|
||||||
|
visitor_threshold INTEGER NOT NULL,
|
||||||
|
level_id INT auto_increment,
|
||||||
|
PRIMARY KEY(level_id),
|
||||||
|
CONSTRAINT `fk_mcaptcha_config_id`
|
||||||
|
FOREIGN KEY (config_id)
|
||||||
|
REFERENCES mcaptcha_config (config_id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
);
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS mcaptcha_pow_fetched_stats (
|
||||||
|
config_id INTEGER NOT NULL,
|
||||||
|
time timestamp NOT NULL DEFAULT now(),
|
||||||
|
CONSTRAINT `fk_mcaptcha_config_id_pow_fetched_stats`
|
||||||
|
FOREIGN KEY (config_id)
|
||||||
|
REFERENCES mcaptcha_config (config_id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
|
||||||
|
);
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS mcaptcha_pow_solved_stats (
|
||||||
|
config_id INTEGER NOT NULL,
|
||||||
|
time timestamp NOT NULL DEFAULT now(),
|
||||||
|
CONSTRAINT `fk_mcaptcha_config_id_pow_solved_stats`
|
||||||
|
FOREIGN KEY (config_id)
|
||||||
|
REFERENCES mcaptcha_config (config_id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
);
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS mcaptcha_pow_confirmed_stats (
|
||||||
|
config_id INTEGER NOT NULL,
|
||||||
|
time timestamp NOT NULL DEFAULT now(),
|
||||||
|
CONSTRAINT `fk_mcaptcha_config_id_pow_confirmed_stats`
|
||||||
|
FOREIGN KEY (config_id)
|
||||||
|
REFERENCES mcaptcha_config (config_id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
|
||||||
|
);
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
-- Add migration script here
|
||||||
|
CREATE TABLE IF NOT EXISTS mcaptcha_notifications (
|
||||||
|
id INT auto_increment,
|
||||||
|
PRIMARY KEY(id),
|
||||||
|
|
||||||
|
tx INT NOT NULL,
|
||||||
|
rx INT NOT NULL,
|
||||||
|
heading varchar(30) NOT NULL,
|
||||||
|
message varchar(250) NOT NULL,
|
||||||
|
-- todo: mv read -> read_notification
|
||||||
|
read_notification BOOLEAN DEFAULT null,
|
||||||
|
received timestamp NOT NULL DEFAULT now(),
|
||||||
|
|
||||||
|
CONSTRAINT `fk_mcaptcha_mcaptcha_user_notifications_tx`
|
||||||
|
FOREIGN KEY (tx)
|
||||||
|
REFERENCES mcaptcha_users (ID)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
);
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS mcaptcha_sitekey_user_provided_avg_traffic (
|
||||||
|
config_id INT NOT NULL,
|
||||||
|
PRIMARY KEY(config_id),
|
||||||
|
avg_traffic INTEGER DEFAULT NULL,
|
||||||
|
peak_sustainable_traffic INTEGER DEFAULT NULL,
|
||||||
|
broke_my_site_traffic INT DEFAULT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT `fk_mcaptcha_sitekey_user_provided_avg_trafic_config_id`
|
||||||
|
FOREIGN KEY (config_id)
|
||||||
|
REFERENCES mcaptcha_config (config_id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
);
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE mcaptcha_sitekey_user_provided_avg_traffic
|
||||||
|
MODIFY avg_traffic INTEGER NOT NULL,
|
||||||
|
MODIFY peak_sustainable_traffic INTEGER NOT NULL;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- Add migration script here
|
||||||
|
ALTER TABLE mcaptcha_notifications MODIFY heading varchar(100) NOT NULL;
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS mcaptcha_pow_analytics (
|
||||||
|
ID INT auto_increment,
|
||||||
|
PRIMARY KEY(ID),
|
||||||
|
config_id INTEGER NOT NULL,
|
||||||
|
time INTEGER NOT NULL,
|
||||||
|
difficulty_factor INTEGER NOT NULL,
|
||||||
|
worker_type VARCHAR(100) NOT NULL,
|
||||||
|
CONSTRAINT `fk_mcaptcha_config_id_pow_analytics`
|
||||||
|
FOREIGN KEY (config_id)
|
||||||
|
REFERENCES mcaptcha_config (config_id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
);
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS mcaptcha_psuedo_campaign_id (
|
||||||
|
ID INT auto_increment,
|
||||||
|
PRIMARY KEY(ID),
|
||||||
|
psuedo_id varchar(100) NOT NULL UNIQUE,
|
||||||
|
config_id INT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT `fk_mcaptcha_psuedo_campaign_id_config_id`
|
||||||
|
FOREIGN KEY (config_id)
|
||||||
|
REFERENCES mcaptcha_config (config_id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
|
||||||
|
);
|
||||||
1040
db/db-sqlx-maria/sqlx-data.json
Normal file
1040
db/db-sqlx-maria/sqlx-data.json
Normal file
File diff suppressed because it is too large
Load Diff
55
db/db-sqlx-maria/src/errors.rs
Normal file
55
db/db-sqlx-maria/src/errors.rs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! Error-handling utilities
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use db_core::dev::*;
|
||||||
|
use sqlx::Error;
|
||||||
|
|
||||||
|
/// map custom row not found error to DB error
|
||||||
|
pub fn map_row_not_found_err(e: Error, row_not_found: DBError) -> DBError {
|
||||||
|
if let Error::RowNotFound = e {
|
||||||
|
row_not_found
|
||||||
|
} else {
|
||||||
|
map_register_err(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// map postgres errors to [DBError](DBError) types
|
||||||
|
pub fn map_register_err(e: Error) -> DBError {
|
||||||
|
if let Error::Database(err) = e {
|
||||||
|
if err.code() == Some(Cow::from("23000")) {
|
||||||
|
let msg = err.message();
|
||||||
|
if msg.contains("for key 'name'") {
|
||||||
|
DBError::UsernameTaken
|
||||||
|
} else if msg.contains("for key 'email'") {
|
||||||
|
DBError::EmailTaken
|
||||||
|
} else if msg.contains("for key 'secret'") {
|
||||||
|
DBError::SecretTaken
|
||||||
|
} else if msg.contains("for key 'captcha_key'") {
|
||||||
|
DBError::CaptchaKeyTaken
|
||||||
|
} else {
|
||||||
|
DBError::DBError(Box::new(Error::Database(err)))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBError::DBError(Box::new(Error::Database(err)))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBError::DBError(Box::new(e))
|
||||||
|
}
|
||||||
|
}
|
||||||
24
db/db-sqlx-maria/src/get_all_unread_notifications.sql
Normal file
24
db/db-sqlx-maria/src/get_all_unread_notifications.sql
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
-- gets all unread notifications a user has
|
||||||
|
SELECT
|
||||||
|
mcaptcha_notifications.id,
|
||||||
|
mcaptcha_notifications.heading,
|
||||||
|
mcaptcha_notifications.message,
|
||||||
|
mcaptcha_notifications.received,
|
||||||
|
mcaptcha_users.name
|
||||||
|
FROM
|
||||||
|
mcaptcha_notifications
|
||||||
|
INNER JOIN
|
||||||
|
mcaptcha_users
|
||||||
|
ON
|
||||||
|
mcaptcha_notifications.tx = mcaptcha_users.id
|
||||||
|
WHERE
|
||||||
|
mcaptcha_notifications.rx = (
|
||||||
|
SELECT
|
||||||
|
id
|
||||||
|
FROM
|
||||||
|
mcaptcha_users
|
||||||
|
WHERE
|
||||||
|
name = ?
|
||||||
|
)
|
||||||
|
AND
|
||||||
|
mcaptcha_notifications.read_notification IS NULL;
|
||||||
1148
db/db-sqlx-maria/src/lib.rs
Normal file
1148
db/db-sqlx-maria/src/lib.rs
Normal file
File diff suppressed because it is too large
Load Diff
14
db/db-sqlx-maria/src/mark_notification_read.sql
Normal file
14
db/db-sqlx-maria/src/mark_notification_read.sql
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
-- mark a notification as read
|
||||||
|
UPDATE mcaptcha_notifications
|
||||||
|
SET read_notification = TRUE
|
||||||
|
WHERE
|
||||||
|
mcaptcha_notifications.id = ?
|
||||||
|
AND
|
||||||
|
mcaptcha_notifications.rx = (
|
||||||
|
SELECT
|
||||||
|
id
|
||||||
|
FROM
|
||||||
|
mcaptcha_users
|
||||||
|
WHERE
|
||||||
|
name = ?
|
||||||
|
);
|
||||||
92
db/db-sqlx-maria/src/tests.rs
Normal file
92
db/db-sqlx-maria/src/tests.rs
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#![cfg(test)]
|
||||||
|
|
||||||
|
use sqlx::mysql::MySqlPoolOptions;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
use crate::*;
|
||||||
|
|
||||||
|
use db_core::tests::*;
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn everyting_works() {
|
||||||
|
const EMAIL: &str = "mariadbuser@foo.com";
|
||||||
|
const NAME: &str = "mariadbuser";
|
||||||
|
const PASSWORD: &str = "pasdfasdfasdfadf";
|
||||||
|
const SECRET1: &str = "mariadbsecret1";
|
||||||
|
// captcha config
|
||||||
|
const CAPTCHA_SECRET: &str = "mariadbcaptchasecret";
|
||||||
|
const CAPTCHA_DESCRIPTION: &str = "mariadbcaptchadescription";
|
||||||
|
const CAPTCHA_DURATION: i32 = 30;
|
||||||
|
// notification config
|
||||||
|
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,
|
||||||
|
message: MESSAGE,
|
||||||
|
heading: HEADING,
|
||||||
|
};
|
||||||
|
|
||||||
|
let url = env::var("MARIA_DATABASE_URL").unwrap();
|
||||||
|
let pool_options = MySqlPoolOptions::new().max_connections(2);
|
||||||
|
let connection_options = ConnectionOptions::Fresh(Fresh {
|
||||||
|
pool_options,
|
||||||
|
url,
|
||||||
|
disable_logging: false,
|
||||||
|
});
|
||||||
|
let db = connection_options.connect().await.unwrap();
|
||||||
|
|
||||||
|
db.migrate().await.unwrap();
|
||||||
|
let p = Register {
|
||||||
|
username: NAME,
|
||||||
|
email: Some(EMAIL),
|
||||||
|
hash: PASSWORD,
|
||||||
|
secret: SECRET1,
|
||||||
|
};
|
||||||
|
|
||||||
|
let c = CreateCaptcha {
|
||||||
|
duration: CAPTCHA_DURATION,
|
||||||
|
key: CAPTCHA_SECRET,
|
||||||
|
description: CAPTCHA_DESCRIPTION,
|
||||||
|
};
|
||||||
|
database_works(&db, &p, &c, &LEVELS, &TRAFFIC_PATTERN, &ADD_NOTIFICATION).await;
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT name, password FROM mcaptcha_users WHERE email = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "password",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Blob",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4113
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 262140
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "ed943cbf7e16536d81010255ce2f5beb207b2b9d44cb859fa9f2233405b80ae0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"query": "INSERT INTO mcaptcha_users \n (name , password, secret) VALUES (?, ?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 3
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "5d5a106981345e9f62bc2239c00cdc683d3aaaa820d63da300dc51e3f6f363d3"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,39 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT name, password FROM mcaptcha_users WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "password",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Blob",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4113
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 262140
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "dd5ff10b88fa6f374e105b6bed9e34e0870ac8dd7ce36dfb09d13a1b7005b2eb"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,65 @@
|
|||||||
|
{
|
||||||
|
"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": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 2,
|
||||||
|
"name": "config_id",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 515
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 3,
|
||||||
|
"name": "duration",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 1
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "3812693a9ae4402d900bcbf680981e6194073bd1937af11a77daa3776fb4c873"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"query": "UPDATE mcaptcha_users set email = ?\n WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "9cb416de904872d66af90baa0024f382ce6f8344464c607fe6e6c2572816dfc2"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,11 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"query": "UPDATE mcaptcha_users set password = ?\n WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "cad5b403470f26c565e74a1dca19b7dee066141dec0f708070067e34d5bf72cc"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"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": {
|
||||||
|
"bits": 515
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "66ec7df10484f8e0206f3c97afc9136021589556c38dbbed341d6574487f79f2"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT duration FROM mcaptcha_config \n where captcha_key= ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "duration",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 1
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "8acbf84d4801e86221d8f6324ae50488a0986182d66b20ad414bce4e2ac18eca"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"query": "UPDATE mcaptcha_users set name = ?\n WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "676a9f1761c3b63cf16d7d4dd6261507cc7707feb32d458f4b946ed9caa53721"
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"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": {
|
||||||
|
"bits": 515
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "duration",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 1
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 2,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 3,
|
||||||
|
"name": "captcha_key",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "9c435148ed5655e79dd1e73e3566ce23b7c6d38edcedbb988c95813c5da893ed"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,39 @@
|
|||||||
|
{
|
||||||
|
"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": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "visitor_threshold",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "df6de3b96afcfb7f364f98954995e506b19e80e7f88204405d970c360ad5e1a0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,11 @@
|
|||||||
|
{
|
||||||
|
"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,11 @@
|
|||||||
|
{
|
||||||
|
"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,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT email FROM mcaptcha_users WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "email",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
true
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "413ea53cea8b8f114fc009bad527b054a68a94477dfcc50d860d45bbd864d4f1"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"query": "UPDATE mcaptcha_users set secret = ?\n WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "7838ade4a48068e25c6f117ee8e38f088b867b1ab08a7dd0269b76891266ace6"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT name from mcaptcha_users WHERE email = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "caa1638ee510ef62b86817e5d2baeaca8dfa432c23d7630c0e70737211a4680b"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"query": "UPDATE mcaptcha_users set email = ?\n WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "9cb416de904872d66af90baa0024f382ce6f8344464c607fe6e6c2572816dfc2"
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"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": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "visitor_threshold",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "6d43e6ceb54a0ff8a803bd96dd9134b15da01d48776ac0cf3d66a2997dadce5e"
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
{
|
||||||
|
"query": "-- 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": {
|
||||||
|
"bits": 515
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "heading",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 2,
|
||||||
|
"name": "message",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 1000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 3,
|
||||||
|
"name": "received",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Timestamp",
|
||||||
|
"flags": {
|
||||||
|
"bits": 1185
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 19
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 4,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "b9b0c63380bc0dfdea8aae092dcefceb316fe94667d74f53d53063810cdd2ba8"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,11 @@
|
|||||||
|
{
|
||||||
|
"query": "DELETE FROM mcaptcha_users WHERE name = (?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "6d1b6e5e58ca2ba285cab7b050bbdc43de1f3e46cf7d420bc95c124a1c7c9d1f"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,11 @@
|
|||||||
|
{
|
||||||
|
"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,11 @@
|
|||||||
|
{
|
||||||
|
"query": "-- 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": "cf333541509213f11a9bf7119dcb3289bb77abf1482fc1d47e7f5bb27bdc8d97"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,11 @@
|
|||||||
|
{
|
||||||
|
"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,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT email FROM mcaptcha_users WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "email",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
true
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "413ea53cea8b8f114fc009bad527b054a68a94477dfcc50d860d45bbd864d4f1"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT duration FROM mcaptcha_config \n where captcha_key= ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "duration",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 1
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "8acbf84d4801e86221d8f6324ae50488a0986182d66b20ad414bce4e2ac18eca"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"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": {
|
||||||
|
"bits": 1185
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 19
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "daac5e937aeac2f106eb89154b431fa8bd1bd7baa95e51704fdcdf50bd970a1d"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT secret FROM mcaptcha_users WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "secret",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "dd9b4dec39405ff19af21faabb6a7c3bb3207e7e785fe15357146b88c6c27f01"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"query": "insert into mcaptcha_users \n (name , password, email, secret) values (?, ?, ?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 4
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "8ec8bbde0c02a99f74d12e6778f123a973283e6d56b6861b30f559768617848a"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,11 @@
|
|||||||
|
{
|
||||||
|
"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,11 @@
|
|||||||
|
{
|
||||||
|
"query": "UPDATE mcaptcha_users set password = ?\n WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "cad5b403470f26c565e74a1dca19b7dee066141dec0f708070067e34d5bf72cc"
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"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": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "visitor_threshold",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "df6de3b96afcfb7f364f98954995e506b19e80e7f88204405d970c360ad5e1a0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"query": "UPDATE mcaptcha_users set secret = ?\n WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "7838ade4a48068e25c6f117ee8e38f088b867b1ab08a7dd0269b76891266ace6"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT config_id from mcaptcha_config WHERE captcha_key = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "config_id",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 515
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "a89c066db044cddfdebee6a0fd0d80a5a26dcb7ecc00a9899f5634b72ea0a952"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"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": {
|
||||||
|
"bits": 515
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "66ec7df10484f8e0206f3c97afc9136021589556c38dbbed341d6574487f79f2"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,39 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT name, password FROM mcaptcha_users WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "password",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Blob",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4113
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 262140
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "dd5ff10b88fa6f374e105b6bed9e34e0870ac8dd7ce36dfb09d13a1b7005b2eb"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"query": "INSERT INTO mcaptcha_users \n (name , password, secret) VALUES (?, ?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 3
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "5d5a106981345e9f62bc2239c00cdc683d3aaaa820d63da300dc51e3f6f363d3"
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT name, password FROM mcaptcha_users WHERE email = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "password",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Blob",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4113
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 262140
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "ed943cbf7e16536d81010255ce2f5beb207b2b9d44cb859fa9f2233405b80ae0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT name from mcaptcha_users WHERE email = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "caa1638ee510ef62b86817e5d2baeaca8dfa432c23d7630c0e70737211a4680b"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"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": {
|
||||||
|
"bits": 1185
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 19
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "1367dceb151a766a901b5dd771d0b75d0bc61d2fef17a94a90c8ffa0065e2c44"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT config_id from mcaptcha_config WHERE captcha_key = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "config_id",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 515
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "a89c066db044cddfdebee6a0fd0d80a5a26dcb7ecc00a9899f5634b72ea0a952"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT name from mcaptcha_users WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "e6569a6064d0e07abea4c0bd4686cdfdaac64f0109ac40efaed06a744a2eaf5e"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT config_id from mcaptcha_config WHERE captcha_key = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "config_id",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 515
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "a89c066db044cddfdebee6a0fd0d80a5a26dcb7ecc00a9899f5634b72ea0a952"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
{
|
||||||
|
"query": "-- 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": {
|
||||||
|
"bits": 515
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "heading",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 2,
|
||||||
|
"name": "message",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 1000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 3,
|
||||||
|
"name": "received",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Timestamp",
|
||||||
|
"flags": {
|
||||||
|
"bits": 1185
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 19
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 4,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "b9b0c63380bc0dfdea8aae092dcefceb316fe94667d74f53d53063810cdd2ba8"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT secret FROM mcaptcha_users WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "secret",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "dd9b4dec39405ff19af21faabb6a7c3bb3207e7e785fe15357146b88c6c27f01"
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"query": "SELECT name from mcaptcha_users WHERE name = ?",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "name",
|
||||||
|
"type_info": {
|
||||||
|
"type": "VarString",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4101
|
||||||
|
},
|
||||||
|
"char_set": 224,
|
||||||
|
"max_size": 400
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "e6569a6064d0e07abea4c0bd4686cdfdaac64f0109ac40efaed06a744a2eaf5e"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"query": "DELETE FROM mcaptcha_users WHERE name = (?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "6d1b6e5e58ca2ba285cab7b050bbdc43de1f3e46cf7d420bc95c124a1c7c9d1f"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"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,26 @@
|
|||||||
|
{
|
||||||
|
"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": {
|
||||||
|
"bits": 1185
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 19
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "d4b92e8099cd29cfdb99aadeeada739bb6858667fc65f528ec484e98a9da21bc"
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"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": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "peak_sustainable_traffic",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 4097
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 2,
|
||||||
|
"name": "broke_my_site_traffic",
|
||||||
|
"type_info": {
|
||||||
|
"type": "Long",
|
||||||
|
"flags": {
|
||||||
|
"bits": 0
|
||||||
|
},
|
||||||
|
"char_set": 63,
|
||||||
|
"max_size": 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "e91116ebce127833488130cf1060e0817e5677f39588632452b8d621688c405a"
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user