diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000000000000000000000000000000000000..217f26ad8754a7bcb265e9e9adb4fa0f52361146 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[profile.release] +strip = true diff --git a/.gitignore b/.gitignore index a3656a86b539dd59609910c01615d358db12d795..4824170bbc6f3cbec9634435d5272eea78e2eea3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,15 @@ +# misc target -.maid TODO.md bin .idea build testing +.in # prevent duplicate README -crates/maid/client/README.md \ No newline at end of file +crates/maid/client/README.md + +# maid +.maid/cache +.maid/temp \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index f5aebb6f597728157c099197f23e6a5796861ee4..94a8834359ee5eb79183055dd997c1a072a6d3af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -119,6 +119,54 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" + +[[package]] +name = "atomic" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994" +dependencies = [ + "bytemuck", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -146,6 +194,12 @@ version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +[[package]] +name = "binascii" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" + [[package]] name = "bitflags" version = "1.3.2" @@ -226,6 +280,12 @@ version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +[[package]] +name = "bytemuck" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" + [[package]] name = "byteorder" version = "1.5.0" @@ -360,6 +420,17 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +[[package]] +name = "cookie" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cd91cf61412820176e137621345ee43b3f4423e589e7ae4e50d601d93e35ef8" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + [[package]] name = "core-foundation" version = "0.9.3" @@ -488,6 +559,39 @@ dependencies = [ "serde", ] +[[package]] +name = "devise" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6eacefd3f541c66fc61433d65e54e0e46e0a029a819a7dbbc7a7b489e8a85f8" +dependencies = [ + "devise_codegen", + "devise_core", +] + +[[package]] +name = "devise_codegen" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8cf4b8dd484ede80fd5c547592c46c3745a617c8af278e2b72bea86b2dfed6" +dependencies = [ + "devise_core", + "quote", +] + +[[package]] +name = "devise_core" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35b50dba0afdca80b187392b24f2499a88c336d5a8493e4b4ccfb608708be56a" +dependencies = [ + "bitflags 2.4.1", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn", +] + [[package]] name = "digest" version = "0.10.7" @@ -564,6 +668,20 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "figment" +version = "0.10.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "649f3e5d826594057e9a519626304d8da859ea8a0b18ce99500c586b8d45faee" +dependencies = [ + "atomic 0.6.0", + "pear", + "serde", + "toml", + "uncased", + "version_check", +] + [[package]] name = "filetime" version = "0.2.22" @@ -720,6 +838,19 @@ dependencies = [ "slab", ] +[[package]] +name = "generator" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" +dependencies = [ + "cc", + "libc", + "log", + "rustversion", + "windows", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -747,6 +878,12 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "global_placeholders" version = "0.1.0" @@ -794,30 +931,6 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" -[[package]] -name = "headers" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" -dependencies = [ - "base64", - "bytes", - "headers-core", - "http", - "httpdate", - "mime", - "sha1", -] - -[[package]] -name = "headers-core" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" -dependencies = [ - "http", -] - [[package]] name = "heck" version = "0.4.1" @@ -1009,6 +1122,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "inlinable_string" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" + [[package]] name = "inotify" version = "0.9.6" @@ -1151,6 +1270,21 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "loom" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "serde", + "serde_json", + "tracing", + "tracing-subscriber", +] + [[package]] name = "macros-rs" version = "0.4.0" @@ -1185,7 +1319,6 @@ dependencies = [ "pretty_number", "reqwest", "serde", - "serde_derive", "serde_json", "serde_yaml", "strip-ansi-escapes", @@ -1221,6 +1354,8 @@ dependencies = [ "log", "macros-rs", "ntapi", + "rocket", + "rocket_ws", "serde", "serde_derive", "serde_json", @@ -1231,10 +1366,18 @@ dependencies = [ "tokio-util", "tungstenite", "uuid", - "warp", "winapi", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "memchr" version = "2.6.4" @@ -1278,16 +1421,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "mime_guess" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -1324,6 +1457,8 @@ dependencies = [ "memchr", "mime", "spin", + "tokio", + "tokio-util", "version_check", ] @@ -1393,6 +1528,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-traits" version = "0.2.17" @@ -1477,6 +1622,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parking_lot" version = "0.12.1" @@ -1500,6 +1651,35 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pear" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a386cd715229d399604b50d1361683fe687066f42d56f54be995bc6868f71c" +dependencies = [ + "inlinable_string", + "pear_codegen", + "yansi", +] + +[[package]] +name = "pear_codegen" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f0f13dac8069c139e8300a6510e3f4143ecf5259c60b116a9b271b4ca0d54" +dependencies = [ + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -1620,6 +1800,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "version_check", + "yansi", +] + [[package]] name = "quote" version = "1.0.33" @@ -1697,6 +1890,26 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "ref-cast" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "regex" version = "1.10.2" @@ -1705,8 +1918,17 @@ checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -1717,9 +1939,15 @@ checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.2", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.2" @@ -1764,6 +1992,121 @@ dependencies = [ "winreg", ] +[[package]] +name = "rmp" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20" +dependencies = [ + "byteorder", + "num-traits", + "paste", +] + +[[package]] +name = "rmp-serde" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + +[[package]] +name = "rocket" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e7bb57ccb26670d73b6a47396c83139447b9e7878cab627fdfe9ea8da489150" +dependencies = [ + "async-stream", + "async-trait", + "atomic 0.5.3", + "binascii", + "bytes", + "either", + "figment", + "futures", + "indexmap 2.0.2", + "log", + "memchr", + "multer", + "num_cpus", + "parking_lot", + "pin-project-lite", + "rand", + "ref-cast", + "rmp-serde", + "rocket_codegen", + "rocket_http", + "serde", + "serde_json", + "state", + "tempfile", + "time", + "tokio", + "tokio-stream", + "tokio-util", + "ubyte", + "version_check", + "yansi", +] + +[[package]] +name = "rocket_codegen" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2238066abf75f21be6cd7dc1a09d5414a671f4246e384e49fe3f8a4936bd04c" +dependencies = [ + "devise", + "glob", + "indexmap 2.0.2", + "proc-macro2", + "quote", + "rocket_http", + "syn", + "unicode-xid", + "version_check", +] + +[[package]] +name = "rocket_http" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37a1663694d059fe5f943ea5481363e48050acedd241d46deb2e27f71110389e" +dependencies = [ + "cookie", + "either", + "futures", + "http", + "hyper", + "indexmap 2.0.2", + "log", + "memchr", + "pear", + "percent-encoding", + "pin-project-lite", + "ref-cast", + "serde", + "smallvec", + "stable-pattern", + "state", + "time", + "tokio", + "uncased", +] + +[[package]] +name = "rocket_ws" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6677b3fe72e2d73dd632c412546ed8153e8685c830ee8d20e4488575cb905d9" +dependencies = [ + "rocket", + "tokio-tungstenite", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1784,13 +2127,10 @@ dependencies = [ ] [[package]] -name = "rustls-pemfile" -version = "1.0.3" +name = "rustversion" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" -dependencies = [ - "base64", -] +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" @@ -1853,18 +2193,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.190" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", @@ -1965,6 +2305,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "signal-hook" version = "0.3.17" @@ -2036,6 +2385,24 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "stable-pattern" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4564168c00635f88eaed410d5efa8131afa8d8699a612c80c455a0ba05c21045" +dependencies = [ + "memchr", +] + +[[package]] +name = "state" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b8c4a4445d81357df8b1a650d0d0d6fbbbfe99d064aa5e02f3e4022061476d8" +dependencies = [ + "loom", +] + [[package]] name = "strip-ansi-escapes" version = "0.2.0" @@ -2145,6 +2512,16 @@ dependencies = [ "syn", ] +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "time" version = "0.3.30" @@ -2312,11 +2689,22 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tracing-core" version = "0.1.32" @@ -2324,6 +2712,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] @@ -2358,6 +2776,15 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "ubyte" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f720def6ce1ee2fc44d40ac9ed6d3a59c361c80a75a7aa8e75bb9baed31cf2ea" +dependencies = [ + "serde", +] + [[package]] name = "ucd-trie" version = "0.1.6" @@ -2365,11 +2792,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] -name = "unicase" -version = "2.7.0" +name = "uncased" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +checksum = "9b9bc53168a4be7402ab86c3aad243a84dd7381d09be0eddc81280c1da95ca68" dependencies = [ + "serde", "version_check", ] @@ -2406,6 +2834,12 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "unsafe-libyaml" version = "0.2.9" @@ -2445,6 +2879,12 @@ dependencies = [ "rand", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vcpkg" version = "0.2.15" @@ -2496,37 +2936,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "warp" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e92e22e03ff1230c03a1a8ee37d2f89cd489e2e541b7550d6afad96faed169" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "headers", - "http", - "hyper", - "log", - "mime", - "mime_guess", - "multer", - "percent-encoding", - "pin-project", - "rustls-pemfile", - "scoped-tls", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-stream", - "tokio-tungstenite", - "tokio-util", - "tower-service", - "tracing", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2640,6 +3049,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-core" version = "0.51.1" @@ -2809,6 +3227,15 @@ dependencies = [ "libc", ] +[[package]] +name = "yansi" +version = "1.0.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" +dependencies = [ + "is-terminal", +] + [[package]] name = "zerocopy" version = "0.7.20" diff --git a/Maidfile.toml b/Maidfile.toml index 6e6cd3305b921f15e3f1e02699ebc46a4a148dfe..c9df2cf36c2a8eb2591a82c94f040e5568ca4066 100644 --- a/Maidfile.toml +++ b/Maidfile.toml @@ -11,7 +11,7 @@ version = "1.1.0" # build on a remote server [project.server] -address = { host = "100.79.107.11", port = 3500, ssl = false } +address = { host = "localhost", port = 3500, ssl = false } token = "test_token" # global enviroment diff --git a/crates/maid/client/Cargo.toml b/crates/maid/client/Cargo.toml index b120bfb4a22b4faabef18a218732fa848009a13f..d028191d5b0274435d5353d79e199d25476ed814 100644 --- a/crates/maid/client/Cargo.toml +++ b/crates/maid/client/Cargo.toml @@ -24,7 +24,6 @@ toml = "0.8.6" json5 = "0.4.1" notify = "6.1.1" inquire = "0.6.2" -serde = "1.0.190" anyhow = "1.0.75" fs_extra = "1.3.0" termcolor = "1.3.0" @@ -35,11 +34,11 @@ serde_yaml = "0.9.27" merkle_hash = "3.5.0" merge-struct = "0.1.0" data-encoding = "2.4.0" -serde_derive = "1.0.190" text_placeholder = "0.5.0" strip-ansi-escapes = "0.2.0" clap-verbosity-flag = "2.1.0" notify-debouncer-mini = "0.4.1" +serde = { version = "1.0.192", features = ["derive"] } human_bytes = { version = "0.4.3", default-features = false } tungstenite = { version = "0.20.1", features = ["native-tls"] } diff --git a/crates/maid/client/src/server/api/health.rs b/crates/maid/client/src/server/api/health.rs index 856851de98d2b09fabee21bd4fcd81a166b21251..94a73ac980b5ed55786a33d1635c24c6facd1333 100644 --- a/crates/maid/client/src/server/api/health.rs +++ b/crates/maid/client/src/server/api/health.rs @@ -1,4 +1,4 @@ -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Value { diff --git a/crates/maid/client/src/structs.rs b/crates/maid/client/src/structs.rs index 3d8c77805ce7505658337888e56d119a45e19d20..2446afef2f9ed0f18abdeb5fdc4b9566c5307bf5 100644 --- a/crates/maid/client/src/structs.rs +++ b/crates/maid/client/src/structs.rs @@ -1,4 +1,4 @@ -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; use std::collections::BTreeMap; use std::path::PathBuf; diff --git a/crates/maid/server/Cargo.toml b/crates/maid/server/Cargo.toml index 769f2e847a9a0f9875c840afbd1323eb510248ce..41e9b7b53aec1ace914d71bd43e764f2fccf4f4c 100644 --- a/crates/maid/server/Cargo.toml +++ b/crates/maid/server/Cargo.toml @@ -19,13 +19,11 @@ global_placeholders.workspace = true # make workspace home = "0.5.5" -warp = "0.3.6" bytes = "1.5.0" ntapi = "0.4.1" libc = "0.2.149" winapi = "0.3.9" anyhow = "1.0.75" -serde = "1.0.190" chrono = "0.4.31" futures = "0.3.29" bollard = "0.15.0" @@ -40,3 +38,6 @@ futures-util = "0.3.29" serde_derive = "1.0.190" text_placeholder = "0.5.0" tokio = { version = "1.33.0", features = ["full"] } +serde = { version = "1.0.192", features = ["derive"] } +rocket = { version = "0.5.0", features = ["json", "msgpack"] } +rocket_ws = "0.1.0" diff --git a/crates/maid/server/src/docker/container.rs b/crates/maid/server/src/docker/container.rs index 4bf3db83a58db72bc605b8b9245bc6cdfc90e604..7747fcba6fef09a57f6bcb12def6eb6ff5c9545d 100644 --- a/crates/maid/server/src/docker/container.rs +++ b/crates/maid/server/src/docker/container.rs @@ -3,18 +3,19 @@ use bollard::Docker; use futures_util::stream::StreamExt; use std::collections::HashMap; -pub async fn list(docker: Docker) -> Result, Box> { +pub async fn list(docker: &Docker) -> Result, Box> { let mut filter: HashMap> = HashMap::new(); let mut container_list: Vec = vec![]; filter.insert(String::from("status"), vec![String::from("running")]); - let containers = &docker - .list_containers(Some(ListContainersOptions { - all: true, - filters: filter, - ..Default::default() - })) - .await?; + let containers = + &docker + .list_containers(Some(ListContainersOptions { + all: true, + filters: filter, + ..Default::default() + })) + .await?; if containers.is_empty() { Ok(container_list) diff --git a/crates/maid/server/src/docker/run.rs b/crates/maid/server/src/docker/run.rs index ddad9ca3d4ba4c6b7cabd8a0829621fca84a8a0e..898587dba2bb97d0e819396214058860a37607d1 100644 --- a/crates/maid/server/src/docker/run.rs +++ b/crates/maid/server/src/docker/run.rs @@ -1,232 +1,232 @@ -use crate::structs::ConnectionData; -use crate::table; - -use bollard::container::{Config, DownloadFromContainerOptions, RemoveContainerOptions, UploadToContainerOptions}; -use bollard::exec::{CreateExecOptions, StartExecResults}; -use bollard::image::CreateImageOptions; -use bollard::{errors::Error, Docker}; -use bytes::Bytes; -use flate2::{write::GzEncoder, Compression}; -use futures_core::Stream; -use futures_util::stream::{SplitSink, SplitStream, TryStreamExt}; -use futures_util::{SinkExt, StreamExt}; -use macros_rs::{fmtstr, str, string}; -use std::default::Default; -use std::io::Write; -use std::path::PathBuf; -use std::sync::Arc; -use text_placeholder::Template; -use tokio::sync::Mutex; -use warp::hyper::Body; -use warp::ws::{Message, WebSocket}; - -pub async fn concat_byte_stream(s: S) -> Result, Error> -where - S: Stream>, -{ - s.try_fold(Vec::new(), |mut acc, chunk| async move { - acc.extend_from_slice(&chunk[..]); - Ok(acc) - }) - .await -} - -// add error handling to all the unwraps -pub async fn exec(tx: SplitSink, mut rx: SplitStream, docker: Docker) -> Result<(), Box> { - let mut parsed: Option = None; - let tx_ref = Arc::new(Mutex::new(tx)); - - while parsed.is_none() { - if let Some(result) = rx.next().await { - let msg = result.unwrap(); - match serde_json::from_str::(msg.to_str().unwrap()) { - Ok(value) => { - parsed = Some(value); - } - Err(err) => { - eprintln!("Failed to deserialize JSON: {:?}", err); - } - } - } - } - - let parsed = parsed.unwrap(); - let name = &parsed.info.name; - - println!("creating container for task [{name}]"); - docker - .create_image( - Some(CreateImageOptions { - from_image: str!(parsed.info.remote.image.clone()), - ..Default::default() - }), - None, - None, - ) - .for_each(|msg| { - let tx_ref = Arc::clone(&tx_ref); - - async move { - let msg = msg.as_ref().expect("Failed to get CreateImageInfo"); - let formatted = format!("{} {}", msg.status.clone().unwrap_or_else(|| string!("Waiting")), msg.progress.clone().unwrap_or_else(|| string!(""))); - - let mut tx_lock = tx_ref.lock().await; - tx_lock - .send(Message::text( - serde_json::to_string(&serde_json::json!({ - "level": "docker", - "time": chrono::Utc::now().timestamp_millis(), - "data": { "message": formatted }, - })) - .unwrap(), - )) - .await; - } - }) - .await; - - let config = Config { - image: Some(parsed.info.remote.image), - tty: Some(true), - ..Default::default() - }; - - let id = docker.create_container::<&str, String>(None, config).await?.id; - println!("created container"); - - docker.start_container::(&id, None).await?; - println!("started container"); - - let tx_ref = Arc::clone(&tx_ref); - let mut tx_lock = tx_ref.lock().await; - - tx_lock - .send(Message::text( - serde_json::to_string(&serde_json::json!({ - "level": "success", - "time": chrono::Utc::now().timestamp_millis(), - "data": { "binary": true }, - })) - .unwrap(), - )) - .await - .unwrap(); - - if let Some(result) = rx.next().await { - println!("received message: binary"); - - let msg = result.unwrap(); - fn bytes_to_body(bytes: &[u8]) -> Body { Body::from(bytes.to_vec()) } - - // note: this `Result` may be an `Err` variant, which should be handled - // help: use `let _ = ...` to ignore the resulting value - docker - .upload_to_container(&id, Some(UploadToContainerOptions { path: "/opt", ..Default::default() }), bytes_to_body(&msg.as_bytes())) - .await; - println!("wrote tarfile to container"); - } - - let dependencies = match &parsed.maidfile.tasks[&parsed.info.name].depends { - Some(deps) => { - let mut dep_script: Vec = vec![]; - for item in deps.iter() { - dep_script.push( - parsed.maidfile.tasks[item] - .script - .as_array() - .map(|arr| arr.iter().map(|val| val.as_str().unwrap_or_default()).collect::>().join("\n")) - .unwrap_or_default(), - ); - } - dep_script.join("\n") - } - None => { - string!("") - } - }; - - // move common things such as structs and helpers to seperate crate - let table = table::create(parsed.maidfile.clone(), &parsed.info.args, PathBuf::new().join("/opt")); - let script = Template::new_with_placeholder(str!(parsed.info.script.join("\n")), "%{", "}").fill_with_hashmap(&table); - let dependencies = Template::new_with_placeholder(str!(dependencies), "%{", "}").fill_with_hashmap(&table); - - let exec = docker - .create_exec( - &id, - CreateExecOptions { - attach_stdout: Some(true), - attach_stderr: Some(true), - cmd: Some(vec![ - str!(parsed.info.remote.shell), - "-c", - fmtstr!("cd /opt && touch script.sh && echo '{dependencies}\n{script}' > script.sh && chmod +x script.sh && ./script.sh"), - ]), - ..Default::default() - }, - ) - .await? - .id; - - if let StartExecResults::Attached { mut output, .. } = docker.start_exec(&exec, None).await? { - tx_lock - .send(Message::text( - serde_json::to_string(&serde_json::json!({ - "level": "build", - "time": chrono::Utc::now().timestamp_millis(), - "data": { "message": "waiting for build to finish..." }, - })) - .unwrap(), - )) - .await - .unwrap(); - - while let Some(Ok(msg)) = output.next().await { - if !parsed.info.remote.silent { - tx_lock - .send(Message::text( - serde_json::to_string(&serde_json::json!({ - "level": "none", - "time": chrono::Utc::now().timestamp_millis(), - "data": { "message": msg.to_string() }, - })) - .unwrap(), - )) - .await - .unwrap(); - } - } - } - - let res = docker.download_from_container( - &id, - Some(DownloadFromContainerOptions { - path: fmtstr!("/opt/{}", parsed.info.remote.pull.clone()), - }), - ); - let bytes = concat_byte_stream(res).await?; - let mut encoder = GzEncoder::new(Vec::new(), Compression::default()); - - encoder.write_all(&bytes)?; - let compressed_data = encoder.finish()?; - - tx_lock.send(Message::binary(compressed_data)).await.unwrap(); - println!("sent message: binary, from [{}]", parsed.info.remote.pull); - - tx_lock - .send(Message::text( - serde_json::to_string(&serde_json::json!({ - "level": "success", - "time": chrono::Utc::now().timestamp_millis(), - "data": { "done": true }, - })) - .unwrap(), - )) - .await - .unwrap(); - println!("sent message: [done]"); - - println!("deleted old container"); - // delete container if socket closed - docker.remove_container(&id, Some(RemoveContainerOptions { force: true, ..Default::default() })).await?; - Ok(()) -} +// use crate::structs::ConnectionData; +// use crate::table; +// +// use bollard::container::{Config, DownloadFromContainerOptions, RemoveContainerOptions, UploadToContainerOptions}; +// use bollard::exec::{CreateExecOptions, StartExecResults}; +// use bollard::image::CreateImageOptions; +// use bollard::{errors::Error, Docker}; +// use bytes::Bytes; +// use flate2::{write::GzEncoder, Compression}; +// use futures_core::Stream; +// use futures_util::stream::{SplitSink, SplitStream, TryStreamExt}; +// use futures_util::{SinkExt, StreamExt}; +// use macros_rs::{fmtstr, str, string}; +// use std::default::Default; +// use std::io::Write; +// use std::path::PathBuf; +// use std::sync::Arc; +// use text_placeholder::Template; +// use tokio::sync::Mutex; +// +// pub async fn concat_byte_stream(s: S) -> Result, Error> +// where +// S: Stream>, +// { +// s.try_fold(Vec::new(), |mut acc, chunk| async move { +// acc.extend_from_slice(&chunk[..]); +// Ok(acc) +// }) +// .await +// } +// +// // add error handling to all the unwraps +// pub async fn exec(tx: SplitSink, mut rx: SplitStream, docker: Docker) -> Result<(), Box> { +// let mut parsed: Option = None; +// let tx_ref = Arc::new(Mutex::new(tx)); +// +// while parsed.is_none() { +// if let Some(result) = rx.next().await { +// let msg = result.unwrap(); +// match serde_json::from_str::(msg.to_str().unwrap()) { +// Ok(value) => { +// parsed = Some(value); +// } +// Err(err) => { +// eprintln!("Failed to deserialize JSON: {:?}", err); +// } +// } +// } +// } +// +// let parsed = parsed.unwrap(); +// let name = &parsed.info.name; +// +// println!("creating container for task [{name}]"); +// docker +// .create_image( +// Some(CreateImageOptions { +// from_image: str!(parsed.info.remote.image.clone()), +// ..Default::default() +// }), +// None, +// None, +// ) +// .for_each(|msg| { +// let tx_ref = Arc::clone(&tx_ref); +// +// async move { +// let msg = msg.as_ref().expect("Failed to get CreateImageInfo"); +// let formatted = format!("{} {}", msg.status.clone().unwrap_or_else(|| string!("Waiting")), msg.progress.clone().unwrap_or_else(|| string!(""))); +// +// let mut tx_lock = tx_ref.lock().await; +// tx_lock +// .send(Message::text( +// serde_json::to_string(&serde_json::json!({ +// "level": "docker", +// "time": chrono::Utc::now().timestamp_millis(), +// "data": { "message": formatted }, +// })) +// .unwrap(), +// )) +// .await; +// } +// }) +// .await; +// +// let config = +// Config { +// image: Some(parsed.info.remote.image), +// tty: Some(true), +// ..Default::default() +// }; +// +// let id = docker.create_container::<&str, String>(None, config).await?.id; +// println!("created container"); +// +// docker.start_container::(&id, None).await?; +// println!("started container"); +// +// let tx_ref = Arc::clone(&tx_ref); +// let mut tx_lock = tx_ref.lock().await; +// +// tx_lock +// .send(Message::text( +// serde_json::to_string(&serde_json::json!({ +// "level": "success", +// "time": chrono::Utc::now().timestamp_millis(), +// "data": { "binary": true }, +// })) +// .unwrap(), +// )) +// .await +// .unwrap(); +// +// if let Some(result) = rx.next().await { +// println!("received message: binary"); +// +// let msg = result.unwrap(); +// fn bytes_to_body(bytes: &[u8]) -> Body { Body::from(bytes.to_vec()) } +// +// // note: this `Result` may be an `Err` variant, which should be handled +// // help: use `let _ = ...` to ignore the resulting value +// docker +// .upload_to_container(&id, Some(UploadToContainerOptions { path: "/opt", ..Default::default() }), bytes_to_body(&msg.as_bytes())) +// .await; +// println!("wrote tarfile to container"); +// } +// +// let dependencies = match &parsed.maidfile.tasks[&parsed.info.name].depends { +// Some(deps) => { +// let mut dep_script: Vec = vec![]; +// for item in deps.iter() { +// dep_script.push( +// parsed.maidfile.tasks[item] +// .script +// .as_array() +// .map(|arr| arr.iter().map(|val| val.as_str().unwrap_or_default()).collect::>().join("\n")) +// .unwrap_or_default(), +// ); +// } +// dep_script.join("\n") +// } +// None => { +// string!("") +// } +// }; +// +// // move common things such as structs and helpers to seperate crate +// let table = table::create(parsed.maidfile.clone(), &parsed.info.args, PathBuf::new().join("/opt")); +// let script = Template::new_with_placeholder(str!(parsed.info.script.join("\n")), "%{", "}").fill_with_hashmap(&table); +// let dependencies = Template::new_with_placeholder(str!(dependencies), "%{", "}").fill_with_hashmap(&table); +// +// let exec = docker +// .create_exec( +// &id, +// CreateExecOptions { +// attach_stdout: Some(true), +// attach_stderr: Some(true), +// cmd: Some(vec![ +// str!(parsed.info.remote.shell), +// "-c", +// fmtstr!("cd /opt && touch script.sh && echo '{dependencies}\n{script}' > script.sh && chmod +x script.sh && ./script.sh"), +// ]), +// ..Default::default() +// }, +// ) +// .await? +// .id; +// +// if let StartExecResults::Attached { mut output, .. } = docker.start_exec(&exec, None).await? { +// tx_lock +// .send(Message::text( +// serde_json::to_string(&serde_json::json!({ +// "level": "build", +// "time": chrono::Utc::now().timestamp_millis(), +// "data": { "message": "waiting for build to finish..." }, +// })) +// .unwrap(), +// )) +// .await +// .unwrap(); +// +// while let Some(Ok(msg)) = output.next().await { +// if !parsed.info.remote.silent { +// tx_lock +// .send(Message::text( +// serde_json::to_string(&serde_json::json!({ +// "level": "none", +// "time": chrono::Utc::now().timestamp_millis(), +// "data": { "message": msg.to_string() }, +// })) +// .unwrap(), +// )) +// .await +// .unwrap(); +// } +// } +// } +// +// let res = +// docker.download_from_container( +// &id, +// Some(DownloadFromContainerOptions { +// path: fmtstr!("/opt/{}", parsed.info.remote.pull.clone()), +// }), +// ); +// let bytes = concat_byte_stream(res).await?; +// let mut encoder = GzEncoder::new(Vec::new(), Compression::default()); +// +// encoder.write_all(&bytes)?; +// let compressed_data = encoder.finish()?; +// +// tx_lock.send(Message::binary(compressed_data)).await.unwrap(); +// println!("sent message: binary, from [{}]", parsed.info.remote.pull); +// +// tx_lock +// .send(Message::text( +// serde_json::to_string(&serde_json::json!({ +// "level": "success", +// "time": chrono::Utc::now().timestamp_millis(), +// "data": { "done": true }, +// })) +// .unwrap(), +// )) +// .await +// .unwrap(); +// println!("sent message: [done]"); +// +// println!("deleted old container"); +// // delete container if socket closed +// docker.remove_container(&id, Some(RemoveContainerOptions { force: true, ..Default::default() })).await?; +// Ok(()) +// } diff --git a/crates/maid/server/src/main.rs b/crates/maid/server/src/main.rs index 881ef786eae0a61a26cd98ea5eab537231a72d80..b06122fd215ab367ad1e1d07b29922fa9c14565d 100644 --- a/crates/maid/server/src/main.rs +++ b/crates/maid/server/src/main.rs @@ -1,59 +1,31 @@ -mod helpers; mod docker; mod globals; +mod helpers; mod structs; mod table; -use futures_util::{SinkExt, StreamExt}; -use macros_rs::{fmtstr, ternary}; -use std::convert::Infallible; -use warp::ws::Message; -use warp::{Filter, Reply}; -use bollard::Docker; +use bollard::{Docker, API_DEFAULT_VERSION}; +use docker::container; +use macros_rs::ternary; +use rocket::{get, launch, routes, State}; +use rocket_ws::{Config, Stream, WebSocket}; +use serde_json::{json, Value}; use std::env; -#[tokio::main] -async fn main() { - globals::init(); - - let port = 3500; - let token = "test_token".to_string(); - - let auth = warp::header::exact("Authorization", fmtstr!("Bearer {}", token)); - let health = warp::path!("api" / "health").and_then(health_handler); - - let gateway = warp::path!("ws" / "gateway").and(warp::ws()).map(|ws: warp::ws::Ws| { - ws.on_upgrade(|websocket| async { - let (mut tx, rx) = websocket.split(); - let socket = Docker::connect_with_socket_defaults().unwrap(); - - tx.send(Message::text( - serde_json::to_string(&serde_json::json!({ - "level": "success", - "time": chrono::Utc::now().timestamp_millis(), - "data": { "connected": true, "message": "client connected" }, - })) - .unwrap(), - )) - .await - .unwrap(); - - docker::run::exec(tx, rx, socket).await.unwrap(); - }) - }); - - let routes = health.or(gateway).and(auth); - warp::serve(routes).run(([0, 0, 0, 0], port)).await; +struct DockerState { + docker: Result, } -async fn health_handler() -> Result { - let socket = Docker::connect_with_socket_defaults().unwrap(); +#[get("/api/health")] +async fn health(docker_state: &State) -> Value { + let socket = &docker_state.docker.as_ref().unwrap(); let info = socket.version().await.unwrap(); - + let containers = container::list(socket).await.unwrap(); + let uptime = helpers::format::duration(helpers::os::uptime()); let version = format!("Docker v{} (build {})", &info.version.clone().unwrap(), &info.git_commit.clone().unwrap()); - - Ok(warp::reply::json(&serde_json::json!({ + + json!({ "version": { "data": format!("v{}", env!("CARGO_PKG_VERSION")), "hue": "red" @@ -76,9 +48,75 @@ async fn health_handler() -> Result { "hue": "cyan" }, "containers": { - "data": docker::container::list(socket).await.unwrap(), + "data": containers, "hue": "bright blue" } } - }))) + }) } + +#[get("/echo")] +fn stream(ws: WebSocket) -> Stream!['static] { + let ws = ws.config(Config { + max_send_queue: Some(5), + ..Default::default() + }); + + Stream! { ws => + for await message in ws { + yield message?; + } + } +} + +#[launch] +#[tokio::main] +async fn rocket() -> _ { + globals::init(); + + let http = true; + let token = "test_token".to_string(); + + std::env::set_var("ROCKET_PORT", "3500"); + + let socket = async move { + let socket = match http { + true => Docker::connect_with_http("100.79.107.11:4250", 120, API_DEFAULT_VERSION)?.clone(), + false => Docker::connect_with_socket_defaults()?.clone(), + }; + + Ok::(socket) + }; + + let docker_socket = tokio::spawn(socket); + let docker_socket = docker_socket.await.unwrap(); + + rocket::build().manage(DockerState { docker: docker_socket }).mount("/", routes![health, stream]) +} + +// #[tokio::main] +// async fn main() -> { +// // let connection = Docker::connect_with_http( +// // "http://my-custom-docker-server:2735", 4, API_DEFAULT_VERSION) +// // .unwrap(); +// +// // let session = SessionBuilder::default() +// // .user("root".to_string()) +// // .port(22) +// // .known_hosts_check(KnownHosts::Accept) +// // .control_directory(std::env::temp_dir()) +// // .connect_timeout(Duration::from_secs(5)) +// // .connect("100.79.107.11") +// // .await; +// +// let auth = warp::header::exact("Authorization", fmtstr!("Bearer {}", token)); +// let health = warp::path!("api" / "health").and_then(health_handler); +// +// +// +// +// +// let routes = health.or(gateway).and(auth); +// +// Ok(warp::serve(routes).run(([0, 0, 0, 0], port)).await) +// } diff --git a/crates/maid/server/src/structs.rs b/crates/maid/server/src/structs.rs index aba623850ea3a353cea8f44dc0cbc980dab37cb3..ddb7b023ff6eeac39244fe358dc84ab4758d4501 100644 --- a/crates/maid/server/src/structs.rs +++ b/crates/maid/server/src/structs.rs @@ -1,4 +1,4 @@ -use serde_derive::{Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::BTreeMap; diff --git a/scripts/build.toml b/scripts/build.toml index 9a57865947ad5df35b7754892f28382751e2a8ac..21cc9e403163162327ecc0117c4ee9210252faf0 100644 --- a/scripts/build.toml +++ b/scripts/build.toml @@ -39,6 +39,6 @@ script = [ silent = false exclusive = true shell = "/bin/bash" -image = "messense/cargo-zigbuild:latest" +image = "themackabu/rust:zigbuild-1.74.0" push = ["crates", "Cargo.toml", "Cargo.lock"] pull = "build"