summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Cargo.lock494
-rw-r--r--Cargo.toml5
-rw-r--r--docker-compose.yml2
-rw-r--r--src/error.rs6
-rw-r--r--src/main.rs91
-rw-r--r--src/requests/device.rs44
-rw-r--r--src/requests/start.rs131
-rw-r--r--webol-cli.toml2
9 files changed, 610 insertions, 166 deletions
diff --git a/.gitignore b/.gitignore
index 13a2081..f337b94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
1/target 1/target
2/postgres-data 2/postgres-data
3webol-cli.toml
diff --git a/Cargo.lock b/Cargo.lock
index b2c6d30..5620d60 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
19 19
20[[package]] 20[[package]]
21name = "ahash" 21name = "ahash"
22version = "0.7.6" 22version = "0.7.7"
23source = "registry+https://github.com/rust-lang/crates.io-index" 23source = "registry+https://github.com/rust-lang/crates.io-index"
24checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" 24checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd"
25dependencies = [ 25dependencies = [
26 "getrandom", 26 "getrandom",
27 "once_cell", 27 "once_cell",
@@ -63,7 +63,7 @@ version = "1.0.0"
63source = "registry+https://github.com/rust-lang/crates.io-index" 63source = "registry+https://github.com/rust-lang/crates.io-index"
64checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" 64checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
65dependencies = [ 65dependencies = [
66 "windows-sys", 66 "windows-sys 0.48.0",
67] 67]
68 68
69[[package]] 69[[package]]
@@ -73,7 +73,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
73checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" 73checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628"
74dependencies = [ 74dependencies = [
75 "anstyle", 75 "anstyle",
76 "windows-sys", 76 "windows-sys 0.48.0",
77] 77]
78 78
79[[package]] 79[[package]]
@@ -116,9 +116,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
116 116
117[[package]] 117[[package]]
118name = "base64" 118name = "base64"
119version = "0.21.4" 119version = "0.21.5"
120source = "registry+https://github.com/rust-lang/crates.io-index" 120source = "registry+https://github.com/rust-lang/crates.io-index"
121checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" 121checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
122 122
123[[package]] 123[[package]]
124name = "bitflags" 124name = "bitflags"
@@ -148,6 +148,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
148checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" 148checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
149 149
150[[package]] 150[[package]]
151name = "byteorder"
152version = "1.5.0"
153source = "registry+https://github.com/rust-lang/crates.io-index"
154checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
155
156[[package]]
151name = "bytes" 157name = "bytes"
152version = "1.5.0" 158version = "1.5.0"
153source = "registry+https://github.com/rust-lang/crates.io-index" 159source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -155,9 +161,9 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
155 161
156[[package]] 162[[package]]
157name = "cc" 163name = "cc"
158version = "1.0.83" 164version = "1.0.84"
159source = "registry+https://github.com/rust-lang/crates.io-index" 165source = "registry+https://github.com/rust-lang/crates.io-index"
160checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" 166checksum = "0f8e7c90afad890484a21653d08b6e209ae34770fb5ee298f9c699fcc1e5c856"
161dependencies = [ 167dependencies = [
162 "libc", 168 "libc",
163] 169]
@@ -170,9 +176,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
170 176
171[[package]] 177[[package]]
172name = "clap" 178name = "clap"
173version = "4.4.6" 179version = "4.4.8"
174source = "registry+https://github.com/rust-lang/crates.io-index" 180source = "registry+https://github.com/rust-lang/crates.io-index"
175checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" 181checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64"
176dependencies = [ 182dependencies = [
177 "clap_builder", 183 "clap_builder",
178 "clap_derive", 184 "clap_derive",
@@ -180,9 +186,9 @@ dependencies = [
180 186
181[[package]] 187[[package]]
182name = "clap_builder" 188name = "clap_builder"
183version = "4.4.6" 189version = "4.4.8"
184source = "registry+https://github.com/rust-lang/crates.io-index" 190source = "registry+https://github.com/rust-lang/crates.io-index"
185checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" 191checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc"
186dependencies = [ 192dependencies = [
187 "anstream", 193 "anstream",
188 "anstyle", 194 "anstyle",
@@ -191,10 +197,19 @@ dependencies = [
191] 197]
192 198
193[[package]] 199[[package]]
200name = "clap_complete"
201version = "4.4.4"
202source = "registry+https://github.com/rust-lang/crates.io-index"
203checksum = "bffe91f06a11b4b9420f62103854e90867812cd5d01557f853c5ee8e791b12ae"
204dependencies = [
205 "clap",
206]
207
208[[package]]
194name = "clap_derive" 209name = "clap_derive"
195version = "4.4.2" 210version = "4.4.7"
196source = "registry+https://github.com/rust-lang/crates.io-index" 211source = "registry+https://github.com/rust-lang/crates.io-index"
197checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" 212checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
198dependencies = [ 213dependencies = [
199 "heck", 214 "heck",
200 "proc-macro2", 215 "proc-macro2",
@@ -204,9 +219,9 @@ dependencies = [
204 219
205[[package]] 220[[package]]
206name = "clap_lex" 221name = "clap_lex"
207version = "0.5.1" 222version = "0.6.0"
208source = "registry+https://github.com/rust-lang/crates.io-index" 223source = "registry+https://github.com/rust-lang/crates.io-index"
209checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" 224checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
210 225
211[[package]] 226[[package]]
212name = "colorchoice" 227name = "colorchoice"
@@ -234,6 +249,19 @@ dependencies = [
234] 249]
235 250
236[[package]] 251[[package]]
252name = "console"
253version = "0.15.7"
254source = "registry+https://github.com/rust-lang/crates.io-index"
255checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8"
256dependencies = [
257 "encode_unicode",
258 "lazy_static",
259 "libc",
260 "unicode-width",
261 "windows-sys 0.45.0",
262]
263
264[[package]]
237name = "core-foundation" 265name = "core-foundation"
238version = "0.9.3" 266version = "0.9.3"
239source = "registry+https://github.com/rust-lang/crates.io-index" 267source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -251,9 +279,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
251 279
252[[package]] 280[[package]]
253name = "cpufeatures" 281name = "cpufeatures"
254version = "0.2.10" 282version = "0.2.11"
255source = "registry+https://github.com/rust-lang/crates.io-index" 283source = "registry+https://github.com/rust-lang/crates.io-index"
256checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" 284checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0"
257dependencies = [ 285dependencies = [
258 "libc", 286 "libc",
259] 287]
@@ -269,6 +297,12 @@ dependencies = [
269] 297]
270 298
271[[package]] 299[[package]]
300name = "data-encoding"
301version = "2.4.0"
302source = "registry+https://github.com/rust-lang/crates.io-index"
303checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
304
305[[package]]
272name = "digest" 306name = "digest"
273version = "0.10.7" 307version = "0.10.7"
274source = "registry+https://github.com/rust-lang/crates.io-index" 308source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -296,7 +330,7 @@ dependencies = [
296 "libc", 330 "libc",
297 "option-ext", 331 "option-ext",
298 "redox_users", 332 "redox_users",
299 "windows-sys", 333 "windows-sys 0.48.0",
300] 334]
301 335
302[[package]] 336[[package]]
@@ -306,6 +340,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
306checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" 340checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257"
307 341
308[[package]] 342[[package]]
343name = "encode_unicode"
344version = "0.3.6"
345source = "registry+https://github.com/rust-lang/crates.io-index"
346checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
347
348[[package]]
309name = "encoding_rs" 349name = "encoding_rs"
310version = "0.8.33" 350version = "0.8.33"
311source = "registry+https://github.com/rust-lang/crates.io-index" 351source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -316,12 +356,12 @@ dependencies = [
316 356
317[[package]] 357[[package]]
318name = "errno" 358name = "errno"
319version = "0.3.5" 359version = "0.3.6"
320source = "registry+https://github.com/rust-lang/crates.io-index" 360source = "registry+https://github.com/rust-lang/crates.io-index"
321checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" 361checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e"
322dependencies = [ 362dependencies = [
323 "libc", 363 "libc",
324 "windows-sys", 364 "windows-sys 0.48.0",
325] 365]
326 366
327[[package]] 367[[package]]
@@ -362,45 +402,58 @@ dependencies = [
362 402
363[[package]] 403[[package]]
364name = "futures-channel" 404name = "futures-channel"
365version = "0.3.28" 405version = "0.3.29"
366source = "registry+https://github.com/rust-lang/crates.io-index" 406source = "registry+https://github.com/rust-lang/crates.io-index"
367checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" 407checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb"
368dependencies = [ 408dependencies = [
369 "futures-core", 409 "futures-core",
370] 410]
371 411
372[[package]] 412[[package]]
373name = "futures-core" 413name = "futures-core"
374version = "0.3.28" 414version = "0.3.29"
375source = "registry+https://github.com/rust-lang/crates.io-index" 415source = "registry+https://github.com/rust-lang/crates.io-index"
376checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" 416checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c"
377 417
378[[package]] 418[[package]]
379name = "futures-io" 419name = "futures-io"
380version = "0.3.28" 420version = "0.3.29"
381source = "registry+https://github.com/rust-lang/crates.io-index" 421source = "registry+https://github.com/rust-lang/crates.io-index"
382checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" 422checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa"
423
424[[package]]
425name = "futures-macro"
426version = "0.3.29"
427source = "registry+https://github.com/rust-lang/crates.io-index"
428checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb"
429dependencies = [
430 "proc-macro2",
431 "quote",
432 "syn",
433]
383 434
384[[package]] 435[[package]]
385name = "futures-sink" 436name = "futures-sink"
386version = "0.3.28" 437version = "0.3.29"
387source = "registry+https://github.com/rust-lang/crates.io-index" 438source = "registry+https://github.com/rust-lang/crates.io-index"
388checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" 439checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817"
389 440
390[[package]] 441[[package]]
391name = "futures-task" 442name = "futures-task"
392version = "0.3.28" 443version = "0.3.29"
393source = "registry+https://github.com/rust-lang/crates.io-index" 444source = "registry+https://github.com/rust-lang/crates.io-index"
394checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" 445checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2"
395 446
396[[package]] 447[[package]]
397name = "futures-util" 448name = "futures-util"
398version = "0.3.28" 449version = "0.3.29"
399source = "registry+https://github.com/rust-lang/crates.io-index" 450source = "registry+https://github.com/rust-lang/crates.io-index"
400checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" 451checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104"
401dependencies = [ 452dependencies = [
402 "futures-core", 453 "futures-core",
403 "futures-io", 454 "futures-io",
455 "futures-macro",
456 "futures-sink",
404 "futures-task", 457 "futures-task",
405 "memchr", 458 "memchr",
406 "pin-project-lite", 459 "pin-project-lite",
@@ -420,9 +473,9 @@ dependencies = [
420 473
421[[package]] 474[[package]]
422name = "getrandom" 475name = "getrandom"
423version = "0.2.10" 476version = "0.2.11"
424source = "registry+https://github.com/rust-lang/crates.io-index" 477source = "registry+https://github.com/rust-lang/crates.io-index"
425checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" 478checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
426dependencies = [ 479dependencies = [
427 "cfg-if", 480 "cfg-if",
428 "libc", 481 "libc",
@@ -477,9 +530,9 @@ checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
477 530
478[[package]] 531[[package]]
479name = "http" 532name = "http"
480version = "0.2.9" 533version = "0.2.10"
481source = "registry+https://github.com/rust-lang/crates.io-index" 534source = "registry+https://github.com/rust-lang/crates.io-index"
482checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" 535checksum = "f95b9abcae896730d42b78e09c155ed4ddf82c07b4de772c64aee5b2d8b7c150"
483dependencies = [ 536dependencies = [
484 "bytes", 537 "bytes",
485 "fnv", 538 "fnv",
@@ -567,10 +620,32 @@ dependencies = [
567] 620]
568 621
569[[package]] 622[[package]]
623name = "indicatif"
624version = "0.17.7"
625source = "registry+https://github.com/rust-lang/crates.io-index"
626checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25"
627dependencies = [
628 "console",
629 "instant",
630 "number_prefix",
631 "portable-atomic",
632 "unicode-width",
633]
634
635[[package]]
636name = "instant"
637version = "0.1.12"
638source = "registry+https://github.com/rust-lang/crates.io-index"
639checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
640dependencies = [
641 "cfg-if",
642]
643
644[[package]]
570name = "ipnet" 645name = "ipnet"
571version = "2.8.0" 646version = "2.9.0"
572source = "registry+https://github.com/rust-lang/crates.io-index" 647source = "registry+https://github.com/rust-lang/crates.io-index"
573checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" 648checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
574 649
575[[package]] 650[[package]]
576name = "itoa" 651name = "itoa"
@@ -580,9 +655,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
580 655
581[[package]] 656[[package]]
582name = "js-sys" 657name = "js-sys"
583version = "0.3.64" 658version = "0.3.65"
584source = "registry+https://github.com/rust-lang/crates.io-index" 659source = "registry+https://github.com/rust-lang/crates.io-index"
585checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" 660checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8"
586dependencies = [ 661dependencies = [
587 "wasm-bindgen", 662 "wasm-bindgen",
588] 663]
@@ -606,9 +681,20 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
606 681
607[[package]] 682[[package]]
608name = "libc" 683name = "libc"
609version = "0.2.149" 684version = "0.2.150"
610source = "registry+https://github.com/rust-lang/crates.io-index" 685source = "registry+https://github.com/rust-lang/crates.io-index"
611checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" 686checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
687
688[[package]]
689name = "libredox"
690version = "0.0.1"
691source = "registry+https://github.com/rust-lang/crates.io-index"
692checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8"
693dependencies = [
694 "bitflags 2.4.1",
695 "libc",
696 "redox_syscall",
697]
612 698
613[[package]] 699[[package]]
614name = "linked-hash-map" 700name = "linked-hash-map"
@@ -618,9 +704,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
618 704
619[[package]] 705[[package]]
620name = "linux-raw-sys" 706name = "linux-raw-sys"
621version = "0.4.10" 707version = "0.4.11"
622source = "registry+https://github.com/rust-lang/crates.io-index" 708source = "registry+https://github.com/rust-lang/crates.io-index"
623checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" 709checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829"
624 710
625[[package]] 711[[package]]
626name = "log" 712name = "log"
@@ -657,13 +743,13 @@ dependencies = [
657 743
658[[package]] 744[[package]]
659name = "mio" 745name = "mio"
660version = "0.8.8" 746version = "0.8.9"
661source = "registry+https://github.com/rust-lang/crates.io-index" 747source = "registry+https://github.com/rust-lang/crates.io-index"
662checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" 748checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0"
663dependencies = [ 749dependencies = [
664 "libc", 750 "libc",
665 "wasi", 751 "wasi",
666 "windows-sys", 752 "windows-sys 0.48.0",
667] 753]
668 754
669[[package]] 755[[package]]
@@ -705,6 +791,12 @@ dependencies = [
705] 791]
706 792
707[[package]] 793[[package]]
794name = "number_prefix"
795version = "0.4.0"
796source = "registry+https://github.com/rust-lang/crates.io-index"
797checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
798
799[[package]]
708name = "object" 800name = "object"
709version = "0.32.1" 801version = "0.32.1"
710source = "registry+https://github.com/rust-lang/crates.io-index" 802source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -721,9 +813,9 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
721 813
722[[package]] 814[[package]]
723name = "openssl" 815name = "openssl"
724version = "0.10.57" 816version = "0.10.59"
725source = "registry+https://github.com/rust-lang/crates.io-index" 817source = "registry+https://github.com/rust-lang/crates.io-index"
726checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" 818checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33"
727dependencies = [ 819dependencies = [
728 "bitflags 2.4.1", 820 "bitflags 2.4.1",
729 "cfg-if", 821 "cfg-if",
@@ -753,9 +845,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
753 845
754[[package]] 846[[package]]
755name = "openssl-sys" 847name = "openssl-sys"
756version = "0.9.93" 848version = "0.9.95"
757source = "registry+https://github.com/rust-lang/crates.io-index" 849source = "registry+https://github.com/rust-lang/crates.io-index"
758checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" 850checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9"
759dependencies = [ 851dependencies = [
760 "cc", 852 "cc",
761 "libc", 853 "libc",
@@ -793,9 +885,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
793 885
794[[package]] 886[[package]]
795name = "pest" 887name = "pest"
796version = "2.7.4" 888version = "2.7.5"
797source = "registry+https://github.com/rust-lang/crates.io-index" 889source = "registry+https://github.com/rust-lang/crates.io-index"
798checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" 890checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5"
799dependencies = [ 891dependencies = [
800 "memchr", 892 "memchr",
801 "thiserror", 893 "thiserror",
@@ -804,9 +896,9 @@ dependencies = [
804 896
805[[package]] 897[[package]]
806name = "pest_derive" 898name = "pest_derive"
807version = "2.7.4" 899version = "2.7.5"
808source = "registry+https://github.com/rust-lang/crates.io-index" 900source = "registry+https://github.com/rust-lang/crates.io-index"
809checksum = "35513f630d46400a977c4cb58f78e1bfbe01434316e60c37d27b9ad6139c66d8" 901checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2"
810dependencies = [ 902dependencies = [
811 "pest", 903 "pest",
812 "pest_generator", 904 "pest_generator",
@@ -814,9 +906,9 @@ dependencies = [
814 906
815[[package]] 907[[package]]
816name = "pest_generator" 908name = "pest_generator"
817version = "2.7.4" 909version = "2.7.5"
818source = "registry+https://github.com/rust-lang/crates.io-index" 910source = "registry+https://github.com/rust-lang/crates.io-index"
819checksum = "bc9fc1b9e7057baba189b5c626e2d6f40681ae5b6eb064dc7c7834101ec8123a" 911checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227"
820dependencies = [ 912dependencies = [
821 "pest", 913 "pest",
822 "pest_meta", 914 "pest_meta",
@@ -827,9 +919,9 @@ dependencies = [
827 919
828[[package]] 920[[package]]
829name = "pest_meta" 921name = "pest_meta"
830version = "2.7.4" 922version = "2.7.5"
831source = "registry+https://github.com/rust-lang/crates.io-index" 923source = "registry+https://github.com/rust-lang/crates.io-index"
832checksum = "1df74e9e7ec4053ceb980e7c0c8bd3594e977fde1af91daba9c928e8e8c6708d" 924checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6"
833dependencies = [ 925dependencies = [
834 "once_cell", 926 "once_cell",
835 "pest", 927 "pest",
@@ -855,6 +947,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
855checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" 947checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
856 948
857[[package]] 949[[package]]
950name = "portable-atomic"
951version = "1.5.1"
952source = "registry+https://github.com/rust-lang/crates.io-index"
953checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b"
954
955[[package]]
956name = "ppv-lite86"
957version = "0.2.17"
958source = "registry+https://github.com/rust-lang/crates.io-index"
959checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
960
961[[package]]
858name = "proc-macro2" 962name = "proc-macro2"
859version = "1.0.69" 963version = "1.0.69"
860source = "registry+https://github.com/rust-lang/crates.io-index" 964source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -873,31 +977,52 @@ dependencies = [
873] 977]
874 978
875[[package]] 979[[package]]
876name = "redox_syscall" 980name = "rand"
877version = "0.2.16" 981version = "0.8.5"
878source = "registry+https://github.com/rust-lang/crates.io-index" 982source = "registry+https://github.com/rust-lang/crates.io-index"
879checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 983checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
880dependencies = [ 984dependencies = [
881 "bitflags 1.3.2", 985 "libc",
986 "rand_chacha",
987 "rand_core",
988]
989
990[[package]]
991name = "rand_chacha"
992version = "0.3.1"
993source = "registry+https://github.com/rust-lang/crates.io-index"
994checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
995dependencies = [
996 "ppv-lite86",
997 "rand_core",
998]
999
1000[[package]]
1001name = "rand_core"
1002version = "0.6.4"
1003source = "registry+https://github.com/rust-lang/crates.io-index"
1004checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
1005dependencies = [
1006 "getrandom",
882] 1007]
883 1008
884[[package]] 1009[[package]]
885name = "redox_syscall" 1010name = "redox_syscall"
886version = "0.3.5" 1011version = "0.4.1"
887source = "registry+https://github.com/rust-lang/crates.io-index" 1012source = "registry+https://github.com/rust-lang/crates.io-index"
888checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" 1013checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
889dependencies = [ 1014dependencies = [
890 "bitflags 1.3.2", 1015 "bitflags 1.3.2",
891] 1016]
892 1017
893[[package]] 1018[[package]]
894name = "redox_users" 1019name = "redox_users"
895version = "0.4.3" 1020version = "0.4.4"
896source = "registry+https://github.com/rust-lang/crates.io-index" 1021source = "registry+https://github.com/rust-lang/crates.io-index"
897checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" 1022checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4"
898dependencies = [ 1023dependencies = [
899 "getrandom", 1024 "getrandom",
900 "redox_syscall 0.2.16", 1025 "libredox",
901 "thiserror", 1026 "thiserror",
902] 1027]
903 1028
@@ -907,7 +1032,7 @@ version = "0.11.22"
907source = "registry+https://github.com/rust-lang/crates.io-index" 1032source = "registry+https://github.com/rust-lang/crates.io-index"
908checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" 1033checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b"
909dependencies = [ 1034dependencies = [
910 "base64 0.21.4", 1035 "base64 0.21.5",
911 "bytes", 1036 "bytes",
912 "encoding_rs", 1037 "encoding_rs",
913 "futures-core", 1038 "futures-core",
@@ -968,15 +1093,15 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
968 1093
969[[package]] 1094[[package]]
970name = "rustix" 1095name = "rustix"
971version = "0.38.20" 1096version = "0.38.21"
972source = "registry+https://github.com/rust-lang/crates.io-index" 1097source = "registry+https://github.com/rust-lang/crates.io-index"
973checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" 1098checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
974dependencies = [ 1099dependencies = [
975 "bitflags 2.4.1", 1100 "bitflags 2.4.1",
976 "errno", 1101 "errno",
977 "libc", 1102 "libc",
978 "linux-raw-sys", 1103 "linux-raw-sys",
979 "windows-sys", 1104 "windows-sys 0.48.0",
980] 1105]
981 1106
982[[package]] 1107[[package]]
@@ -991,7 +1116,7 @@ version = "0.1.22"
991source = "registry+https://github.com/rust-lang/crates.io-index" 1116source = "registry+https://github.com/rust-lang/crates.io-index"
992checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" 1117checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88"
993dependencies = [ 1118dependencies = [
994 "windows-sys", 1119 "windows-sys 0.48.0",
995] 1120]
996 1121
997[[package]] 1122[[package]]
@@ -1019,18 +1144,18 @@ dependencies = [
1019 1144
1020[[package]] 1145[[package]]
1021name = "serde" 1146name = "serde"
1022version = "1.0.189" 1147version = "1.0.192"
1023source = "registry+https://github.com/rust-lang/crates.io-index" 1148source = "registry+https://github.com/rust-lang/crates.io-index"
1024checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" 1149checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
1025dependencies = [ 1150dependencies = [
1026 "serde_derive", 1151 "serde_derive",
1027] 1152]
1028 1153
1029[[package]] 1154[[package]]
1030name = "serde_derive" 1155name = "serde_derive"
1031version = "1.0.189" 1156version = "1.0.192"
1032source = "registry+https://github.com/rust-lang/crates.io-index" 1157source = "registry+https://github.com/rust-lang/crates.io-index"
1033checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" 1158checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
1034dependencies = [ 1159dependencies = [
1035 "proc-macro2", 1160 "proc-macro2",
1036 "quote", 1161 "quote",
@@ -1039,9 +1164,9 @@ dependencies = [
1039 1164
1040[[package]] 1165[[package]]
1041name = "serde_json" 1166name = "serde_json"
1042version = "1.0.107" 1167version = "1.0.108"
1043source = "registry+https://github.com/rust-lang/crates.io-index" 1168source = "registry+https://github.com/rust-lang/crates.io-index"
1044checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" 1169checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
1045dependencies = [ 1170dependencies = [
1046 "itoa", 1171 "itoa",
1047 "ryu", 1172 "ryu",
@@ -1061,6 +1186,17 @@ dependencies = [
1061] 1186]
1062 1187
1063[[package]] 1188[[package]]
1189name = "sha1"
1190version = "0.10.6"
1191source = "registry+https://github.com/rust-lang/crates.io-index"
1192checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
1193dependencies = [
1194 "cfg-if",
1195 "cpufeatures",
1196 "digest",
1197]
1198
1199[[package]]
1064name = "sha2" 1200name = "sha2"
1065version = "0.10.8" 1201version = "0.10.8"
1066source = "registry+https://github.com/rust-lang/crates.io-index" 1202source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1097,7 +1233,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1097checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" 1233checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"
1098dependencies = [ 1234dependencies = [
1099 "libc", 1235 "libc",
1100 "windows-sys", 1236 "windows-sys 0.48.0",
1101] 1237]
1102 1238
1103[[package]] 1239[[package]]
@@ -1108,9 +1244,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
1108 1244
1109[[package]] 1245[[package]]
1110name = "syn" 1246name = "syn"
1111version = "2.0.38" 1247version = "2.0.39"
1112source = "registry+https://github.com/rust-lang/crates.io-index" 1248source = "registry+https://github.com/rust-lang/crates.io-index"
1113checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" 1249checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
1114dependencies = [ 1250dependencies = [
1115 "proc-macro2", 1251 "proc-macro2",
1116 "quote", 1252 "quote",
@@ -1140,15 +1276,15 @@ dependencies = [
1140 1276
1141[[package]] 1277[[package]]
1142name = "tempfile" 1278name = "tempfile"
1143version = "3.8.0" 1279version = "3.8.1"
1144source = "registry+https://github.com/rust-lang/crates.io-index" 1280source = "registry+https://github.com/rust-lang/crates.io-index"
1145checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" 1281checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5"
1146dependencies = [ 1282dependencies = [
1147 "cfg-if", 1283 "cfg-if",
1148 "fastrand", 1284 "fastrand",
1149 "redox_syscall 0.3.5", 1285 "redox_syscall",
1150 "rustix", 1286 "rustix",
1151 "windows-sys", 1287 "windows-sys 0.48.0",
1152] 1288]
1153 1289
1154[[package]] 1290[[package]]
@@ -1188,9 +1324,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
1188 1324
1189[[package]] 1325[[package]]
1190name = "tokio" 1326name = "tokio"
1191version = "1.33.0" 1327version = "1.34.0"
1192source = "registry+https://github.com/rust-lang/crates.io-index" 1328source = "registry+https://github.com/rust-lang/crates.io-index"
1193checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" 1329checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9"
1194dependencies = [ 1330dependencies = [
1195 "backtrace", 1331 "backtrace",
1196 "bytes", 1332 "bytes",
@@ -1199,7 +1335,19 @@ dependencies = [
1199 "num_cpus", 1335 "num_cpus",
1200 "pin-project-lite", 1336 "pin-project-lite",
1201 "socket2 0.5.5", 1337 "socket2 0.5.5",
1202 "windows-sys", 1338 "tokio-macros",
1339 "windows-sys 0.48.0",
1340]
1341
1342[[package]]
1343name = "tokio-macros"
1344version = "2.2.0"
1345source = "registry+https://github.com/rust-lang/crates.io-index"
1346checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
1347dependencies = [
1348 "proc-macro2",
1349 "quote",
1350 "syn",
1203] 1351]
1204 1352
1205[[package]] 1353[[package]]
@@ -1213,10 +1361,22 @@ dependencies = [
1213] 1361]
1214 1362
1215[[package]] 1363[[package]]
1364name = "tokio-tungstenite"
1365version = "0.20.1"
1366source = "registry+https://github.com/rust-lang/crates.io-index"
1367checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c"
1368dependencies = [
1369 "futures-util",
1370 "log",
1371 "tokio",
1372 "tungstenite",
1373]
1374
1375[[package]]
1216name = "tokio-util" 1376name = "tokio-util"
1217version = "0.7.9" 1377version = "0.7.10"
1218source = "registry+https://github.com/rust-lang/crates.io-index" 1378source = "registry+https://github.com/rust-lang/crates.io-index"
1219checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" 1379checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15"
1220dependencies = [ 1380dependencies = [
1221 "bytes", 1381 "bytes",
1222 "futures-core", 1382 "futures-core",
@@ -1267,6 +1427,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1267checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" 1427checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
1268 1428
1269[[package]] 1429[[package]]
1430name = "tungstenite"
1431version = "0.20.1"
1432source = "registry+https://github.com/rust-lang/crates.io-index"
1433checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9"
1434dependencies = [
1435 "byteorder",
1436 "bytes",
1437 "data-encoding",
1438 "http",
1439 "httparse",
1440 "log",
1441 "rand",
1442 "sha1",
1443 "thiserror",
1444 "url",
1445 "utf-8",
1446]
1447
1448[[package]]
1270name = "typenum" 1449name = "typenum"
1271version = "1.17.0" 1450version = "1.17.0"
1272source = "registry+https://github.com/rust-lang/crates.io-index" 1451source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1300,6 +1479,12 @@ dependencies = [
1300] 1479]
1301 1480
1302[[package]] 1481[[package]]
1482name = "unicode-width"
1483version = "0.1.11"
1484source = "registry+https://github.com/rust-lang/crates.io-index"
1485checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
1486
1487[[package]]
1303name = "url" 1488name = "url"
1304version = "2.4.1" 1489version = "2.4.1"
1305source = "registry+https://github.com/rust-lang/crates.io-index" 1490source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1311,6 +1496,12 @@ dependencies = [
1311] 1496]
1312 1497
1313[[package]] 1498[[package]]
1499name = "utf-8"
1500version = "0.7.6"
1501source = "registry+https://github.com/rust-lang/crates.io-index"
1502checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
1503
1504[[package]]
1314name = "utf8parse" 1505name = "utf8parse"
1315version = "0.2.1" 1506version = "0.2.1"
1316source = "registry+https://github.com/rust-lang/crates.io-index" 1507source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1345,9 +1536,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
1345 1536
1346[[package]] 1537[[package]]
1347name = "wasm-bindgen" 1538name = "wasm-bindgen"
1348version = "0.2.87" 1539version = "0.2.88"
1349source = "registry+https://github.com/rust-lang/crates.io-index" 1540source = "registry+https://github.com/rust-lang/crates.io-index"
1350checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" 1541checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce"
1351dependencies = [ 1542dependencies = [
1352 "cfg-if", 1543 "cfg-if",
1353 "wasm-bindgen-macro", 1544 "wasm-bindgen-macro",
@@ -1355,9 +1546,9 @@ dependencies = [
1355 1546
1356[[package]] 1547[[package]]
1357name = "wasm-bindgen-backend" 1548name = "wasm-bindgen-backend"
1358version = "0.2.87" 1549version = "0.2.88"
1359source = "registry+https://github.com/rust-lang/crates.io-index" 1550source = "registry+https://github.com/rust-lang/crates.io-index"
1360checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" 1551checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217"
1361dependencies = [ 1552dependencies = [
1362 "bumpalo", 1553 "bumpalo",
1363 "log", 1554 "log",
@@ -1370,9 +1561,9 @@ dependencies = [
1370 1561
1371[[package]] 1562[[package]]
1372name = "wasm-bindgen-futures" 1563name = "wasm-bindgen-futures"
1373version = "0.4.37" 1564version = "0.4.38"
1374source = "registry+https://github.com/rust-lang/crates.io-index" 1565source = "registry+https://github.com/rust-lang/crates.io-index"
1375checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" 1566checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02"
1376dependencies = [ 1567dependencies = [
1377 "cfg-if", 1568 "cfg-if",
1378 "js-sys", 1569 "js-sys",
@@ -1382,9 +1573,9 @@ dependencies = [
1382 1573
1383[[package]] 1574[[package]]
1384name = "wasm-bindgen-macro" 1575name = "wasm-bindgen-macro"
1385version = "0.2.87" 1576version = "0.2.88"
1386source = "registry+https://github.com/rust-lang/crates.io-index" 1577source = "registry+https://github.com/rust-lang/crates.io-index"
1387checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" 1578checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2"
1388dependencies = [ 1579dependencies = [
1389 "quote", 1580 "quote",
1390 "wasm-bindgen-macro-support", 1581 "wasm-bindgen-macro-support",
@@ -1392,9 +1583,9 @@ dependencies = [
1392 1583
1393[[package]] 1584[[package]]
1394name = "wasm-bindgen-macro-support" 1585name = "wasm-bindgen-macro-support"
1395version = "0.2.87" 1586version = "0.2.88"
1396source = "registry+https://github.com/rust-lang/crates.io-index" 1587source = "registry+https://github.com/rust-lang/crates.io-index"
1397checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" 1588checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907"
1398dependencies = [ 1589dependencies = [
1399 "proc-macro2", 1590 "proc-macro2",
1400 "quote", 1591 "quote",
@@ -1405,15 +1596,15 @@ dependencies = [
1405 1596
1406[[package]] 1597[[package]]
1407name = "wasm-bindgen-shared" 1598name = "wasm-bindgen-shared"
1408version = "0.2.87" 1599version = "0.2.88"
1409source = "registry+https://github.com/rust-lang/crates.io-index" 1600source = "registry+https://github.com/rust-lang/crates.io-index"
1410checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" 1601checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b"
1411 1602
1412[[package]] 1603[[package]]
1413name = "web-sys" 1604name = "web-sys"
1414version = "0.3.64" 1605version = "0.3.65"
1415source = "registry+https://github.com/rust-lang/crates.io-index" 1606source = "registry+https://github.com/rust-lang/crates.io-index"
1416checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" 1607checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85"
1417dependencies = [ 1608dependencies = [
1418 "js-sys", 1609 "js-sys",
1419 "wasm-bindgen", 1610 "wasm-bindgen",
@@ -1424,12 +1615,17 @@ name = "webol-cli"
1424version = "0.1.0" 1615version = "0.1.0"
1425dependencies = [ 1616dependencies = [
1426 "clap", 1617 "clap",
1618 "clap_complete",
1427 "config", 1619 "config",
1428 "dirs", 1620 "dirs",
1621 "futures-util",
1622 "indicatif",
1429 "once_cell", 1623 "once_cell",
1430 "reqwest", 1624 "reqwest",
1431 "serde", 1625 "serde",
1432 "serde_json", 1626 "serde_json",
1627 "tokio",
1628 "tokio-tungstenite",
1433] 1629]
1434 1630
1435[[package]] 1631[[package]]
@@ -1456,11 +1652,35 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
1456 1652
1457[[package]] 1653[[package]]
1458name = "windows-sys" 1654name = "windows-sys"
1655version = "0.45.0"
1656source = "registry+https://github.com/rust-lang/crates.io-index"
1657checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
1658dependencies = [
1659 "windows-targets 0.42.2",
1660]
1661
1662[[package]]
1663name = "windows-sys"
1459version = "0.48.0" 1664version = "0.48.0"
1460source = "registry+https://github.com/rust-lang/crates.io-index" 1665source = "registry+https://github.com/rust-lang/crates.io-index"
1461checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 1666checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
1462dependencies = [ 1667dependencies = [
1463 "windows-targets", 1668 "windows-targets 0.48.5",
1669]
1670
1671[[package]]
1672name = "windows-targets"
1673version = "0.42.2"
1674source = "registry+https://github.com/rust-lang/crates.io-index"
1675checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
1676dependencies = [
1677 "windows_aarch64_gnullvm 0.42.2",
1678 "windows_aarch64_msvc 0.42.2",
1679 "windows_i686_gnu 0.42.2",
1680 "windows_i686_msvc 0.42.2",
1681 "windows_x86_64_gnu 0.42.2",
1682 "windows_x86_64_gnullvm 0.42.2",
1683 "windows_x86_64_msvc 0.42.2",
1464] 1684]
1465 1685
1466[[package]] 1686[[package]]
@@ -1469,53 +1689,95 @@ version = "0.48.5"
1469source = "registry+https://github.com/rust-lang/crates.io-index" 1689source = "registry+https://github.com/rust-lang/crates.io-index"
1470checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 1690checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
1471dependencies = [ 1691dependencies = [
1472 "windows_aarch64_gnullvm", 1692 "windows_aarch64_gnullvm 0.48.5",
1473 "windows_aarch64_msvc", 1693 "windows_aarch64_msvc 0.48.5",
1474 "windows_i686_gnu", 1694 "windows_i686_gnu 0.48.5",
1475 "windows_i686_msvc", 1695 "windows_i686_msvc 0.48.5",
1476 "windows_x86_64_gnu", 1696 "windows_x86_64_gnu 0.48.5",
1477 "windows_x86_64_gnullvm", 1697 "windows_x86_64_gnullvm 0.48.5",
1478 "windows_x86_64_msvc", 1698 "windows_x86_64_msvc 0.48.5",
1479] 1699]
1480 1700
1481[[package]] 1701[[package]]
1482name = "windows_aarch64_gnullvm" 1702name = "windows_aarch64_gnullvm"
1703version = "0.42.2"
1704source = "registry+https://github.com/rust-lang/crates.io-index"
1705checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
1706
1707[[package]]
1708name = "windows_aarch64_gnullvm"
1483version = "0.48.5" 1709version = "0.48.5"
1484source = "registry+https://github.com/rust-lang/crates.io-index" 1710source = "registry+https://github.com/rust-lang/crates.io-index"
1485checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 1711checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
1486 1712
1487[[package]] 1713[[package]]
1488name = "windows_aarch64_msvc" 1714name = "windows_aarch64_msvc"
1715version = "0.42.2"
1716source = "registry+https://github.com/rust-lang/crates.io-index"
1717checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
1718
1719[[package]]
1720name = "windows_aarch64_msvc"
1489version = "0.48.5" 1721version = "0.48.5"
1490source = "registry+https://github.com/rust-lang/crates.io-index" 1722source = "registry+https://github.com/rust-lang/crates.io-index"
1491checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 1723checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
1492 1724
1493[[package]] 1725[[package]]
1494name = "windows_i686_gnu" 1726name = "windows_i686_gnu"
1727version = "0.42.2"
1728source = "registry+https://github.com/rust-lang/crates.io-index"
1729checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
1730
1731[[package]]
1732name = "windows_i686_gnu"
1495version = "0.48.5" 1733version = "0.48.5"
1496source = "registry+https://github.com/rust-lang/crates.io-index" 1734source = "registry+https://github.com/rust-lang/crates.io-index"
1497checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 1735checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
1498 1736
1499[[package]] 1737[[package]]
1500name = "windows_i686_msvc" 1738name = "windows_i686_msvc"
1739version = "0.42.2"
1740source = "registry+https://github.com/rust-lang/crates.io-index"
1741checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
1742
1743[[package]]
1744name = "windows_i686_msvc"
1501version = "0.48.5" 1745version = "0.48.5"
1502source = "registry+https://github.com/rust-lang/crates.io-index" 1746source = "registry+https://github.com/rust-lang/crates.io-index"
1503checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 1747checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
1504 1748
1505[[package]] 1749[[package]]
1506name = "windows_x86_64_gnu" 1750name = "windows_x86_64_gnu"
1751version = "0.42.2"
1752source = "registry+https://github.com/rust-lang/crates.io-index"
1753checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
1754
1755[[package]]
1756name = "windows_x86_64_gnu"
1507version = "0.48.5" 1757version = "0.48.5"
1508source = "registry+https://github.com/rust-lang/crates.io-index" 1758source = "registry+https://github.com/rust-lang/crates.io-index"
1509checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 1759checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
1510 1760
1511[[package]] 1761[[package]]
1512name = "windows_x86_64_gnullvm" 1762name = "windows_x86_64_gnullvm"
1763version = "0.42.2"
1764source = "registry+https://github.com/rust-lang/crates.io-index"
1765checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
1766
1767[[package]]
1768name = "windows_x86_64_gnullvm"
1513version = "0.48.5" 1769version = "0.48.5"
1514source = "registry+https://github.com/rust-lang/crates.io-index" 1770source = "registry+https://github.com/rust-lang/crates.io-index"
1515checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 1771checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
1516 1772
1517[[package]] 1773[[package]]
1518name = "windows_x86_64_msvc" 1774name = "windows_x86_64_msvc"
1775version = "0.42.2"
1776source = "registry+https://github.com/rust-lang/crates.io-index"
1777checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
1778
1779[[package]]
1780name = "windows_x86_64_msvc"
1519version = "0.48.5" 1781version = "0.48.5"
1520source = "registry+https://github.com/rust-lang/crates.io-index" 1782source = "registry+https://github.com/rust-lang/crates.io-index"
1521checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 1783checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
@@ -1527,7 +1789,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1527checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" 1789checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
1528dependencies = [ 1790dependencies = [
1529 "cfg-if", 1791 "cfg-if",
1530 "windows-sys", 1792 "windows-sys 0.48.0",
1531] 1793]
1532 1794
1533[[package]] 1795[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 69d6f98..ca76349 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,9 +11,14 @@ path = "src/main.rs"
11 11
12[dependencies] 12[dependencies]
13clap = { version = "4.4.6", features = ["derive"] } 13clap = { version = "4.4.6", features = ["derive"] }
14clap_complete = "4.4.4"
14config = "0.13.3" 15config = "0.13.3"
15dirs = "5.0.1" 16dirs = "5.0.1"
17futures-util = "0.3.29"
18indicatif = "0.17.7"
16once_cell = "1.18.0" 19once_cell = "1.18.0"
17reqwest = { version = "0.11.22", features = ["blocking"] } 20reqwest = { version = "0.11.22", features = ["blocking"] }
18serde = "1.0.189" 21serde = "1.0.189"
19serde_json = "1.0.107" 22serde_json = "1.0.107"
23tokio = { version = "1.33.0", features = ["macros", "rt-multi-thread", "io-std"] }
24tokio-tungstenite = "0.20.1"
diff --git a/docker-compose.yml b/docker-compose.yml
index 0a52d16..3a0ade5 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,6 +1,6 @@
1services: 1services:
2 webol: 2 webol:
3 image: ghcr.io/fxqnlr/webol:dev-2 3 image: ghcr.io/fxqnlr/webol:dev-6
4 container_name: webol 4 container_name: webol
5 restart: no 5 restart: no
6 depends_on: 6 depends_on:
diff --git a/src/error.rs b/src/error.rs
index d35991b..f15c60a 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,9 +1,11 @@
1use std::fmt::Debug; 1use std::{fmt::Debug, num::ParseIntError};
2 2
3pub enum CliError { 3pub enum CliError {
4 Reqwest(reqwest::Error), 4 Reqwest(reqwest::Error),
5 Config(config::ConfigError), 5 Config(config::ConfigError),
6 Serde(serde_json::Error), 6 Serde(serde_json::Error),
7 Parse(ParseIntError),
8 WsResponse,
7} 9}
8 10
9impl Debug for CliError { 11impl Debug for CliError {
@@ -12,6 +14,8 @@ impl Debug for CliError {
12 Self::Reqwest(err) => { err.fmt(f) }, 14 Self::Reqwest(err) => { err.fmt(f) },
13 Self::Config(err) => { err.fmt(f) }, 15 Self::Config(err) => { err.fmt(f) },
14 Self::Serde(err) => { err.fmt(f) }, 16 Self::Serde(err) => { err.fmt(f) },
17 Self::Parse(err) => { err.fmt(f) },
18 Self::WsResponse => { f.write_str("Error in Response") },
15 } 19 }
16 } 20 }
17} 21}
diff --git a/src/main.rs b/src/main.rs
index ab7e476..afe6fac 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,10 @@
1use clap::{Parser, Subcommand}; 1use std::{fmt::Display, time::Duration};
2
3use clap::{Parser, Command, CommandFactory, Subcommand};
4use clap_complete::{generate, Shell, Generator};
2use config::SETTINGS; 5use config::SETTINGS;
3use error::CliError; 6use error::CliError;
7use indicatif::{ProgressBar, ProgressStyle, MultiProgress};
4use requests::{start::start, device}; 8use requests::{start::start, device};
5use reqwest::header::{HeaderMap, HeaderValue}; 9use reqwest::header::{HeaderMap, HeaderValue};
6use serde::Deserialize; 10use serde::Deserialize;
@@ -9,7 +13,15 @@ mod config;
9mod error; 13mod error;
10mod requests; 14mod requests;
11 15
12/// webol http client 16static OVERVIEW_STYLE: &str = "{spinner:.green} ({elapsed}{wide_msg}";
17static OVERVIEW_ERROR: &str = "✗ ({elapsed}) {wide_msg}";
18static OVERVIEW_DONE: &str = "✓ ({elapsed}) {wide_msg}";
19static DEFAULT_STYLE: &str = " {spinner:.green} {wide_msg}";
20static DONE_STYLE: &str = " ✓ {wide_msg}";
21static ERROR_STYLE: &str = " ✗ {wide_msg}";
22static TICK_SPEED: u64 = 1000 / 16;
23
24/// webol client
13#[derive(Parser)] 25#[derive(Parser)]
14#[command(author, version, about, long_about = None)] 26#[command(author, version, about, long_about = None)]
15struct Args { 27struct Args {
@@ -21,12 +33,17 @@ struct Args {
21enum Commands { 33enum Commands {
22 Start { 34 Start {
23 /// id of the device 35 /// id of the device
24 id: String 36 id: String,
37 #[arg(short, long)]
38 ping: Option<bool>
25 }, 39 },
26 Device { 40 Device {
27 #[command(subcommand)] 41 #[command(subcommand)]
28 devicecmd: DeviceCmd, 42 devicecmd: DeviceCmd,
29 } 43 },
44 CliGen {
45 id: Shell,
46 },
30} 47}
31 48
32#[derive(Subcommand)] 49#[derive(Subcommand)]
@@ -34,7 +51,8 @@ enum DeviceCmd {
34 Add { 51 Add {
35 id: String, 52 id: String,
36 mac: String, 53 mac: String,
37 broadcast_addr: String 54 broadcast_addr: String,
55 ip: String
38 }, 56 },
39 Get { 57 Get {
40 id: String, 58 id: String,
@@ -42,35 +60,46 @@ enum DeviceCmd {
42 Edit { 60 Edit {
43 id: String, 61 id: String,
44 mac: String, 62 mac: String,
45 broadcast_addr: String 63 broadcast_addr: String,
64 ip: String
46 }, 65 },
47} 66}
48 67
49fn main() -> Result<(), CliError> { 68#[tokio::main]
69async fn main() -> Result<(), CliError> {
50 let cli = Args::parse(); 70 let cli = Args::parse();
51 71
52 match cli.commands { 72 match cli.commands {
53 Commands::Start { id } => { 73 Commands::Start { id, ping } => {
54 start(id)?; 74 start(id, ping.unwrap_or(true)).await?;
55 }, 75 },
56 Commands::Device { devicecmd } => { 76 Commands::Device { devicecmd } => {
57 match devicecmd { 77 match devicecmd {
58 DeviceCmd::Add { id, mac, broadcast_addr } => { 78 DeviceCmd::Add { id, mac, broadcast_addr, ip } => {
59 device::put(id, mac, broadcast_addr)?; 79 device::put(id, mac, broadcast_addr, ip).await?;
60 }, 80 },
61 DeviceCmd::Get { id } => { 81 DeviceCmd::Get { id } => {
62 device::get(id)?; 82 device::get(id).await?;
63 }, 83 },
64 DeviceCmd::Edit { id, mac, broadcast_addr } => { 84 DeviceCmd::Edit { id, mac, broadcast_addr, ip } => {
65 device::post(id, mac, broadcast_addr)?; 85 device::post(id, mac, broadcast_addr, ip).await?;
66 }, 86 },
67 } 87 }
88 },
89 Commands::CliGen { id } => {
90 eprintln!("Generating completion file for {id:?}...");
91 let mut cmd = Args::command();
92 print_completions(id, &mut cmd)
68 } 93 }
69 } 94 }
70 95
71 Ok(()) 96 Ok(())
72} 97}
73 98
99fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
100 generate(gen, cmd, cmd.get_name().to_string(), &mut std::io::stdout());
101}
102
74fn default_headers() -> Result<HeaderMap, CliError> { 103fn default_headers() -> Result<HeaderMap, CliError> {
75 let mut map = HeaderMap::new(); 104 let mut map = HeaderMap::new();
76 map.append("Accept-Content", HeaderValue::from_str("application/json").unwrap()); 105 map.append("Accept-Content", HeaderValue::from_str("application/json").unwrap());
@@ -87,14 +116,44 @@ fn default_headers() -> Result<HeaderMap, CliError> {
87 Ok(map) 116 Ok(map)
88} 117}
89 118
90fn format_url(path: &str) -> Result<String, CliError> { 119fn format_url(path: &str, protocol: Protocols) -> Result<String, CliError> {
91 Ok(format!( 120 Ok(format!(
92 "{}/{}", 121 "{}://{}/{}",
122 protocol,
93 SETTINGS.get_string("server").map_err(CliError::Config)?, 123 SETTINGS.get_string("server").map_err(CliError::Config)?,
94 path 124 path
95 )) 125 ))
96} 126}
97 127
128fn add_pb(mp: &MultiProgress, template: &str, message: String) -> ProgressBar {
129 let pb = mp.add(ProgressBar::new(1));
130 pb.set_style(ProgressStyle::with_template(template).unwrap());
131 pb.enable_steady_tick(Duration::from_millis(TICK_SPEED));
132 pb.set_message(message);
133
134 pb
135}
136
137fn finish_pb(pb: ProgressBar, message: String, template: &str) {
138 pb.set_style(ProgressStyle::with_template(template).unwrap());
139 pb.finish_with_message(message);
140
141}
142
143enum Protocols {
144 Http,
145 Websocket,
146}
147
148impl Display for Protocols {
149 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
150 match self {
151 Self::Http => f.write_str("http"),
152 Self::Websocket => f.write_str("ws")
153 }
154 }
155}
156
98#[derive(Debug, Deserialize)] 157#[derive(Debug, Deserialize)]
99struct ErrorResponse { 158struct ErrorResponse {
100 error: String 159 error: String
diff --git a/src/requests/device.rs b/src/requests/device.rs
index 525745a..cbc838e 100644
--- a/src/requests/device.rs
+++ b/src/requests/device.rs
@@ -1,55 +1,65 @@
1use crate::{error::CliError, default_headers, format_url}; 1use crate::{error::CliError, default_headers, format_url, Protocols};
2 2
3pub fn put(id: String, mac: String, broadcast_addr: String) -> Result<(), CliError> { 3pub async fn put(id: String, mac: String, broadcast_addr: String, ip: String) -> Result<(), CliError> {
4 let res = reqwest::blocking::Client::new() 4 let url = format_url("device", Protocols::Http)?;
5 .put(format_url("device")?) 5 println!("{}", url);
6 let res = reqwest::Client::new()
7 .put(url)
6 .headers(default_headers()?) 8 .headers(default_headers()?)
7 .body( 9 .body(
8 format!( 10 format!(
9 r#"{{"id": "{}", "mac": "{}", "broadcast_addr": "{}"}}"#, 11 r#"{{"id": "{}", "mac": "{}", "broadcast_addr": "{}", "ip": "{}"}}"#,
10 id, 12 id,
11 mac, 13 mac,
12 broadcast_addr 14 broadcast_addr,
15 ip
13 ) 16 )
14 ) 17 )
15 .send() 18 .send()
19 .await
16 .map_err(CliError::Reqwest)? 20 .map_err(CliError::Reqwest)?
17 .text(); 21 .text()
22 .await;
18 23
19 println!("{:?}", res); 24 println!("{:?}", res);
20 Ok(()) 25 Ok(())
21} 26}
22 27
23pub fn get(id: String) -> Result<(), CliError> { 28pub async fn get(id: String) -> Result<(), CliError> {
24 let res = reqwest::blocking::Client::new() 29 let res = reqwest::Client::new()
25 .get(format_url("device")?) 30 .get(format_url("device", Protocols::Http)?)
26 .headers(default_headers()?) 31 .headers(default_headers()?)
27 .body( 32 .body(
28 format!(r#"{{"id": "{}"}}"#, id) 33 format!(r#"{{"id": "{}"}}"#, id)
29 ) 34 )
30 .send() 35 .send()
36 .await
31 .map_err(CliError::Reqwest)? 37 .map_err(CliError::Reqwest)?
32 .text(); 38 .text()
39 .await;
33 40
34 println!("{:?}", res); 41 println!("{:?}", res);
35 Ok(()) 42 Ok(())
36} 43}
37 44
38pub fn post(id: String, mac: String, broadcast_addr: String) -> Result<(), CliError> { 45pub async fn post(id: String, mac: String, broadcast_addr: String, ip: String) -> Result<(), CliError> {
39 let res = reqwest::blocking::Client::new() 46 let res = reqwest::Client::new()
40 .post(format_url("device")?) 47 .post(format_url("device", Protocols::Http)?)
41 .headers(default_headers()?) 48 .headers(default_headers()?)
42 .body( 49 .body(
43 format!( 50 format!(
44 r#"{{"id": "{}", "mac": "{}", "broadcast_addr": "{}"}}"#, 51 r#"{{"id": "{}", "mac": "{}", "broadcast_addr": "{}", "ip": "{}"}}"#,
45 id, 52 id,
46 mac, 53 mac,
47 broadcast_addr 54 broadcast_addr,
55 ip
48 ) 56 )
49 ) 57 )
50 .send() 58 .send()
59 .await
51 .map_err(CliError::Reqwest)? 60 .map_err(CliError::Reqwest)?
52 .text(); 61 .text()
62 .await;
53 63
54 println!("{:?}", res); 64 println!("{:?}", res);
55 Ok(()) 65 Ok(())
diff --git a/src/requests/start.rs b/src/requests/start.rs
index 30f65b9..ca4ca44 100644
--- a/src/requests/start.rs
+++ b/src/requests/start.rs
@@ -1,49 +1,152 @@
1use futures_util::{StreamExt, SinkExt};
2use indicatif::{MultiProgress, ProgressBar};
1use reqwest::StatusCode; 3use reqwest::StatusCode;
2use serde::Deserialize; 4use serde::Deserialize;
5use tokio_tungstenite::{connect_async, tungstenite::Message};
3 6
4use crate::{config::SETTINGS, error::CliError, default_headers, ErrorResponse}; 7use crate::{error::CliError, default_headers, ErrorResponse, format_url, Protocols, OVERVIEW_STYLE, DEFAULT_STYLE, DONE_STYLE, finish_pb, ERROR_STYLE, OVERVIEW_ERROR, OVERVIEW_DONE, add_pb};
5 8
6pub fn start(id: String) -> Result<(), CliError> { 9pub async fn start(id: String, ping: bool) -> Result<(), CliError> {
7 let res = reqwest::blocking::Client::new() 10
8 .post( 11 let send_start = MultiProgress::new();
9 format!( 12 let overview = add_pb(&send_start, OVERVIEW_STYLE, format!(") start {}", id));
10 "{}/start", 13
11 SETTINGS.get_string("server").map_err(CliError::Config)? 14 // TODO: calculate average start-time on server
12 ) 15 let url = format_url("start", Protocols::Http)?;
13 ) 16 let connect = add_pb(&send_start, DEFAULT_STYLE, format!("connect to {}", url));
17 let res = reqwest::Client::new()
18 .post(url)
14 .headers(default_headers()?) 19 .headers(default_headers()?)
15 .body( 20 .body(
16 format!(r#"{{"id": "{}"}}"#, id) 21 format!(r#"{{"id": "{}", "ping": {}}}"#, id, ping)
17 ) 22 )
18 .send() 23 .send()
24 .await
19 .map_err(CliError::Reqwest)?; 25 .map_err(CliError::Reqwest)?;
26 finish_pb(connect, "connected, got response".to_string(), DONE_STYLE);
20 27
28 let res_pb = add_pb(&send_start, DEFAULT_STYLE, "analyzing response".to_string());
21 match res.status() { 29 match res.status() {
22 StatusCode::OK => { 30 StatusCode::OK => {
23 let body = serde_json::from_str::<StartResponse>( 31 let body = serde_json::from_str::<StartResponse>(
24 &res.text().map_err(CliError::Reqwest)? 32 &res.text().await.map_err(CliError::Reqwest)?
25 ) 33 )
26 .map_err(CliError::Serde)?; 34 .map_err(CliError::Serde)?;
27 35
28 if body.boot { 36 if body.boot {
29 println!("successfully started {}", body.id); 37 finish_pb(res_pb, "sent start packet".to_string(), DONE_STYLE);
38 }
39
40 if ping {
41 let status = status_socket(body.uuid, &send_start, &overview, id).await?;
42 if status {
43 finish_pb(overview, format!("successfully started {}", body.id), OVERVIEW_DONE);
44 } else {
45 finish_pb(overview, format!("error while starting {}", body.id), OVERVIEW_ERROR);
46 }
30 } 47 }
31 }, 48 },
32 _ => { 49 _ => {
33 let body = serde_json::from_str::<ErrorResponse>( 50 let body = serde_json::from_str::<ErrorResponse>(
34 &res.text().map_err(CliError::Reqwest)? 51 &res.text().await.map_err(CliError::Reqwest)?
35 ) 52 )
36 .map_err(CliError::Serde)?; 53 .map_err(CliError::Serde)?;
37 54
38 println!("got error: {}", body.error); 55 res_pb.finish_with_message(format!("got error: {}", body.error));
39 } 56 }
40 } 57 }
41 58
42 Ok(()) 59 Ok(())
43} 60}
44 61
62async fn status_socket(uuid: String, pb: &MultiProgress, overview: &ProgressBar, id: String) -> Result<bool, CliError> {
63 // TODO: Remove unwraps
64 let ws_pb = add_pb(pb, DEFAULT_STYLE, "connect to websocket".to_string());
65 let (mut ws_stream, _response) = connect_async(format_url("status", Protocols::Websocket)?)
66 .await
67 .expect("Failed to connect");
68 finish_pb(ws_pb, "connected to websocket".to_string(), DONE_STYLE);
69
70 ws_stream.send(Message::Text(uuid.clone())).await.unwrap();
71
72 // Get ETA
73 let eta_msg = ws_stream.next().await.unwrap().unwrap();
74 let eta = get_eta(eta_msg.into_text().unwrap(), uuid.clone())? + overview.elapsed().as_secs();
75 overview.set_message(format!("/{}) start {}", eta, id));
76
77 let msg_pb = add_pb(pb, DEFAULT_STYLE, "await message".to_string());
78 let msg = ws_stream.next().await.unwrap();
79 finish_pb(msg_pb, "received message".to_string(), DONE_STYLE);
80
81 ws_stream.close(None).await.unwrap();
82
83 let v_pb = add_pb(pb, DEFAULT_STYLE, "verify response".to_string());
84 let res = verify_response(msg.unwrap().to_string(), uuid)?;
85 match res {
86 Verified::WrongUuid => {
87 finish_pb(v_pb, "returned wrong uuid".to_string(), ERROR_STYLE);
88 Ok(false)
89 },
90 Verified::ResponseType(res_type) => {
91 match res_type {
92 ResponseType::Start => {
93 finish_pb(v_pb, "device started".to_string(), DONE_STYLE);
94 Ok(true)
95 },
96 ResponseType::Timeout => {
97 finish_pb(v_pb, "ping timed out".to_string(), ERROR_STYLE);
98 Ok(false)
99 },
100 ResponseType::NotFound => {
101 finish_pb(v_pb, "unknown uuid".to_string(), ERROR_STYLE);
102 Ok(false)
103 },
104 }
105 }
106 }
107}
108
109fn get_eta(msg: String, uuid: String) -> Result<u64, CliError> {
110 let spl: Vec<&str> = msg.split('_').collect();
111 if (spl[0] != "eta") || (spl[2] != uuid) { return Err(CliError::WsResponse); };
112 Ok(u64::from_str_radix(spl[1], 10).map_err(CliError::Parse)?)
113}
114
115fn verify_response(res: String, org_uuid: String) -> Result<Verified, CliError> {
116 let spl: Vec<&str> = res.split('_').collect();
117 let res_type = spl[0];
118 let uuid = spl[1];
119
120 if uuid != org_uuid { return Ok(Verified::WrongUuid) };
121
122 Ok(Verified::ResponseType(ResponseType::from(res_type)?))
123}
124
45#[derive(Debug, Deserialize)] 125#[derive(Debug, Deserialize)]
46struct StartResponse { 126struct StartResponse {
47 boot: bool, 127 boot: bool,
48 id: String, 128 id: String,
129 uuid: String,
130}
131
132enum Verified {
133 ResponseType(ResponseType),
134 WrongUuid
135}
136
137enum ResponseType {
138 Start,
139 Timeout,
140 NotFound,
141}
142
143impl ResponseType {
144 fn from(value: &str) -> Result<Self, CliError> {
145 match value {
146 "start" => Ok(ResponseType::Start),
147 "timeout" => Ok(ResponseType::Timeout),
148 "notfound" => Ok(ResponseType::NotFound),
149 _ => Err(CliError::WsResponse),
150 }
151 }
49} 152}
diff --git a/webol-cli.toml b/webol-cli.toml
index 3eabc97..822af46 100644
--- a/webol-cli.toml
+++ b/webol-cli.toml
@@ -1,2 +1,2 @@
1server = "http://localhost:7229" 1server = "localhost:7229"
2key = "aaa" 2key = "aaa"