aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKunoiSayami <[email protected]>2021-07-13 00:13:44 +0800
committerKunoiSayami <[email protected]>2021-07-13 00:13:44 +0800
commit29680c6a0ac46684ad6c6712896649f6acff737f (patch)
tree9cfc603f103345198bff5e175504c61d2b90908c
parente92521c9143fb41fbb664ac6864e575fd79416b3 (diff)
feat(core): Rewritten configure file parserv3.0.0
* feat(core): Support full protect mode * feat(test): Reduced sleeping time and support new parser * feat(crate): Bump version
-rw-r--r--Cargo.lock274
-rw-r--r--Cargo.toml4
-rw-r--r--README.md5
-rw-r--r--src/datastructures.rs258
-rw-r--r--src/main.rs4
-rw-r--r--src/test.rs14
6 files changed, 325 insertions, 234 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 11b771a..e4e96f5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -9,22 +9,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc7d7cd957c9ed92288a7c3c96af81fa5291f65247a76a34dac7b6af74e52ba0"
dependencies = [
"futures-core",
- "tokio 1.5.0",
+ "tokio 1.8.1",
]
[[package]]
name = "ahash"
-version = "0.4.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e"
-
-[[package]]
-name = "ahash"
-version = "0.7.2"
+version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f200cbb1e856866d9eade941cf3aa0c5d7dd36f74311c4273b494f4ef036957"
+checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98"
dependencies = [
- "getrandom 0.2.2",
+ "getrandom 0.2.3",
"once_cell",
"version_check",
]
@@ -49,9 +43,9 @@ dependencies = [
[[package]]
name = "anyhow"
-version = "1.0.40"
+version = "1.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b"
+checksum = "595d3cfa7a60d4555cb5067b99f07142a08ea778de5cf993f7b75c7d8fabc486"
[[package]]
name = "arc-swap"
@@ -61,9 +55,9 @@ checksum = "dabe5a181f83789739c194cbe5a897dde195078fac08568d09221fd6137a7ba8"
[[package]]
name = "argon2"
-version = "0.2.0"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8fa6ffe98a5aacd627ea719b7295646e6c457ff78bc87dff0a8d1e1a00c80557"
+checksum = "d60f5f3113c903294dc81dd8cf0012963ed4dda8bc931c864e12e175356ff98b"
dependencies = [
"blake2",
"password-hash",
@@ -118,12 +112,11 @@ dependencies = [
[[package]]
name = "async-io"
-version = "1.4.1"
+version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4bbfd5cf2794b1e908ea8457e6c45f8f8f1f6ec5f74617bf4662623f47503c3b"
+checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b"
dependencies = [
"concurrent-queue",
- "fastrand",
"futures-lite",
"libc",
"log",
@@ -175,7 +168,7 @@ dependencies = [
"memchr",
"num_cpus",
"once_cell",
- "pin-project-lite 0.2.6",
+ "pin-project-lite 0.2.7",
"pin-utils",
"slab",
"wasm-bindgen-futures",
@@ -323,9 +316,9 @@ checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7"
[[package]]
name = "bumpalo"
-version = "3.6.1"
+version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe"
+checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631"
[[package]]
name = "byte-tools"
@@ -359,9 +352,9 @@ checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba"
[[package]]
name = "cc"
-version = "1.0.67"
+version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd"
+checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2"
[[package]]
name = "cfg-if"
@@ -377,7 +370,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cgit-simple-authentication"
-version = "2.0.0"
+version = "3.0.0"
dependencies = [
"anyhow",
"argon2",
@@ -390,14 +383,14 @@ dependencies = [
"log4rs",
"openssl",
"rand 0.7.3",
- "rand_core 0.6.2",
+ "rand_core 0.6.3",
"redis",
"regex",
"serde",
"serde_json",
"sqlx",
"tempdir",
- "tokio 1.5.0",
+ "tokio 1.8.1",
"tokio-stream",
"toml",
"url",
@@ -434,15 +427,15 @@ dependencies = [
[[package]]
name = "combine"
-version = "4.5.2"
+version = "4.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cc4369b5e4c0cddf64ad8981c0111e7df4f7078f4d6ba98fb31f2e17c4c57b7e"
+checksum = "a2d47c1b11006b87e492b53b313bb699ce60e16613c4dddaa91f8f7c220ab2fa"
dependencies = [
"bytes 0.5.6",
"bytes 1.0.1",
"futures-util",
"memchr",
- "pin-project-lite 0.2.6",
+ "pin-project-lite 0.2.7",
"tokio 0.2.25",
]
@@ -473,9 +466,9 @@ checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b"
[[package]]
name = "cpufeatures"
-version = "0.1.3"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "281f563b2c3a0e535ab12d81d3c5859045795256ad269afa7c19542585b68f93"
+checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef"
dependencies = [
"libc",
]
@@ -501,9 +494,9 @@ dependencies = [
[[package]]
name = "crossbeam-queue"
-version = "0.3.1"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0f6cb3c7f5b8e51bc3ebb73a2327ad4abdbd119dc13223f14f961d2f38486756"
+checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
@@ -511,11 +504,10 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
-version = "0.8.4"
+version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278"
+checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"
dependencies = [
- "autocfg",
"cfg-if 1.0.0",
"lazy_static",
]
@@ -589,9 +581,9 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "env_logger"
-version = "0.8.3"
+version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f"
+checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
dependencies = [
"atty",
"humantime",
@@ -730,16 +722,16 @@ checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1"
[[package]]
name = "futures-lite"
-version = "1.11.3"
+version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b4481d0cd0de1d204a4fa55e7d45f07b1d958abcb06714b3446438e2eff695fb"
+checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48"
dependencies = [
"fastrand",
"futures-core",
"futures-io",
"memchr",
"parking",
- "pin-project-lite 0.2.6",
+ "pin-project-lite 0.2.7",
"waker-fn",
]
@@ -782,7 +774,7 @@ dependencies = [
"futures-sink",
"futures-task",
"memchr",
- "pin-project-lite 0.2.6",
+ "pin-project-lite 0.2.7",
"pin-utils",
"proc-macro-hack",
"proc-macro-nested",
@@ -821,9 +813,9 @@ dependencies = [
[[package]]
name = "getrandom"
-version = "0.2.2"
+version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
+checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
dependencies = [
"cfg-if 1.0.0",
"libc",
@@ -859,36 +851,36 @@ dependencies = [
[[package]]
name = "hashbrown"
-version = "0.9.1"
+version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
+checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
- "ahash 0.4.7",
+ "ahash",
]
[[package]]
name = "hashlink"
-version = "0.6.0"
+version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d99cf782f0dc4372d26846bec3de7804ceb5df083c2d4462c0b8d2330e894fa8"
+checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf"
dependencies = [
"hashbrown",
]
[[package]]
name = "heck"
-version = "0.3.2"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac"
+checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "hermit-abi"
-version = "0.1.18"
+version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
+checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
@@ -918,9 +910,9 @@ dependencies = [
[[package]]
name = "indexmap"
-version = "1.6.2"
+version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
+checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
dependencies = [
"autocfg",
"hashbrown",
@@ -928,9 +920,9 @@ dependencies = [
[[package]]
name = "instant"
-version = "0.1.9"
+version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
+checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
dependencies = [
"cfg-if 1.0.0",
]
@@ -999,9 +991,9 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.94"
+version = "0.2.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
+checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790"
[[package]]
name = "libsqlite3-sys"
@@ -1112,9 +1104,9 @@ dependencies = [
[[package]]
name = "mio"
-version = "0.7.11"
+version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956"
+checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16"
dependencies = [
"libc",
"log",
@@ -1237,9 +1229,9 @@ dependencies = [
[[package]]
name = "once_cell"
-version = "1.7.2"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
+checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]]
name = "opaque-debug"
@@ -1255,9 +1247,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "openssl"
-version = "0.10.34"
+version = "0.10.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d7830286ad6a3973c0f1d9b73738f69c76b739301d0229c4b96501695cbe4c8"
+checksum = "549430950c79ae24e6d02e0b7404534ecf311d94cc9f861e9e4020187d13d885"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
@@ -1284,9 +1276,9 @@ dependencies = [
[[package]]
name = "openssl-sys"
-version = "0.9.63"
+version = "0.9.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6b0d6fb7d80f877617dfcb014e605e2b5ab2fb0afdf27935219bb6bd984cb98"
+checksum = "7a7907e3bfa08bb85105209cdfcb6c63d109f8f6c1ed6ca318fff5c1853fbc1d"
dependencies = [
"autocfg",
"cc",
@@ -1298,9 +1290,9 @@ dependencies = [
[[package]]
name = "ordered-float"
-version = "2.2.0"
+version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b50b8919aecb97e5ee9aceef27e24f39c46b11831130f4a6b7b091ec5de0de12"
+checksum = "6dea6388d3d5498ec651701f14edbaf463c924b5d8829fb2848ccf0bcc7b3c69"
dependencies = [
"num-traits",
]
@@ -1331,7 +1323,7 @@ dependencies = [
"cfg-if 1.0.0",
"instant",
"libc",
- "redox_syscall 0.2.8",
+ "redox_syscall 0.2.9",
"smallvec",
"winapi 0.3.9",
]
@@ -1343,7 +1335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1a5d4e9c205d2c1ae73b84aab6240e98218c0e72e63b50422cfb2d1ca952282"
dependencies = [
"base64ct",
- "rand_core 0.6.2",
+ "rand_core 0.6.3",
"subtle",
]
@@ -1404,9 +1396,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777"
[[package]]
name = "pin-project-lite"
-version = "0.2.6"
+version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
+checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443"
[[package]]
name = "pin-utils"
@@ -1422,14 +1414,14 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
[[package]]
name = "polling"
-version = "2.0.3"
+version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fc12d774e799ee9ebae13f4076ca003b40d18a11ac0f3641e6f899618580b7b"
+checksum = "92341d779fa34ea8437ef4d82d440d5e1ce3f3ff7f824aa64424cd481f9a1f25"
dependencies = [
"cfg-if 1.0.0",
"libc",
"log",
- "wepoll-sys",
+ "wepoll-ffi",
"winapi 0.3.9",
]
@@ -1453,9 +1445,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
[[package]]
name = "proc-macro2"
-version = "1.0.26"
+version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
+checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
dependencies = [
"unicode-xid",
]
@@ -1509,14 +1501,14 @@ dependencies = [
[[package]]
name = "rand"
-version = "0.8.3"
+version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
+checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [
"libc",
- "rand_chacha 0.3.0",
- "rand_core 0.6.2",
- "rand_hc 0.3.0",
+ "rand_chacha 0.3.1",
+ "rand_core 0.6.3",
+ "rand_hc 0.3.1",
]
[[package]]
@@ -1531,12 +1523,12 @@ dependencies = [
[[package]]
name = "rand_chacha"
-version = "0.3.0"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
+checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
- "rand_core 0.6.2",
+ "rand_core 0.6.3",
]
[[package]]
@@ -1565,11 +1557,11 @@ dependencies = [
[[package]]
name = "rand_core"
-version = "0.6.2"
+version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
+checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [
- "getrandom 0.2.2",
+ "getrandom 0.2.3",
]
[[package]]
@@ -1583,11 +1575,11 @@ dependencies = [
[[package]]
name = "rand_hc"
-version = "0.3.0"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
+checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [
- "rand_core 0.6.2",
+ "rand_core 0.6.3",
]
[[package]]
@@ -1628,9 +1620,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]]
name = "redox_syscall"
-version = "0.2.8"
+version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc"
+checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee"
dependencies = [
"bitflags",
]
@@ -1685,9 +1677,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "security-framework"
-version = "2.2.0"
+version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3670b1d2fdf6084d192bc71ead7aabe6c06aa2ea3fbd9cc3ac111fa5c2b1bd84"
+checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467"
dependencies = [
"bitflags",
"core-foundation",
@@ -1698,9 +1690,9 @@ dependencies = [
[[package]]
name = "security-framework-sys"
-version = "2.2.0"
+version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3676258fd3cfe2c9a0ec99ce3038798d847ce3e4bb17746373eb9f0f1ac16339"
+checksum = "7e4effb91b4b8b6fb7732e670b6cee160278ff8e6bf485c7805d9e319d76e284"
dependencies = [
"core-foundation-sys",
"libc",
@@ -1793,9 +1785,9 @@ dependencies = [
[[package]]
name = "signal-hook-registry"
-version = "1.3.0"
+version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6"
+checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0"
dependencies = [
"libc",
]
@@ -1837,9 +1829,9 @@ dependencies = [
[[package]]
name = "sqlx"
-version = "0.5.2"
+version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d582b9bc04ec6c03084196efc42c2226b018e9941f03ee62bd88921d500917c0"
+checksum = "ba82f79b31f30acebf19905bcd8b978f46891b9d0723f578447361a8910b6584"
dependencies = [
"sqlx-core",
"sqlx-macros",
@@ -1847,11 +1839,11 @@ dependencies = [
[[package]]
name = "sqlx-core"
-version = "0.5.2"
+version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "de52d1d473cebb2abb79c886ef6a8023e965e34c0676a99cfeac2cc7f0fde4c1"
+checksum = "7f23af36748ec8ea8d49ef8499839907be41b0b1178a4e82b8cb45d29f531dc9"
dependencies = [
- "ahash 0.7.2",
+ "ahash",
"atoi",
"bitflags",
"byteorder",
@@ -1889,14 +1881,15 @@ dependencies = [
[[package]]
name = "sqlx-macros"
-version = "0.5.2"
+version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a40f0be97e704d3fbf059e7e3333c3735639146a72d586c5534c70e79da88a4"
+checksum = "47e4a2349d1ffd60a03ca0de3f116ba55d7f406e55a0d84c64a5590866d94c06"
dependencies = [
"dotenv",
"either",
"futures",
"heck",
+ "once_cell",
"proc-macro2",
"quote",
"serde_json",
@@ -1909,14 +1902,14 @@ dependencies = [
[[package]]
name = "sqlx-rt"
-version = "0.5.2"
+version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6ae97ab05063ed515cdc23d90253213aa24dda0a288c5ec079af3d10f9771bc"
+checksum = "8199b421ecf3493ee9ef3e7bc90c904844cfb2ea7ea2f57347a93f52bfd3e057"
dependencies = [
"actix-rt",
"native-tls",
"once_cell",
- "tokio 1.5.0",
+ "tokio 1.8.1",
"tokio-native-tls",
]
@@ -1950,9 +1943,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
[[package]]
name = "syn"
-version = "1.0.72"
+version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82"
+checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
dependencies = [
"proc-macro2",
"quote",
@@ -1983,8 +1976,8 @@ checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
dependencies = [
"cfg-if 1.0.0",
"libc",
- "rand 0.8.3",
- "redox_syscall 0.2.8",
+ "rand 0.8.4",
+ "redox_syscall 0.2.9",
"remove_dir_all",
"winapi 0.3.9",
]
@@ -2009,18 +2002,18 @@ dependencies = [
[[package]]
name = "thiserror"
-version = "1.0.24"
+version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e"
+checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.24"
+version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
+checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745"
dependencies = [
"proc-macro2",
"quote",
@@ -2083,19 +2076,19 @@ dependencies = [
[[package]]
name = "tokio"
-version = "1.5.0"
+version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83f0c8e7c0addab50b663055baf787d0af7f413a46e6e7fb9559a4e4db7137a5"
+checksum = "98c8b05dc14c75ea83d63dd391100353789f5f24b8b3866542a5e85c8be8e985"
dependencies = [
"autocfg",
"bytes 1.0.1",
"libc",
"memchr",
- "mio 0.7.11",
+ "mio 0.7.13",
"num_cpus",
"once_cell",
"parking_lot",
- "pin-project-lite 0.2.6",
+ "pin-project-lite 0.2.7",
"signal-hook-registry",
"tokio-macros",
"winapi 0.3.9",
@@ -2103,9 +2096,9 @@ dependencies = [
[[package]]
name = "tokio-macros"
-version = "1.1.0"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57"
+checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110"
dependencies = [
"proc-macro2",
"quote",
@@ -2119,18 +2112,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
dependencies = [
"native-tls",
- "tokio 1.5.0",
+ "tokio 1.8.1",
]
[[package]]
name = "tokio-stream"
-version = "0.1.5"
+version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e177a5d8c3bf36de9ebe6d58537d8879e964332f93fb3339e43f618c81361af0"
+checksum = "7b2f3f698253f03119ac0102beaa64f67a67e08074d03a22d18784104543727f"
dependencies = [
"futures-core",
- "pin-project-lite 0.2.6",
- "tokio 1.5.0",
+ "pin-project-lite 0.2.7",
+ "tokio 1.8.1",
]
[[package]]
@@ -2194,18 +2187,18 @@ dependencies = [
[[package]]
name = "unicode-normalization"
-version = "0.1.17"
+version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef"
+checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9"
dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-segmentation"
-version = "1.7.1"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
+checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
name = "unicode-width"
@@ -2252,23 +2245,24 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
dependencies = [
- "getrandom 0.2.2",
+ "getrandom 0.2.3",
]
[[package]]
name = "value-bag"
-version = "1.0.0-alpha.6"
+version = "1.0.0-alpha.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6b676010e055c99033117c2343b33a40a30b91fecd6c49055ac9cd2d6c305ab1"
+checksum = "dd320e1520f94261153e96f7534476ad869c14022aee1e59af7c778075d840ae"
dependencies = [
"ctor",
+ "version_check",
]
[[package]]
name = "vcpkg"
-version = "0.2.12"
+version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cbdbff6266a24120518560b5dc983096efb98462e51d0d68169895b237be3e5d"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "vec_map"
@@ -2377,10 +2371,10 @@ dependencies = [
]
[[package]]
-name = "wepoll-sys"
-version = "3.0.1"
+name = "wepoll-ffi"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fcb14dea929042224824779fbc82d9fab8d2e6d3cbc0ac404de8edf489e77ff"
+checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb"
dependencies = [
"cc",
]
diff --git a/Cargo.toml b/Cargo.toml
index 0cd5638..f48ed89 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "cgit-simple-authentication"
-version = "2.0.0"
+version = "3.0.0"
authors = ["KunoiSayami <[email protected]>"]
edition = "2018"
@@ -29,4 +29,4 @@ regex = "1"
[target.aarch64-unknown-linux-musl.dependencies]
openssl = { version = "0.10", features = ["vendored"] }
-cpufeatures = "0.1.3" \ No newline at end of file
+cpufeatures = "0.1.3"
diff --git a/README.md b/README.md
index 83337aa..0c3207a 100644
--- a/README.md
+++ b/README.md
@@ -20,12 +20,13 @@ cgit-simple-auth-database=/etc/cgit/auth.db
# Should authenticate in repositories root view
cgit-simple-auth-bypass-root=false
# Should enable authenticate in all repository
-cgit-simple-auth-full-protect=true
+# Available options: full, part, none
+cgit-simple-auth-protect=full
```
Available options for repositories:
-_You should set `cgit-simple-auth-full-protect=false`_
+_You should set `cgit-simple-auth-protect=part`_
```conf
repo.url=test
diff --git a/src/datastructures.rs b/src/datastructures.rs
index 51f000c..6e03679 100644
--- a/src/datastructures.rs
+++ b/src/datastructures.rs
@@ -79,26 +79,7 @@ pub struct Config {
database: String,
pub bypass_root: bool,
pub(crate) test: bool,
-
- /// To set specify repository protect, You should setup repo's protect attribute
- /// First, set cgit-simple-auth-protect to none in /etc/cgitrc file
- ///
- /// # Examples
- ///
- /// In /etc/cgitrc:
- /// ```conf
- /// cgit-simple-auth-full-protect=false
- /// ```
- ///
- /// In repo.conf
- /// ```conf
- /// repo.url=test
- /// repo.protect=true
- /// ```
- ///
- /// Default behavior is protect all repository
- protect_all: bool,
- protected_repos: Vec<String>,
+ protect_config: ProtectSettings,
}
impl Default for Config {
@@ -108,8 +89,7 @@ impl Default for Config {
database: DEFAULT_DATABASE_LOCATION.to_string(),
bypass_root: false,
test: false,
- protect_all: true,
- protected_repos: Default::default(),
+ protect_config: Default::default()
}
}
}
@@ -125,7 +105,8 @@ impl Config {
let mut cookie_ttl: u64 = DEFAULT_COOKIE_TTL;
let mut database: &str = "/etc/cgit/auth.db";
let mut bypass_root: bool = false;
- let mut protect_all: bool = true;
+ let mut protect_enabled: bool = true;
+ let mut protect_white_list_mode: bool = true;
for line in file.lines() {
let line = line.trim();
@@ -144,71 +125,35 @@ impl Config {
"cookie-ttl" => cookie_ttl = value.parse().unwrap_or(DEFAULT_COOKIE_TTL),
"database" => database = value,
"bypass-root" => bypass_root = value.to_lowercase().eq("true"),
- "full-protect" => protect_all = !value.to_lowercase().eq("false"),
+ "protect" => {
+ match value.to_lowercase().as_str() {
+ "full" => {
+ protect_enabled = true;
+ protect_white_list_mode = true;
+ }
+ "part" => {
+ protect_enabled = true;
+ protect_white_list_mode = false;
+ }
+ "none" => {
+ protect_enabled = false;
+ }
+ _ => {}
+ }
+ },
_ => {}
}
}
- let protected_repos = if !protect_all {
- Self::load_protect_repos_from_file(path)
- } else {
- Default::default()
- };
-
Self {
cookie_ttl,
database: database.to_string(),
bypass_root,
test: false,
- protect_all,
- protected_repos,
+ protect_config: ProtectSettings::from_path(protect_enabled, protect_white_list_mode, path)
}
}
- pub fn load_protect_repos_from_file<P: AsRef<Path>>(path: P) -> Vec<String> {
- let context = read_to_string(path).unwrap();
-
- let mut protect_repos = Vec::new();
-
- let mut current_repo: &str = "";
-
- for line in context.lines() {
- let line = line.trim();
- if line.starts_with('#') || !line.contains('=') {
- continue;
- }
-
- let (key, value) = if line.contains('#') {
- line.split_once('#')
- .unwrap()
- .0
- .trim()
- .split_once('=')
- .unwrap()
- } else {
- line.split_once('=').unwrap()
- };
-
- if key.eq("repo.url") {
- current_repo = value.trim();
- continue;
- }
-
- if key.eq("repo.protect")
- && value.trim().to_lowercase().eq("true")
- && !current_repo.is_empty()
- {
- protect_repos.push(current_repo.to_string());
- }
-
- if key.eq("include") {
- let r = Self::load_protect_repos_from_file(value);
- protect_repos.extend(r)
- }
- }
- protect_repos
- }
-
pub fn get_database_location(&self) -> &str {
self.database.as_str()
}
@@ -276,15 +221,12 @@ impl Config {
}
pub fn check_repo_protect(&self, repo: &str) -> bool {
- if self.protect_all {
- return true;
- }
- self.protected_repos.iter().any(|x| x.eq(repo))
+ self.protect_config.check_repo_protect(repo)
}
#[cfg(test)]
- pub(crate) fn query_is_all_protected(&self) -> bool {
- self.protect_all
+ pub(crate) fn get_white_list_mode_status(&self) -> bool {
+ self.protect_config.get_white_list_mode_status()
}
}
@@ -295,12 +237,160 @@ impl TestSuite for Config {
bypass_root: false,
cookie_ttl: DEFAULT_COOKIE_TTL,
test: true,
- protect_all: false,
- protected_repos: vec!["test".to_string(), "repo".to_string()],
+ protect_config: ProtectSettings::generate_test_config()
}
}
}
+
+
+/// To set specify repository protect, You should setup repo's protect attribute
+/// First, set cgit-simple-auth-protect to none in /etc/cgitrc file
+///
+/// # Examples
+///
+/// In /etc/cgitrc:
+/// ```conf
+/// # Available value: full, part, none
+/// cgit-simple-auth-protect=none
+/// ```
+///
+/// If option set to `part`, only some repositories will be protected
+/// which is enabled protect manually by `repo.protect=true`
+///
+/// If option set to `full`, vice versa. You can manually disable protection
+/// by set `repo.protect=false`
+///
+///
+/// In repo.conf
+/// ```conf
+/// repo.url=test
+/// repo.protect=true
+/// ```
+///
+/// If option set to `none`, all protection will be disabled.
+///
+/// Default behavior is protect all repository
+
+#[derive(Debug, Clone, Default)]
+struct ProtectSettings {
+ protect_enabled: bool,
+ /// If white list mode set to true,
+ /// Only repository in repos is unprotected
+ protect_white_list_mode: bool,
+ repos: Vec<String>
+}
+
+impl ProtectSettings {
+ pub fn from_path<P: AsRef<Path>>(protect_enabled: bool, protect_white_list_mode: bool, path: P) -> Self {
+ Self {
+ protect_enabled,
+ protect_white_list_mode,
+ repos: if protect_enabled {
+ Self::load_repos_from_path(protect_white_list_mode, path)
+ } else {
+ Default::default()
+ }
+ }
+ }
+
+ fn load_repos_from_path<P: AsRef<Path>>(white_list_mode: bool, path: P) -> Vec<String> {
+ let context = read_to_string(path).unwrap();
+
+ Self::load_repos_from_context(white_list_mode, &context)
+
+ }
+
+ fn load_repos_from_context(white_list_mode: bool, s: &String) -> Vec<String> {
+ let mut repos: Vec<String> = Default::default();
+
+ let mut last_insert_repo = "";
+ let mut last_repo = "";
+
+ for line in s.trim().lines() {
+ let line = line.trim();
+
+ if line.is_empty() || line.starts_with('#') || !line.contains('=') {
+ continue
+ }
+
+ let (key, value) = if line.contains('#') {
+ line.split_once('#')
+ .unwrap()
+ .0
+ .trim()
+ .split_once('=')
+ .unwrap()
+ } else {
+ line.split_once('=').unwrap()
+ };
+
+ if key.eq("include") {
+ repos.extend(Self::load_repos_from_path(white_list_mode, value));
+ continue
+ }
+
+ if !key.starts_with("repo.") {
+ continue
+ }
+
+ let (_, key) = key.split_once(".").unwrap();
+
+
+ if key.eq("url") {
+ last_repo = value;
+ }
+
+ if key.eq("protect") {
+ if last_repo.is_empty() {
+ continue
+ }
+ let value = value.to_lowercase();
+
+ if (white_list_mode && value.eq("false")) || (!white_list_mode && value.eq("true")) {
+ if last_insert_repo.eq(last_repo) {
+ log::warn!("Found duplicate options in repo {}", last_repo);
+ continue
+ }
+ repos.push(last_repo.to_string());
+ last_insert_repo = last_repo;
+ }
+ }
+
+ }
+ repos
+ }
+
+ pub fn check_repo_protect(&self, repo: &str) -> bool {
+ if !self.protect_enabled {
+ return false;
+ }
+ let ret = self.repos.iter().any(|x| x.eq(repo));
+ if self.protect_white_list_mode {
+ !ret
+ } else {
+ ret
+ }
+ }
+
+ #[cfg(test)]
+ pub(crate) fn get_white_list_mode_status(&self) -> bool {
+ self.protect_white_list_mode
+ }
+
+}
+
+impl TestSuite for ProtectSettings {
+ fn generate_test_config() -> Self {
+ Self {
+ protect_enabled: true,
+ protect_white_list_mode: false,
+ repos: vec!["test".to_string(), "repo".to_string()],
+ }
+ }
+}
+
+
#[derive(Debug, Clone, Default)]
pub struct FormData {
user: String,
diff --git a/src/main.rs b/src/main.rs
index be653fc..00b52a6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -109,6 +109,7 @@ async fn cmd_authenticate_cookie(matches: &ArgMatches<'_>, cfg: Config) -> Resul
let mut bypass = false;
+ // TODO: bypass root not working properly if we select sort mode
if cfg.bypass_root && current_url.eq("/") && repo.is_empty() {
bypass = true;
}
@@ -147,7 +148,8 @@ async fn cmd_authenticate_cookie(matches: &ArgMatches<'_>, cfg: Config) -> Resul
.get::<_, String>(format!("cgit_auth_{}", cookie.get_key()))
.await
{
- log::debug!("Cookie is valid");
+ // TODO: Extend cookie ttl in each authenticate request
+ //log::debug!("Cookie is valid");
if cookie.eq_body(r.as_str()) {
if repo.is_empty() {
return Ok(true);
diff --git a/src/test.rs b/src/test.rs
index fee2e0f..68ba29d 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -212,7 +212,7 @@ mod core {
fn test_91_auth_pass() {
lock(&PathBuf::from("test/REPO_USER_ADDED"), 10);
// If process is too fast, this function may got Database locked error
- sleep(Duration::from_millis(50));
+ sleep(Duration::from_millis(10));
let s = test_auth_post();
@@ -309,7 +309,7 @@ mod core {
let tmpdir = tempdir::TempDir::new("test").unwrap();
let another_file_path = format!(
- "include={}/REPO_SETTING # TEST\ncgit-simple-auth-full-protect=false",
+ "include={}/REPO_SETTING # TEST\ncgit-simple-auth-protect=part",
tmpdir.path().to_str().unwrap()
);
write_to_specify_file(&tmpdir.path().join("CFG"), another_file_path.as_bytes()).unwrap();
@@ -321,8 +321,10 @@ mod core {
let cfg = Config::load_from_path(tmpdir.path().join("CFG"));
- assert!(cfg.check_repo_protect("test"));
- assert!(!cfg.query_is_all_protected());
+ assert!(cfg.check_repo_protect("test"), "struct: {:#?}", cfg);
+ assert!(!cfg.get_white_list_mode_status());
+ // TODO:
+ //assert!(!cfg.query_is_all_protected());
write_to_specify_file(
&tmpdir.path().join("REPO_SETTING"),
@@ -333,7 +335,9 @@ mod core {
let cfg = Config::load_from_path(tmpdir.path().join("CFG"));
assert!(!cfg.check_repo_protect("test"));
- assert!(!cfg.query_is_all_protected());
+ assert!(!cfg.get_white_list_mode_status());
+ // TODO:
+ //assert!(!cfg.query_is_all_protected());
tmpdir.close().unwrap();
}