Merge pull request #10 from mCaptcha/update-deps

Update deps
This commit is contained in:
Aravinth Manivannan 2023-10-17 14:46:09 +05:30 committed by GitHub
commit 0355f303f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 456 additions and 321 deletions

View file

@ -1,50 +0,0 @@
name: Coverage
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- master
jobs:
build_and_test:
strategy:
fail-fast: false
matrix:
version:
- stable
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: ⚡ Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install ${{ matrix.version }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu
profile: minimal
override: false
- name: Generate coverage file
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
uses: actions-rs/tarpaulin@v0.1
with:
version: '0.15.0'
args: '-t 1200 --out Xml --all --all-features --no-fail-fast'
- name: Upload to Codecov
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
uses: codecov/codecov-action@v2
with:
file: cobertura.xml

View file

@ -35,7 +35,6 @@ jobs:
/var/lib/docker
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: configure GPG key
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/cache'
run: echo -n "$RELEASE_BOT_GPG_SIGNING_KEY" | gpg --batch --import --pinentry-mode loopback

558
Cargo.lock generated
View file

@ -4,9 +4,9 @@ version = 3
[[package]]
name = "addr2line"
version = "0.17.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b"
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
dependencies = [
"gimli",
]
@ -19,33 +19,13 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "aho-corasick"
version = "0.7.18"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
dependencies = [
"memchr",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "autocfg"
version = "1.1.0"
@ -54,9 +34,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "backtrace"
version = "0.3.66"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7"
checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
dependencies = [
"addr2line",
"cc",
@ -69,24 +49,24 @@ dependencies = [
[[package]]
name = "bindgen"
version = "0.59.2"
version = "0.66.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8"
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
dependencies = [
"bitflags",
"bitflags 2.4.1",
"cexpr",
"clang-sys",
"clap",
"env_logger",
"lazy_static",
"lazycell",
"log",
"peeking_take_while",
"prettyplease",
"proc-macro2",
"quote 1.0.20",
"quote 1.0.33",
"regex",
"rustc-hash",
"shlex",
"syn 2.0.38",
"which",
]
@ -97,10 +77,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cc"
version = "1.0.73"
name = "bitflags"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
[[package]]
name = "cc"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
[[package]]
name = "cexpr"
@ -119,30 +108,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clang-sys"
version = "1.3.3"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b"
checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
dependencies = [
"glob",
"libc",
"libloading",
]
[[package]]
name = "clap"
version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim 0.8.0",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "convert_case"
version = "0.4.0"
@ -151,9 +125,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
[[package]]
name = "darling"
version = "0.12.4"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f2c43f534ea4b0b049015d00269734195e6d3f0f6635cb692251aca6f9f8b3c"
checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850"
dependencies = [
"darling_core",
"darling_macro",
@ -161,58 +135,58 @@ dependencies = [
[[package]]
name = "darling_core"
version = "0.12.4"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36"
checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote 1.0.20",
"strsim 0.10.0",
"syn 1.0.98",
"quote 1.0.33",
"strsim",
"syn 1.0.109",
]
[[package]]
name = "darling_macro"
version = "0.12.4"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a"
checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e"
dependencies = [
"darling_core",
"quote 1.0.20",
"syn 1.0.98",
"quote 1.0.33",
"syn 1.0.109",
]
[[package]]
name = "derive_builder"
version = "0.10.2"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d13202debe11181040ae9063d739fa32cfcaaebe2275fe387703460ae2365b30"
checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8"
dependencies = [
"derive_builder_macro",
]
[[package]]
name = "derive_builder_core"
version = "0.10.2"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5"
checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f"
dependencies = [
"darling",
"proc-macro2",
"quote 1.0.20",
"syn 1.0.98",
"quote 1.0.33",
"syn 1.0.109",
]
[[package]]
name = "derive_builder_macro"
version = "0.10.2"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73"
checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e"
dependencies = [
"derive_builder_core",
"syn 1.0.98",
"syn 1.0.109",
]
[[package]]
@ -223,16 +197,16 @@ checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
dependencies = [
"convert_case",
"proc-macro2",
"quote 1.0.20",
"quote 1.0.33",
"rustc_version",
"syn 1.0.98",
"syn 1.0.109",
]
[[package]]
name = "either"
version = "1.7.0"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "enum-primitive-derive"
@ -246,16 +220,13 @@ dependencies = [
]
[[package]]
name = "env_logger"
version = "0.9.0"
name = "errno"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
"libc",
"windows-sys",
]
[[package]]
@ -266,9 +237,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "getrandom"
version = "0.2.7"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
dependencies = [
"cfg-if",
"libc",
@ -277,37 +248,31 @@ dependencies = [
[[package]]
name = "gimli"
version = "0.26.2"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d"
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
[[package]]
name = "glob"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "heck"
version = "0.4.0"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.1.19"
name = "home"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
dependencies = [
"libc",
"windows-sys",
]
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "ident_case"
version = "1.0.1"
@ -316,9 +281,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "itoa"
version = "1.0.2"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]]
name = "lazy_static"
@ -334,15 +299,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.126"
version = "0.2.149"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
[[package]]
name = "libloading"
version = "0.7.3"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
"winapi",
@ -350,8 +315,8 @@ dependencies = [
[[package]]
name = "libmcaptcha"
version = "0.1.4"
source = "git+https://github.com/mCaptcha/libmcaptcha?branch=master#374dcc936ad5d030517be73a4d939cbe245fd9ac"
version = "0.2.4"
source = "git+https://github.com/mCaptcha/libmcaptcha?tag=0.2.4#681a5c6380373440f56f4c0bda2ffac5654df773"
dependencies = [
"derive_builder",
"derive_more",
@ -361,14 +326,37 @@ dependencies = [
]
[[package]]
name = "log"
version = "0.4.17"
name = "linkme"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
checksum = "91ed2ee9464ff9707af8e9ad834cffa4802f072caad90639c583dd3c62e6e608"
dependencies = [
"cfg-if",
"linkme-impl",
]
[[package]]
name = "linkme-impl"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba125974b109d512fccbc6c0244e7580143e460895dfd6ea7f8bbb692fd94396"
dependencies = [
"proc-macro2",
"quote 1.0.33",
"syn 2.0.38",
]
[[package]]
name = "linux-raw-sys"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f"
[[package]]
name = "log"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "mcaptcha-cache"
version = "0.1.0"
@ -385,9 +373,18 @@ dependencies = [
[[package]]
name = "memchr"
version = "2.5.0"
version = "2.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
[[package]]
name = "memoffset"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
dependencies = [
"autocfg",
]
[[package]]
name = "minimal-lexical"
@ -397,18 +394,31 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.5.3"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc"
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
dependencies = [
"adler",
]
[[package]]
name = "nom"
version = "7.1.1"
name = "nix"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
dependencies = [
"bitflags 1.3.2",
"cfg-if",
"libc",
"memoffset",
"pin-utils",
]
[[package]]
name = "nom"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr",
"minimal-lexical",
@ -420,27 +430,33 @@ version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
dependencies = [
"num-traits 0.2.15",
"num-traits 0.2.17",
]
[[package]]
name = "num-traits"
version = "0.2.15"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
dependencies = [
"autocfg",
]
[[package]]
name = "object"
version = "0.29.0"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
dependencies = [
"memchr",
]
[[package]]
name = "once_cell"
version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "peeking_take_while"
version = "0.1.2"
@ -449,21 +465,37 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "pin-project-lite"
version = "0.2.9"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "ppv-lite86"
version = "0.2.16"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "prettyplease"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d"
dependencies = [
"proc-macro2",
"syn 2.0.38",
]
[[package]]
name = "proc-macro2"
version = "1.0.40"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
dependencies = [
"unicode-ident",
]
@ -476,9 +508,9 @@ checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
[[package]]
name = "quote"
version = "1.0.20"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
@ -506,35 +538,65 @@ dependencies = [
[[package]]
name = "rand_core"
version = "0.6.3"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
]
[[package]]
name = "redis-module"
version = "1.0.1"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04133364fe1a1fce0d9e3b6baf2877bec48c01c9cfea1ed3f76b862b0ac09032"
checksum = "5d56e69a7b714b77ac2b43f5ae97b401b9174b7f4548553481cfa113f73c810f"
dependencies = [
"backtrace",
"bindgen",
"bitflags",
"bitflags 2.4.1",
"cc",
"cfg-if",
"enum-primitive-derive",
"libc",
"num-traits 0.2.15",
"linkme",
"log",
"nix",
"num-traits 0.2.17",
"redis-module-macros-internals",
"regex",
"serde",
"strum_macros",
]
[[package]]
name = "regex"
version = "1.6.0"
name = "redis-module-macros-internals"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
checksum = "21305e9453d5a343287d2c93d285941de0faa1b6ca6151a4d62bcfe6090a2082"
dependencies = [
"lazy_static",
"proc-macro2",
"quote 1.0.33",
"syn 1.0.109",
]
[[package]]
name = "regex"
version = "1.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
dependencies = [
"aho-corasick",
"memchr",
@ -543,15 +605,15 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.6.27"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "rustc-demangle"
version = "0.1.21"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustc-hash"
@ -569,48 +631,61 @@ dependencies = [
]
[[package]]
name = "rustversion"
version = "1.0.8"
name = "rustix"
version = "0.38.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24c8ad4f0c00e1eb5bc7614d236a7f1300e3dbd76b68cac8e06fb00b015ad8d8"
checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed"
dependencies = [
"bitflags 2.4.1",
"errno",
"libc",
"linux-raw-sys",
"windows-sys",
]
[[package]]
name = "rustversion"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
[[package]]
name = "ryu"
version = "1.0.10"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695"
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]]
name = "semver"
version = "1.0.12"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1"
checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090"
[[package]]
name = "serde"
version = "1.0.140"
version = "1.0.189"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03"
checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.140"
version = "1.0.189"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da"
checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5"
dependencies = [
"proc-macro2",
"quote 1.0.20",
"syn 1.0.98",
"quote 1.0.33",
"syn 2.0.38",
]
[[package]]
name = "serde_json"
version = "1.0.82"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7"
checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
dependencies = [
"itoa",
"ryu",
@ -619,15 +694,9 @@ dependencies = [
[[package]]
name = "shlex"
version = "1.1.0"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380"
[[package]]
name = "strsim"
@ -637,15 +706,15 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "strum_macros"
version = "0.24.2"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4faebde00e8ff94316c01800f9054fd2ba77d30d9e922541913051d1d978918b"
checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59"
dependencies = [
"heck",
"proc-macro2",
"quote 1.0.20",
"quote 1.0.33",
"rustversion",
"syn 1.0.98",
"syn 1.0.109",
]
[[package]]
@ -661,12 +730,23 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.98"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote 1.0.20",
"quote 1.0.33",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
dependencies = [
"proc-macro2",
"quote 1.0.33",
"unicode-ident",
]
@ -679,45 +759,21 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "termcolor"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [
"winapi-util",
]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]]
name = "tokio"
version = "1.20.0"
version = "1.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57aec3cfa4c296db7255446efb4928a6be304b431a806216105542a67b6ca82e"
checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653"
dependencies = [
"autocfg",
"backtrace",
"pin-project-lite",
]
[[package]]
name = "unicode-ident"
version = "1.0.2"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7"
[[package]]
name = "unicode-width"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-xid"
@ -725,12 +781,6 @@ version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
@ -739,13 +789,14 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "which"
version = "4.2.5"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae"
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
dependencies = [
"either",
"lazy_static",
"libc",
"home",
"once_cell",
"rustix",
]
[[package]]
@ -764,17 +815,74 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"

View file

@ -9,22 +9,24 @@ homepage = "https://github.com/mcaptcha/cache"
license = "AGPLv3 or later version"
[lib]
crate-type = ["cdylib"]
crate-type = ["cdylib", "rlib"]
name = "cache"
[dependencies]
redis-module = { version="1", features = ["experimental-api"]}
redis-module = { version="2.0.5", features = ["min-redis-compatibility-version-6-0"], default-features=false}
libc = "0.2"
serde_json = "1.0.81"
serde = {version = "1.0.137", features = ["derive"]}
lazy_static = "1.4"
rand = "0.8"
derive_more = "0.99"
libmcaptcha = { branch = "master", git = "https://github.com/mCaptcha/libmcaptcha", features = ["minimal"], default-features = false }
libmcaptcha = { version = "0.2.4", tag="0.2.4", git = "https://github.com/mCaptcha/libmcaptcha", features = ["minimal"], default-features = false }
#libmcaptcha = { path = "../libmcaptcha", features = ["minimal"], default-features = false}
#[target.x86_64-unknown-linux-musl]
#linker = "cc"
[features]
test = ["redis-module/test"]
#[features]
#test = ["redis-module/test"]
[dev-dependencies]
redis-module = { version="2.0.5", features = ["min-redis-compatibility-version-7-2"], default-features=false}

View file

@ -1,7 +1,7 @@
ARG REDIS_VER=6.2.6
ARG REDIS_VER=7.0
# stretch|bionic|buster
ARG OSNICK=bullseye
ARG OSNICK=bookworm
# ARCH=x64|arm64v8|arm32v7
ARG ARCH=x64

View file

@ -18,13 +18,12 @@ dev:
doc:
cargo doc --no-deps --workspace --all-features --document-private-items
docker:
docker build -t mcaptcha/cache:0.1.0-beta -t mcaptcha/cache:latest .
docker: docker
docker push mcaptcha/cache:0.1.0-beta
docker push mcaptcha/cache:latest
docker-build:
docker build -t mcaptcha/cache:0.1.0-beta -t mcaptcha/cache:latest .
docker buildx build -t mcaptcha/cache:0.1.0-beta -t mcaptcha/cache:latest . --load
docker-run:
docker run -d --name=$(DOCKER_CONTAINER) \
@ -41,9 +40,9 @@ env:
@-pip install codespell
test:
@ . venv/bin/activate && ./scripts/spellcheck.sh -c
cargo test --all --all-features --no-fail-fast
./tests/test.py
#@ . venv/bin/activate && ./scripts/spellcheck.sh -c
# cargo test --all --all-features --no-fail-fast
xml-test-coverage:
cargo tarpaulin -t 1200 --out Xml --all --all-features --no-fail-fast

View file

@ -85,7 +85,10 @@ impl Bucket {
let bucket_name = bucket_name.unwrap();
let bucket = ctx.open_key_writable(&RedisString::create(ctx.ctx, bucket_name));
let bucket = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
bucket_name.as_bytes(),
));
if bucket.key_type() == KeyType::Empty {
ctx.log_debug(&format!("Bucket doesn't exist: {}", key_name));
} else {
@ -125,8 +128,10 @@ impl Bucket {
"reading captcha: {} with decr count {}",
&captcha, count
));
let stored_captcha =
ctx.open_key_writable(&RedisString::create(ctx.ctx, &captcha));
let stored_captcha = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
captcha.as_bytes(),
));
if stored_captcha.key_type() == KeyType::Empty {
continue;
}
@ -146,24 +151,27 @@ impl Bucket {
// get bucket
let bucket_name = get_bucket_name(bucket_instant);
let timer = ctx.open_key_writable(&RedisString::create(
let timer = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
&get_timer_name_from_bucket_name(&bucket_name),
get_timer_name_from_bucket_name(&bucket_name).as_bytes(),
));
let _ = timer.delete();
ctx.log_debug(&format!("Bucket instant: {}", &bucket_instant));
let bucket = ctx.open_key_writable(&RedisString::create(ctx.ctx, &bucket_name));
let bucket = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
bucket_name.as_bytes(),
));
Bucket::decrement_runner(ctx, &bucket);
if let Err(e) = bucket.delete() {
ctx.log_warning(&format!("enountered error while deleting hashmap: {:?}", e));
}
let timer = ctx.open_key_writable(&RedisString::create(
let timer = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
&get_timer_name_from_bucket_name(&bucket_name),
get_timer_name_from_bucket_name(&bucket_name).as_bytes(),
));
if let Err(e) = timer.delete() {
ctx.log_warning(&format!(
@ -179,7 +187,10 @@ impl Bucket {
let captcha_name = get_captcha_key(&captcha);
// ctx.log_debug(&captcha_name);
// increment
let captcha = ctx.open_key_writable(&RedisString::create(ctx.ctx, &captcha_name));
let captcha = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
captcha_name.as_bytes(),
));
ctx.log_debug("loading mcaptcha");
let captcha = MCaptcha::get_mut_mcaptcha(&captcha)?;
@ -216,7 +227,10 @@ impl Bucket {
// ctx.log_debug(&format!("Bucket name: {}", &bucket_name));
// get bucket
let bucket = ctx.open_key_writable(&RedisString::create(ctx.ctx, &bucket_name));
let bucket = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
bucket_name.as_bytes(),
));
match bucket.get_value::<Bucket>(&MCAPTCHA_BUCKET_TYPE)? {
Some(bucket) => match bucket.decrement.get_mut(&captcha_name) {
@ -230,9 +244,9 @@ impl Bucket {
let mut counter = Bucket::new(ctx, duration)?;
counter.decrement.insert(captcha_name, 1);
bucket.set_value(&MCAPTCHA_BUCKET_TYPE, counter)?;
let timer = ctx.open_key_writable(&RedisString::create(
let timer = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
&get_timer_name_from_bucket_name(&bucket_name),
get_timer_name_from_bucket_name(&bucket_name).as_bytes(),
));
timer.write("1")?;
timer.set_expire(Duration::from_secs(duration + BUCKET_EXPIRY_OFFSET))?;
@ -265,16 +279,21 @@ pub static MCAPTCHA_BUCKET_TYPE: RedisType = RedisType::new(
// Currently unused by Redis
mem_usage: None,
mem_usage2: None,
digest: None,
// Aux data
aux_load: None,
aux_save: None,
aux_save2: None,
aux_save_triggers: 0,
free_effort: None,
free_effort2: None,
unlink: None,
unlink2: None,
copy: None,
copy2: None,
defrag: None,
},
);

View file

@ -52,7 +52,10 @@ impl Challenge {
let challenge_name = get_challenge_name(&captcha, &add_challenge.challenge);
let key = ctx.open_key_writable(&RedisString::create(ctx.ctx, &challenge_name));
let key = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
challenge_name.as_bytes(),
));
if key.key_type() != KeyType::Empty {
return Err(CacheError::DuplicateChallenge.into());
}
@ -71,7 +74,10 @@ impl Challenge {
let challenge_name = get_challenge_name(&captcha, &challenge);
let key = ctx.open_key_writable(&RedisString::create(ctx.ctx, &challenge_name));
let key = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
challenge_name.as_bytes(),
));
if key.key_type() == KeyType::Empty {
Err(CacheError::ChallengeNotFound.into())
} else {
@ -87,7 +93,10 @@ impl Challenge {
let challenge_name = get_challenge_name(&captcha, &challenge);
let key = ctx.open_key_writable(&RedisString::create(ctx.ctx, &challenge_name));
let key = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
challenge_name.as_bytes(),
));
if key.key_type() == KeyType::Empty {
return Err(CacheError::ChallengeNotFound.into());
}
@ -114,16 +123,21 @@ pub static MCAPTCHA_CHALLENGE_TYPE: RedisType = RedisType::new(
// Currently unused by Redis
mem_usage: None,
mem_usage2: None,
digest: None,
// Aux data
aux_load: None,
aux_save: None,
aux_save2: None,
aux_save_triggers: 0,
free_effort: None,
free_effort2: None,
unlink: None,
unlink2: None,
copy: None,
copy2: None,
defrag: None,
},
);

View file

@ -15,11 +15,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use lazy_static::lazy_static;
use redis_module::NotifyEvent;
use redis_module::{redis_command, redis_event_handler, redis_module};
use redis_module::{NextArg, RedisResult};
//use redis_module::{NotifyEvent, key};
//use redis_module::{redis_command, redis_event_handler, redis_module};
use redis_module::{
key, redis_command, redis_event_handler, redis_module, Context, NextArg, NotifyEvent,
RedisError, RedisResult, RedisString, RedisValue, Status,
};
//use redis_module::{NextArg, RedisResult};
//use redis_module::RedisError;
use redis_module::Context;
//use redis_module::Context;
mod bucket;
mod challenge;
@ -64,17 +68,19 @@ lazy_static! {
pub static ref PREFIX_CHALLENGE: String = format!("{}:CHALLENGE", PKG_NAME);
}
pub fn on_delete(ctx: &Context, event_type: NotifyEvent, event: &str, key_name: &str) {
pub fn on_delete(ctx: &Context, event_type: NotifyEvent, event: &str, key_name: &[u8]) {
let key_name = redis_module::RedisString::create_from_slice(ctx.ctx, key_name);
let key_name = key_name.to_string();
let msg = format!(
"Received event: {:?} on key: {} via event: {}",
event_type, key_name, event
);
ctx.log_debug(msg.as_str());
if utils::is_bucket_timer(key_name) {
bucket::Bucket::on_delete(ctx, event_type, event, key_name);
} else if utils::is_mcaptcha_safety(key_name) {
crate::safety::MCaptchaSafety::on_delete(ctx, event_type, event, key_name);
if utils::is_bucket_timer(&key_name) {
bucket::Bucket::on_delete(ctx, event_type, event, &key_name);
} else if utils::is_mcaptcha_safety(&key_name) {
crate::safety::MCaptchaSafety::on_delete(ctx, event_type, event, &key_name);
}
}
@ -85,6 +91,7 @@ pub mod redis {
redis_module! {
name: "mcaptcha_cache",
version: PKG_VERSION,
allocator: (redis_module::alloc::RedisAlloc, redis_module::alloc::RedisAlloc),
data_types: [MCAPTCHA_BUCKET_TYPE, MCAPTCHA_MCAPTCHA_TYPE, MCAPTCHA_SAFETY_TYPE, MCAPTCHA_CHALLENGE_TYPE],
commands: [
["MCAPTCHA_CACHE.ADD_VISITOR", bucket::Bucket::counter_create, "write", 1, 1, 1],

View file

@ -112,7 +112,10 @@ impl MCaptcha {
let key_name = args.next_string()?;
let key_name = get_captcha_key(&key_name);
let stored_captcha = ctx.open_key(&RedisString::create(ctx.ctx, &key_name));
let stored_captcha = ctx.open_key(&RedisString::create_from_slice(
ctx.ctx,
key_name.as_bytes(),
));
if stored_captcha.key_type() == KeyType::Empty {
return CacheError::new(format!("key {} not found", key_name)).into();
}
@ -137,7 +140,10 @@ impl MCaptcha {
#[inline]
fn add_captcha_runner(ctx: &Context, key_name: &str, mcaptcha: MCaptcha) -> RedisResult {
let duration = mcaptcha.get_duration();
let key = ctx.open_key_writable(&RedisString::create(ctx.ctx, key_name));
let key = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
key_name.as_bytes(),
));
if key.key_type() == KeyType::Empty {
key.set_value(&MCAPTCHA_MCAPTCHA_TYPE, mcaptcha)?;
ctx.log_debug(&format!("mcaptcha {} created", key_name));
@ -155,7 +161,10 @@ impl MCaptcha {
let mut args = args.into_iter().skip(1);
let key_name = get_captcha_key(&args.next_string()?);
let key = ctx.open_key(&RedisString::create(ctx.ctx, &key_name));
let key = ctx.open_key(&RedisString::create_from_slice(
ctx.ctx,
key_name.as_bytes(),
));
if Self::captcha_exists_runner(&key) {
Ok(RedisValue::Integer(0))
} else {
@ -175,7 +184,10 @@ impl MCaptcha {
let key_name = get_captcha_key(&args.next_string()?);
let new_name = get_captcha_key(&args.next_string()?);
let key = ctx.open_key(&RedisString::create(ctx.ctx, &key_name));
let key = ctx.open_key(&RedisString::create_from_slice(
ctx.ctx,
key_name.as_bytes(),
));
if Self::captcha_exists_runner(&key) {
if let Some(mcaptcha) = Self::get_mcaptcha(&key)? {
let mcaptcha = MCaptcha {
@ -202,7 +214,10 @@ impl MCaptcha {
#[inline]
fn delete_captcha_runner(ctx: &Context, key_name: &str) -> RedisResult {
let key = ctx.open_key_writable(&RedisString::create(ctx.ctx, key_name));
let key = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
key_name.as_bytes(),
));
if key.key_type() == KeyType::Empty {
Err(RedisError::nonexistent_key())
} else {
@ -224,16 +239,21 @@ pub static MCAPTCHA_MCAPTCHA_TYPE: RedisType = RedisType::new(
// Currently unused by Redis
mem_usage: None,
mem_usage2: None,
digest: None,
// Aux data
aux_load: None,
aux_save: None,
aux_save2: None,
aux_save_triggers: 0,
free_effort: None,
free_effort2: None,
unlink: None,
unlink2: None,
copy: None,
copy2: None,
defrag: None,
},
);

View file

@ -48,7 +48,10 @@ impl MCaptchaSafety {
return;
}
let mcaptcha_name = mcaptcha_name.unwrap();
let mcaptcha = ctx.open_key(&RedisString::create(ctx.ctx, mcaptcha_name));
let mcaptcha = ctx.open_key(&RedisString::create_from_slice(
ctx.ctx,
mcaptcha_name.as_bytes(),
));
if mcaptcha.key_type() == KeyType::Empty {
ctx.log_warning(&format!("mcaptcha {} is empty", mcaptcha_name));
return;
@ -101,7 +104,10 @@ impl MCaptchaSafety {
#[allow(clippy::new_ret_no_self)]
pub fn new(ctx: &Context, duration: u64, mcaptcha_name: &str) -> CacheResult<()> {
let safety_name = get_safety_name(mcaptcha_name);
let safety = ctx.open_key_writable(&RedisString::create(ctx.ctx, &safety_name));
let safety = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
safety_name.as_bytes(),
));
if safety.key_type() == KeyType::Empty {
let safety_val = MCaptchaSafety {};
@ -130,7 +136,10 @@ impl MCaptchaSafety {
/// executes when timer goes off. Refreshes expiry timer and resets timer
fn boost(ctx: &Context, (safety_name, duration): (String, u64)) {
let safety = ctx.open_key_writable(&RedisString::create(ctx.ctx, &safety_name));
let safety = ctx.open_key_writable(&RedisString::create_from_slice(
ctx.ctx,
safety_name.as_bytes(),
));
// if safety is available in cache then refresh timer
if let Ok(Some(_safety_val)) = safety.get_value::<Self>(&MCAPTCHA_SAFETY_TYPE) {
@ -149,7 +158,10 @@ impl MCaptchaSafety {
return;
}
let mcaptcha_name = mcaptcha_name.unwrap();
let mcaptcha = ctx.open_key(&RedisString::create(ctx.ctx, mcaptcha_name));
let mcaptcha = ctx.open_key(&RedisString::create_from_slice(
ctx.ctx,
mcaptcha_name.as_bytes(),
));
if mcaptcha.key_type() == KeyType::Empty {
return;
}
@ -180,16 +192,21 @@ pub static MCAPTCHA_SAFETY_TYPE: RedisType = RedisType::new(
// Currently unused by Redis
mem_usage: None,
mem_usage2: None,
digest: None,
// Aux data
aux_load: None,
aux_save: None,
aux_save2: None,
aux_save_triggers: 0,
free_effort: None,
free_effort2: None,
unlink: None,
unlink2: None,
copy: None,
copy2: None,
defrag: None,
},
);