add command works ,fix warnings, proxy repaired, docker start arguments defined

This commit is contained in:
2026-06-05 22:03:22 +02:00
parent e52763c35e
commit 25d7a6ffd1
19 changed files with 819 additions and 132 deletions

640
Cargo.lock generated
View File

@ -2,6 +2,23 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 4 version = 4
[[package]]
name = "adler2"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "aes"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1fc76eaeac4c9164506c466d4ffdd8ec9d0c5bf57ee97177c4d8eceb3a0e138"
dependencies = [
"cipher",
"cpubits",
"cpufeatures",
]
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "1.1.4" version = "1.1.4"
@ -70,6 +87,12 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "anyhow"
version = "1.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
[[package]] [[package]]
name = "async-channel" name = "async-channel"
version = "1.9.0" version = "1.9.0"
@ -207,6 +230,16 @@ version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"
[[package]]
name = "block-buffer"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be"
dependencies = [
"hybrid-array",
"zeroize",
]
[[package]] [[package]]
name = "blocking" name = "blocking"
version = "1.6.2" version = "1.6.2"
@ -281,6 +314,15 @@ version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
[[package]]
name = "bzip2"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3a53fac24f34a81bc9954b5d6cfce0c21e18ec6959f44f56e8e90e4bb7c346c"
dependencies = [
"libbz2-rs-sys",
]
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.63" version = "1.2.63"
@ -288,6 +330,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "556e016178bb5662a08681bbe0f00f8e17631781a4dfc8c45e466e4b185ec27f" checksum = "556e016178bb5662a08681bbe0f00f8e17631781a4dfc8c45e466e4b185ec27f"
dependencies = [ dependencies = [
"find-msvc-tools", "find-msvc-tools",
"jobserver",
"libc",
"shlex", "shlex",
] ]
@ -310,6 +354,16 @@ dependencies = [
"windows-link", "windows-link",
] ]
[[package]]
name = "cipher"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c"
dependencies = [
"crypto-common",
"inout",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.6.1" version = "4.6.1"
@ -337,6 +391,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
[[package]]
name = "cmov"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"
[[package]] [[package]]
name = "colorchoice" name = "colorchoice"
version = "1.0.5" version = "1.0.5"
@ -352,18 +412,72 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "const-oid"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
[[package]]
name = "constant_time_eq"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b"
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.7" version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "cpubits"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"
[[package]]
name = "cpufeatures"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
dependencies = [
"libc",
]
[[package]]
name = "crc32fast"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
dependencies = [
"cfg-if",
]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.21" version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "crypto-common"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
dependencies = [
"hybrid-array",
]
[[package]]
name = "ctutils"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e"
dependencies = [
"cmov",
]
[[package]] [[package]]
name = "darling" name = "darling"
version = "0.21.3" version = "0.21.3"
@ -399,6 +513,21 @@ dependencies = [
"syn 2.0.117", "syn 2.0.117",
] ]
[[package]]
name = "deflate64"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac6b926516df9c60bfa16e107b21086399f8285a44ca9711344b9e553c5146e2"
[[package]]
name = "deranged"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
dependencies = [
"powerfmt",
]
[[package]] [[package]]
name = "diesel" name = "diesel"
version = "2.3.9" version = "2.3.9"
@ -447,6 +576,19 @@ dependencies = [
"syn 2.0.117", "syn 2.0.117",
] ]
[[package]]
name = "digest"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
dependencies = [
"block-buffer",
"const-oid",
"crypto-common",
"ctutils",
"zeroize",
]
[[package]] [[package]]
name = "displaydoc" name = "displaydoc"
version = "0.2.5" version = "0.2.5"
@ -473,6 +615,7 @@ dependencies = [
"serde", "serde",
"thiserror", "thiserror",
"tokio", "tokio",
"zip",
] ]
[[package]] [[package]]
@ -501,6 +644,12 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.3.14" version = "0.3.14"
@ -550,12 +699,28 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
[[package]]
name = "flate2"
version = "1.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"
dependencies = [
"miniz_oxide",
"zlib-rs",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]] [[package]]
name = "form_urlencoded" name = "form_urlencoded"
version = "1.2.2" version = "1.2.2"
@ -635,6 +800,33 @@ dependencies = [
"slab", "slab",
] ]
[[package]]
name = "getrandom"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
"libc",
"r-efi 5.3.0",
"wasip2",
]
[[package]]
name = "getrandom"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"r-efi 6.0.0",
"wasip2",
"wasip3",
"wasm-bindgen",
]
[[package]] [[package]]
name = "gloo-timers" name = "gloo-timers"
version = "0.3.0" version = "0.3.0"
@ -647,6 +839,21 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "hashbrown"
version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [
"foldhash",
]
[[package]]
name = "hashbrown"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.5.0" version = "0.5.0"
@ -665,6 +872,15 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "hmac"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f"
dependencies = [
"digest",
]
[[package]] [[package]]
name = "http" name = "http"
version = "1.4.0" version = "1.4.0"
@ -710,6 +926,15 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]
name = "hybrid-array"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9155a582abd142abc056962c29e3ce5ff2ad5469f4246b537ed42c5deba857da"
dependencies = [
"typenum",
]
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "1.9.0" version = "1.9.0"
@ -887,6 +1112,12 @@ dependencies = [
"zerovec", "zerovec",
] ]
[[package]]
name = "id-arena"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
[[package]] [[package]]
name = "ident_case" name = "ident_case"
version = "1.0.1" version = "1.0.1"
@ -914,6 +1145,27 @@ dependencies = [
"icu_properties", "icu_properties",
] ]
[[package]]
name = "indexmap"
version = "2.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
dependencies = [
"equivalent",
"hashbrown 0.17.1",
"serde",
"serde_core",
]
[[package]]
name = "inout"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7"
dependencies = [
"hybrid-array",
]
[[package]] [[package]]
name = "is_terminal_polyfill" name = "is_terminal_polyfill"
version = "1.70.2" version = "1.70.2"
@ -926,6 +1178,16 @@ version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "jobserver"
version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33"
dependencies = [
"getrandom 0.3.4",
"libc",
]
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.98" version = "0.3.98"
@ -953,6 +1215,18 @@ dependencies = [
"log", "log",
] ]
[[package]]
name = "leb128fmt"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
[[package]]
name = "libbz2-rs-sys"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34b357333733e8260735ba5894eb928c02ecc69c78715f01a8019e7fa7f2db4c"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.186" version = "0.2.186"
@ -989,12 +1263,31 @@ dependencies = [
"value-bag", "value-bag",
] ]
[[package]]
name = "lzma-rust2"
version = "0.16.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce716bf1a316f47a280fc76295f6495b5bea4752bca01c3b3885e101b1c23c02"
dependencies = [
"sha2",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.8.0" version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
[[package]]
name = "miniz_oxide"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
dependencies = [
"adler2",
"simd-adler32",
]
[[package]] [[package]]
name = "mio" name = "mio"
version = "1.2.0" version = "1.2.0"
@ -1006,6 +1299,12 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "num-conv"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.19" version = "0.2.19"
@ -1056,6 +1355,16 @@ dependencies = [
"windows-link", "windows-link",
] ]
[[package]]
name = "pbkdf2"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "112d82ceb8c5bf524d9af484d4e4970c9fd5a0cc15ba14ad93dccd28873b0629"
dependencies = [
"digest",
"hmac",
]
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.3.2" version = "2.3.2"
@ -1114,6 +1423,18 @@ dependencies = [
"zerovec", "zerovec",
] ]
[[package]]
name = "powerfmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "ppmd-rust"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efca4c95a19a79d1c98f791f10aebd5c1363b473244630bb7dbde1dc98455a24"
[[package]] [[package]]
name = "pq-sys" name = "pq-sys"
version = "0.7.5" version = "0.7.5"
@ -1125,6 +1446,16 @@ dependencies = [
"vcpkg", "vcpkg",
] ]
[[package]]
name = "prettyplease"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
dependencies = [
"proc-macro2",
"syn 2.0.117",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.106" version = "1.0.106"
@ -1143,6 +1474,18 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "r-efi"
version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
name = "r-efi"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
[[package]] [[package]]
name = "r2d2" name = "r2d2"
version = "0.8.10" version = "0.8.10"
@ -1232,6 +1575,12 @@ 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 = "semver"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.228" version = "1.0.228"
@ -1298,6 +1647,28 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "sha1"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "sha2"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]] [[package]]
name = "shlex" name = "shlex"
version = "2.0.1" version = "2.0.1"
@ -1314,6 +1685,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "simd-adler32"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.12" version = "0.4.12"
@ -1401,6 +1778,26 @@ dependencies = [
"syn 2.0.117", "syn 2.0.117",
] ]
[[package]]
name = "time"
version = "0.3.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c"
dependencies = [
"deranged",
"js-sys",
"num-conv",
"powerfmt",
"serde_core",
"time-core",
]
[[package]]
name = "time-core"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca"
[[package]] [[package]]
name = "tinystr" name = "tinystr"
version = "0.8.3" version = "0.8.3"
@ -1482,12 +1879,30 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "typed-path"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e28f89b80c87b8fb0cf04ab448d5dd0dd0ade2f8891bae878de66a75a28600e"
[[package]]
name = "typenum"
version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.24" version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "unicode-xid"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]] [[package]]
name = "url" name = "url"
version = "2.5.8" version = "2.5.8"
@ -1539,6 +1954,24 @@ version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "wasip2"
version = "1.0.3+wasi-0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6"
dependencies = [
"wit-bindgen 0.57.1",
]
[[package]]
name = "wasip3"
version = "0.4.0+wasi-0.3.0-rc-2026-01-06"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"
dependencies = [
"wit-bindgen 0.51.0",
]
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.121" version = "0.2.121"
@ -1594,6 +2027,40 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "wasm-encoder"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319"
dependencies = [
"leb128fmt",
"wasmparser",
]
[[package]]
name = "wasm-metadata"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
dependencies = [
"anyhow",
"indexmap",
"wasm-encoder",
"wasmparser",
]
[[package]]
name = "wasmparser"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
dependencies = [
"bitflags",
"hashbrown 0.15.5",
"indexmap",
"semver",
]
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@ -1684,6 +2151,100 @@ dependencies = [
"windows-link", "windows-link",
] ]
[[package]]
name = "wit-bindgen"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
dependencies = [
"wit-bindgen-rust-macro",
]
[[package]]
name = "wit-bindgen"
version = "0.57.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
[[package]]
name = "wit-bindgen-core"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"
dependencies = [
"anyhow",
"heck",
"wit-parser",
]
[[package]]
name = "wit-bindgen-rust"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
dependencies = [
"anyhow",
"heck",
"indexmap",
"prettyplease",
"syn 2.0.117",
"wasm-metadata",
"wit-bindgen-core",
"wit-component",
]
[[package]]
name = "wit-bindgen-rust-macro"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a"
dependencies = [
"anyhow",
"prettyplease",
"proc-macro2",
"quote",
"syn 2.0.117",
"wit-bindgen-core",
"wit-bindgen-rust",
]
[[package]]
name = "wit-component"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
dependencies = [
"anyhow",
"bitflags",
"indexmap",
"log",
"serde",
"serde_derive",
"serde_json",
"wasm-encoder",
"wasm-metadata",
"wasmparser",
"wit-parser",
]
[[package]]
name = "wit-parser"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
dependencies = [
"anyhow",
"id-arena",
"indexmap",
"log",
"semver",
"serde",
"serde_derive",
"serde_json",
"unicode-xid",
"wasmparser",
]
[[package]] [[package]]
name = "writeable" name = "writeable"
version = "0.6.3" version = "0.6.3"
@ -1734,6 +2295,12 @@ dependencies = [
"synstructure", "synstructure",
] ]
[[package]]
name = "zeroize"
version = "1.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0"
[[package]] [[package]]
name = "zerotrie" name = "zerotrie"
version = "0.2.4" version = "0.2.4"
@ -1767,8 +2334,81 @@ dependencies = [
"syn 2.0.117", "syn 2.0.117",
] ]
[[package]]
name = "zip"
version = "8.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b"
dependencies = [
"aes",
"bzip2",
"constant_time_eq",
"crc32fast",
"deflate64",
"flate2",
"getrandom 0.4.2",
"hmac",
"indexmap",
"lzma-rust2",
"memchr",
"pbkdf2",
"ppmd-rust",
"sha1",
"time",
"typed-path",
"zeroize",
"zopfli",
"zstd",
]
[[package]]
name = "zlib-rs"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3be3d40e40a133f9c916ee3f9f4fa2d9d63435b5fbe1bfc6d9dae0aa0ada1513"
[[package]] [[package]]
name = "zmij" name = "zmij"
version = "1.0.21" version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
[[package]]
name = "zopfli"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249"
dependencies = [
"bumpalo",
"crc32fast",
"log",
"simd-adler32",
]
[[package]]
name = "zstd"
version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a"
dependencies = [
"zstd-safe",
]
[[package]]
name = "zstd-safe"
version = "7.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d"
dependencies = [
"zstd-sys",
]
[[package]]
name = "zstd-sys"
version = "2.0.16+zstd.1.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748"
dependencies = [
"cc",
"pkg-config",
]

