mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
Compare commits
64 Commits
wip-publis
...
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 |
4
.github/workflows/coverage.yml
vendored
4
.github/workflows/coverage.yml
vendored
@@ -52,7 +52,7 @@ jobs:
|
||||
|
||||
|
||||
maria:
|
||||
image: mariadb
|
||||
image: mariadb:10
|
||||
env:
|
||||
MARIADB_USER: "maria"
|
||||
MARIADB_PASSWORD: "password"
|
||||
@@ -103,7 +103,7 @@ jobs:
|
||||
run: make frontend
|
||||
|
||||
- name: Run the frontend tests
|
||||
run: make frontend-test
|
||||
run: make test.frontend
|
||||
|
||||
- name: Run migrations
|
||||
run: make migrate
|
||||
|
||||
10
.github/workflows/linux.yml
vendored
10
.github/workflows/linux.yml
vendored
@@ -54,7 +54,7 @@ jobs:
|
||||
- 10025:1025
|
||||
|
||||
maria:
|
||||
image: mariadb
|
||||
image: mariadb:10
|
||||
env:
|
||||
MARIADB_USER: "maria"
|
||||
MARIADB_PASSWORD: "password"
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: configure GPG key
|
||||
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/dumbserve'
|
||||
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 }}
|
||||
@@ -104,6 +104,9 @@ jobs:
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: install nightwatch dep
|
||||
run: sudo apt-get install xvfb
|
||||
|
||||
- name: Run migrations
|
||||
run: make migrate
|
||||
env:
|
||||
@@ -128,6 +131,9 @@ jobs:
|
||||
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
|
||||
|
||||
207
Cargo.lock
generated
207
Cargo.lock
generated
@@ -376,13 +376,19 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arc-swap"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6"
|
||||
|
||||
[[package]]
|
||||
name = "argon2-creds"
|
||||
version = "0.2.2"
|
||||
source = "git+https://github.com/realaravinth/argon2-creds?branch=master#9f43fd564448cae609d148a700de91e2aea6474c"
|
||||
dependencies = [
|
||||
"ammonia",
|
||||
"derive_builder 0.11.1",
|
||||
"derive_builder",
|
||||
"derive_more",
|
||||
"lazy_static",
|
||||
"rand",
|
||||
@@ -597,7 +603,7 @@ version = "0.2.0"
|
||||
source = "git+https://github.com/realaravinth/cache-buster#7ca4545722fb99be30698a5e72c7d982a70fa11f"
|
||||
dependencies = [
|
||||
"data-encoding",
|
||||
"derive_builder 0.11.1",
|
||||
"derive_builder",
|
||||
"mime",
|
||||
"mime_guess",
|
||||
"serde 1.0.143",
|
||||
@@ -879,6 +885,7 @@ dependencies = [
|
||||
"futures",
|
||||
"sqlx",
|
||||
"url",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -891,6 +898,7 @@ dependencies = [
|
||||
"futures",
|
||||
"sqlx",
|
||||
"url",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -904,34 +912,13 @@ dependencies = [
|
||||
"pem-rfc7468",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d13202debe11181040ae9063d739fa32cfcaaebe2275fe387703460ae2365b30"
|
||||
dependencies = [
|
||||
"derive_builder_macro 0.10.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11d918e7dabe374a51dae0f29d818fece3b218b8b4eabec3bc4d42c537e7ed8f"
|
||||
dependencies = [
|
||||
"derive_builder_macro 0.11.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder_core"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"derive_builder_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -946,23 +933,13 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder_macro"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73"
|
||||
dependencies = [
|
||||
"derive_builder_core 0.10.2",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder_macro"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8a2ac71b4a9a590dde6cee3ca4687aca5e7ce06f4ee297c5a959de5f1e42b2e"
|
||||
dependencies = [
|
||||
"derive_builder_core 0.11.1",
|
||||
"derive_builder_core",
|
||||
"syn",
|
||||
]
|
||||
|
||||
@@ -1108,7 +1085,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"windows-sys",
|
||||
"windows-sys 0.36.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1593,9 +1570,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.129"
|
||||
version = "0.2.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64de3cc433455c14174d42e554d4027ee631c4d046d43e3ecc6efc4636cdc7a7"
|
||||
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
@@ -1605,12 +1582,12 @@ checksum = "292a948cd991e376cf75541fe5b97a1081d713c618b4f1b9500f8844e49eb565"
|
||||
|
||||
[[package]]
|
||||
name = "libmcaptcha"
|
||||
version = "0.2.2"
|
||||
source = "git+https://github.com/mCaptcha/libmcaptcha?branch=master#4efe8cdfee94766dd85647ad6f1ecc1b486b40a7"
|
||||
version = "0.2.3"
|
||||
source = "git+https://github.com/mCaptcha/libmcaptcha?tag=0.2.3#6bc0d11f8839d18c4d930cac0c0b86505ed1b2f6"
|
||||
dependencies = [
|
||||
"actix",
|
||||
"crossbeam-channel",
|
||||
"derive_builder 0.10.2",
|
||||
"derive_builder",
|
||||
"derive_more",
|
||||
"log",
|
||||
"num_cpus",
|
||||
@@ -1725,7 +1702,7 @@ dependencies = [
|
||||
"db-core",
|
||||
"db-sqlx-maria",
|
||||
"db-sqlx-postgres",
|
||||
"derive_builder 0.11.1",
|
||||
"derive_builder",
|
||||
"derive_more",
|
||||
"futures",
|
||||
"lazy_static",
|
||||
@@ -1747,6 +1724,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"url",
|
||||
"urlencoding",
|
||||
"uuid",
|
||||
"validator",
|
||||
]
|
||||
|
||||
@@ -1805,7 +1783,7 @@ dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"windows-sys",
|
||||
"windows-sys 0.36.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2002,9 +1980,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.41"
|
||||
version = "0.10.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0"
|
||||
checksum = "518915b97df115dd36109bfa429a48b8f737bd05508cf9588977b599648926d2"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
@@ -2043,9 +2021,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.75"
|
||||
version = "0.9.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f"
|
||||
checksum = "666416d899cf077260dac8698d60a60b435a46d57e82acb1be3d0dad87284e5b"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cc",
|
||||
@@ -2100,7 +2078,7 @@ dependencies = [
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-sys",
|
||||
"windows-sys 0.36.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2220,7 +2198,7 @@ version = "0.3.1"
|
||||
source = "git+https://github.com/mcaptcha/pow_sha256?tag=0.3.1#3b4e28706a8946987ba02f98e1f816d9fa156dad"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"derive_builder 0.11.1",
|
||||
"derive_builder",
|
||||
"num",
|
||||
"serde 1.0.143",
|
||||
"sha2 0.10.2",
|
||||
@@ -2229,10 +2207,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "pow_sha256"
|
||||
version = "0.3.1"
|
||||
source = "git+https://github.com/mcaptcha/pow_sha256#3b4e28706a8946987ba02f98e1f816d9fa156dad"
|
||||
source = "git+https://github.com/mcaptcha/pow_sha256#148f1cb70d19114d1340661a77b2b679e95715f6"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"derive_builder 0.11.1",
|
||||
"derive_builder",
|
||||
"num",
|
||||
"serde 1.0.143",
|
||||
"sha2 0.10.2",
|
||||
@@ -2320,6 +2298,17 @@ version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fee2dce59f7a43418e3382c766554c614e06a552d53a8f07ef499ea4b332c0f"
|
||||
|
||||
[[package]]
|
||||
name = "r2d2"
|
||||
version = "0.8.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51de85fb3fb6524929c8a2eb85e6b6d363de4e8c48f9e2c2eac4944abc181c93"
|
||||
dependencies = [
|
||||
"log",
|
||||
"parking_lot 0.12.1",
|
||||
"scheduled-thread-pool",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
@@ -2356,15 +2345,18 @@ version = "0.21.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a80b5f38d7f5a020856a0e16e40a9cfabf88ae8f0e4c2dcd8a3114c1e470852"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"combine",
|
||||
"crc16",
|
||||
"dtoa",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"itoa 0.4.8",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"r2d2",
|
||||
"rand",
|
||||
"sha1 0.6.1",
|
||||
"tokio",
|
||||
@@ -2596,7 +2588,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"windows-sys",
|
||||
"windows-sys 0.36.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scheduled-thread-pool"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3cbc66816425a074528352f5789333ecff06ca41b36b0b0efdfbb29edc391a19"
|
||||
dependencies = [
|
||||
"parking_lot 0.12.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2813,9 +2814,9 @@ checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.4.4"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"
|
||||
checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
@@ -3199,22 +3200,20 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.20.1"
|
||||
version = "1.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581"
|
||||
checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"bytes",
|
||||
"libc",
|
||||
"memchr",
|
||||
"mio",
|
||||
"num_cpus",
|
||||
"once_cell",
|
||||
"parking_lot 0.12.1",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"winapi",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3386,9 +3385,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "urlencoding"
|
||||
version = "2.1.0"
|
||||
version = "2.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68b90931029ab9b034b300b797048cf23723400aa757e8a2bfb9d748102f9821"
|
||||
checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9"
|
||||
|
||||
[[package]]
|
||||
name = "utf-8"
|
||||
@@ -3396,6 +3395,16 @@ version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"serde 1.0.143",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "validator"
|
||||
version = "0.15.0"
|
||||
@@ -3597,43 +3606,109 @@ version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
|
||||
dependencies = [
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_msvc",
|
||||
"windows_aarch64_msvc 0.36.1",
|
||||
"windows_i686_gnu 0.36.1",
|
||||
"windows_i686_msvc 0.36.1",
|
||||
"windows_x86_64_gnu 0.36.1",
|
||||
"windows_x86_64_msvc 0.36.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.45.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc 0.42.2",
|
||||
"windows_i686_gnu 0.42.2",
|
||||
"windows_i686_msvc 0.42.2",
|
||||
"windows_x86_64_gnu 0.42.2",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc 0.42.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
|
||||
|
||||
[[package]]
|
||||
name = "yaml-rust"
|
||||
version = "0.4.5"
|
||||
|
||||
@@ -59,8 +59,8 @@ log = "0.4"
|
||||
lazy_static = "1.4"
|
||||
|
||||
|
||||
#libmcaptcha = { version = "0.2.2", git = "https://github.com/mCaptcha/libmcaptcha", features = ["full"], tag ="0.2.2" }
|
||||
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"]}
|
||||
|
||||
rand = "0.8"
|
||||
@@ -78,7 +78,8 @@ lettre = { version = "0.10.0-rc.3", features = [
|
||||
"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]
|
||||
|
||||
@@ -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/utils/cache-bust/target /src/utils/cache-bust/target
|
||||
COPY --from=frontend /src/static/cache/bundle/ /src/static/cache/bundle/
|
||||
COPY --from=frontend /src/docs/openapi/dist/ /src/docs/openapi/dist/
|
||||
RUN cargo --version
|
||||
RUN make cache-bust
|
||||
RUN cargo build --release
|
||||
|
||||
132
Makefile
132
Makefile
@@ -2,6 +2,39 @@ BUNDLE = static/cache/bundle
|
||||
OPENAPI = docs/openapi
|
||||
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
|
||||
yarn install
|
||||
cd docs/openapi && yarn install
|
||||
@@ -11,6 +44,30 @@ define cache_bust ## run cache_busting program
|
||||
cd utils/cache-bust && cargo run
|
||||
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
|
||||
$(call cache_bust)
|
||||
cargo build
|
||||
@@ -35,10 +92,6 @@ clean: ## Delete build artifacts
|
||||
@yarn cache clean
|
||||
@-rm $(CLEAN_UP)
|
||||
|
||||
coverage: migrate ## Generate code coverage report in HTML format
|
||||
$(call cache_bust)
|
||||
cargo tarpaulin -t 1200 --out Html
|
||||
|
||||
doc: ## Generate documentation
|
||||
#yarn doc
|
||||
cargo doc --no-deps --workspace --all-features
|
||||
@@ -54,6 +107,19 @@ env: ## Setup development environtment
|
||||
cargo fetch
|
||||
$(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
|
||||
$(call frontend_env)
|
||||
|
||||
@@ -76,10 +142,6 @@ frontend: ## Build frontend
|
||||
@./scripts/librejs.sh
|
||||
@./scripts/cachebust.sh
|
||||
|
||||
frontend-test: ## Run frontend tests
|
||||
cd $(OPENAPI)&& yarn test
|
||||
yarn test
|
||||
|
||||
lint: ## Lint codebase
|
||||
cargo fmt -v --all -- --emit files
|
||||
cargo clippy --workspace --tests --all-features
|
||||
@@ -87,7 +149,10 @@ lint: ## Lint codebase
|
||||
cd $(OPENAPI)&& yarn test
|
||||
|
||||
migrate: ## Run database migrations
|
||||
cd db/db-migrations/ && cargo run
|
||||
$(call run_migrations)
|
||||
|
||||
migrate.dev: ## Run database migrations during development
|
||||
$(call run_dev_migrations)
|
||||
|
||||
release: frontend ## Build app with release optimizations
|
||||
$(call cache_bust)
|
||||
@@ -98,34 +163,49 @@ run: frontend ## Run app in debug mode
|
||||
cargo run
|
||||
|
||||
|
||||
sqlx-offline-data: ## prepare sqlx offline data
|
||||
db.sqlx.offline: ## prepare sqlx offline data
|
||||
cd db/db-sqlx-postgres && cargo sqlx prepare \
|
||||
--database-url=${POSTGRES_DATABASE_URL} -- \
|
||||
--all-features
|
||||
cd db/db-sqlx-maria && cargo sqlx prepare \
|
||||
--database-url=${MARIA_DATABASE_URL} -- \
|
||||
--all-features
|
||||
# cd db/db-sqlx-sqlite/ \
|
||||
# && DATABASE_URL=${SQLITE_DATABASE_URL} cargo sqlx prepare
|
||||
|
||||
test-db: ## run tests on database
|
||||
cd db/db-sqlx-postgres &&\
|
||||
DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
||||
cargo test --no-fail-fast
|
||||
test: frontend-test frontend ## Run all available tests
|
||||
test: frontend ## Run all available tests
|
||||
$(call test_frontend)
|
||||
$(call cache_bust)
|
||||
cd db/db-sqlx-postgres &&\
|
||||
DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
||||
cargo test --no-fail-fast
|
||||
cd db/db-sqlx-maria &&\
|
||||
DATABASE_URL=${MARIA_DATABASE_URL}\
|
||||
cargo test --no-fail-fast
|
||||
cargo test --no-fail-fast
|
||||
$(call test_db_sqlx_postgres)
|
||||
$(call test_db_sqlx_maria)
|
||||
$(call test_core)
|
||||
# ./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)
|
||||
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
|
||||
@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}'
|
||||
|
||||
61
README.md
61
README.md
@@ -32,18 +32,18 @@ yourself!](https://demo.mcaptcha.org/widget/?sitekey=pHy0AktWyOKuxZDzFfoaewncWec
|
||||
|
||||
## How does it work?
|
||||
|
||||
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.
|
||||
|
||||
2. We'll validate the proof:
|
||||
|
||||
- **if validation is unsuccessful**, they will be prevented from
|
||||
accessing their target website
|
||||
- **if validation is successful**, read on,
|
||||
- **if validation is unsuccessful**, they will be prevented from
|
||||
accessing their target website
|
||||
- **if validation is successful**, read on,
|
||||
|
||||
3. They will be issued a token that they should submit along
|
||||
with their request/form submission to the target website.
|
||||
@@ -54,8 +54,8 @@ When a user wants to do something on an mCaptcha-protected website,
|
||||
The whole process is automated from the user's POV. All they have to do
|
||||
is click on a button to initiate the process.
|
||||
|
||||
mCaptcha makes interacting with websites (computationally)expensive for
|
||||
the user. A well-behaving user will experience a slight delay(no delay
|
||||
mCaptcha makes interacting with websites (computationally) expensive for
|
||||
the user. A well-behaving user will experience a slight delay (no delay
|
||||
when under moderate load to 2s when under attack; PoW difficulty is
|
||||
variable) but if someone wants to hammer your site, they will have to do
|
||||
more work to send requests than your server will have to do to respond
|
||||
@@ -63,14 +63,14 @@ to their request.
|
||||
|
||||
## Why use mCaptcha?
|
||||
|
||||
- [x] **Free software, privacy focused**
|
||||
- [x] **Seamless UX** - No more annoying CAPTCHAs!
|
||||
- [x] **No tracking:** Our CAPTCHA routes are cookie free!
|
||||
- [x] **IP address independent:** your users are behind a NAT? We got you covered!
|
||||
- [x] **Resistant to replay attacks:** proof-of-work configurations have
|
||||
short lifetimes(30s) and can be used only once. If a user submits a
|
||||
PoW to an already used configuration or an expired one, their proof
|
||||
will be rejected.
|
||||
- [x] **Free software, privacy focused**
|
||||
- [x] **Seamless UX** - No more annoying CAPTCHAs!
|
||||
- [x] **No tracking:** Our CAPTCHA routes are cookie free!
|
||||
- [x] **IP address independent:** your users are behind a NAT? We got you covered!
|
||||
- [x] **Resistant to replay attacks:** proof-of-work configurations have
|
||||
short lifetimes (30s) and can be used only once. If a user submits a
|
||||
PoW to an already used configuration or an expired one, their proof
|
||||
will be rejected.
|
||||
|
||||
## Demo
|
||||
|
||||
@@ -87,15 +87,15 @@ monitor console and network activity.
|
||||
|
||||
### Demo servers are available at:
|
||||
|
||||
- https://demo.mcaptcha.org/
|
||||
- https://demo2.mcaptcha.org/ (runs on a Raspberry Pi!)
|
||||
- https://demo.mcaptcha.org/
|
||||
- https://demo2.mcaptcha.org/ (runs on a Raspberry Pi!)
|
||||
|
||||
> Core functionality is working but it's still very much
|
||||
> work-in-progress. Since we don't have a stable release yet, hosted
|
||||
> demo servers might be a few versions behind `master`. Please check footer for
|
||||
> build commit.
|
||||
|
||||
Feel free to provide bogus information while signing up(project under
|
||||
Feel free to provide bogus information while signing up (project under
|
||||
development, database frequently wiped).
|
||||
|
||||
### Self-hosted:
|
||||
@@ -109,9 +109,8 @@ docker-compose up -d
|
||||
|
||||
After the containers are up, visit [http://localhost:7000](http://localhost:7000) and login with the default credentials:
|
||||
|
||||
- username: aaronsw
|
||||
- password: password
|
||||
|
||||
- username: aaronsw
|
||||
- password: password
|
||||
|
||||
It takes a while to build the image so please be patient :)
|
||||
|
||||
@@ -129,3 +128,21 @@ See [DEPLOYMENT.md](./docs/DEPLOYMENT.md)
|
||||
## Configuration:
|
||||
|
||||
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() {
|
||||
// note: add error checking yourself.
|
||||
let output = Command::new("git")
|
||||
.args(&["rev-parse", "HEAD"])
|
||||
.args(["rev-parse", "HEAD"])
|
||||
.output()
|
||||
.unwrap();
|
||||
let git_hash = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
@@ -13,8 +13,8 @@ async-trait = "0.1.51"
|
||||
thiserror = "1.0.30"
|
||||
serde = { version = "1", features = ["derive"]}
|
||||
url = { version = "2.2.2", features = ["serde"] }
|
||||
#libmcaptcha = { version = "0.2.2", git = "https://github.com/mCaptcha/libmcaptcha", features = ["minimal"], default-features = false, tag = "0.2.2"}
|
||||
libmcaptcha = { branch = "master", git = "https://github.com/mCaptcha/libmcaptcha", features = ["full"] }
|
||||
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]
|
||||
default = []
|
||||
|
||||
@@ -250,6 +250,81 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
||||
|
||||
/// fetch PoWConfig confirms
|
||||
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)]
|
||||
@@ -332,7 +407,6 @@ pub struct Secret {
|
||||
/// user's secret
|
||||
pub secret: String,
|
||||
}
|
||||
|
||||
/// Trait to clone MCDatabase
|
||||
pub trait CloneSPDatabase {
|
||||
/// clone DB
|
||||
|
||||
@@ -260,6 +260,60 @@ pub async fn database_works<'a, T: MCDatabase>(
|
||||
db.record_solve(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_config_fetched(p.username, c.key)
|
||||
|
||||
@@ -13,6 +13,7 @@ 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"
|
||||
|
||||
@@ -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
|
||||
|
||||
);
|
||||
@@ -25,6 +25,31 @@
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"14dc89b2988b221fd24e4f319b1d48f5e6c65c760c30d11c9c29087f09cee23a": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "captcha_key",
|
||||
"ordinal": 0,
|
||||
"type_info": {
|
||||
"char_set": 224,
|
||||
"flags": {
|
||||
"bits": 4101
|
||||
},
|
||||
"max_size": 400,
|
||||
"type": "VarString"
|
||||
}
|
||||
}
|
||||
],
|
||||
"nullable": [
|
||||
false
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
}
|
||||
},
|
||||
"query": "SELECT\n captcha_key\n FROM\n mcaptcha_config\n WHERE\n config_id = (\n SELECT\n config_id\n FROM\n mcaptcha_psuedo_campaign_id\n WHERE\n psuedo_id = ?\n );"
|
||||
},
|
||||
"22e697114c3ed5b0156cdceab11a398f1ef3a804f482e1cd948bc615ef95fc92": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
@@ -154,6 +179,31 @@
|
||||
},
|
||||
"query": "INSERT INTO mcaptcha_pow_fetched_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)"
|
||||
},
|
||||
"5ad1ef722a961183228d851813b9f50284520bf8cc8118c765b72c108daaf6fb": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "psuedo_id",
|
||||
"ordinal": 0,
|
||||
"type_info": {
|
||||
"char_set": 224,
|
||||
"flags": {
|
||||
"bits": 4101
|
||||
},
|
||||
"max_size": 400,
|
||||
"type": "VarString"
|
||||
}
|
||||
}
|
||||
],
|
||||
"nullable": [
|
||||
false
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
}
|
||||
},
|
||||
"query": "SELECT psuedo_id FROM\n mcaptcha_psuedo_campaign_id\n WHERE\n config_id = (SELECT config_id FROM mcaptcha_config WHERE captcha_key = (?));\n "
|
||||
},
|
||||
"5d5a106981345e9f62bc2239c00cdc683d3aaaa820d63da300dc51e3f6f363d3": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
@@ -164,6 +214,16 @@
|
||||
},
|
||||
"query": "INSERT INTO mcaptcha_users \n (name , password, secret) VALUES (?, ?, ?)"
|
||||
},
|
||||
"6094468b7fa20043b0da90e366b7f1fa29a8c748e163b6712725440b25ae9361": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
}
|
||||
},
|
||||
"query": "\n DELETE FROM\n mcaptcha_pow_analytics\n WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?\n ) "
|
||||
},
|
||||
"66ec7df10484f8e0206f3c97afc9136021589556c38dbbed341d6574487f79f2": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
@@ -406,6 +466,80 @@
|
||||
},
|
||||
"query": "UPDATE mcaptcha_users set email = ?\n WHERE name = ?"
|
||||
},
|
||||
"9e45969a0f79eab8caba41b0d91e5e3b85a1a68a49136f89fc90793c38f00041": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
}
|
||||
},
|
||||
"query": "\n INSERT INTO\n mcaptcha_psuedo_campaign_id (config_id, psuedo_id)\n VALUES (\n (SELECT config_id FROM mcaptcha_config WHERE captcha_key = (?)),\n ?\n );"
|
||||
},
|
||||
"9f10afb0f242f11c58389803c5e85e244cc59102b8929a21e3fcaa852d57a52c": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"ordinal": 0,
|
||||
"type_info": {
|
||||
"char_set": 63,
|
||||
"flags": {
|
||||
"bits": 515
|
||||
},
|
||||
"max_size": 11,
|
||||
"type": "Long"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "time",
|
||||
"ordinal": 1,
|
||||
"type_info": {
|
||||
"char_set": 63,
|
||||
"flags": {
|
||||
"bits": 4097
|
||||
},
|
||||
"max_size": 11,
|
||||
"type": "Long"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "difficulty_factor",
|
||||
"ordinal": 2,
|
||||
"type_info": {
|
||||
"char_set": 63,
|
||||
"flags": {
|
||||
"bits": 4097
|
||||
},
|
||||
"max_size": 11,
|
||||
"type": "Long"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "worker_type",
|
||||
"ordinal": 3,
|
||||
"type_info": {
|
||||
"char_set": 224,
|
||||
"flags": {
|
||||
"bits": 4097
|
||||
},
|
||||
"max_size": 400,
|
||||
"type": "VarString"
|
||||
}
|
||||
}
|
||||
],
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
],
|
||||
"parameters": {
|
||||
"Right": 3
|
||||
}
|
||||
},
|
||||
"query": "SELECT\n id, time, difficulty_factor, worker_type\n FROM\n mcaptcha_pow_analytics\n WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?\n ) \n ORDER BY ID\n LIMIT ? OFFSET ?"
|
||||
},
|
||||
"a89c066db044cddfdebee6a0fd0d80a5a26dcb7ecc00a9899f5634b72ea0a952": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
@@ -759,6 +893,16 @@
|
||||
},
|
||||
"query": "INSERT INTO mcaptcha_pow_solved_stats \n (config_id, time) VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?)"
|
||||
},
|
||||
"e4d9bf156a368dcee1433dd5ced9f1991aa15f84e0ade916433aada40f68f0aa": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
}
|
||||
},
|
||||
"query": "\n DELETE FROM\n mcaptcha_psuedo_campaign_id\n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?\n );"
|
||||
},
|
||||
"e6569a6064d0e07abea4c0bd4686cdfdaac64f0109ac40efaed06a744a2eaf5e": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
@@ -873,6 +1017,16 @@
|
||||
},
|
||||
"query": "SELECT name, password FROM mcaptcha_users WHERE email = ?"
|
||||
},
|
||||
"f987c4568ab28271d87af47f473b18cf41130a483333e81d5f50199758cbb98b": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Right": 4
|
||||
}
|
||||
},
|
||||
"query": "INSERT INTO mcaptcha_pow_analytics \n (config_id, time, difficulty_factor, worker_type)\n VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?, ?, ?)"
|
||||
},
|
||||
"fc717ff0827ccfaa1cc61a71cc7f71c348ebb03d35895c54b011c03121ad2385": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
|
||||
@@ -22,6 +22,7 @@ use sqlx::mysql::MySqlPoolOptions;
|
||||
use sqlx::types::time::OffsetDateTime;
|
||||
use sqlx::ConnectOptions;
|
||||
use sqlx::MySqlPool;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub mod errors;
|
||||
#[cfg(test)]
|
||||
@@ -73,9 +74,6 @@ impl Connect for ConnectionOptions {
|
||||
if fresh.disable_logging {
|
||||
connect_options.disable_statement_logging();
|
||||
}
|
||||
sqlx::mysql::MySqlConnectOptions::from_str(&fresh.url)
|
||||
.unwrap()
|
||||
.disable_statement_logging();
|
||||
fresh
|
||||
.pool_options
|
||||
.connect_with(connect_options)
|
||||
@@ -898,6 +896,191 @@ impl MCDatabase for Database {
|
||||
|
||||
Ok(Date::dates_to_unix(records))
|
||||
}
|
||||
|
||||
/// record PoW timing
|
||||
async fn analysis_save(
|
||||
&self,
|
||||
captcha_id: &str,
|
||||
d: &CreatePerformanceAnalytics,
|
||||
) -> DBResult<()> {
|
||||
let _ = sqlx::query!(
|
||||
"INSERT INTO mcaptcha_pow_analytics
|
||||
(config_id, time, difficulty_factor, worker_type)
|
||||
VALUES ((SELECT config_id FROM mcaptcha_config where captcha_key= ?), ?, ?, ?)",
|
||||
captcha_id,
|
||||
d.time as i32,
|
||||
d.difficulty_factor as i32,
|
||||
&d.worker_type,
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// fetch PoW analytics
|
||||
async fn analytics_fetch(
|
||||
&self,
|
||||
captcha_id: &str,
|
||||
limit: usize,
|
||||
offset: usize,
|
||||
) -> DBResult<Vec<PerformanceAnalytics>> {
|
||||
struct P {
|
||||
id: i32,
|
||||
time: i32,
|
||||
difficulty_factor: i32,
|
||||
worker_type: String,
|
||||
}
|
||||
|
||||
impl From<P> for PerformanceAnalytics {
|
||||
fn from(v: P) -> Self {
|
||||
Self {
|
||||
id: v.id as usize,
|
||||
time: v.time as u32,
|
||||
difficulty_factor: v.difficulty_factor as u32,
|
||||
worker_type: v.worker_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut c = sqlx::query_as!(
|
||||
P,
|
||||
"SELECT
|
||||
id, time, difficulty_factor, worker_type
|
||||
FROM
|
||||
mcaptcha_pow_analytics
|
||||
WHERE
|
||||
config_id = (
|
||||
SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?
|
||||
)
|
||||
ORDER BY ID
|
||||
LIMIT ? OFFSET ?",
|
||||
&captcha_id,
|
||||
limit as i64,
|
||||
offset as i64,
|
||||
)
|
||||
.fetch_all(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
let mut res = Vec::with_capacity(c.len());
|
||||
for i in c.drain(0..) {
|
||||
res.push(i.into())
|
||||
}
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
/// Create psuedo ID against campaign ID to publish analytics
|
||||
async fn analytics_create_psuedo_id_if_not_exists(
|
||||
&self,
|
||||
captcha_id: &str,
|
||||
) -> DBResult<()> {
|
||||
let id = Uuid::new_v4();
|
||||
sqlx::query!(
|
||||
"
|
||||
INSERT INTO
|
||||
mcaptcha_psuedo_campaign_id (config_id, psuedo_id)
|
||||
VALUES (
|
||||
(SELECT config_id FROM mcaptcha_config WHERE captcha_key = (?)),
|
||||
?
|
||||
);",
|
||||
captcha_id,
|
||||
&id.to_string(),
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get psuedo ID from campaign ID
|
||||
async fn analytics_get_psuedo_id_from_capmaign_id(
|
||||
&self,
|
||||
captcha_id: &str,
|
||||
) -> DBResult<String> {
|
||||
struct ID {
|
||||
psuedo_id: String,
|
||||
}
|
||||
|
||||
let res = sqlx::query_as!(
|
||||
ID,
|
||||
"SELECT psuedo_id FROM
|
||||
mcaptcha_psuedo_campaign_id
|
||||
WHERE
|
||||
config_id = (SELECT config_id FROM mcaptcha_config WHERE captcha_key = (?));
|
||||
",
|
||||
captcha_id
|
||||
).fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
|
||||
Ok(res.psuedo_id)
|
||||
}
|
||||
|
||||
/// Get campaign ID from psuedo ID
|
||||
async fn analytics_get_capmaign_id_from_psuedo_id(
|
||||
&self,
|
||||
psuedo_id: &str,
|
||||
) -> DBResult<String> {
|
||||
struct ID {
|
||||
captcha_key: String,
|
||||
}
|
||||
|
||||
let res = sqlx::query_as!(
|
||||
ID,
|
||||
"SELECT
|
||||
captcha_key
|
||||
FROM
|
||||
mcaptcha_config
|
||||
WHERE
|
||||
config_id = (
|
||||
SELECT
|
||||
config_id
|
||||
FROM
|
||||
mcaptcha_psuedo_campaign_id
|
||||
WHERE
|
||||
psuedo_id = ?
|
||||
);",
|
||||
psuedo_id
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
Ok(res.captcha_key)
|
||||
}
|
||||
|
||||
async fn analytics_delete_all_records_for_campaign(
|
||||
&self,
|
||||
campaign_id: &str,
|
||||
) -> DBResult<()> {
|
||||
let _ = sqlx::query!(
|
||||
"
|
||||
DELETE FROM
|
||||
mcaptcha_psuedo_campaign_id
|
||||
WHERE config_id = (
|
||||
SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?
|
||||
);",
|
||||
campaign_id
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await;
|
||||
|
||||
let _ = sqlx::query!(
|
||||
"
|
||||
DELETE FROM
|
||||
mcaptcha_pow_analytics
|
||||
WHERE
|
||||
config_id = (
|
||||
SELECT config_id FROM mcaptcha_config WHERE captcha_key = ?
|
||||
) ",
|
||||
campaign_id
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -13,6 +13,7 @@ async-trait = "0.1.51"
|
||||
db-core = {path = "../db-core"}
|
||||
futures = "0.3.15"
|
||||
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] }
|
||||
uuid = { version = "1.4.0", features = ["v4", "serde"] }
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "2"
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS mcaptcha_pow_analytics (
|
||||
config_id INTEGER references mcaptcha_config(config_id) ON DELETE CASCADE,
|
||||
time INTEGER NOT NULL,
|
||||
difficulty_factor INTEGER NOT NULL,
|
||||
worker_type VARCHAR(100) NOT NULL,
|
||||
ID SERIAL PRIMARY KEY NOT NULL
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS mcaptcha_psuedo_campaign_id (
|
||||
id SERIAL PRIMARY KEY NOT NULL,
|
||||
config_id INTEGER NOT NULL references mcaptcha_config(config_id) ON DELETE CASCADE,
|
||||
psuedo_id varchar(100) NOT NULL UNIQUE
|
||||
);
|
||||
@@ -1,5 +1,45 @@
|
||||
{
|
||||
"db": "PostgreSQL",
|
||||
"017576128f1c63aee062799a33f872457fe19f5d6429d0af312dc00c244b31cb": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"ordinal": 0,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "time",
|
||||
"ordinal": 1,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "difficulty_factor",
|
||||
"ordinal": 2,
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"name": "worker_type",
|
||||
"ordinal": 3,
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Int8",
|
||||
"Int8"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "SELECT id, time, difficulty_factor, worker_type FROM mcaptcha_pow_analytics\n WHERE \n config_id = (\n SELECT \n config_id FROM mcaptcha_config \n WHERE \n key = $1\n )\n ORDER BY ID\n OFFSET $2 LIMIT $3\n "
|
||||
},
|
||||
"02deb524bb12632af9b7883975f75fdc30d6775d836aff647add1dffd1a4bc00": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
@@ -132,6 +172,26 @@
|
||||
},
|
||||
"query": "UPDATE mcaptcha_users set name = $1\n WHERE name = $2"
|
||||
},
|
||||
"21cdf28d8962389d22c8ddefdad82780f5316737e3d833623512aa12a54a026a": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "key",
|
||||
"ordinal": 0,
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"nullable": [
|
||||
false
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "SELECT\n key\n FROM\n mcaptcha_config\n WHERE\n config_id = (\n SELECT\n config_id\n FROM\n mcaptcha_psuedo_campaign_id\n WHERE\n psuedo_id = $1\n );"
|
||||
},
|
||||
"2b319a202bb983d5f28979d1e371f399125da1122fbda36a5a55b75b9c743451": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
@@ -180,6 +240,18 @@
|
||||
},
|
||||
"query": "SELECT email FROM mcaptcha_users WHERE name = $1"
|
||||
},
|
||||
"30d8945806b4c68b6da800395f61c1e480839093bfcda9c693bf1972a65c7d79": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "\n DELETE FROM\n mcaptcha_psuedo_campaign_id\n WHERE config_id = (\n SELECT config_id FROM mcaptcha_config WHERE key = ($1)\n );"
|
||||
},
|
||||
"3b1c8128fc48b16d8e8ea6957dd4fbc0eb19ae64748fd7824e9f5e1901dd1726": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
@@ -406,6 +478,26 @@
|
||||
},
|
||||
"query": "INSERT INTO mcaptcha_users \n (name , password, secret) VALUES ($1, $2, $3)"
|
||||
},
|
||||
"839dfdfc3543b12128cb2b44bf356cd81f3da380963e5684ec3624a0ea4f9547": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"name": "psuedo_id",
|
||||
"ordinal": 0,
|
||||
"type_info": "Varchar"
|
||||
}
|
||||
],
|
||||
"nullable": [
|
||||
false
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "SELECT psuedo_id FROM\n mcaptcha_psuedo_campaign_id\n WHERE\n config_id = (SELECT config_id FROM mcaptcha_config WHERE key = ($1));\n "
|
||||
},
|
||||
"84484cb6892db29121816bc5bff5702b9e857e20aa14e79d080d78ae7593153b": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
@@ -493,6 +585,33 @@
|
||||
},
|
||||
"query": "SELECT EXISTS (SELECT 1 from mcaptcha_users WHERE name = $1)"
|
||||
},
|
||||
"af47990880a92c63d1cf5192203899c72621479dc6bb47859fb4498264b78033": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Int4",
|
||||
"Int4",
|
||||
"Varchar"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "INSERT INTO mcaptcha_pow_analytics \n (config_id, time, difficulty_factor, worker_type)\n VALUES ((SELECT config_id FROM mcaptcha_config WHERE key = $1), $2, $3, $4)"
|
||||
},
|
||||
"b67da576ff30a1bc8b1c0a79eff07f0622bd9ea035d3de15b91f5e1e8a5fda9b": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "\n DELETE FROM\n mcaptcha_pow_analytics\n WHERE\n config_id = (\n SELECT config_id FROM mcaptcha_config WHERE key = $1\n )\n "
|
||||
},
|
||||
"b97d810814fbeb2df19f47bcfa381bc6fb7ac6832d040b377cf4fca2ca896cfb": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
@@ -545,6 +664,19 @@
|
||||
},
|
||||
"query": "SELECT name, password FROM mcaptcha_users WHERE email = ($1)"
|
||||
},
|
||||
"c1bb8e02d1f9dc28322309d055de3c40ed4e1a1b9453a7e5a93a70e5186d762d": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "\n INSERT INTO\n mcaptcha_psuedo_campaign_id (config_id, psuedo_id)\n VALUES (\n (SELECT config_id FROM mcaptcha_config WHERE key = ($1)),\n $2\n );"
|
||||
},
|
||||
"c2e167e56242de7e0a835e25004b15ca8340545fa0ca7ac8f3293157d2d03d98": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
|
||||
@@ -22,6 +22,7 @@ use sqlx::postgres::PgPoolOptions;
|
||||
use sqlx::types::time::OffsetDateTime;
|
||||
use sqlx::ConnectOptions;
|
||||
use sqlx::PgPool;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub mod errors;
|
||||
#[cfg(test)]
|
||||
@@ -73,9 +74,6 @@ impl Connect for ConnectionOptions {
|
||||
if fresh.disable_logging {
|
||||
connect_options.disable_statement_logging();
|
||||
}
|
||||
sqlx::postgres::PgConnectOptions::from_str(&fresh.url)
|
||||
.unwrap()
|
||||
.disable_statement_logging();
|
||||
fresh
|
||||
.pool_options
|
||||
.connect_with(connect_options)
|
||||
@@ -904,6 +902,194 @@ impl MCDatabase for Database {
|
||||
|
||||
Ok(Date::dates_to_unix(records))
|
||||
}
|
||||
|
||||
/// record PoW timing
|
||||
async fn analysis_save(
|
||||
&self,
|
||||
captcha_id: &str,
|
||||
d: &CreatePerformanceAnalytics,
|
||||
) -> DBResult<()> {
|
||||
let _ = sqlx::query!(
|
||||
"INSERT INTO mcaptcha_pow_analytics
|
||||
(config_id, time, difficulty_factor, worker_type)
|
||||
VALUES ((SELECT config_id FROM mcaptcha_config WHERE key = $1), $2, $3, $4)",
|
||||
captcha_id,
|
||||
d.time as i32,
|
||||
d.difficulty_factor as i32,
|
||||
&d.worker_type,
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// fetch PoW analytics
|
||||
async fn analytics_fetch(
|
||||
&self,
|
||||
captcha_id: &str,
|
||||
limit: usize,
|
||||
offset: usize,
|
||||
) -> DBResult<Vec<PerformanceAnalytics>> {
|
||||
struct P {
|
||||
id: i32,
|
||||
time: i32,
|
||||
difficulty_factor: i32,
|
||||
worker_type: String,
|
||||
}
|
||||
|
||||
impl From<P> for PerformanceAnalytics {
|
||||
fn from(v: P) -> Self {
|
||||
Self {
|
||||
time: v.time as u32,
|
||||
difficulty_factor: v.difficulty_factor as u32,
|
||||
worker_type: v.worker_type,
|
||||
id: v.id as usize,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut c = sqlx::query_as!(
|
||||
P,
|
||||
"SELECT id, time, difficulty_factor, worker_type FROM mcaptcha_pow_analytics
|
||||
WHERE
|
||||
config_id = (
|
||||
SELECT
|
||||
config_id FROM mcaptcha_config
|
||||
WHERE
|
||||
key = $1
|
||||
)
|
||||
ORDER BY ID
|
||||
OFFSET $2 LIMIT $3
|
||||
",
|
||||
&captcha_id,
|
||||
offset as i32,
|
||||
limit as i32
|
||||
)
|
||||
.fetch_all(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
let mut res = Vec::with_capacity(c.len());
|
||||
for i in c.drain(0..) {
|
||||
res.push(i.into())
|
||||
}
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
/// Create psuedo ID against campaign ID to publish analytics
|
||||
async fn analytics_create_psuedo_id_if_not_exists(
|
||||
&self,
|
||||
captcha_id: &str,
|
||||
) -> DBResult<()> {
|
||||
let id = Uuid::new_v4();
|
||||
sqlx::query!(
|
||||
"
|
||||
INSERT INTO
|
||||
mcaptcha_psuedo_campaign_id (config_id, psuedo_id)
|
||||
VALUES (
|
||||
(SELECT config_id FROM mcaptcha_config WHERE key = ($1)),
|
||||
$2
|
||||
);",
|
||||
captcha_id,
|
||||
&id.to_string(),
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get psuedo ID from campaign ID
|
||||
async fn analytics_get_psuedo_id_from_capmaign_id(
|
||||
&self,
|
||||
captcha_id: &str,
|
||||
) -> DBResult<String> {
|
||||
struct ID {
|
||||
psuedo_id: String,
|
||||
}
|
||||
|
||||
let res = sqlx::query_as!(
|
||||
ID,
|
||||
"SELECT psuedo_id FROM
|
||||
mcaptcha_psuedo_campaign_id
|
||||
WHERE
|
||||
config_id = (SELECT config_id FROM mcaptcha_config WHERE key = ($1));
|
||||
",
|
||||
captcha_id
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
|
||||
Ok(res.psuedo_id)
|
||||
}
|
||||
|
||||
/// Get campaign ID from psuedo ID
|
||||
async fn analytics_get_capmaign_id_from_psuedo_id(
|
||||
&self,
|
||||
psuedo_id: &str,
|
||||
) -> DBResult<String> {
|
||||
struct ID {
|
||||
key: String,
|
||||
}
|
||||
|
||||
let res = sqlx::query_as!(
|
||||
ID,
|
||||
"SELECT
|
||||
key
|
||||
FROM
|
||||
mcaptcha_config
|
||||
WHERE
|
||||
config_id = (
|
||||
SELECT
|
||||
config_id
|
||||
FROM
|
||||
mcaptcha_psuedo_campaign_id
|
||||
WHERE
|
||||
psuedo_id = $1
|
||||
);",
|
||||
psuedo_id
|
||||
)
|
||||
.fetch_one(&self.pool)
|
||||
.await
|
||||
.map_err(|e| map_row_not_found_err(e, DBError::CaptchaNotFound))?;
|
||||
Ok(res.key)
|
||||
}
|
||||
|
||||
async fn analytics_delete_all_records_for_campaign(
|
||||
&self,
|
||||
campaign_id: &str,
|
||||
) -> DBResult<()> {
|
||||
let _ = sqlx::query!(
|
||||
"
|
||||
DELETE FROM
|
||||
mcaptcha_psuedo_campaign_id
|
||||
WHERE config_id = (
|
||||
SELECT config_id FROM mcaptcha_config WHERE key = ($1)
|
||||
);",
|
||||
campaign_id
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await;
|
||||
|
||||
let _ = sqlx::query!(
|
||||
"
|
||||
DELETE FROM
|
||||
mcaptcha_pow_analytics
|
||||
WHERE
|
||||
config_id = (
|
||||
SELECT config_id FROM mcaptcha_config WHERE key = $1
|
||||
)
|
||||
",
|
||||
campaign_id
|
||||
)
|
||||
.execute(&self.pool)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -38,7 +38,7 @@ you will be overriding the values set in the configuration files.
|
||||
| `MCAPTCHA_DATEBASE_USERNAME` | database username |
|
||||
| `MCAPTCHA_DATEBASE_POOL` | database connection pool size |
|
||||
| `MCAPTCHA_DATEBASE_DATABASE_TYPE` | database tpye: "postgres" or "maria" |
|
||||
| `DATABSE_URL` (overrides above vars) | database URL in `postgres://user:pass@host:port/dbname` format |
|
||||
| `DATABASE_URL` (overrides above vars) | database URL in `postgres://user:pass@host:port/dbname` format |
|
||||
|
||||
#### Redis
|
||||
|
||||
|
||||
@@ -1799,9 +1799,9 @@ minimatch@3.0.4, minimatch@^3.0.4:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
minimist@^1.2.5:
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
||||
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
||||
version "1.2.8"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
|
||||
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==
|
||||
|
||||
mkdirp@^1.0.4:
|
||||
version "1.0.4"
|
||||
|
||||
103
docs/third-party/NGIZero-green.hex.svg
vendored
Normal file
103
docs/third-party/NGIZero-green.hex.svg
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="Ebene_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="165.92125"
|
||||
height="191.45087"
|
||||
viewBox="0 0 165.92125 191.45086"
|
||||
enable-background="new 0 0 198.425 198.425"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="NGIZero-green.svg"
|
||||
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"><metadata
|
||||
id="metadata4142"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs4140" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1007"
|
||||
id="namedview4138"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1.6820179"
|
||||
inkscape:cx="-191.39267"
|
||||
inkscape:cy="54.855534"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Ebene_1"
|
||||
fit-margin-top="0"
|
||||
fit-margin-left="0"
|
||||
fit-margin-right="0"
|
||||
fit-margin-bottom="0" />
|
||||
<polygon
|
||||
points="36.911,63.104 36.911,66.116 36.911,132.309 36.911,135.321 39.346,136.825 96.715,169.921 99.273,171.419 101.853,169.921 159.319,136.825 161.938,135.321 161.938,132.309 161.938,66.116 161.938,63.104 159.308,61.6 101.841,28.504 99.234,27.006 96.629,28.504 39.347,61.6 "
|
||||
id="polygon4013"
|
||||
style="fill:#96c00a;fill-opacity:1"
|
||||
transform="matrix(1.3249745,0,0,1.3249745,-48.642464,-35.674938)" />
|
||||
<polygon
|
||||
points="161.712,62.925 161.712,131.589 99.212,167.589 36.712,131.589 36.712,62.925 99.212,26.925 "
|
||||
id="polygon4015"
|
||||
style="fill:#97bf00;fill-opacity:0.91764706"
|
||||
transform="matrix(1.3249745,0,0,1.3249745,-48.642464,-35.674938)" />
|
||||
<polygon
|
||||
stroke-miterlimit="10"
|
||||
points="157.712,65.379 157.712,133.046 99.212,166.88 40.712,133.046 40.712,65.379 99.212,31.546 "
|
||||
id="Outerline"
|
||||
transform="matrix(1.3249745,0,0,1.3249745,-48.642464,-35.674938)"
|
||||
style="fill:none;stroke:#ffffff;stroke-width:2;stroke-miterlimit:10"
|
||||
inkscape:label="#outerline" />
|
||||
|
||||
|
||||
<g
|
||||
id="g4281"
|
||||
transform="matrix(1.3249745,0,0,1.3249745,-47.067006,-23.859001)"><path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path42"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.55783975"
|
||||
d="m 133.45691,60.461638 v 0 c 2.27263,0 4.11462,1.841988 4.11462,4.114628 v 27.330241 c 0,2.27264 -1.84199,4.114628 -4.11462,4.114628 -2.27264,0 -4.11463,-1.841988 -4.11463,-4.114628 V 64.576266 c 0,-2.27264 1.84199,-4.114628 4.11463,-4.114628" /><g
|
||||
transform="matrix(0.55783976,0,0,-0.55783976,120.13631,77.682765)"
|
||||
id="g44"><path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path46"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="M 0,0 H -0.506 C -0.57,0 -0.633,-0.008 -0.698,-0.01 -0.762,-0.008 -0.825,0 -0.89,0 h -7.283 c -3.929,0 -7.359,-2.965 -7.613,-6.885 -0.278,-4.296 3.124,-7.867 7.361,-7.867 0.776,0 1.343,-0.754 1.111,-1.494 -0.658,-2.088 -2.341,-3.751 -4.547,-4.333 -2.074,-0.547 -4.276,-0.821 -6.605,-0.821 -4.007,0 -7.574,0.865 -10.7,2.595 -3.127,1.73 -5.57,4.144 -7.331,7.24 -1.761,3.096 -2.641,6.617 -2.641,10.564 0,4.006 0.88,7.558 2.641,10.654 1.761,3.097 4.219,5.493 7.377,7.195 3.156,1.698 6.768,2.549 10.836,2.549 4.681,0 8.865,-1.269 12.55,-3.807 2.341,-1.612 5.524,-1.588 7.757,0.171 3.48,2.741 3.289,8.045 -0.315,10.452 -1.7,1.136 -3.538,2.112 -5.512,2.928 -4.553,1.881 -9.623,2.823 -15.208,2.823 -6.679,0 -12.69,-1.412 -18.03,-4.235 -5.344,-2.822 -9.517,-6.738 -12.522,-11.747 -3.005,-5.008 -4.508,-10.67 -4.508,-16.983 0,-6.315 1.503,-11.975 4.508,-16.984 3.005,-5.009 7.148,-8.924 12.43,-11.747 5.282,-2.824 11.231,-4.235 17.849,-4.235 4.613,0 9.197,0.699 13.751,2.095 0.045,0.014 0.091,0.028 0.136,0.042 7.104,2.202 11.884,8.86 11.884,16.297 v 9.047 C 6.486,-2.904 3.583,0 0,0" /></g><g
|
||||
transform="matrix(0.55783976,0,0,-0.55783976,85.80763,64.525332)"
|
||||
id="g48"><path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path50"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 v -49.176 c 0,-4.023 -3.262,-7.285 -7.286,-7.285 h -1.381 c -2.181,0 -4.247,0.977 -5.631,2.662 l -24.229,29.505 c -1.804,2.197 -5.368,0.921 -5.368,-1.922 v -22.96 c 0,-4.023 -3.261,-7.285 -7.285,-7.285 -4.023,0 -7.285,3.262 -7.285,7.285 V 0 c 0,4.024 3.262,7.285 7.285,7.285 h 1.468 c 2.184,0 4.253,-0.979 5.636,-2.669 l 24.135,-29.475 c 1.802,-2.202 5.37,-0.927 5.37,1.918 V 0 c 0,4.024 3.261,7.285 7.285,7.285 C -3.262,7.285 0,4.024 0,0" /></g></g><g
|
||||
aria-label="Z E R O"
|
||||
transform="matrix(0.94681934,0,0,0.94681934,-209.97267,182.03385)"
|
||||
style="font-variant:normal;font-weight:600;font-stretch:normal;font-size:31.76000023px;font-family:'Montserrat SemiBold';-inkscape-font-specification:Montserrat-SemiBold;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:0.7171717;fill-rule:nonzero;stroke:none"
|
||||
id="text56"><path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 243.58117,-73.015206 h 19.46231 v 3.613321 l -12.42176,15.02707 h 12.77844 v 4.512774 h -20.17567 v -3.613321 l 12.42176,-15.02707 h -12.06508 z"
|
||||
id="path2325" /><path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 278.7684,-73.015206 h 16.11262 v 4.512774 h -10.14211 v 4.311172 h 9.5373 v 4.512773 h -9.5373 v 5.303672 h 10.48328 v 4.512774 H 278.7684 Z"
|
||||
id="path2327" /><path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 320.00367,-62.749034 q 1.87645,0 2.68285,-0.697851 0.82192,-0.697852 0.82192,-2.295157 0,-1.581796 -0.82192,-2.26414 -0.8064,-0.682344 -2.68285,-0.682344 h -2.51226 v 5.939492 z m -2.51226,4.125078 v 8.761915 h -5.97051 v -23.153165 h 9.11859 q 4.57481,0 6.69938,1.535274 2.14008,1.535273 2.14008,4.853945 0,2.295156 -1.11657,3.768399 -1.10105,1.473242 -3.33418,2.171093 1.22512,0.279141 2.18661,1.271641 0.97699,0.976992 1.96949,2.9775 l 3.24113,6.575313 h -6.3582 l -2.82242,-5.753399 q -0.85293,-1.736875 -1.73688,-2.372695 -0.86844,-0.635821 -2.32617,-0.635821 z"
|
||||
id="path2329" /><path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m 357.57911,-69.107237 q -2.72938,0 -4.23364,2.016016 -1.50425,2.016015 -1.50425,5.675859 0,3.644336 1.50425,5.660352 1.50426,2.016015 4.23364,2.016015 2.74488,0 4.24914,-2.016015 1.50426,-2.016016 1.50426,-5.660352 0,-3.659844 -1.50426,-5.675859 -1.50426,-2.016016 -4.24914,-2.016016 z m 0,-4.32668 q 5.58281,0 8.7464,3.19461 3.1636,3.194609 3.1636,8.823945 0,5.613828 -3.1636,8.808438 -3.16359,3.194609 -8.7464,3.194609 -5.56731,0 -8.74641,-3.194609 -3.16359,-3.19461 -3.16359,-8.808438 0,-5.629336 3.16359,-8.823945 3.1791,-3.19461 8.74641,-3.19461 z"
|
||||
id="path2331" /></g></svg>
|
||||
|
After Width: | Height: | Size: 7.3 KiB |
39
scripts/integration.sh
Executable file
39
scripts/integration.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
trap cleanup SIGINT SIGTERM ERR EXIT
|
||||
|
||||
readonly PROJECT_ROOT=$(realpath $(dirname $(dirname "${BASH_SOURCE[0]}")))
|
||||
|
||||
source $PROJECT_ROOT/scripts/lib.sh
|
||||
|
||||
is_ci(){
|
||||
if [ -z ${CI+x} ];
|
||||
then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
docker-compose down -v --remove-orphans || true
|
||||
docker-compose up -d
|
||||
cd $(mktemp -d)
|
||||
pwd
|
||||
find
|
||||
git clone https://github.com/mCaptcha/integration .
|
||||
|
||||
if is_ci
|
||||
then
|
||||
yarn install
|
||||
xvfb-run --auto-servernum npm run test.chrome
|
||||
xvfb-run --auto-servernum npm run test.firefox
|
||||
else
|
||||
yarn install
|
||||
npx nightwatch ./test/mCaptcha.ts
|
||||
fi
|
||||
|
||||
cd $PROJECT_ROOT
|
||||
docker-compose down -v --remove-orphans || true
|
||||
@@ -97,14 +97,15 @@ delete_dir() {
|
||||
}
|
||||
|
||||
upload_dist() {
|
||||
delete_dir $1
|
||||
upload_dir="mCaptcha/$1"
|
||||
delete_dir $upload_dir
|
||||
|
||||
pushd $TMP_DIR
|
||||
for file in $TARBALL $TARBALL.asc $TARBALL.sha256
|
||||
do
|
||||
curl -v \
|
||||
-F upload=@$file \
|
||||
"$DUMBSERVE_HOST/api/v1/files/upload?path=$1/"
|
||||
"$DUMBSERVE_HOST/api/v1/files/upload?path=$upload_dir"
|
||||
done
|
||||
popd
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ pub struct CreateCaptcha {
|
||||
pub levels: Vec<Level>,
|
||||
pub duration: u32,
|
||||
pub description: String,
|
||||
pub publish_benchmarks: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
@@ -52,6 +53,11 @@ pub async fn create(
|
||||
) -> ServiceResult<impl Responder> {
|
||||
let username = id.identity().unwrap();
|
||||
let mcaptcha_config = runner::create(&payload, &data, &username).await?;
|
||||
if payload.publish_benchmarks {
|
||||
data.db
|
||||
.analytics_create_psuedo_id_if_not_exists(&mcaptcha_config.key)
|
||||
.await?;
|
||||
}
|
||||
Ok(HttpResponse::Ok().json(mcaptcha_config))
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,9 @@ pub struct TrafficPatternRequest {
|
||||
pub broke_my_site_traffic: Option<u32>,
|
||||
/// Captcha description
|
||||
pub description: String,
|
||||
|
||||
/// publish benchmarks
|
||||
pub publish_benchmarks: bool,
|
||||
}
|
||||
|
||||
impl From<&TrafficPatternRequest> for TrafficPattern {
|
||||
@@ -127,12 +130,14 @@ async fn create(
|
||||
levels,
|
||||
duration: data.settings.captcha.default_difficulty_strategy.duration,
|
||||
description: payload.description,
|
||||
publish_benchmarks: payload.publish_benchmarks,
|
||||
};
|
||||
|
||||
let mcaptcha_config = create_runner(&msg, &data, &username).await?;
|
||||
data.db
|
||||
.add_traffic_pattern(&username, &mcaptcha_config.key, &pattern)
|
||||
.await?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(mcaptcha_config))
|
||||
}
|
||||
|
||||
@@ -162,6 +167,7 @@ async fn update(
|
||||
duration: data.settings.captcha.default_difficulty_strategy.duration,
|
||||
description: payload.pattern.description,
|
||||
key: payload.key,
|
||||
publish_benchmarks: payload.pattern.publish_benchmarks,
|
||||
};
|
||||
|
||||
update_captcha_runner(&msg, &data, &username).await?;
|
||||
@@ -292,6 +298,7 @@ pub mod tests {
|
||||
peak_sustainable_traffic: 1_000_000,
|
||||
broke_my_site_traffic: Some(10_000_000),
|
||||
description: NAME.into(),
|
||||
publish_benchmarks: false,
|
||||
};
|
||||
|
||||
let default_levels = calculate(
|
||||
@@ -323,6 +330,11 @@ pub mod tests {
|
||||
assert_eq!(get_level_resp.status(), StatusCode::OK);
|
||||
let res_levels: Vec<Level> = test::read_body_json(get_level_resp).await;
|
||||
assert_eq!(res_levels, default_levels);
|
||||
assert!(!data
|
||||
.db
|
||||
.analytics_captcha_is_published(&token_key.key)
|
||||
.await
|
||||
.unwrap());
|
||||
// END create_easy
|
||||
|
||||
// START update_easy
|
||||
@@ -331,6 +343,7 @@ pub mod tests {
|
||||
peak_sustainable_traffic: 10_000,
|
||||
broke_my_site_traffic: Some(1_000_000),
|
||||
description: NAME.into(),
|
||||
publish_benchmarks: true,
|
||||
};
|
||||
|
||||
let updated_default_values = calculate(
|
||||
@@ -352,6 +365,11 @@ pub mod tests {
|
||||
)
|
||||
.await;
|
||||
assert_eq!(update_token_resp.status(), StatusCode::OK);
|
||||
assert!(data
|
||||
.db
|
||||
.analytics_captcha_is_published(&token_key.key)
|
||||
.await
|
||||
.unwrap());
|
||||
|
||||
let get_level_resp = test::call_service(
|
||||
&app,
|
||||
@@ -394,5 +412,52 @@ pub mod tests {
|
||||
));
|
||||
assert!(body.contains(&payload.pattern.avg_traffic.to_string()));
|
||||
assert!(body.contains(&payload.pattern.peak_sustainable_traffic.to_string()));
|
||||
|
||||
// START update_easy to delete published results
|
||||
let mut payload2 = TrafficPatternRequest {
|
||||
avg_traffic: 100_000,
|
||||
peak_sustainable_traffic: 1_000_000,
|
||||
broke_my_site_traffic: Some(10_000_000),
|
||||
description: NAME.into(),
|
||||
publish_benchmarks: true,
|
||||
};
|
||||
|
||||
let add_token_resp = test::call_service(
|
||||
&app,
|
||||
post_request!(&payload2, ROUTES.captcha.easy.create)
|
||||
.cookie(cookies.clone())
|
||||
.to_request(),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(add_token_resp.status(), StatusCode::OK);
|
||||
|
||||
assert!(data
|
||||
.db
|
||||
.analytics_captcha_is_published(&token_key.key)
|
||||
.await
|
||||
.unwrap());
|
||||
|
||||
let token_key2: MCaptchaDetails = test::read_body_json(add_token_resp).await;
|
||||
|
||||
payload2.publish_benchmarks = false;
|
||||
|
||||
let payload = UpdateTrafficPattern {
|
||||
pattern: payload2,
|
||||
key: token_key2.key.clone(),
|
||||
};
|
||||
|
||||
let update_token_resp = test::call_service(
|
||||
&app,
|
||||
post_request!(&payload, ROUTES.captcha.easy.update)
|
||||
.cookie(cookies.clone())
|
||||
.to_request(),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(update_token_resp.status(), StatusCode::OK);
|
||||
assert!(!data
|
||||
.db
|
||||
.analytics_captcha_is_published(&token_key2.key)
|
||||
.await
|
||||
.unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ pub async fn level_routes_work(data: ArcData) {
|
||||
levels: levels.clone(),
|
||||
description: add_level.description,
|
||||
duration: add_level.duration,
|
||||
publish_benchmarks: true,
|
||||
};
|
||||
|
||||
let add_token_resp = test::call_service(
|
||||
|
||||
@@ -76,6 +76,7 @@ pub struct UpdateCaptcha {
|
||||
pub duration: u32,
|
||||
pub description: String,
|
||||
pub key: String,
|
||||
pub publish_benchmarks: bool,
|
||||
}
|
||||
|
||||
#[my_codegen::post(
|
||||
@@ -139,6 +140,16 @@ pub mod runner {
|
||||
e
|
||||
);
|
||||
}
|
||||
|
||||
if payload.publish_benchmarks {
|
||||
data.db
|
||||
.analytics_create_psuedo_id_if_not_exists(&payload.key)
|
||||
.await?;
|
||||
} else {
|
||||
data.db
|
||||
.analytics_delete_all_records_for_campaign(&payload.key)
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +109,8 @@ pub async fn init_mcaptcha(data: &AppData, key: &str) -> ServiceResult<()> {
|
||||
|
||||
for level in levels.iter() {
|
||||
let level = LevelBuilder::default()
|
||||
.visitor_threshold(level.visitor_threshold as u32)
|
||||
.difficulty_factor(level.difficulty_factor as u32)
|
||||
.visitor_threshold(level.visitor_threshold)
|
||||
.difficulty_factor(level.difficulty_factor)
|
||||
.unwrap()
|
||||
.build()
|
||||
.unwrap();
|
||||
@@ -250,6 +250,7 @@ pub mod tests {
|
||||
levels: levels.into(),
|
||||
duration: 30,
|
||||
description: "dummy".into(),
|
||||
publish_benchmarks: true,
|
||||
};
|
||||
|
||||
// 1. add level
|
||||
@@ -267,11 +268,11 @@ pub mod tests {
|
||||
key: token_key.key.clone(),
|
||||
};
|
||||
|
||||
let url = V1_API_ROUTES.pow.get_config;
|
||||
let _url = V1_API_ROUTES.pow.get_config;
|
||||
let mut prev = 0;
|
||||
for (count, l) in levels.iter().enumerate() {
|
||||
for l in prev..l.visitor_threshold * 2 {
|
||||
let get_config_resp = test::call_service(
|
||||
for _l in prev..l.visitor_threshold * 2 {
|
||||
let _get_config_resp = test::call_service(
|
||||
&app,
|
||||
post_request!(&get_config_payload, V1_API_ROUTES.pow.get_config)
|
||||
.to_request(),
|
||||
|
||||
@@ -32,6 +32,27 @@ pub struct ValidationToken {
|
||||
pub token: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct ApiWork {
|
||||
pub string: String,
|
||||
pub result: String,
|
||||
pub nonce: u64,
|
||||
pub key: String,
|
||||
pub time: Option<u32>,
|
||||
pub worker_type: Option<String>,
|
||||
}
|
||||
|
||||
impl From<ApiWork> for Work {
|
||||
fn from(value: ApiWork) -> Self {
|
||||
Self {
|
||||
string: value.string,
|
||||
nonce: value.nonce,
|
||||
result: value.result,
|
||||
key: value.key,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// API keys are mcaptcha actor names
|
||||
|
||||
/// route handler that verifies PoW and issues a solution token
|
||||
@@ -39,7 +60,7 @@ pub struct ValidationToken {
|
||||
#[my_codegen::post(path = "V1_API_ROUTES.pow.verify_pow()")]
|
||||
pub async fn verify_pow(
|
||||
req: HttpRequest,
|
||||
payload: web::Json<Work>,
|
||||
payload: web::Json<ApiWork>,
|
||||
data: AppData,
|
||||
) -> ServiceResult<impl Responder> {
|
||||
#[cfg(not(test))]
|
||||
@@ -52,8 +73,19 @@ pub async fn verify_pow(
|
||||
let ip = "127.0.1.1".into();
|
||||
|
||||
let key = payload.key.clone();
|
||||
let res = data.captcha.verify_pow(payload.into_inner(), ip).await?;
|
||||
let payload = payload.into_inner();
|
||||
let worker_type = payload.worker_type.clone();
|
||||
let time = payload.time;
|
||||
let (res, difficulty_factor) = data.captcha.verify_pow(payload.into(), ip).await?;
|
||||
data.stats.record_solve(&data, &key).await?;
|
||||
if time.is_some() && worker_type.is_some() {
|
||||
let analytics = db_core::CreatePerformanceAnalytics {
|
||||
difficulty_factor,
|
||||
time: time.unwrap(),
|
||||
worker_type: worker_type.unwrap(),
|
||||
};
|
||||
data.db.analysis_save(&key, &analytics).await?;
|
||||
}
|
||||
let payload = ValidationToken { token: res };
|
||||
Ok(HttpResponse::Ok().json(payload))
|
||||
}
|
||||
@@ -81,6 +113,81 @@ pub mod tests {
|
||||
verify_pow_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn verify_analytics_pow_works_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
verify_analytics_pow_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn verify_analytics_pow_works_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
verify_analytics_pow_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn verify_analytics_pow_works(data: ArcData) {
|
||||
const NAME: &str = "powanalyticsuser";
|
||||
const PASSWORD: &str = "testingpas";
|
||||
const EMAIL: &str = "powanalyticsuser@a.com";
|
||||
let data = &data;
|
||||
|
||||
delete_user(data, NAME).await;
|
||||
|
||||
register_and_signin(data, NAME, EMAIL, PASSWORD).await;
|
||||
let (_, _signin_resp, token_key) = add_levels_util(data, NAME, PASSWORD).await;
|
||||
let app = get_app!(data).await;
|
||||
|
||||
let get_config_payload = GetConfigPayload {
|
||||
key: token_key.key.clone(),
|
||||
};
|
||||
|
||||
// update and check changes
|
||||
|
||||
let get_config_resp = test::call_service(
|
||||
&app,
|
||||
post_request!(&get_config_payload, V1_API_ROUTES.pow.get_config)
|
||||
.to_request(),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(get_config_resp.status(), StatusCode::OK);
|
||||
let config: PoWConfig = test::read_body_json(get_config_resp).await;
|
||||
|
||||
let pow = pow_sha256::ConfigBuilder::default()
|
||||
.salt(config.salt)
|
||||
.build()
|
||||
.unwrap();
|
||||
let work = pow
|
||||
.prove_work(&config.string.clone(), config.difficulty_factor)
|
||||
.unwrap();
|
||||
|
||||
let work = ApiWork {
|
||||
string: config.string.clone(),
|
||||
result: work.result,
|
||||
nonce: work.nonce,
|
||||
key: token_key.key.clone(),
|
||||
time: Some(100),
|
||||
worker_type: Some("wasm".into()),
|
||||
};
|
||||
|
||||
let pow_verify_resp = test::call_service(
|
||||
&app,
|
||||
post_request!(&work, V1_API_ROUTES.pow.verify_pow).to_request(),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(pow_verify_resp.status(), StatusCode::OK);
|
||||
let limit = 50;
|
||||
let offset = 0;
|
||||
let mut analytics = data
|
||||
.db
|
||||
.analytics_fetch(&token_key.key, limit, offset)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(analytics.len(), 1);
|
||||
let a = analytics.pop().unwrap();
|
||||
assert_eq!(a.time, work.time.unwrap());
|
||||
assert_eq!(a.worker_type, work.worker_type.unwrap());
|
||||
}
|
||||
|
||||
pub async fn verify_pow_works(data: ArcData) {
|
||||
const NAME: &str = "powverifyusr";
|
||||
const PASSWORD: &str = "testingpas";
|
||||
@@ -129,6 +236,12 @@ pub mod tests {
|
||||
)
|
||||
.await;
|
||||
assert_eq!(pow_verify_resp.status(), StatusCode::OK);
|
||||
assert!(data
|
||||
.db
|
||||
.analytics_fetch(&token_key.key, 50, 0)
|
||||
.await
|
||||
.unwrap()
|
||||
.is_empty());
|
||||
|
||||
let string_not_found = test::call_service(
|
||||
&app,
|
||||
|
||||
10
src/data.rs
10
src/data.rs
@@ -83,7 +83,11 @@ impl SystemGroup {
|
||||
enum_system_wrapper!(get_pow, String, CaptchaResult<Option<PoWConfig>>);
|
||||
|
||||
// utility function to verify [Work]
|
||||
pub async fn verify_pow(&self, msg: Work, ip: String) -> CaptchaResult<String> {
|
||||
pub async fn verify_pow(
|
||||
&self,
|
||||
msg: Work,
|
||||
ip: String,
|
||||
) -> CaptchaResult<(String, u32)> {
|
||||
match self {
|
||||
Self::Embedded(val) => val.verify_pow(msg, ip).await,
|
||||
Self::Redis(val) => val.verify_pow(msg, ip).await,
|
||||
@@ -203,9 +207,9 @@ impl Data {
|
||||
};
|
||||
|
||||
let stats: Box<dyn Stats> = if s.captcha.enable_stats {
|
||||
Box::new(Real::default())
|
||||
Box::<Real>::default()
|
||||
} else {
|
||||
Box::new(Dummy::default())
|
||||
Box::<Dummy>::default()
|
||||
};
|
||||
|
||||
let data = Data {
|
||||
|
||||
@@ -132,7 +132,7 @@ mod tests {
|
||||
let duration = Duration::from_secs(DURATION);
|
||||
|
||||
// register works
|
||||
let _ = DemoUser::register_demo_user(&data).await.unwrap();
|
||||
DemoUser::register_demo_user(&data).await.unwrap();
|
||||
let payload = AccountCheckPayload {
|
||||
val: DEMO_USER.into(),
|
||||
};
|
||||
|
||||
@@ -35,15 +35,22 @@ struct AdvanceEditPage {
|
||||
name: String,
|
||||
key: String,
|
||||
levels: Vec<Level>,
|
||||
publish_benchmarks: bool,
|
||||
}
|
||||
|
||||
impl AdvanceEditPage {
|
||||
fn new(config: Captcha, levels: Vec<Level>, key: String) -> Self {
|
||||
fn new(
|
||||
config: Captcha,
|
||||
levels: Vec<Level>,
|
||||
key: String,
|
||||
publish_benchmarks: bool,
|
||||
) -> Self {
|
||||
AdvanceEditPage {
|
||||
duration: config.duration as u32,
|
||||
name: config.description,
|
||||
levels,
|
||||
key,
|
||||
publish_benchmarks,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,8 +70,9 @@ pub async fn advance(
|
||||
|
||||
let config = data.db.get_captcha_config(&username, &key).await?;
|
||||
let levels = data.db.get_captcha_levels(Some(&username), &key).await?;
|
||||
let publish_benchmarks = data.db.analytics_captcha_is_published(&key).await?;
|
||||
|
||||
let body = AdvanceEditPage::new(config, levels, key)
|
||||
let body = AdvanceEditPage::new(config, levels, key, publish_benchmarks)
|
||||
.render_once()
|
||||
.unwrap();
|
||||
Ok(HttpResponse::Ok()
|
||||
@@ -106,11 +114,14 @@ pub async fn easy(
|
||||
match data.db.get_traffic_pattern(&username, &key).await {
|
||||
Ok(c) => {
|
||||
let config = data.db.get_captcha_config(&username, &key).await?;
|
||||
let publish_benchmarks =
|
||||
data.db.analytics_captcha_is_published(&key).await?;
|
||||
let pattern = TrafficPatternRequest {
|
||||
peak_sustainable_traffic: c.peak_sustainable_traffic as u32,
|
||||
avg_traffic: c.avg_traffic as u32,
|
||||
broke_my_site_traffic: c.broke_my_site_traffic.map(|n| n as u32),
|
||||
peak_sustainable_traffic: c.peak_sustainable_traffic,
|
||||
avg_traffic: c.avg_traffic,
|
||||
broke_my_site_traffic: c.broke_my_site_traffic.map(|n| n),
|
||||
description: config.description,
|
||||
publish_benchmarks,
|
||||
};
|
||||
|
||||
let page = EasyEditPage::new(key, pattern).render_once().unwrap();
|
||||
|
||||
@@ -36,6 +36,7 @@ struct IndexPage {
|
||||
key: String,
|
||||
levels: Vec<Level>,
|
||||
stats: CaptchaStats,
|
||||
publish_benchmarks: bool,
|
||||
}
|
||||
|
||||
impl IndexPage {
|
||||
@@ -44,6 +45,7 @@ impl IndexPage {
|
||||
config: Captcha,
|
||||
levels: Vec<Level>,
|
||||
key: String,
|
||||
publish_benchmarks: bool,
|
||||
) -> Self {
|
||||
IndexPage {
|
||||
duration: config.duration as u32,
|
||||
@@ -51,6 +53,7 @@ impl IndexPage {
|
||||
levels,
|
||||
key,
|
||||
stats,
|
||||
publish_benchmarks,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,8 +73,9 @@ pub async fn view_sitekey(
|
||||
let config = data.db.get_captcha_config(&username, &key).await?;
|
||||
let levels = data.db.get_captcha_levels(Some(&username), &key).await?;
|
||||
let stats = data.stats.fetch(&data, &username, &key).await?;
|
||||
let publish_benchmarks = data.db.analytics_captcha_is_published(&key).await?;
|
||||
|
||||
let body = IndexPage::new(stats, config, levels, key)
|
||||
let body = IndexPage::new(stats, config, levels, key, publish_benchmarks)
|
||||
.render_once()
|
||||
.unwrap();
|
||||
Ok(HttpResponse::Ok()
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
* 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/>.
|
||||
*/
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
use std::{env, fs};
|
||||
|
||||
use config::{Config, ConfigError, Environment, File};
|
||||
use derive_more::Display;
|
||||
use log::{debug, warn};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
@@ -152,25 +152,34 @@ impl Settings {
|
||||
.expect("unable to set capatcha.enable_stats default config");
|
||||
|
||||
if let Ok(path) = env::var("MCAPTCHA_CONFIG") {
|
||||
s.merge(File::with_name(&path))?;
|
||||
let absolute_path = Path::new(&path).canonicalize().unwrap();
|
||||
log::info!(
|
||||
"Loading config file from {}",
|
||||
absolute_path.to_str().unwrap()
|
||||
);
|
||||
s.merge(File::with_name(absolute_path.to_str().unwrap()))?;
|
||||
} else if Path::new(CURRENT_DIR).exists() {
|
||||
let absolute_path = fs::canonicalize(CURRENT_DIR).unwrap();
|
||||
log::info!(
|
||||
"Loading config file from {}",
|
||||
absolute_path.to_str().unwrap()
|
||||
);
|
||||
// merging default config from file
|
||||
s.merge(File::with_name(CURRENT_DIR))?;
|
||||
s.merge(File::with_name(absolute_path.to_str().unwrap()))?;
|
||||
} else if Path::new(ETC).exists() {
|
||||
log::info!("{}", format!("Loading config file from {}", ETC));
|
||||
s.merge(File::with_name(ETC))?;
|
||||
} else {
|
||||
log::warn!("configuration file not found");
|
||||
log::warn!("Configuration file not found");
|
||||
}
|
||||
|
||||
s.merge(Environment::with_prefix("MCAPTCHA").separator("_"))?;
|
||||
|
||||
check_url(&s);
|
||||
|
||||
match env::var("PORT") {
|
||||
Ok(val) => {
|
||||
s.set("server.port", val).unwrap();
|
||||
}
|
||||
Err(e) => warn!("couldn't interpret PORT: {}", e),
|
||||
if let Ok(val) = env::var("PORT") {
|
||||
s.set("server.port", val).unwrap();
|
||||
log::info!("Overriding [server].port with environment variable");
|
||||
}
|
||||
|
||||
match env::var("DATABASE_URL") {
|
||||
@@ -180,8 +189,9 @@ impl Settings {
|
||||
let database_type = DBType::from_url(&url).unwrap();
|
||||
s.set("database.database_type", database_type.to_string())
|
||||
.unwrap();
|
||||
log::info!("Overriding [database].url and [database].database_type with environment variable");
|
||||
}
|
||||
Err(e) => {
|
||||
Err(_e) => {
|
||||
set_database_url(&mut s);
|
||||
}
|
||||
}
|
||||
@@ -215,8 +225,11 @@ fn set_database_url(s: &mut Config) {
|
||||
r"postgres://{}:{}@{}:{}/{}",
|
||||
s.get::<String>("database.username")
|
||||
.expect("Couldn't access database username"),
|
||||
s.get::<String>("database.password")
|
||||
.expect("Couldn't access database password"),
|
||||
urlencoding::encode(
|
||||
s.get::<String>("database.password")
|
||||
.expect("Couldn't access database password")
|
||||
.as_str()
|
||||
),
|
||||
s.get::<String>("database.hostname")
|
||||
.expect("Couldn't access database hostname"),
|
||||
s.get::<String>("database.port")
|
||||
|
||||
@@ -52,8 +52,8 @@ pub mod pg {
|
||||
settings.captcha.runners = Some(1);
|
||||
settings.database.url = url.clone();
|
||||
settings.database.database_type = DBType::Postgres;
|
||||
let data = Data::new(&settings).await;
|
||||
data
|
||||
|
||||
Data::new(&settings).await
|
||||
}
|
||||
}
|
||||
pub mod maria {
|
||||
@@ -71,8 +71,8 @@ pub mod maria {
|
||||
settings.captcha.runners = Some(1);
|
||||
settings.database.url = url.clone();
|
||||
settings.database.database_type = DBType::Maria;
|
||||
let data = Data::new(&settings).await;
|
||||
data
|
||||
|
||||
Data::new(&settings).await
|
||||
}
|
||||
}
|
||||
//pub async fn get_data() -> ArcData {
|
||||
@@ -118,7 +118,7 @@ macro_rules! get_app {
|
||||
.wrap(actix_middleware::NormalizePath::new(
|
||||
actix_middleware::TrailingSlash::Trim,
|
||||
))
|
||||
.configure(crate::routes::services),
|
||||
.configure($crate::routes::services),
|
||||
)
|
||||
};
|
||||
($data:expr) => {
|
||||
@@ -262,5 +262,6 @@ pub fn get_level_data() -> CreateCaptcha {
|
||||
levels,
|
||||
duration: 30,
|
||||
description: "dummy".into(),
|
||||
publish_benchmarks: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
* mCaptcha is a PoW based DoS protection software.
|
||||
* This is the frontend web component of the mCaptcha system
|
||||
* Copyright © 2023 Aravinth Manivnanan <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/>.
|
||||
* Use of this source code is governed by Apache 2.0 or MIT license.
|
||||
* You shoud have received a copy of MIT and Apache 2.0 along with
|
||||
* this program. If not, see <https://spdx.org/licenses/MIT.html> for
|
||||
* MIT or <http://www.apache.org/licenses/LICENSE-2.0> for Apache.
|
||||
*/
|
||||
|
||||
* {
|
||||
|
||||
@@ -8,6 +8,16 @@
|
||||
class="auth__logo" alt="mcaptcha logo" />
|
||||
|
||||
|
||||
<. if !crate::SETTINGS.allow_registration { .>
|
||||
<table class="reg-closed__table">
|
||||
<thead class="reg-closed__table-heading">
|
||||
<tr><th colspan="4" class="reg-closed__table-title-text">Registration closed</th></tr>
|
||||
</thead>
|
||||
<tbody class="reg-closed__body">
|
||||
<tr><td class="reg-closed__body-text">This mCaptcha instance is closed for registrations.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<. } else {.>
|
||||
<form
|
||||
method="POST"
|
||||
action="<.= crate::V1_API_ROUTES.auth.register .>"
|
||||
@@ -73,5 +83,6 @@
|
||||
<a href="<.= crate::PAGES.auth.login .>" class="auth__secondary-action__link">Log in</a>
|
||||
</p>
|
||||
<. include!("../demo-user-banner.html"); .>
|
||||
<. } .>
|
||||
</div>
|
||||
<. include!("../../components/footers.html"); .>
|
||||
|
||||
32
templates/auth/register/main.scss
Normal file
32
templates/auth/register/main.scss
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Gusted <postmaster@gusted.xyz>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
@import '../../components/table/main';
|
||||
|
||||
.reg-closed__table {
|
||||
@include table;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.reg-closed__table-title-text {
|
||||
@include table__title-text;
|
||||
}
|
||||
|
||||
.reg-closed__body-text {
|
||||
display: block;
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
@@ -45,5 +45,16 @@
|
||||
<. } .>
|
||||
<. } .>
|
||||
|
||||
<label class="sitekey-form__label" for="publish_benchmarks">
|
||||
Anonymously publish CAPTCHA performance statistics to help other webmasters
|
||||
<input
|
||||
class="sitekey-form__input"
|
||||
type="checkbox"
|
||||
name="publish_benchmarks"
|
||||
id="publish_benchmarks"
|
||||
/>
|
||||
</label>
|
||||
|
||||
|
||||
<button class="sitekey-form__submit" type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
@@ -38,6 +38,13 @@ export const addSubmitEventListener = (): void =>
|
||||
const submit = async (e: Event) => {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
const PUBLISH_BENCHMARKS = <HTMLInputElement>(
|
||||
FORM.querySelector("#publish_benchmarks")
|
||||
);
|
||||
|
||||
|
||||
|
||||
const description = validateDescription(e);
|
||||
const duration = validateDuration();
|
||||
|
||||
@@ -50,6 +57,7 @@ const submit = async (e: Event) => {
|
||||
levels: levels,
|
||||
duration,
|
||||
description,
|
||||
publish_benchmarks: PUBLISH_BENCHMARKS.checked,
|
||||
};
|
||||
|
||||
console.debug(`[form submition] json payload: ${JSON.stringify(payload)}`);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
/>
|
||||
</label>
|
||||
|
||||
|
||||
<label class="sitekey-form__label" for="avg_traffic">
|
||||
Average Traffic of your website
|
||||
<input
|
||||
@@ -38,7 +39,6 @@
|
||||
</label>
|
||||
|
||||
|
||||
|
||||
<label class="sitekey-form__label" for="avg_traffic">
|
||||
Maximum traffic that your website can handle
|
||||
<input
|
||||
@@ -68,5 +68,17 @@
|
||||
/>
|
||||
</label>
|
||||
|
||||
|
||||
<label class="sitekey-form__label" for="publish_benchmarks">
|
||||
Anonymously publish CAPTCHA performance statistics to help other webmasters
|
||||
<input
|
||||
class="sitekey-form__input"
|
||||
type="checkbox"
|
||||
name="publish_benchmarks"
|
||||
id="publish_benchmarks"
|
||||
/>
|
||||
</label>
|
||||
|
||||
|
||||
<button class="sitekey-form__submit" type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
@@ -42,6 +42,7 @@ type TrafficPattern = {
|
||||
peak_sustainable_traffic: number;
|
||||
broke_my_site_traffic?: number;
|
||||
description: string;
|
||||
publish_benchmarks: boolean;
|
||||
};
|
||||
|
||||
export const validate = (e: Event): TrafficPattern => {
|
||||
@@ -49,9 +50,7 @@ export const validate = (e: Event): TrafficPattern => {
|
||||
|
||||
let broke_is_set = false;
|
||||
|
||||
const AVG_TRAFFIC = <HTMLInputElement>(
|
||||
FORM.querySelector("#avg_traffic")
|
||||
);
|
||||
const AVG_TRAFFIC = <HTMLInputElement>FORM.querySelector("#avg_traffic");
|
||||
const PEAK_TRAFFIC = <HTMLInputElement>(
|
||||
FORM.querySelector("#peak_sustainable_traffic")
|
||||
);
|
||||
@@ -59,6 +58,10 @@ export const validate = (e: Event): TrafficPattern => {
|
||||
FORM.querySelector("#broke_my_site_traffic")
|
||||
);
|
||||
|
||||
const PUBLISH_BENCHMARKS = <HTMLInputElement>(
|
||||
FORM.querySelector("#publish_benchmarks")
|
||||
);
|
||||
|
||||
isBlankString(AVG_TRAFFIC.value, avg_traffic_name);
|
||||
isBlankString(PEAK_TRAFFIC.value, peak_traffic_name);
|
||||
|
||||
@@ -101,6 +104,7 @@ export const validate = (e: Event): TrafficPattern => {
|
||||
peak_sustainable_traffic,
|
||||
broke_my_site_traffic,
|
||||
description,
|
||||
publish_benchmarks: PUBLISH_BENCHMARKS.checked,
|
||||
};
|
||||
|
||||
return payload;
|
||||
|
||||
@@ -16,6 +16,22 @@
|
||||
<. } .>
|
||||
<. let level = levels.len() + 1; .>
|
||||
<. include!("../add/advance/add-level.html"); .>
|
||||
|
||||
<label class="sitekey-form__label" for="publish_benchmarks">
|
||||
Anonymously publish CAPTCHA performance statistics to help other webmasters
|
||||
<input
|
||||
class="sitekey-form__input"
|
||||
type="checkbox"
|
||||
id="publish_benchmarks"
|
||||
name="publish_benchmarks"
|
||||
<. if publish_benchmarks { .>
|
||||
checked
|
||||
<. }.>
|
||||
/>
|
||||
</label>
|
||||
|
||||
|
||||
|
||||
<button data-sitekey="<.= key .>"
|
||||
id="sitekey-form__submit" class="sitekey-form__submit" type="submit">
|
||||
Submit
|
||||
|
||||
@@ -61,6 +61,21 @@
|
||||
/>
|
||||
</label>
|
||||
|
||||
|
||||
|
||||
<label class="sitekey-form__label" for="publish_benchmarks">
|
||||
Anonymously publish CAPTCHA performance statistics to help other webmasters
|
||||
<input
|
||||
class="sitekey-form__input"
|
||||
type="checkbox"
|
||||
id="publish_benchmarks"
|
||||
name="publish_benchmarks"
|
||||
<. if pattern.publish_benchmarks { .>
|
||||
checked
|
||||
<. }.>
|
||||
/>
|
||||
</label>
|
||||
|
||||
<button data-sitekey="<.= key .>" class="sitekey-form__submit" type="submit">
|
||||
Submit
|
||||
</button>
|
||||
|
||||
@@ -47,11 +47,19 @@ const submit = async (e: Event) => {
|
||||
|
||||
const key = BTN.get().dataset.sitekey;
|
||||
|
||||
|
||||
const PUBLISH_BENCHMARKS = <HTMLInputElement>(
|
||||
Add.FORM.querySelector("#publish_benchmarks")
|
||||
);
|
||||
|
||||
|
||||
|
||||
const payload = {
|
||||
levels,
|
||||
duration,
|
||||
description,
|
||||
key,
|
||||
publish_benchmarks: PUBLISH_BENCHMARKS.checked,
|
||||
};
|
||||
|
||||
console.debug(`[form submition] json payload: ${JSON.stringify(payload)}`);
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
<label class="sitekey-form__level-label" for="difficulty<.= num .>">
|
||||
Difficulty
|
||||
<input
|
||||
readonly="readonly"
|
||||
type="number"
|
||||
id="difficulty<.= num .>"
|
||||
class="sitekey-form__level-input"
|
||||
|
||||
@@ -23,6 +23,23 @@
|
||||
<. for (count, level) in levels.iter().enumerate() { .>
|
||||
<. include!("./existing-level.html"); .>
|
||||
<. } .>
|
||||
|
||||
<label class="sitekey-form__label" for="publish_benchmarks">
|
||||
Anonymously publish CAPTCHA performance statistics to help other webmasters
|
||||
<input
|
||||
class="sitekey-form__input"
|
||||
type="checkbox"
|
||||
id="publish_benchmarks"
|
||||
readonly="readonly"
|
||||
name="publish_benchmarks"
|
||||
<. if publish_benchmarks { .>
|
||||
checked
|
||||
<. }.>
|
||||
/>
|
||||
</label>
|
||||
|
||||
|
||||
|
||||
<./* synchronise with "./__form-bottom.html" Lines below should break form */.>
|
||||
</form>
|
||||
<. include!("./stats.html"); .>
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
<span id="widget__verification-text--before">I'm not a robot</span>
|
||||
<span id="widget__verification-text--during">Processing...</span>
|
||||
<span id="widget__verification-text--after">Verified!</span>
|
||||
<span id="widget__verification-text--error">Something wen't wrong</span>
|
||||
<span id="widget__verification-text--error">Something went wrong</span>
|
||||
</label>
|
||||
<div class="widget__mcaptcha-details">
|
||||
<a href="<.= crate::PKG_HOMEPAGE .>"
|
||||
class="widget__mcaptcha-logo-container"
|
||||
target="_blank"
|
||||
>
|
||||
<img
|
||||
class="widget__mcaptcha-logo"
|
||||
@@ -33,12 +34,14 @@
|
||||
<p class="widget__mcaptcha-brand-name">mCaptcha</p>
|
||||
</a>
|
||||
<div class="widget__mcaptcha-info-container">
|
||||
<a class="widget__mcaptcha-info-link"
|
||||
href="<.= crate::PKG_HOMEPAGE .><.= crate::PAGES.privacy .>">
|
||||
<a class="widget__mcaptcha-info-link"
|
||||
target="_blank"
|
||||
href="<.= crate::PKG_HOMEPAGE .><.= crate::PAGES.privacy .>">
|
||||
Privacy
|
||||
</a>
|
||||
<a class="widget__mcaptcha-info-link"
|
||||
href="<.= crate::PKG_HOMEPAGE .><.= crate::PAGES.security .>">
|
||||
target="_blank"
|
||||
href="<.= crate::PKG_HOMEPAGE .><.= crate::PAGES.security .>">
|
||||
Terms
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -55,7 +55,7 @@ export const solveCaptchaRunner = async (e: Event): Promise<void> => {
|
||||
worker.onmessage = async (event: MessageEvent) => {
|
||||
const resp: ServiceWorkerWork = event.data;
|
||||
console.log(
|
||||
`Proof generated. Difficuly: ${config.difficulty_factor} Duration: ${resp.duration}`
|
||||
`Proof generated. Difficuly: ${config.difficulty_factor} Duration: ${resp.work.time}`
|
||||
);
|
||||
|
||||
const proof: Work = {
|
||||
@@ -63,6 +63,8 @@ export const solveCaptchaRunner = async (e: Event): Promise<void> => {
|
||||
string: config.string,
|
||||
nonce: resp.work.nonce,
|
||||
result: resp.work.result,
|
||||
time: Math.trunc(resp.work.time),
|
||||
worker_type: resp.work.worker_type,
|
||||
};
|
||||
|
||||
// 3. submit work
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
* mCaptcha is a PoW based DoS protection software.
|
||||
* This is the frontend web component of the mCaptcha system
|
||||
* Copyright © 2023 Aravinth Manivnanan <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/>.
|
||||
* Use of this source code is governed by Apache 2.0 or MIT license.
|
||||
* You shoud have received a copy of MIT and Apache 2.0 along with
|
||||
* this program. If not, see <https://spdx.org/licenses/MIT.html> for
|
||||
* MIT or <http://www.apache.org/licenses/LICENSE-2.0> for Apache.
|
||||
*/
|
||||
|
||||
@import '../reset';
|
||||
@import "../reset";
|
||||
|
||||
.widget__contaienr {
|
||||
align-items: center;
|
||||
|
||||
@@ -11,31 +11,66 @@
|
||||
|
||||
import { gen_pow } from "@mcaptcha/pow-wasm";
|
||||
import * as p from "@mcaptcha/pow_sha256-polyfill";
|
||||
import { WasmWork, PoWConfig } from "./types";
|
||||
import { WasmWork, PoWConfig, SubmitWork } from "./types";
|
||||
|
||||
/**
|
||||
* proove work
|
||||
* @param {PoWConfig} config - the proof-of-work configuration using which
|
||||
* work needs to be computed
|
||||
* */
|
||||
const prove = async (config: PoWConfig): Promise<WasmWork> => {
|
||||
let proof: WasmWork = null;
|
||||
const prove = async (config: PoWConfig): Promise<SubmitWork> => {
|
||||
const WASM = "wasm";
|
||||
const JS = "js";
|
||||
if (WasmSupported) {
|
||||
let proof: WasmWork = null;
|
||||
let res: SubmitWork = null;
|
||||
let time: number = null;
|
||||
|
||||
const t0 = performance.now();
|
||||
const proofString = gen_pow(
|
||||
config.salt,
|
||||
config.string,
|
||||
config.difficulty_factor
|
||||
);
|
||||
const t1 = performance.now();
|
||||
time = t1 - t0;
|
||||
|
||||
proof = JSON.parse(proofString);
|
||||
const worker_type = WASM;
|
||||
res = {
|
||||
result: proof.result,
|
||||
nonce: proof.nonce,
|
||||
worker_type,
|
||||
time,
|
||||
};
|
||||
return res;
|
||||
} else {
|
||||
console.log("WASM unsupported, expect delay during proof generation");
|
||||
|
||||
let proof: WasmWork = null;
|
||||
let time: number = null;
|
||||
let res: SubmitWork = null;
|
||||
|
||||
const t0 = performance.now();
|
||||
|
||||
proof = await p.generate_work(
|
||||
config.salt,
|
||||
config.string,
|
||||
config.difficulty_factor
|
||||
);
|
||||
const t1 = performance.now();
|
||||
time = t1 - t0;
|
||||
|
||||
const worker_type = JS;
|
||||
res = {
|
||||
result: proof.result,
|
||||
nonce: proof.nonce,
|
||||
worker_type,
|
||||
time,
|
||||
};
|
||||
|
||||
return res;
|
||||
}
|
||||
return proof;
|
||||
};
|
||||
|
||||
// credits: @jf-bastien on Stack Overflow
|
||||
|
||||
@@ -1,37 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
* mCaptcha is a PoW based DoS protection software.
|
||||
* This is the frontend web component of the mCaptcha system
|
||||
* Copyright © 2023 Aravinth Manivnanan <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/>.
|
||||
* Use of this source code is governed by Apache 2.0 or MIT license.
|
||||
* You shoud have received a copy of MIT and Apache 2.0 along with
|
||||
* this program. If not, see <https://spdx.org/licenses/MIT.html> for
|
||||
* MIT or <http://www.apache.org/licenses/LICENSE-2.0> for Apache.
|
||||
*/
|
||||
import prove from "./prove";
|
||||
import { PoWConfig, ServiceWorkerWork } from "./types";
|
||||
|
||||
import log from "../logger";
|
||||
|
||||
import prove from "./prove";
|
||||
import {PoWConfig, ServiceWorkerWork} from "./types";
|
||||
|
||||
log.log("worker registered");
|
||||
onmessage = async (e) => {
|
||||
console.debug("message received at worker");
|
||||
const config: PoWConfig = e.data;
|
||||
|
||||
const t0 = performance.now();
|
||||
const work = await prove(config);
|
||||
|
||||
const t1 = performance.now();
|
||||
const duration = t1 - t0;
|
||||
|
||||
const res: ServiceWorkerWork = {
|
||||
work,
|
||||
duration,
|
||||
};
|
||||
|
||||
postMessage(res);
|
||||
|
||||
@@ -14,6 +14,15 @@ export type Work = {
|
||||
nonce: number;
|
||||
string: string;
|
||||
key: string;
|
||||
time: number;
|
||||
worker_type: string;
|
||||
};
|
||||
|
||||
export type SubmitWork = {
|
||||
time: number;
|
||||
worker_type: string;
|
||||
result: string;
|
||||
nonce: number;
|
||||
};
|
||||
|
||||
export type WasmWork = {
|
||||
@@ -22,8 +31,7 @@ export type WasmWork = {
|
||||
};
|
||||
|
||||
export type ServiceWorkerWork = {
|
||||
work: WasmWork;
|
||||
duration: number;
|
||||
work: SubmitWork;
|
||||
};
|
||||
|
||||
export type PoWConfig = {
|
||||
|
||||
Reference in New Issue
Block a user