mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Move modules to individual projects. Change API syntax.
This commit is contained in:
+356
-8
@@ -22,6 +22,41 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android_system_properties"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bincode"
|
||||||
|
version = "2.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740"
|
||||||
|
dependencies = [
|
||||||
|
"bincode_derive",
|
||||||
|
"serde",
|
||||||
|
"unty",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bincode_derive"
|
||||||
|
version = "2.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09"
|
||||||
|
dependencies = [
|
||||||
|
"virtue",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.3.2"
|
version = "1.3.2"
|
||||||
@@ -61,6 +96,12 @@ dependencies = [
|
|||||||
"hybrid-array",
|
"hybrid-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.19.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cbc"
|
name = "cbc"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
@@ -70,6 +111,16 @@ dependencies = [
|
|||||||
"cipher",
|
"cipher",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.2.49"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "90583009037521a116abf44494efecd645ba48b6622457080f080b85544e2215"
|
||||||
|
dependencies = [
|
||||||
|
"find-msvc-tools",
|
||||||
|
"shlex",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "1.0.4"
|
version = "1.0.4"
|
||||||
@@ -88,6 +139,19 @@ version = "0.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chrono"
|
||||||
|
version = "0.4.42"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
|
||||||
|
dependencies = [
|
||||||
|
"iana-time-zone",
|
||||||
|
"js-sys",
|
||||||
|
"num-traits",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cipher"
|
name = "cipher"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
@@ -98,6 +162,20 @@ dependencies = [
|
|||||||
"inout",
|
"inout",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "client"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"unshell-lib",
|
||||||
|
"unshell-obfuscate",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "core-foundation-sys"
|
||||||
|
version = "0.8.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpufeatures"
|
name = "cpufeatures"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
@@ -107,6 +185,21 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-channel"
|
||||||
|
version = "0.5.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-utils"
|
||||||
|
version = "0.8.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-common"
|
name = "crypto-common"
|
||||||
version = "0.1.7"
|
version = "0.1.7"
|
||||||
@@ -127,6 +220,12 @@ dependencies = [
|
|||||||
"crypto-common",
|
"crypto-common",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "find-msvc-tools"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "generic-array"
|
name = "generic-array"
|
||||||
version = "0.14.7"
|
version = "0.14.7"
|
||||||
@@ -170,6 +269,30 @@ dependencies = [
|
|||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone"
|
||||||
|
version = "0.1.64"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb"
|
||||||
|
dependencies = [
|
||||||
|
"android_system_properties",
|
||||||
|
"core-foundation-sys",
|
||||||
|
"iana-time-zone-haiku",
|
||||||
|
"js-sys",
|
||||||
|
"log",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone-haiku"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inout"
|
name = "inout"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
@@ -180,12 +303,38 @@ dependencies = [
|
|||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.83"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.178"
|
version = "0.2.178"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
|
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libloading"
|
||||||
|
version = "0.8.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lock_api"
|
name = "lock_api"
|
||||||
version = "0.4.14"
|
version = "0.4.14"
|
||||||
@@ -195,12 +344,33 @@ dependencies = [
|
|||||||
"scopeguard",
|
"scopeguard",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.29"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.7.6"
|
version = "2.7.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.21.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot"
|
name = "parking_lot"
|
||||||
version = "0.12.5"
|
version = "0.12.5"
|
||||||
@@ -324,12 +494,67 @@ version = "0.8.8"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.22"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.228"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||||
|
dependencies = [
|
||||||
|
"serde_core",
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_core"
|
||||||
|
version = "1.0.228"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.228"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.111",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.145"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"memchr",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
"serde_core",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha2"
|
name = "sha2"
|
||||||
version = "0.10.9"
|
version = "0.10.9"
|
||||||
@@ -341,6 +566,12 @@ dependencies = [
|
|||||||
"digest",
|
"digest",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shlex"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smallvec"
|
name = "smallvec"
|
||||||
version = "1.15.1"
|
version = "1.15.1"
|
||||||
@@ -409,14 +640,6 @@ version = "1.0.22"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unshell-config"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"unshell-obfuscate",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unshell-crypt"
|
name = "unshell-crypt"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -431,6 +654,21 @@ dependencies = [
|
|||||||
"sha2",
|
"sha2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unshell-lib"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"bincode",
|
||||||
|
"chrono",
|
||||||
|
"crossbeam-channel",
|
||||||
|
"libc",
|
||||||
|
"libloading",
|
||||||
|
"rand",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"unshell-obfuscate",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unshell-obfuscate"
|
name = "unshell-obfuscate"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
@@ -443,12 +681,24 @@ dependencies = [
|
|||||||
"unshell-crypt",
|
"unshell-crypt",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unty"
|
||||||
|
version = "0.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.5"
|
version = "0.9.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "virtue"
|
||||||
|
version = "0.0.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasip2"
|
name = "wasip2"
|
||||||
version = "1.0.1+wasi-0.2.4"
|
version = "1.0.1+wasi-0.2.4"
|
||||||
@@ -458,6 +708,51 @@ dependencies = [
|
|||||||
"wit-bindgen",
|
"wit-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.106"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"once_cell",
|
||||||
|
"rustversion",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.106"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.106"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.111",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.106"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@@ -480,12 +775,65 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.62.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
||||||
|
dependencies = [
|
||||||
|
"windows-implement",
|
||||||
|
"windows-interface",
|
||||||
|
"windows-link",
|
||||||
|
"windows-result",
|
||||||
|
"windows-strings",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-implement"
|
||||||
|
version = "0.60.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.111",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-interface"
|
||||||
|
version = "0.59.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.111",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-link"
|
name = "windows-link"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-result"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-strings"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wit-bindgen"
|
name = "wit-bindgen"
|
||||||
version = "0.46.0"
|
version = "0.46.0"
|
||||||
@@ -1,21 +1,20 @@
|
|||||||
cargo-features = ["trim-paths"]
|
cargo-features = ["trim-paths"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "unshell-config"
|
name = "client"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["obfuscate"]
|
log_debug = ["unshell-lib/log_debug"]
|
||||||
|
obfuscate = ["unshell-lib/obfuscate"]
|
||||||
obfuscate = ["unshell-obfuscate/obfuscate"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = { version = "0.2.178", default-features = false }
|
unshell-lib = {path = "../../unshell-lib", default-featues = false}
|
||||||
|
unshell-obfuscate = {path = "../../unshell-obfuscate", default-featues = false}
|
||||||
unshell-obfuscate = {path = "../unshell-obfuscate", default-features=false}
|
|
||||||
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
strip = true # Strip symbols from the binary
|
strip = true # Strip symbols from the binary
|
||||||
+11
-6
@@ -1,17 +1,22 @@
|
|||||||
use std::{
|
use std::{
|
||||||
net::TcpStream,
|
net,
|
||||||
sync::{
|
sync::{
|
||||||
Arc,
|
Arc, Mutex,
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
},
|
},
|
||||||
thread::{self, JoinHandle},
|
thread::{self, JoinHandle},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{config::RuntimeConfig, network::Stream, *};
|
use unshell_lib::{
|
||||||
|
config::RuntimeConfig,
|
||||||
|
module::Manager,
|
||||||
|
network::{Stream, TcpStream},
|
||||||
|
*,
|
||||||
|
};
|
||||||
// use unshell_modules::{Manager, ModuleRuntime};
|
// use unshell_modules::{Manager, ModuleRuntime};
|
||||||
|
|
||||||
use crate::ModuleRuntime;
|
use unshell_lib::ModuleRuntime;
|
||||||
|
|
||||||
pub struct ClientRuntime {
|
pub struct ClientRuntime {
|
||||||
config: &'static RuntimeConfig,
|
config: &'static RuntimeConfig,
|
||||||
@@ -86,7 +91,7 @@ impl ModuleRuntime for ClientRuntime {
|
|||||||
debug!("Connecting to server...");
|
debug!("Connecting to server...");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let stream = match TcpStream::connect(host) {
|
let stream = match net::TcpStream::connect(host) {
|
||||||
Ok(stream) => stream,
|
Ok(stream) => stream,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to connect to server: {}", e);
|
error!("Failed to connect to server: {}", e);
|
||||||
@@ -99,7 +104,7 @@ impl ModuleRuntime for ClientRuntime {
|
|||||||
thread::sleep(Duration::from_millis(100));
|
thread::sleep(Duration::from_millis(100));
|
||||||
// Duration::from_millis(100);
|
// Duration::from_millis(100);
|
||||||
|
|
||||||
let stream = crate::network::TcpStream::new(stream);
|
let stream = TcpStream::new(stream);
|
||||||
let stream_clone = stream.try_clone().unwrap();
|
let stream_clone = stream.try_clone().unwrap();
|
||||||
|
|
||||||
manager.lock().unwrap().add_connection(stream_clone);
|
manager.lock().unwrap().add_connection(stream_clone);
|
||||||
@@ -2,21 +2,19 @@ mod client_runtime;
|
|||||||
|
|
||||||
pub const MODULE_NAME: &'static str = "client";
|
pub const MODULE_NAME: &'static str = "client";
|
||||||
|
|
||||||
// pub use unshell_modules::setup_logger;
|
|
||||||
|
|
||||||
// use unshell_modules::{Manager, ModuleRuntime, module_interface};
|
|
||||||
|
|
||||||
use std::any::TypeId;
|
use std::any::TypeId;
|
||||||
|
|
||||||
use crate::{
|
use unshell_lib::{
|
||||||
ModuleError,
|
ModuleError,
|
||||||
ModuleRuntime,
|
ModuleRuntime,
|
||||||
client::client_runtime::ClientRuntime,
|
// client::client_runtime::ClientRuntime,
|
||||||
config::{InterfaceWrapper, NamedComponent, RuntimeConfig},
|
config::{InterfaceWrapper, NamedComponent, RuntimeConfig},
|
||||||
module_interface,
|
module_interface,
|
||||||
warn, // module_interface,
|
warn, // module_interface,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::client_runtime::ClientRuntime;
|
||||||
|
|
||||||
pub extern "C" fn test1() {
|
pub extern "C" fn test1() {
|
||||||
warn!("Test1 called xxxxxxxxxxx");
|
warn!("Test1 called xxxxxxxxxxx");
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
name="Client"
|
||||||
|
version="0.1"
|
||||||
|
description="Test Client module"
|
||||||
|
authors=["astatin3"]
|
||||||
|
|
||||||
|
|
||||||
|
[config]
|
||||||
|
header1 = { Header = "Header123" }
|
||||||
|
integer1 = { Integer = {}}
|
||||||
|
|
||||||
|
[build_config]
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "server"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
name="Server"
|
||||||
|
version="0.1"
|
||||||
|
description="Test server module for unshell"
|
||||||
|
authors=["astatin3"]
|
||||||
|
|
||||||
|
|
||||||
|
[config]
|
||||||
|
header1 = { Header = "Header123" }
|
||||||
|
integer1 = { Integer = {}}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
name="UnShell Core"
|
||||||
|
version="0.1"
|
||||||
|
description="Core components for UnShell"
|
||||||
|
authors=["astatin3"]
|
||||||
|
|
||||||
|
child_components = [
|
||||||
|
"client/unshell_component.toml",
|
||||||
|
"server/unshell_component.toml"
|
||||||
|
]
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#![no_std]
|
|
||||||
#![no_main]
|
|
||||||
|
|
||||||
#[unsafe(no_mangle)]
|
|
||||||
fn main() {
|
|
||||||
let a = 135;
|
|
||||||
|
|
||||||
unshell_obfuscate::junk_asm!(15.);
|
|
||||||
|
|
||||||
unsafe { libc::exit(a as i32) }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[panic_handler]
|
|
||||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
|
||||||
loop {}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
use unshell_obfuscate::obfuscated_symbol;
|
|
||||||
|
|
||||||
use crate::config::NamedComponent;
|
|
||||||
|
|
||||||
/// Publicly facing accessor function for the payload to load inside the breakout modules.
|
|
||||||
#[obfuscated_symbol]
|
|
||||||
pub fn get_components() -> Vec<NamedComponent> {
|
|
||||||
return vec![
|
|
||||||
#[cfg(feature = "client")]
|
|
||||||
crate::client::get_named_component(),
|
|
||||||
#[cfg(feature = "server")]
|
|
||||||
crate::server::get_named_component(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,11 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
pub mod client;
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod logger;
|
pub mod logger;
|
||||||
pub mod module;
|
pub mod module;
|
||||||
pub mod network;
|
pub mod network;
|
||||||
pub mod server;
|
pub mod server;
|
||||||
|
|
||||||
mod components;
|
|
||||||
pub use components::get_components;
|
|
||||||
|
|
||||||
mod announcement;
|
mod announcement;
|
||||||
use std::{
|
use std::{
|
||||||
fmt::{self, Debug},
|
fmt::{self, Debug},
|
||||||
|
|||||||
@@ -7,12 +7,36 @@ use axum::{
|
|||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use unshell_lib::{debug, info};
|
use unshell_lib::{debug, info};
|
||||||
|
|
||||||
|
// axum_extra::
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
api::{auth, structs::CurrentUser},
|
api::{auth, structs::CurrentUser},
|
||||||
logger::Logger,
|
logger::Logger,
|
||||||
server::Server,
|
server::Server,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
macro_rules! route_get {
|
||||||
|
($router:expr, $path:expr, $func:expr) => {{
|
||||||
|
{
|
||||||
|
$router.route(
|
||||||
|
$path,
|
||||||
|
get($func).layer(middleware::from_fn(auth::authorize)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
// macro_rules! route_post {
|
||||||
|
// ($router:expr, $path:expr, $func:expr) => {{
|
||||||
|
// {
|
||||||
|
// $router.route(
|
||||||
|
// $path,
|
||||||
|
// post($func).layer(middleware::from_fn(auth::authorize)),
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// }};
|
||||||
|
// }
|
||||||
|
|
||||||
pub async fn start_api(address: &str, server: Server) {
|
pub async fn start_api(address: &str, server: Server) {
|
||||||
let listener = TcpListener::bind(address)
|
let listener = TcpListener::bind(address)
|
||||||
.await
|
.await
|
||||||
@@ -21,88 +45,21 @@ pub async fn start_api(address: &str, server: Server) {
|
|||||||
info!("Listening on {}", listener.local_addr().unwrap());
|
info!("Listening on {}", listener.local_addr().unwrap());
|
||||||
|
|
||||||
let mut router = Router::new().route("/api/auth", post(auth::sign_in));
|
let mut router = Router::new().route("/api/auth", post(auth::sign_in));
|
||||||
router = route_get_trees(router);
|
|
||||||
router = route_get_all_tree_values(router);
|
|
||||||
router = route_get_tree_keys(router);
|
|
||||||
router = route_trees(router);
|
router = route_trees(router);
|
||||||
|
|
||||||
router = route_get_log(router);
|
router = route_get!(router, "/api/log/{*offset}", Logger::poll_logs_api);
|
||||||
|
router = route_get!(router, "/api/trees", Server::get_trees_api);
|
||||||
|
router = route_get!(router, "/api/keys/{*path}", Server::all_tree_keys_api);
|
||||||
|
router = route_get!(router, "/api/values/{*path}", Server::all_tree_values_api);
|
||||||
|
|
||||||
|
// router = route_get_log(router);
|
||||||
|
|
||||||
axum::serve(listener, router.with_state(server))
|
axum::serve(listener, router.with_state(server))
|
||||||
.await
|
.await
|
||||||
.expect("Error serving application");
|
.expect("Error serving application");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route the "keys" api for each tree
|
|
||||||
fn route_get_log(router: Router<Server>) -> Router<Server> {
|
|
||||||
router.route(
|
|
||||||
"/api/log/{offset}",
|
|
||||||
get(
|
|
||||||
async |State(_): State<Server>,
|
|
||||||
Extension(_): Extension<CurrentUser>,
|
|
||||||
Path(offset): Path<usize>| {
|
|
||||||
debug!("GET /api/log/{}", offset);
|
|
||||||
let result = Logger::poll_logs(offset);
|
|
||||||
|
|
||||||
Json(serde_json::to_value(result).unwrap())
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.layer(middleware::from_fn(auth::authorize)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Route the "keys" api for each tree
|
|
||||||
fn route_get_trees(router: Router<Server>) -> Router<Server> {
|
|
||||||
router.route(
|
|
||||||
"/api/trees",
|
|
||||||
get(
|
|
||||||
async |State(server): State<Server>, Extension(_): Extension<CurrentUser>| {
|
|
||||||
debug!("GET /api/trees");
|
|
||||||
let result = server.get_trees();
|
|
||||||
|
|
||||||
Json(serde_json::to_value(result).unwrap())
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.layer(middleware::from_fn(auth::authorize)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Route the "keys" api for each tree
|
|
||||||
fn route_get_tree_keys(router: Router<Server>) -> Router<Server> {
|
|
||||||
router.route(
|
|
||||||
"/api/keys/{*path}",
|
|
||||||
get(
|
|
||||||
async |State(server): State<Server>,
|
|
||||||
Path(path): Path<String>,
|
|
||||||
Extension(_): Extension<CurrentUser>| {
|
|
||||||
debug!("GET /api/keys/{}", path);
|
|
||||||
let result = server.get_keys(&path);
|
|
||||||
|
|
||||||
Json(serde_json::to_value(result).unwrap())
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.layer(middleware::from_fn(auth::authorize)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Route the "values" api to get all the values for each tree
|
|
||||||
fn route_get_all_tree_values(router: Router<Server>) -> Router<Server> {
|
|
||||||
router.route(
|
|
||||||
"/api/values/{*path}",
|
|
||||||
get(
|
|
||||||
async |State(server): State<Server>,
|
|
||||||
Path(path): Path<String>,
|
|
||||||
Extension(_): Extension<CurrentUser>| {
|
|
||||||
debug!("GET /api/values/{}", path);
|
|
||||||
let result = server.all_tree_values(&path);
|
|
||||||
|
|
||||||
Json(serde_json::to_value(result).unwrap())
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.layer(middleware::from_fn(auth::authorize)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop through all trees and add /api/<tree>/<path> POST aand GET listeners for them
|
// Loop through all trees and add /api/<tree>/<path> POST aand GET listeners for them
|
||||||
fn route_trees(mut router: Router<Server>) -> Router<Server> {
|
fn route_trees(mut router: Router<Server>) -> Router<Server> {
|
||||||
for tree in crate::DATABASE_TREES.iter() {
|
for tree in crate::DATABASE_TREES.iter() {
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ pub mod app;
|
|||||||
mod auth;
|
mod auth;
|
||||||
mod structs;
|
mod structs;
|
||||||
|
|
||||||
|
pub use structs::CurrentUser;
|
||||||
|
|
||||||
static EXPIRE_DURATION: Duration = Duration::hours(12);
|
static EXPIRE_DURATION: Duration = Duration::hours(12);
|
||||||
|
|
||||||
#[dynamic]
|
#[dynamic]
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use crate::config::ConfigStructField;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
|
||||||
|
pub struct Blob {
|
||||||
|
name: String,
|
||||||
|
|
||||||
|
parent_component: String,
|
||||||
|
// parent_runtime: String,
|
||||||
|
config: HashMap<String, ConfigStructField>,
|
||||||
|
}
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
mod blob;
|
||||||
|
|
||||||
|
pub use blob::Blob;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
error::Error,
|
error::Error,
|
||||||
@@ -67,7 +71,7 @@ pub struct ComponentState {
|
|||||||
|
|
||||||
pub fn load_config(path: &PathBuf) -> Result<Vec<ComponentState>, Box<dyn Error>> {
|
pub fn load_config(path: &PathBuf) -> Result<Vec<ComponentState>, Box<dyn Error>> {
|
||||||
let path_absolute = fs::canonicalize(path.clone())?;
|
let path_absolute = fs::canonicalize(path.clone())?;
|
||||||
debug!("Loading data from path: `{}`", path_absolute);
|
debug!("Loading data from path: `{:?}`", path_absolute);
|
||||||
|
|
||||||
// Read string as path
|
// Read string as path
|
||||||
let config_str = fs::read_to_string(path.clone())?;
|
let config_str = fs::read_to_string(path.clone())?;
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ pub static DEFAULT_HOST: String = "localhost".to_string();
|
|||||||
#[static_init::dynamic]
|
#[static_init::dynamic]
|
||||||
pub static DATABASE_NAME: String = "database".to_string();
|
pub static DATABASE_NAME: String = "database".to_string();
|
||||||
|
|
||||||
#[static_init::dynamic]
|
// #[static_init::dynamic]
|
||||||
pub static SERVER_CONFIG: unshell_lib::config::PayloadConfig = unshell_lib::config::PayloadConfig {
|
// pub static SERVER_CONFIG: unshell_lib::config::PayloadConfig = unshell_lib::config::PayloadConfig {
|
||||||
id: "Server",
|
// id: "Server",
|
||||||
components: unshell_lib::get_components(),
|
// components: unshell_lib::get_components(),
|
||||||
runtime_config: Vec::new(),
|
// runtime_config: Vec::new(),
|
||||||
};
|
// };
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
|
use axum::extract::{Path, State};
|
||||||
|
use axum::{Extension, Json};
|
||||||
use chrono::Local;
|
use chrono::Local;
|
||||||
|
use unshell_lib::debug;
|
||||||
// use lazy_static::lazy_static;
|
// use lazy_static::lazy_static;
|
||||||
use std::fs::{self, File, OpenOptions};
|
use std::fs::{self, File, OpenOptions};
|
||||||
use std::io::{BufRead, BufReader, Write};
|
use std::io::{BufRead, BufReader, Write};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use crate::Server;
|
||||||
|
use crate::api::CurrentUser;
|
||||||
|
|
||||||
// --- Constants ---
|
// --- Constants ---
|
||||||
/// The directory where log files will be stored.
|
/// The directory where log files will be stored.
|
||||||
const LOG_DIR: &str = "logs";
|
const LOG_DIR: &str = "logs";
|
||||||
@@ -125,6 +131,18 @@ impl Logger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Route the "keys" api for each tree
|
||||||
|
pub async fn poll_logs_api(
|
||||||
|
State(_): State<Server>,
|
||||||
|
Extension(_): Extension<CurrentUser>,
|
||||||
|
Path(offset): Path<usize>,
|
||||||
|
) -> axum::Json<serde_json::Value> {
|
||||||
|
debug!("GET /api/log/{}", offset);
|
||||||
|
let result = Self::poll_logs(offset);
|
||||||
|
|
||||||
|
Json(serde_json::to_value(result).unwrap())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Example Usage ---
|
// --- Example Usage ---
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
use crate::Server;
|
||||||
|
|
||||||
|
impl Server {
|
||||||
|
pub fn get_blobs(&self) -> Result<Vec<Value>, String> {
|
||||||
|
Ok(Vec::new())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use axum::{
|
||||||
|
Extension, Json,
|
||||||
|
extract::{Path, State},
|
||||||
|
};
|
||||||
|
use serde_json::Value;
|
||||||
use sled::Tree;
|
use sled::Tree;
|
||||||
use unshell_lib::error;
|
use unshell_lib::{debug, error};
|
||||||
|
|
||||||
use crate::server::Server;
|
use crate::{api::CurrentUser, server::Server};
|
||||||
|
|
||||||
// #[derive(Clone)]
|
|
||||||
// pub struct Database {
|
|
||||||
// db: sled::Db,
|
|
||||||
// }
|
|
||||||
|
|
||||||
impl Server {
|
impl Server {
|
||||||
fn get_tree(&self, tree_name: &str) -> Result<Tree, String> {
|
fn get_tree(&self, tree_name: &str) -> Result<Tree, String> {
|
||||||
@@ -18,12 +18,17 @@ impl Server {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_trees(&self) -> Vec<String> {
|
pub async fn get_trees_api(State(server): State<Server>) -> Json<Value> {
|
||||||
self.db
|
debug!("GET tree list");
|
||||||
|
|
||||||
|
let result = server
|
||||||
|
.db
|
||||||
.tree_names()
|
.tree_names()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|n| String::from_utf8_lossy(&n.to_vec()).to_string())
|
.map(|n| String::from_utf8_lossy(&n.to_vec()).to_string())
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
|
Json(serde_json::to_value(result).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn put_value(&self, tree_name: &str, key: &str, value: &str) -> Result<(), String> {
|
pub fn put_value(&self, tree_name: &str, key: &str, value: &str) -> Result<(), String> {
|
||||||
@@ -50,7 +55,7 @@ impl Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_keys(&self, tree_name: &str) -> Result<Vec<String>, String> {
|
fn get_keys(&self, tree_name: &str) -> Result<Vec<String>, String> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.get_tree(tree_name)?
|
.get_tree(tree_name)?
|
||||||
.iter()
|
.iter()
|
||||||
@@ -61,15 +66,35 @@ impl Server {
|
|||||||
.collect::<Vec<String>>())
|
.collect::<Vec<String>>())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all_tree_values(&self, tree_name: &str) -> Result<HashMap<String, String>, String> {
|
// Route the "keys" api for each tree
|
||||||
Ok(self
|
pub async fn all_tree_keys_api(
|
||||||
.get_keys(tree_name)?
|
State(server): State<Server>,
|
||||||
|
Path(tree_name): Path<String>,
|
||||||
|
Extension(_): Extension<CurrentUser>,
|
||||||
|
) -> Json<Value> {
|
||||||
|
let result = server.get_keys(&tree_name);
|
||||||
|
|
||||||
|
Json(serde_json::to_value(result).unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Route the "values" api to get all the values for each tree
|
||||||
|
pub async fn all_tree_values_api(
|
||||||
|
State(server): State<Server>,
|
||||||
|
Path(tree_name): Path<String>,
|
||||||
|
Extension(_): Extension<CurrentUser>,
|
||||||
|
) -> Json<Value> {
|
||||||
|
let result = || -> Result<HashMap<String, String>, String> {
|
||||||
|
Ok(server
|
||||||
|
.get_keys(&tree_name)?
|
||||||
.iter()
|
.iter()
|
||||||
.map(|key| -> Result<(String, String), String> {
|
.map(|key| -> Result<(String, String), String> {
|
||||||
Ok((key.clone(), self.get_value(tree_name, &key)?))
|
Ok((key.clone(), server.get_value(&tree_name, &key)?))
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<(String, String)>, String>>()?
|
.collect::<Result<Vec<(String, String)>, String>>()?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<HashMap<String, String>>())
|
.collect::<HashMap<String, String>>())
|
||||||
|
}();
|
||||||
|
|
||||||
|
Json(serde_json::to_value(result).unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::{error::Error, path::PathBuf};
|
use std::{error::Error, path::PathBuf};
|
||||||
|
|
||||||
|
mod blobs;
|
||||||
mod database;
|
mod database;
|
||||||
mod manager;
|
mod manager;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user