diff --git a/Cargo.lock b/Cargo.lock index 06b3a9000..9fc3e052a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -172,7 +172,7 @@ checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" dependencies = [ "async-channel 2.1.1", "async-executor", - "async-io 2.2.2", + "async-io 2.3.0", "async-lock 3.3.0", "blocking", "futures-lite 2.2.0", @@ -201,9 +201,9 @@ dependencies = [ [[package]] name = "async-io" -version = "2.2.2" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6afaa937395a620e33dc6a742c593c01aced20aa376ffb0f628121198578ccc7" +checksum = "fb41eb19024a91746eba0773aa5e16036045bbf45733766661099e182ea6a744" dependencies = [ "async-lock 3.3.0", "cfg-if", @@ -211,8 +211,8 @@ dependencies = [ "futures-io", "futures-lite 2.2.0", "parking", - "polling 3.3.1", - "rustix 0.38.28", + "polling 3.3.2", + "rustix 0.38.30", "slab", "tracing", "windows-sys 0.52.0", @@ -251,7 +251,7 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.28", + "rustix 0.38.30", "windows-sys 0.48.0", ] @@ -261,13 +261,13 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" dependencies = [ - "async-io 2.2.2", + "async-io 2.3.0", "async-lock 2.8.0", "atomic-waker", "cfg-if", "futures-core", "futures-io", - "rustix 0.38.28", + "rustix 0.38.30", "signal-hook-registry", "slab", "windows-sys 0.48.0", @@ -335,9 +335,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.6" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79fed4cdb43e993fcdadc7e58a09fd0e3e649c4436fa11da71c9f1f3ee7feb9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bit-set" @@ -362,9 +362,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bitmaps" @@ -409,7 +409,7 @@ dependencies = [ "futures-core", "futures-util", "hex", - "http", + "http 0.2.11", "hyper", "hyperlocal", "log", @@ -494,15 +494,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", "serde", - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] @@ -740,7 +740,7 @@ version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62c6fcf842f17f8c78ecf7c81d75c5ce84436b41ee07e03f490fbb5f5a8731d8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "byteorder", "chrono", "diesel_derives", @@ -840,9 +840,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "humantime", "is-terminal", @@ -1246,7 +1246,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.11", "indexmap 2.1.0", "slab", "tokio", @@ -1274,9 +1274,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "hex" @@ -1295,6 +1295,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1302,7 +1313,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.11", "pin-project-lite", ] @@ -1335,13 +1346,13 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.11", "http-body", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.5", "tokio", "tower-service", "tracing", @@ -1485,7 +1496,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" dependencies = [ "hermit-abi", - "rustix 0.38.28", + "rustix 0.38.30", "windows-sys 0.52.0", ] @@ -1515,9 +1526,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] @@ -1609,9 +1620,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "liquid" @@ -1933,6 +1944,7 @@ dependencies = [ "notify", "ntex 1.0.0", "ntex-cors", + "openssl", "rand", "serde", "serde_json", @@ -1953,6 +1965,7 @@ dependencies = [ "nanocl_error", "nanocl_stubs", "ntex 1.0.0", + "openssl", "serde", "serde_json", "tokio", @@ -2046,7 +2059,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "libc", ] @@ -2067,7 +2080,7 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "crossbeam-channel", "filetime", "fsevent-sys", @@ -2088,7 +2101,7 @@ checksum = "7e8da0767496674cfc59663af137b9487a1af597809ba952be07d742f4f75fef" dependencies = [ "async-channel 2.1.1", "base64", - "bitflags 2.4.1", + "bitflags 2.4.2", "encoding_rs", "httparse", "httpdate", @@ -2111,7 +2124,7 @@ dependencies = [ "oneshot", "percent-encoding", "pin-project-lite", - "polling 3.3.1", + "polling 3.3.2", "regex", "serde", "serde_json", @@ -2129,7 +2142,7 @@ checksum = "e5d57146b1df3f045ef60662a0bf2fd03f830fa37dec9381cb2e18956d21e8eb" dependencies = [ "async-channel 2.1.1", "base64", - "bitflags 2.4.1", + "bitflags 2.4.2", "encoding_rs", "httparse", "httpdate", @@ -2150,12 +2163,12 @@ dependencies = [ "ntex-service 2.0.0", "ntex-tls 1.0.0", "ntex-tokio 0.4.0", - "ntex-util 1.0.0", + "ntex-util 1.0.1", "oneshot", "openssl", "percent-encoding", "pin-project-lite", - "polling 3.3.1", + "polling 3.3.2", "regex", "serde", "serde_json", @@ -2175,18 +2188,18 @@ dependencies = [ "log", "ntex-bytes", "ntex-io 1.0.0", - "ntex-util 1.0.0", + "ntex-util 1.0.1", "oneshot", "pin-project-lite", ] [[package]] name = "ntex-bytes" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49e9debc2c3423d3764780060dcb11c7ba7124c2b0833da76218d6771d783297" +checksum = "f7acd545400175382999b237d093abbfc5d77c0192e6284438b3302cc5a7d922" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "bytes", "futures-core", "serde", @@ -2235,7 +2248,7 @@ dependencies = [ "ntex-service 2.0.0", "ntex-tls 1.0.0", "ntex-tokio 0.4.0", - "ntex-util 1.0.0", + "ntex-util 1.0.1", "openssl", "thiserror", ] @@ -2262,7 +2275,7 @@ dependencies = [ "log", "ntex-bytes", "ntex-io 1.0.0", - "ntex-util 1.0.0", + "ntex-util 1.0.1", "oneshot", ] @@ -2272,7 +2285,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138b90775e51cfb9e0a6df6b8f12cfb80ee1d23344a02a138385844061c388fb" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "fxhash", "log", "nanorand", @@ -2294,7 +2307,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d7eee598e3b94175cef2f8c3818b61460307be543f2d9132aac36ac8d78f3d5" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "fxhash", "log", "nanorand", @@ -2305,19 +2318,19 @@ dependencies = [ "ntex-io 1.0.0", "ntex-rt", "ntex-service 2.0.0", - "ntex-util 1.0.0", + "ntex-util 1.0.1", "pin-project-lite", "thiserror", ] [[package]] name = "ntex-http" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3efd2dec66aa4c56ede8fe413d5d9a435938a849927bfd76663b7ada671cd494" +checksum = "f81e205c980c693cb426f55669078bc311973f7e27a34f7ea4d0ce4069dedd05" dependencies = [ "fxhash", - "http", + "http 1.0.0", "itoa", "log", "ntex-bytes", @@ -2330,7 +2343,7 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62c21a70836a8bfd9a673ee86dcf37d35e23b06449faa70bed25ce7c75ca0e81" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "log", "ntex-bytes", "ntex-codec", @@ -2345,12 +2358,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ab3509390c5e2aa677c6444bc8ab1a57059b6f28b7cf55d48d93ddb39d52e90" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "log", "ntex-bytes", "ntex-codec", "ntex-service 2.0.0", - "ntex-util 1.0.0", + "ntex-util 1.0.1", "pin-project-lite", ] @@ -2367,11 +2380,11 @@ dependencies = [ [[package]] name = "ntex-router" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928151097c88a16f21e153bca5a8a19a1df25cdf96a6b348d9dd72b93d8c8bb1" +checksum = "bb9c68c26a87ffca54339be5f95223339db3e7bcc5d64733fef20812970a746f" dependencies = [ - "http", + "http 1.0.0", "log", "ntex-bytes", "regex", @@ -2437,7 +2450,7 @@ dependencies = [ "ntex-bytes", "ntex-io 1.0.0", "ntex-service 2.0.0", - "ntex-util 1.0.0", + "ntex-util 1.0.1", "openssl", "pin-project-lite", ] @@ -2465,7 +2478,7 @@ dependencies = [ "log", "ntex-bytes", "ntex-io 1.0.0", - "ntex-util 1.0.0", + "ntex-util 1.0.1", "pin-project-lite", "tokio", ] @@ -2476,7 +2489,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3376de7b99ba5209c1d73bf62bb3642f5158a26dac6347321088ea848c84019b" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "futures-core", "futures-sink", "futures-timer", @@ -2490,11 +2503,11 @@ dependencies = [ [[package]] name = "ntex-util" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d07c0746ae24cd097ed9a75ccec8796af10cc278c312c5ebe950b3ff8aeef18" +checksum = "caad794a6eb4d73fb4c13b7874fe3e6e9042deab50d6d325b584436efd0db433" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "futures-core", "futures-sink", "futures-timer", @@ -2644,7 +2657,7 @@ version = "0.10.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "foreign-types", "libc", @@ -2791,18 +2804,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", @@ -2834,9 +2847,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" [[package]] name = "polling" @@ -2856,14 +2869,14 @@ dependencies = [ [[package]] name = "polling" -version = "3.3.1" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" +checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" dependencies = [ "cfg-if", "concurrent-queue 2.4.0", "pin-project-lite", - "rustix 0.38.28", + "rustix 0.38.30", "tracing", "windows-sys 0.52.0", ] @@ -2921,9 +2934,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -2995,7 +3008,7 @@ checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.4", + "regex-automata 0.4.5", "regex-syntax 0.8.2", ] @@ -3010,9 +3023,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -3125,14 +3138,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", - "linux-raw-sys 0.4.12", + "linux-raw-sys 0.4.13", "windows-sys 0.52.0", ] @@ -3212,18 +3225,18 @@ checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", @@ -3243,9 +3256,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "4d1bd37ce2324cf3bf85e5a25f96eb4baf0d5aa6eba43e7ae8958870c4ec48ed" dependencies = [ "itoa", "ryu", @@ -3286,9 +3299,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.4.0" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" +checksum = "f5c9fdb6b00a489875b22efd4b78fe2b363b72265cc5f6eb2e2b9ee270e6140c" dependencies = [ "base64", "chrono", @@ -3386,9 +3399,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" @@ -3486,7 +3499,7 @@ dependencies = [ "cfg-if", "fastrand 2.0.1", "redox_syscall", - "rustix 0.38.28", + "rustix 0.38.30", "windows-sys 0.52.0", ] @@ -3768,9 +3781,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -3872,9 +3885,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" dependencies = [ "getrandom", "serde", @@ -3948,9 +3961,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3958,9 +3971,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", @@ -3973,9 +3986,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" dependencies = [ "cfg-if", "js-sys", @@ -3985,9 +3998,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3995,9 +4008,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", @@ -4008,15 +4021,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" dependencies = [ "js-sys", "wasm-bindgen", @@ -4205,9 +4218,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.33" +version = "0.5.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7520bbdec7211caa7c4e682eb1fbe07abe20cee6756b6e00f537c82c11816aa" +checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" dependencies = [ "memchr", ] diff --git a/bin/nanocl/src/commands/state.rs b/bin/nanocl/src/commands/state.rs index ce51174f0..d49cca168 100644 --- a/bin/nanocl/src/commands/state.rs +++ b/bin/nanocl/src/commands/state.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; use futures::StreamExt; use nanocld_client::stubs::system::ObjPsStatusKind; +use nanocld_client::ConnectOpts; use serde_json::{Map, Value}; use clap::{Arg, Command, ArgAction}; use bollard_next::service::HostConfig; @@ -220,10 +221,18 @@ fn gen_client( .ok_or(IoError::not_found("Version", "is not specified"))?; paths.remove(paths.len() - 1); let url = paths.join("/"); - NanocldClient::connect_to(&url, Some(version.into())) + NanocldClient::connect_to(&ConnectOpts { + url, + version: Some(version.into()), + ..Default::default() + }) } api_version if state_ref.data.api_version.starts_with('v') => { - NanocldClient::connect_to(host, Some(api_version.clone())) + NanocldClient::connect_to(&ConnectOpts { + url: host.into(), + version: Some(api_version.clone()), + ..Default::default() + }) } _ => { let mut paths = state_ref @@ -240,7 +249,11 @@ fn gen_client( paths.remove(paths.len() - 1); let url = paths.join("/"); let url = format!("https://{url}"); - NanocldClient::connect_to(&url, Some(version.into())) + NanocldClient::connect_to(&ConnectOpts { + url, + version: Some(version.into()), + ..Default::default() + }) } }; Ok(client) diff --git a/bin/nanocl/src/main.rs b/bin/nanocl/src/main.rs index c7003f757..897d923b5 100644 --- a/bin/nanocl/src/main.rs +++ b/bin/nanocl/src/main.rs @@ -1,7 +1,7 @@ use clap::Parser; use dotenvy::dotenv; -use nanocld_client::NanocldClient; +use nanocld_client::{ConnectOpts, NanocldClient}; use nanocl_error::io::{IoError, IoResult}; mod utils; @@ -42,7 +42,10 @@ fn create_cli_config(cli_args: &Cli) -> IoResult { .unwrap_or("http://nanocl.internal:8585".into()); } } - let client = NanocldClient::connect_to(&host, None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: host.clone(), + ..Default::default() + }); Ok(CliConfig { host, client, diff --git a/bin/nanocl/src/utils/mod.rs b/bin/nanocl/src/utils/mod.rs index 98e51e40c..1fcef2675 100644 --- a/bin/nanocl/src/utils/mod.rs +++ b/bin/nanocl/src/utils/mod.rs @@ -10,9 +10,13 @@ pub mod progress; #[cfg(test)] pub mod tests { + use nanocld_client::{ConnectOpts, NanocldClient}; pub fn get_test_client() -> NanocldClient { - NanocldClient::connect_to("http://nanocl.internal:8585", None) + NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }) } #[macro_export] @@ -71,5 +75,4 @@ pub mod tests { } pub use assert_cli_ok; - use nanocld_client::NanocldClient; } diff --git a/bin/nanocld/Cargo.toml b/bin/nanocld/Cargo.toml index e9e5b648c..7188f08c0 100644 --- a/bin/nanocld/Cargo.toml +++ b/bin/nanocld/Cargo.toml @@ -85,3 +85,4 @@ utoipa = { version = "4.2", features = ["yaml"], optional = true } notify = "6.1" ntex-cors = "0.5" rand = "0.8" +openssl = { version = "0.10" } diff --git a/bin/nanocld/specs/swagger.yaml b/bin/nanocld/specs/swagger.yaml index b83569e42..3c565ce90 100644 --- a/bin/nanocld/specs/swagger.yaml +++ b/bin/nanocld/specs/swagger.yaml @@ -2854,6 +2854,18 @@ components: format: int32 description: Group id minimum: 0 + cert: + type: string + description: Certificate path + nullable: true + cert_key: + type: string + description: Certificate key path + nullable: true + cert_ca: + type: string + description: Ca certificate path + nullable: true DeviceMapping: type: object description: A device mapping between the host and container diff --git a/bin/nanocld/src/cli.rs b/bin/nanocld/src/cli.rs index 6ddbe6038..f2729a28a 100644 --- a/bin/nanocld/src/cli.rs +++ b/bin/nanocld/src/cli.rs @@ -34,6 +34,34 @@ pub struct Cli { /// Group id #[clap(long, default_value = "0")] pub gid: u32, + /// Optional certificate path + #[clap(long)] + pub cert: Option, + /// Optional certificate key path + #[clap(long)] + pub cert_key: Option, + /// Optional ca certificate path + #[clap(long)] + pub cert_ca: Option, +} + +impl Default for Cli { + fn default() -> Self { + Self { + hosts: None, + docker_host: None, + state_dir: None, + conf_dir: String::from("/etc/nanocl"), + gateway: None, + hostname: None, + nodes: vec![], + advertise_addr: None, + gid: 0, + cert: None, + cert_key: None, + cert_ca: None, + } + } } /// Cli arguments unit test diff --git a/bin/nanocld/src/config.rs b/bin/nanocld/src/config.rs index c78f7d8a1..6ddc0fda0 100644 --- a/bin/nanocld/src/config.rs +++ b/bin/nanocld/src/config.rs @@ -63,6 +63,9 @@ fn gen_daemon_conf( advertise_addr, nodes: args.nodes.clone(), conf_dir: args.conf_dir.clone(), + cert: args.cert.clone(), + cert_key: args.cert_key.clone(), + cert_ca: args.cert_ca.clone(), }) } @@ -104,15 +107,11 @@ mod tests { #[test] fn merge_config() { let args = Cli { - gid: 0, hosts: Some(vec![String::from("unix:///run/nanocl/nanocl.sock")]), state_dir: Some(String::from("/var/lib/nanocl")), docker_host: Some(String::from("/var/run/docker.sock")), conf_dir: String::from("/etc/nanocl"), - gateway: None, - hostname: None, - advertise_addr: None, - nodes: Vec::default(), + ..Default::default() }; let config = DaemonConfigFile { hosts: Some(vec![String::from("unix:///run/nanocl/nanocl.sock")]), @@ -177,15 +176,11 @@ mod tests { #[test] fn init_config() { let args = Cli { - gid: 0, hosts: Some(vec![String::from("unix:///run/nanocl/nanocl.sock")]), state_dir: Some(String::from("/var/lib/nanocl")), docker_host: Some(String::from("/var/run/docker.sock")), conf_dir: String::from("/etc/nanocl"), - gateway: None, - advertise_addr: None, - hostname: None, - nodes: Vec::default(), + ..Default::default() }; let config = init(&args).unwrap(); assert_eq!(config.hosts, args.hosts.unwrap()); diff --git a/bin/nanocld/src/subsystem/init.rs b/bin/nanocld/src/subsystem/init.rs index 32a9f3dcd..8b7ddcb77 100644 --- a/bin/nanocld/src/subsystem/init.rs +++ b/bin/nanocld/src/subsystem/init.rs @@ -157,14 +157,10 @@ mod tests { let home = std::env::var("HOME").expect("Failed to get home dir"); let args = cli::Cli { gid: 0, - hosts: None, - docker_host: None, state_dir: Some(format!("{home}/.nanocl_dev/state")), conf_dir: String::from("/etc/nanocl"), - gateway: None, nodes: Vec::default(), - hostname: None, - advertise_addr: None, + ..Default::default() }; log::debug!("args: {args:?}"); let config = config::init(&args).expect("Expect to init config"); diff --git a/bin/nanocld/src/utils/server.rs b/bin/nanocld/src/utils/server.rs index f1124019b..1c7c1ea41 100644 --- a/bin/nanocld/src/utils/server.rs +++ b/bin/nanocld/src/utils/server.rs @@ -1,5 +1,6 @@ use ntex::web; use ntex_cors::Cors; +use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; use nanocl_utils::ntex::middlewares; @@ -14,11 +15,11 @@ pub async fn gen( daemon_state: SystemState, ) -> std::io::Result { log::info!("server::gen: start"); - let hosts = daemon_state.config.hosts.clone(); + let daemon_state_ptr = daemon_state.clone(); let mut server = web::HttpServer::new(move || { web::App::new() // bind config state - .state(daemon_state.clone()) + .state(daemon_state_ptr.clone()) .state( web::types::PayloadConfig::new(20_000_000_000), // <- limit size of the payload ) @@ -32,7 +33,9 @@ pub async fn gen( .configure(services::ntex_config) .default_service(web::route().to(services::unhandled)) }); + let config = daemon_state.config.clone(); let mut count = 0; + let hosts = config.hosts.clone(); let len = hosts.len(); while count < len { let host = &hosts[count]; @@ -47,13 +50,35 @@ pub async fn gen( }; } else if host.starts_with("tcp://") { let addr = host.replace("tcp://", ""); - server = match server.bind(&addr) { - Err(err) => { - log::error!("server::gen: {addr}: {err}"); - return Err(err); - } - Ok(server) => server, - }; + if let Some(cert) = config.cert.clone() { + log::debug!("server::gen: {addr}: with ssl"); + let cert_key = config.cert_key.clone().unwrap(); + let cert_ca = config.cert_ca.clone().unwrap(); + server = match server.bind_openssl(&addr, { + let mut builder = + SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap(); + builder + .set_private_key_file(cert_key, SslFiletype::PEM) + .unwrap(); + builder.set_certificate_chain_file(cert).unwrap(); + builder.set_ca_file(cert_ca).expect("Failed to set ca file"); + builder + }) { + Err(err) => { + log::error!("server::gen: {addr}: {err}"); + return Err(err); + } + Ok(server) => server, + }; + } else { + server = match server.bind(&addr) { + Err(err) => { + log::error!("server::gen: {addr}: {err}"); + return Err(err); + } + Ok(server) => server, + }; + } } else { log::error!( "server::gen: {} invalid protocol [tcp:// | unix://] allowed", diff --git a/bin/ncdns/src/main.rs b/bin/ncdns/src/main.rs index b9eb9d63d..62f059a94 100644 --- a/bin/ncdns/src/main.rs +++ b/bin/ncdns/src/main.rs @@ -25,7 +25,11 @@ async fn run(cli: &Cli) -> IoResult<()> { let mut client = NanocldClient::connect_with_unix_default(); #[cfg(any(feature = "dev", feature = "test"))] { - client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + use nanocld_client::ConnectOpts; + client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); } event::spawn(&client); let server = server::gen(&cli.host, &dnsmasq, &client)?; diff --git a/bin/ncdns/src/server.rs b/bin/ncdns/src/server.rs index 503c4982e..06462bbc3 100644 --- a/bin/ncdns/src/server.rs +++ b/bin/ncdns/src/server.rs @@ -52,11 +52,15 @@ mod tests { use super::*; use crate::dnsmasq::Dnsmasq; use nanocl_error::io::IoResult; + use nanocld_client::ConnectOpts; #[ntex::test] async fn generate_unix_and_tcp() -> IoResult<()> { let dnsmasq = Dnsmasq::new("/tmp/ncdns"); - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let server = gen("unix:///tmp/ncdns.sock", &dnsmasq, &client)?; server.stop(true).await; let server = gen("tcp://0.0.0.0:9987", &dnsmasq, &client)?; @@ -67,7 +71,10 @@ mod tests { #[test] fn generate_wrong_host() -> IoResult<()> { let dnsmasq = Dnsmasq::new("/tmp/ncdns"); - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let server = gen("wrong://dsadsa", &dnsmasq, &client); assert!(server.is_err()); Ok(()) diff --git a/bin/ncdns/src/utils.rs b/bin/ncdns/src/utils.rs index 191086956..027404790 100644 --- a/bin/ncdns/src/utils.rs +++ b/bin/ncdns/src/utils.rs @@ -152,7 +152,7 @@ pub(crate) async fn remove_entries( #[cfg(test)] pub mod tests { pub use nanocl_utils::ntex::test_client::*; - use nanocld_client::NanocldClient; + use nanocld_client::{ConnectOpts, NanocldClient}; use crate::{version, dnsmasq, services}; @@ -167,8 +167,10 @@ pub mod tests { before(); let dnsmasq = dnsmasq::Dnsmasq::new("/tmp/dnsmasq"); dnsmasq.ensure().unwrap(); - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); - // Create test server + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); // Create test server let srv = ntex::web::test::server(move || { ntex::web::App::new() .state(dnsmasq.clone()) diff --git a/bin/ncproxy/src/subsystem/init.rs b/bin/ncproxy/src/subsystem/init.rs index 3947bdca9..2d7c041d4 100644 --- a/bin/ncproxy/src/subsystem/init.rs +++ b/bin/ncproxy/src/subsystem/init.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use nanocl_error::io::IoResult; -use nanocld_client::NanocldClient; +use nanocld_client::{ConnectOpts, NanocldClient}; use crate::{ cli::Cli, @@ -16,7 +16,10 @@ pub async fn init(cli: &Cli) -> IoResult { let mut client = NanocldClient::connect_with_unix_default(); #[cfg(any(feature = "dev", feature = "test"))] { - client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); } let event_emitter = EventEmitter::new(&client); let state = Arc::new(SystemState { diff --git a/bin/ncproxy/src/utils/mod.rs b/bin/ncproxy/src/utils/mod.rs index cdb1cbfa8..647f1bcaf 100644 --- a/bin/ncproxy/src/utils/mod.rs +++ b/bin/ncproxy/src/utils/mod.rs @@ -14,7 +14,7 @@ pub(crate) mod tests { pub use nanocl_utils::ntex::test_client::*; use nanocld_client::{ stubs::{proxy::ResourceProxyRule, cargo_spec::CargoSpecPartial}, - NanocldClient, + ConnectOpts, NanocldClient, }; use crate::{variables, services}; @@ -29,7 +29,10 @@ pub(crate) mod tests { pub async fn ensure_test_cargo() -> IoResult<()> { const CARGO_NAME: &str = "ncproxy-test"; const CARGO_IMAGE: &str = "ghcr.io/next-hat/nanocl-get-started:latest"; - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); if client.inspect_cargo(CARGO_NAME, None).await.is_err() { let cargo = CargoSpecPartial { name: CARGO_NAME.to_owned(), @@ -47,7 +50,10 @@ pub(crate) mod tests { pub async fn clean_test_cargo() -> IoResult<()> { const CARGO_NAME: &str = "ncproxy-test"; - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); if client.inspect_cargo(CARGO_NAME, None).await.is_err() { return Ok(()); } diff --git a/crates/nanocl_stubs/src/config.rs b/crates/nanocl_stubs/src/config.rs index 949d72192..e29e52979 100644 --- a/crates/nanocl_stubs/src/config.rs +++ b/crates/nanocl_stubs/src/config.rs @@ -27,6 +27,12 @@ pub struct DaemonConfig { pub conf_dir: String, /// Group id pub gid: u32, + /// Certificate path + pub cert: Option, + /// Certificate key path + pub cert_key: Option, + /// Ca certificate path + pub cert_ca: Option, } /// Configuration File of the daemon @@ -58,6 +64,9 @@ impl Default for DaemonConfig { gateway: String::default(), nodes: Vec::default(), advertise_addr: String::default(), + cert: None, + cert_key: None, + cert_ca: None, } } } diff --git a/crates/nanocld_client/Cargo.toml b/crates/nanocld_client/Cargo.toml index 048c0cf9f..2c69f8769 100644 --- a/crates/nanocld_client/Cargo.toml +++ b/crates/nanocld_client/Cargo.toml @@ -18,6 +18,7 @@ tokio = ["ntex/tokio"] glommio = ["ntex/glommio"] async-std = ["ntex/async-std"] utoipa = ["nanocl_stubs/utoipa"] +openssl = ["dep:openssl"] [dev-dependencies] tokio-util = "0.7" @@ -31,3 +32,4 @@ serde = { version = "1.0", features = ["derive"] } bollard-next = { version = "0.15.4" } nanocl_stubs = { version = "0.13", features = ["serde"] } nanocl_error = { version = "0.2", features = ["io", "http_client"] } +openssl = { version = "0.10", optional = true } diff --git a/crates/nanocld_client/src/cargo.rs b/crates/nanocld_client/src/cargo.rs index cdcb18d0f..7d31b3b35 100644 --- a/crates/nanocld_client/src/cargo.rs +++ b/crates/nanocld_client/src/cargo.rs @@ -266,6 +266,8 @@ impl NanocldClient { #[cfg(test)] mod tests { + use crate::ConnectOpts; + use super::*; use nanocl_error::http_client::HttpClientError; @@ -274,7 +276,10 @@ mod tests { #[ntex::test] async fn basic() { const CARGO_NAME: &str = "client-test-cargo"; - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); client.list_cargo(None).await.unwrap(); let new_cargo = CargoSpecPartial { name: CARGO_NAME.into(), @@ -322,7 +327,10 @@ mod tests { #[ntex::test] async fn create_cargo_duplicate_name() { - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let new_cargo = CargoSpecPartial { name: "client-test-cargodup".into(), container: bollard_next::container::Config { diff --git a/crates/nanocld_client/src/exec.rs b/crates/nanocld_client/src/exec.rs index 525d83cab..c18b40a9d 100644 --- a/crates/nanocld_client/src/exec.rs +++ b/crates/nanocld_client/src/exec.rs @@ -122,11 +122,14 @@ mod tests { use bollard_next::exec::{CreateExecOptions, StartExecOptions}; use futures::StreamExt; - use crate::NanocldClient; + use crate::{ConnectOpts, NanocldClient}; #[ntex::test] async fn exec_cargo() { - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let exec = CreateExecOptions { cmd: Some(vec!["echo".into(), "hello".into()]), ..Default::default() diff --git a/crates/nanocld_client/src/http_client.rs b/crates/nanocld_client/src/http_client.rs index a79ecd1f5..25ab7280b 100644 --- a/crates/nanocld_client/src/http_client.rs +++ b/crates/nanocld_client/src/http_client.rs @@ -15,11 +15,40 @@ use crate::error::is_api_error; pub const NANOCLD_DEFAULT_VERSION: &str = "0.13.0"; +#[derive(Clone, Debug)] +pub struct ConnectOpts { + /// Url to connect to + pub url: String, + /// Optional version + pub version: Option, + /// Optional certificate path + pub cert: Option, + /// Optional certificate key path + pub cert_key: Option, + /// Optional ca certificate path + pub cert_ca: Option, +} + #[derive(Clone)] pub struct NanocldClient { pub url: String, pub version: String, pub unix_socket: Option, + pub cert: Option, + pub cert_key: Option, + pub cert_ca: Option, +} + +impl Default for ConnectOpts { + fn default() -> Self { + Self { + url: String::from("unix:///run/nanocl/nanocl.sock"), + version: None, + cert: None, + cert_key: None, + cert_ca: None, + } + } } impl std::fmt::Display for NanocldClient { @@ -34,16 +63,24 @@ impl NanocldClient { unix_socket: Some(String::from("/run/nanocl/nanocl.sock")), version: format!("v{NANOCLD_DEFAULT_VERSION}"), url: "http://localhost".to_owned(), + cert: None, + cert_key: None, + cert_ca: None, } } - pub fn connect_to(url: &str, version: Option) -> Self { + pub fn connect_to(opts: &ConnectOpts) -> Self { + let url = opts.url.clone(); + let version = opts.version.clone(); match url { url if url.starts_with("http://") || url.starts_with("https://") => { NanocldClient { url: url.to_owned(), unix_socket: None, version: version.unwrap_or(format!("v{NANOCLD_DEFAULT_VERSION}")), + cert: opts.cert.clone(), + cert_key: opts.cert_key.clone(), + cert_ca: opts.cert_ca.clone(), } } url if url.starts_with("unix://") => { @@ -52,6 +89,9 @@ impl NanocldClient { url: "http://localhost".to_owned(), unix_socket: Some(path.to_owned()), version: version.unwrap_or(format!("v{NANOCLD_DEFAULT_VERSION}")), + cert: None, + cert_key: None, + cert_ca: None, } } _ => panic!("Invalid url: {}", url), @@ -67,6 +107,9 @@ impl NanocldClient { unix_socket: Some(String::from("/run/nanocl/nanocl.sock")), version: version.to_owned(), url: String::from("http://localhost"), + cert: None, + cert_key: None, + cert_ca: None, } } diff --git a/crates/nanocld_client/src/job.rs b/crates/nanocld_client/src/job.rs index 0e06624fd..579ad9e3d 100644 --- a/crates/nanocld_client/src/job.rs +++ b/crates/nanocld_client/src/job.rs @@ -92,17 +92,25 @@ mod tests { use futures::StreamExt; use bollard_next::container::Config; + use crate::ConnectOpts; + use super::*; #[ntex::test] async fn list_job() { - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); client.list_job().await.unwrap(); } #[ntex::test] async fn basic() { - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let job = client .create_job(&JobPartial { name: "my_test_job".to_owned(), diff --git a/crates/nanocld_client/src/metric.rs b/crates/nanocld_client/src/metric.rs index 360106b55..f9fe607d6 100644 --- a/crates/nanocld_client/src/metric.rs +++ b/crates/nanocld_client/src/metric.rs @@ -69,11 +69,16 @@ impl NanocldClient { #[cfg(test)] mod tests { + use crate::ConnectOpts; + use super::*; #[ntex::test] async fn basic() { - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let metric = client .create_metric(&MetricPartial { kind: "my-source.io/type".to_owned(), diff --git a/crates/nanocld_client/src/namespace.rs b/crates/nanocld_client/src/namespace.rs index dea86e571..a9df84122 100644 --- a/crates/nanocld_client/src/namespace.rs +++ b/crates/nanocld_client/src/namespace.rs @@ -82,12 +82,17 @@ impl NanocldClient { #[cfg(test)] mod tests { + use crate::ConnectOpts; + use super::*; #[ntex::test] async fn basic() { const NAMESPACE: &str = "clientnt"; - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); client.list_namespace().await.unwrap(); let namespace = client.create_namespace(NAMESPACE).await.unwrap(); assert_eq!(namespace.name, NAMESPACE); diff --git a/crates/nanocld_client/src/node.rs b/crates/nanocld_client/src/node.rs index d5b8e578e..14e6d63af 100644 --- a/crates/nanocld_client/src/node.rs +++ b/crates/nanocld_client/src/node.rs @@ -27,11 +27,16 @@ impl NanocldClient { #[cfg(test)] mod tests { + use crate::ConnectOpts; + use super::*; #[ntex::test] async fn basic() { - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let node = client.list_node().await; assert!(node.is_ok()); } diff --git a/crates/nanocld_client/src/process.rs b/crates/nanocld_client/src/process.rs index dcca10992..a48b81290 100644 --- a/crates/nanocld_client/src/process.rs +++ b/crates/nanocld_client/src/process.rs @@ -184,13 +184,18 @@ impl NanocldClient { #[cfg(test)] mod tests { + use crate::ConnectOpts; + use super::*; use futures::StreamExt; #[ntex::test] async fn logs_cargo() { - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let mut rx = client .logs_process( "cargo", diff --git a/crates/nanocld_client/src/resource_kind.rs b/crates/nanocld_client/src/resource_kind.rs index d1fd7ff6c..8bf38fdfb 100644 --- a/crates/nanocld_client/src/resource_kind.rs +++ b/crates/nanocld_client/src/resource_kind.rs @@ -127,6 +127,8 @@ impl NanocldClient { #[cfg(test)] mod tests { + use crate::ConnectOpts; + use super::*; use nanocl_stubs::resource_kind::ResourceKindSpec; @@ -135,7 +137,10 @@ mod tests { async fn basic() { const RESOURCE_KIND_NAME: &str = "test.io/client-test"; const RESOURCE_KIND_VERSION: &str = "v1"; - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let resource_kind = ResourceKindPartial { name: RESOURCE_KIND_NAME.to_owned(), version: RESOURCE_KIND_VERSION.to_owned(), diff --git a/crates/nanocld_client/src/secret.rs b/crates/nanocld_client/src/secret.rs index cd4f2199b..94e432b1c 100644 --- a/crates/nanocld_client/src/secret.rs +++ b/crates/nanocld_client/src/secret.rs @@ -102,12 +102,17 @@ impl NanocldClient { #[cfg(test)] mod tests { + use crate::ConnectOpts; + use super::*; #[ntex::test] async fn basic() { const SECRET_NAME: &str = "secret-test"; - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); client.list_secret(None).await.unwrap(); let secret = SecretPartial { name: SECRET_NAME.to_owned(), diff --git a/crates/nanocld_client/src/system.rs b/crates/nanocld_client/src/system.rs index 919f9dff5..a7c76a96b 100644 --- a/crates/nanocld_client/src/system.rs +++ b/crates/nanocld_client/src/system.rs @@ -77,18 +77,26 @@ impl NanocldClient { #[cfg(test)] mod tests { + use crate::ConnectOpts; + use super::*; #[ntex::test] async fn get_version() { - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let version = client.get_version().await; assert!(version.is_ok()); } #[ntex::test] async fn watch_events() { - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let _stream = client.watch_events().await.unwrap(); // Todo : find a way to test this on CI because it's limited to 2 threads // let _event = stream.next().await.unwrap(); @@ -96,7 +104,10 @@ mod tests { #[ntex::test] async fn info() { - let client = NanocldClient::connect_to("http://nanocl.internal:8585", None); + let client = NanocldClient::connect_to(&ConnectOpts { + url: "http://nanocl.internal:8585".into(), + ..Default::default() + }); let info = client.info().await.unwrap(); assert!(info.docker.containers.unwrap() > 0); } diff --git a/docker-compose.yaml b/docker-compose.yaml index 3b6e9179b..28dc0e74a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -163,6 +163,7 @@ services: - system ports: - 8585:8585 + - 9443:9443 labels: - io.nanocl=enabled - io.nanocl.kind=cargo @@ -182,7 +183,16 @@ services: - -w - /project/bin/nanocld/src - -x - - run --no-default-features --features dev --bin nanocld -- --gid 1001 --state-dir ${STATE_DIR:-${HOME}/.nanocl_dev/state} + - | + run --no-default-features \ + --features dev \ + --bin nanocld \ + -- --hosts tcp://0.0.0.0:9443 \ + --gid 1001 \ + --state-dir ${STATE_DIR:-${HOME}/.nanocl_dev/state} \ + --cert ./tests/server.crt \ + --cert-key ./tests/server.key \ + --cert-ca ./tests/ca.crt dbeaver: container_name: dbeaver.system.c