View File

@ -14,4 +14,5 @@ json = "0.12.4"
regex = "1.12.3" regex = "1.12.3"
serde = "1.0.228" serde = "1.0.228"
thiserror = "2.0.18" thiserror = "2.0.18"
tokio = { version = "1.52.1", features = ["net", "rt", "macros", "signal"] } tokio = { version = "1.52.1", features = ["net", "rt", "macros", "signal", "fs"] }
zip = "8.6.0"

View File

@ -1,7 +1,6 @@
CREATE TABLE "servers" ( CREATE TABLE "servers" (
"id" BIGSERIAL PRIMARY KEY, "id" BIGSERIAL PRIMARY KEY,
"name" varchar(255) UNIQUE NOT NULL, "name" varchar(255) UNIQUE NOT NULL,
"volume_path" varchar(255) UNIQUE NOT NULL,
"last_login" timestamp, "last_login" timestamp,
"container_id" varchar(30), "container_id" varchar(30),
"status" int2 NOT NULL DEFAULT 0, "status" int2 NOT NULL DEFAULT 0,
@ -9,4 +8,4 @@ CREATE TABLE "servers" (
"redirect_ip" varchar(50) "redirect_ip" varchar(50)
); );
insert into servers (name, volume_path, last_login, container_id, status, is_default, redirect_ip) values ('potato', 'nothing', now(), null, 1, false, 'play.hypixel.net:25565'); insert into servers (name, last_login, container_id, status, is_default, redirect_ip) values ('potato', now(), null, 1, false, 'play.hypixel.net:25565');

View File

@ -1,27 +1,69 @@
use clap::{ArgMatches, Command, arg}; use clap::{ArgMatches, Command, arg};
use crate::cli::env_settings; use crate::cli::env_settings;
use crate::utils::validate_name; use crate::status::ServerStatus;
use crate::utils::{ validate_name, extract_archive, move_all_elements};
use diesel::{insert_into, prelude::*};
use crate::{DbPool, models};
use crate::schema;
use tokio::{fs::{File, create_dir}, io::AsyncWriteExt};
use std::path::Path;
use std::time::SystemTime;
pub fn create_subcommand() -> Command { pub fn create_subcommand() -> Command {
let mut arguments = vec![ let mut arguments = vec![
arg!(<NAME> "Name of the server"), arg!(<NAME> "Name of the server"),
arg!([SERVER_ZIP] "initial server zip"), arg!([SERVER_ARCHIVE] "initial server archive (supported : prism zip)"),
]; ];
arguments.extend(env_settings::get_args()); arguments.extend(env_settings::get_args());
Command::new("add") Command::new("add")
.about("add a server") .about("Add a server")
.args(arguments.as_slice()) .args(arguments.as_slice())
} }
pub fn subcommand(arg: &ArgMatches) -> Result<(), String>{ pub async fn subcommand(arg: &ArgMatches, pool: DbPool) -> Result<(), String>{
if !validate_name(arg.get_one::<String>("NAME").unwrap()) { let config = crate::Config::load();
let name = arg.get_one::<String>("NAME").unwrap();
if !validate_name(name) {
return Err("Invalid name provided".to_string()); return Err("Invalid name provided".to_string());
} }
let conn = &mut pool.get().unwrap();
println!("{}", env_settings::args_to_env(arg)); if let Ok(_) = schema::servers::table.filter(schema::servers::name.eq(name)).select(models::Servers::as_select()).first(conn) {
return Err("Server with this name already exists".to_string())
}
let path = config.config_path + "/" + name + "/";
create_dir(&path).await.map_err(|e| format!("failed to create the config folder, reason : {}", e))?;
let mut file = File::create(path.to_string() + "env").await.map_err(|e| format!("failed to create .env file, reason {}", e))?;
file.write_all(env_settings::args_to_env(arg).as_bytes()).await.map_err(|e| format!("Failed to write to env file, reason : {}", e))?;
create_dir(path.to_string() + "server").await.map_err(|e| format!("failed to create server subfolder, reason: {}", e))?;
if let Some(archive) = arg.get_one::<String>("SERVER_ARCHIVE") {
extract_archive(archive.to_owned(), path.to_string() + "tmp").await?;
move_all_elements(Path::new(&(path.to_string() + "tmp/minecraft")), Path::new(&(path.to_string() + "server"))).map_err(|e| format!("failed to move the elements, reason: {}", e))?;
std::fs::remove_dir_all(path.to_string() + "tmp").map_err(|e| format!("failed to remove the tmp dir, reason : {}", e))?;
}
let new_server = models::CreateServer {
name: name,
last_login: Some(SystemTime::now()),
container_id: None,
status: ServerStatus::Stopped,
redirect_ip: None
};
insert_into(schema::servers::dsl::servers).values(&new_server).execute(conn).map_err(|e| format!("Failed to insert in db, error : {:?}", e))?;
Ok(()) Ok(())
} }

View File

@ -1,4 +1,4 @@
use clap::{Command, arg}; use clap::Command;
pub fn create_subcommand() -> Command { pub fn create_subcommand() -> Command {
Command::new("edit") Command::new("edit")

View File

@ -8,13 +8,13 @@ pub fn get_args() -> [Arg; 22] {
Arg::new("SPAWN_PROTECTION").short('s').long("spawn-protection").help("spawn protection size").default_value("0"), Arg::new("SPAWN_PROTECTION").short('s').long("spawn-protection").help("spawn protection size").default_value("0"),
Arg::new("ONLINE_MODE").short('o').long("online-mode").help("false to allow cracked accounts to join").default_value("true"), Arg::new("ONLINE_MODE").short('o').long("online-mode").help("false to allow cracked accounts to join").default_value("true"),
Arg::new("TYPE").short('t').long("type").help("Server type (VANILLA, FORGE, NEOFORGE, PAPER)").default_value("VANILLA"), Arg::new("TYPE").short('t').long("type").help("Server type (VANILLA, FORGE, NEOFORGE, PAPER)").default_value("VANILLA"),
Arg::new("FORGE_VERSION").long("forge-version").help("forge version if set type is FORGE or NEOFORGE").default_value("latest"), //TODO diff handle Arg::new("FORGE_VERSION").long("forge-version").help("forge version if set type is FORGE or NEOFORGE").default_value("latest"),
Arg::new("MOTD").short('M').long("motd").help("MOTD of the server (only shown when the server is running)"), Arg::new("MOTD").short('M').long("motd").help("MOTD of the server (only shown when the server is running)"),
Arg::new("DIFFICULTY").short('d').long("difficulty").help("Difficulty of the server").default_value("easy"), Arg::new("DIFFICULTY").short('d').long("difficulty").help("Difficulty of the server").default_value("easy"),
Arg::new("WHITELIST").short('w').long("whitelist").help("comma separated list of the playsrs to whitelist (disabled if not provied)"), //TODO diff handle Arg::new("WHITELIST").short('w').long("whitelist").help("comma separated list of the playsrs to whitelist (disabled if not provied)"),
Arg::new("OPS").short('O').long("ops").help("comma separated list of the players to give operator permissions to"), Arg::new("OPS").short('O').long("ops").help("comma separated list of the players to give operator permissions to"),
Arg::new("MODE").long("gamemode").default_value("survival"), Arg::new("MODE").long("gamemode").default_value("survival"),
Arg::new("CUSTOM_SERVER_PROPERTIES").long("custom-property").help("add a custom property").action(ArgAction::Append), //TODO diff handle Arg::new("CUSTOM_SERVER_PROPERTIES").long("custom-property").help("add a custom property").action(ArgAction::Append),
Arg::new("ALLOW_FLIGHT").short('f').long("alllow-flight").help("Allow flight in suvival mode").default_value("false"), Arg::new("ALLOW_FLIGHT").short('f').long("alllow-flight").help("Allow flight in suvival mode").default_value("false"),
Arg::new("ALLOW_NETHER").short('n').long("allow-nether").help("Enable the nether dimension").default_value("true"), Arg::new("ALLOW_NETHER").short('n').long("allow-nether").help("Enable the nether dimension").default_value("true"),
Arg::new("HARDCORE").short('H').long("hardcore").help("Enable hardcore mode").default_value("false"), Arg::new("HARDCORE").short('H').long("hardcore").help("Enable hardcore mode").default_value("false"),
@ -30,7 +30,10 @@ pub fn get_args() -> [Arg; 22] {
pub fn args_to_env(arguments: &ArgMatches) -> String { pub fn args_to_env(arguments: &ArgMatches) -> String {
let default_handle = vec!["VERSION", "MEMORY", "MAX_PLAYERS", "SPAWN_PROTECTION", "ONLINE_MODE", "TYPE", "MOTD", "DIFFICULTY", "OPS", "MODE", "ALLOW_FLIGHT", let default_handle = vec!["VERSION", "MEMORY", "MAX_PLAYERS", "SPAWN_PROTECTION", "ONLINE_MODE", "TYPE", "MOTD", "DIFFICULTY", "OPS", "MODE", "ALLOW_FLIGHT",
"ALLOW_NETHER", "HARDCORE", "MAX_TICK_TIME", "PAUSE_WHEN_EMPTY_SECONDS", "PVP", "SPAWN_ANIMALS", "SPAWN_MONSTERS", "SPAWN_NPCS"]; "ALLOW_NETHER", "HARDCORE", "MAX_TICK_TIME", "PAUSE_WHEN_EMPTY_SECONDS", "PVP", "SPAWN_ANIMALS", "SPAWN_MONSTERS", "SPAWN_NPCS"];
let mut res = vec![];
let mut res = vec![
("EULA".to_string(), "TRUE".to_string()),
];
for setting in default_handle { for setting in default_handle {
if let Some(val) = arguments.get_one::<String>(setting) { if let Some(val) = arguments.get_one::<String>(setting) {
@ -55,6 +58,8 @@ pub fn args_to_env(arguments: &ArgMatches) -> String {
// println!("\n\n\narguments : {:?}\nignored:{:?}", arguments, ignored); // println!("\n\n\narguments : {:?}\nignored:{:?}", arguments, ignored);
res.iter() res.iter()
.map(|x| format!("{}=\"{}\"", x.0, x.1)) .map(|x| format!("{}={}", x.0, x.1))
.collect::<Vec<String>>().join("\n") .collect::<Vec<String>>().join("\n")
} }
// START COMMAND :
// docker run --rm --env-file ./env -u 1000:100 -it --volume $PWD/server:/data itzg/minecraft-server

View File

@ -1,4 +1,4 @@
use clap::{Command, arg}; use clap::Command;
pub fn create_subcommand() -> Command { pub fn create_subcommand() -> Command {
Command::new("ls") Command::new("ls")

View File

@ -1,4 +1,4 @@
use clap::{Command, arg}; use clap::Command;
pub fn create_subcommand() -> Command { pub fn create_subcommand() -> Command {
Command::new("remove") Command::new("remove")

View File

@ -1,3 +1,88 @@
use std::fs;
use std::io;
use zip::{ZipArchive, result::ZipError};
use std::path::Path;
pub fn validate_name(name: &str) -> bool{ pub fn validate_name(name: &str) -> bool{
name.chars().all(|c| c.is_alphanumeric() || c == '_' || c == '-') name.chars().all(|c| c.is_alphanumeric() || c == '_' || c == '-')
} }
pub async fn extract_archive(archive_path: String, output: String) -> Result<(), String> {
println!("starting extraction of {}", archive_path);
fs::create_dir(&output).map_err(|e| format!("Failed to create archive output folder, reason : {}", e))?;
let mut archive = match fs::File::open(archive_path)
.map_err(ZipError::from)
.and_then(ZipArchive::new)
{
Ok(archive) => archive,
Err(e) => {
return Err(format!("failed to open archive, reason : {:?}", e));
}
};
for i in 0..archive.len() {
let mut file = match archive.by_index(i) {
Ok(file) => file,
Err(e) => {
return Err(format!("extraction failed, reason : {}", e));
}
};
let mut out_path = match file.enclosed_name() {
Some(path) => path,
None => {
return Err("Invalid file path".to_string());
}
};
out_path = Path::new(&output).join(out_path);
if file.is_dir() {
if let Err(e) = fs::create_dir_all(&out_path) {
return Err(format!("extraction failed, reason : {}", e));
}
} else {
if let Some(p) = out_path.parent()
&& !p.exists()
&& let Err(e) = fs::create_dir_all(p)
{
return Err(format!("extraction failed, reason : {}", e));
}
let _ = fs::File::create(&out_path)
.and_then(|mut outfile| io::copy(&mut file, &mut outfile))
.map_err(|e| format!("extraction failed, reason: {}", e))?;
}
}
println!("extraction done");
Ok(())
}
pub fn move_all_elements(src: &Path, dst: &Path) -> io::Result<()> {
// 1. Ensure the destination directory exists; if not, create it
if !dst.exists() {
fs::create_dir_all(dst)?;
println!("Created destination directory: {:?}", dst);
}
// 2. Read the contents of the source directory
for entry in fs::read_dir(src)? {
let entry = entry?;
let file_name = entry.file_name();
// 3. Construct the new path (destination + filename)
let old_path = entry.path();
let new_path = dst.join(file_name);
// 4. Perform the move
// fs::rename works for both files and directories
fs::rename(&old_path, &new_path)?;
println!("Moved: {:?} -> {:?}", old_path, new_path);
}
Ok(())
}

11
src/config.rs Normal file
View File

@ -0,0 +1,11 @@
pub struct Config {
pub config_path: String
}
impl Config {
pub fn load() -> Self {
Self {
config_path: "/home/tom/desktop/rust/yo_mama/servers".to_string() // that's my program I do what I want
}
}
}

View File

@ -1,16 +1,6 @@
use bollard::Docker; use bollard::Docker;
use std::env;
use std::sync::LazyLock; use std::sync::LazyLock;
use diesel::PgConnection;
use diesel::r2d2::{
Pool,
ConnectionManager
};
pub static mut DOCKER: LazyLock<Docker> = LazyLock::new(|| Docker::connect_with_local_defaults().expect("Failed to connect to the docker socket") ); pub static mut DOCKER: LazyLock<Docker> = LazyLock::new(|| Docker::connect_with_local_defaults().expect("Failed to connect to the docker socket") );

View File

@ -6,25 +6,10 @@
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2026/05/29 21:22:17 by tomoron #+# #+# */ /* Created: 2026/05/29 21:22:17 by tomoron #+# #+# */
/* Updated: 2026/06/05 00:11:54 by tomoron ### ########.fr */ /* Updated: 2026/06/05 17:48:58 by tomoron ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
use tokio::io;
//use bollard::{
// query_parameters::{
// ListImagesOptionsBuilder,
// ListContainersOptionsBuilder,
// CreateContainerOptionsBuilder
// },
// models::{
// ContainerCreateBody
// },
// Docker
//};
mod minecraft; mod minecraft;
use minecraft::mc_socket_listen; use minecraft::mc_socket_listen;
@ -38,9 +23,10 @@ pub mod models;
pub mod status; pub mod status;
mod cli; mod cli;
use cli::*; use cli::*;
mod config;
pub use config::Config;
pub type DbPool = Pool<ConnectionManager<PgConnection>>; pub type DbPool = Pool<ConnectionManager<PgConnection>>;
@ -54,8 +40,7 @@ fn get_connection_pool() -> DbPool {
} }
use clap::{Command, arg}; use clap::Command;
fn cli() -> Command { fn cli() -> Command {
Command::new("dmm") Command::new("dmm")
@ -64,7 +49,7 @@ fn cli() -> Command {
.arg_required_else_help(true) .arg_required_else_help(true)
.subcommand( .subcommand(
Command::new("serverMode") Command::new("serverMode")
.about("start the server manager") .about("Start the server manager")
) )
.subcommand(add::create_subcommand()) .subcommand(add::create_subcommand())
@ -80,72 +65,8 @@ async fn main() -> Result<(), String> {
match arg.subcommand() { match arg.subcommand() {
Some(("serverMode", _)) => { mc_socket_listen(pool).await.map_err(|_| "socket error".to_string())?; }, Some(("serverMode", _)) => { mc_socket_listen(pool).await.map_err(|_| "socket error".to_string())?; },
Some(("add", sub_matches)) => { add::subcommand(sub_matches)?; }, Some(("add", sub_matches)) => { add::subcommand(sub_matches, pool).await?; },
_ => {panic!("subcommand not implemented")} _ => {panic!("subcommand not implemented")}
} }
//
Ok(()) Ok(())
} }
/*
println!("{:?}", docker);
let options = ListImagesOptionsBuilder::default()
.all(true)
.build();
let images = &docker.list_images(Some(options)).await.unwrap();
println!("\n\nimages : {:?}", images);
let options = ListContainersOptionsBuilder::default()
.all(true)
.build();
let containers = docker.list_containers(Some(options)).await.unwrap();
println!("\n\ncontainers : {:?}", containers);
let options = CreateContainerOptionsBuilder::default()
.name("rust-created-container")
.build();
let config = ContainerCreateBody {
image: Some("hello-world".to_string()),
// cmd: Some(vc pec!["/hello".to_string()]),
..Default::default()
};
let container = docker.create_container(Some(options), config).await.unwrap();
let start_res = docker.start_container("rust-created-container", None).await;
*/
/*
*/
//}

View File

@ -6,13 +6,12 @@
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2026/05/07 17:23:09 by tomoron #+# #+# */ /* Created: 2026/05/07 17:23:09 by tomoron #+# #+# */
/* Updated: 2026/05/31 23:23:05 by tomoron ### ########.fr */ /* Updated: 2026/06/05 12:36:46 by tomoron ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
use tokio::net::TcpStream; use tokio::net::TcpStream;
use crate::minecraft::handshake::Handshake; use crate::minecraft::handshake::Handshake;
use crate::minecraft::varint::varint_write;
use std::fmt; use std::fmt;
use crate::models::Servers; use crate::models::Servers;
@ -29,7 +28,7 @@ pub struct Client {
pub server: Option<Result<Servers,diesel::result::Error>>, pub server: Option<Result<Servers,diesel::result::Error>>,
pub dbPool: DbPool pub db_pool: DbPool
} }
use crate::DbPool; use crate::DbPool;
@ -54,7 +53,7 @@ impl Client {
server: None, server: None,
dbPool: pool db_pool: pool
} }
} }
@ -66,7 +65,7 @@ impl Client {
} }
let conn = &mut self.dbPool.get().unwrap(); let conn = &mut self.db_pool.get().unwrap();
let reg = Regex::new(r"^(?:([a-zA-Z-_]*)\.)?mc\.tmoron\.fr$").unwrap(); let reg = Regex::new(r"^(?:([a-zA-Z-_]*)\.)?mc\.tmoron\.fr$").unwrap();
let mut found: Option<String> = None; let mut found: Option<String> = None;

View File

@ -3,7 +3,6 @@ use crate::minecraft::client::client::Client;
use json::object; use json::object;
use crate::minecraft::varint::varint_write; use crate::minecraft::varint::varint_write;
use std::collections::VecDeque; use std::collections::VecDeque;
use tokio::net::TcpStream;
impl Client { impl Client {
pub async fn login_intent_handle(&mut self, mut _packet: &mut VecDeque<u8>, _packet_id: i32) -> Result<(),String> { pub async fn login_intent_handle(&mut self, mut _packet: &mut VecDeque<u8>, _packet_id: i32) -> Result<(),String> {

View File

@ -2,11 +2,9 @@ use crate::minecraft::client::client::Client;
use crate::minecraft::varint::{varint_read, varint_write}; use crate::minecraft::varint::{varint_read, varint_write};
use crate::minecraft::handshake::Handshake; use crate::minecraft::handshake::Handshake;
use crate::models;
use crate::status::ServerStatus; use crate::status::ServerStatus;
use std::collections::VecDeque; use std::collections::VecDeque;
use diesel::result::Error::NotFound;
use tokio::net::TcpStream; use tokio::net::TcpStream;
impl Client { impl Client {
@ -20,9 +18,11 @@ impl Client {
} }
self.handshake = Some(Handshake::from_packet(&mut packet)?); self.handshake = Some(Handshake::from_packet(&mut packet)?);
self.server = Some(self.get_server().await); self.server = Some(self.get_server().await);
// if self.server.as_ref().unwrap().status == ServerStatus::Running { if let Some(Ok(server)) = &self.server {
// return self.proxy_start().await; if server.status == ServerStatus::Running {
// } return self.proxy_start().await;
}
}
if self.handshake.as_ref().unwrap().intent == 2 { if self.handshake.as_ref().unwrap().intent == 2 {
self.login_intent_handle(&mut packet, packet_id).await?; self.login_intent_handle(&mut packet, packet_id).await?;

View File

@ -1,9 +1,6 @@
use crate::minecraft::client::client::Client; use crate::minecraft::client::client::Client;
use diesel::prelude::*;
use diesel::result::Error::NotFound; use diesel::result::Error::NotFound;
use crate::schema;
use crate::models;
use json::object; use json::object;

View File

@ -14,7 +14,6 @@ use crate::schema;
pub struct Servers { pub struct Servers {
pub id: i64, pub id: i64,
pub name: String, pub name: String,
pub volume_path: String,
pub last_login: Option<SystemTime>, pub last_login: Option<SystemTime>,
pub container_id: Option<String>, pub container_id: Option<String>,
pub status: ServerStatus, pub status: ServerStatus,
@ -26,7 +25,6 @@ pub struct Servers {
#[diesel(table_name = schema::servers)] #[diesel(table_name = schema::servers)]
pub struct CreateServer<'a> { pub struct CreateServer<'a> {
pub name: &'a str, pub name: &'a str,
pub volume_path: &'a str,
pub last_login: Option<SystemTime>, pub last_login: Option<SystemTime>,
pub container_id: Option<&'a str>, pub container_id: Option<&'a str>,
pub status: ServerStatus, pub status: ServerStatus,

View File

@ -5,8 +5,6 @@ diesel::table! {
id -> Int8, id -> Int8,
#[max_length = 255] #[max_length = 255]
name -> Varchar, name -> Varchar,
#[max_length = 255]
volume_path -> Varchar,
last_login -> Nullable<Timestamp>, last_login -> Nullable<Timestamp>,
#[max_length = 30] #[max_length = 30]
container_id -> Nullable<Varchar>, container_id -> Nullable<Varchar>,

View File

@ -4,7 +4,9 @@ use diesel::expression::AsExpression;
use diesel::pg::Pg; use diesel::pg::Pg;
use diesel::serialize::{self, ToSql, Output}; use diesel::serialize::{self, ToSql, Output};
use diesel::sql_types::SmallInt; use diesel::sql_types::SmallInt;
use std::fmt::{self, write};
use std::fmt;
use std::io::Write; use std::io::Write;
#[derive(Debug, Clone, Copy, PartialEq, Eq, AsExpression, FromSqlRow, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, AsExpression, FromSqlRow, serde::Serialize, serde::Deserialize)]