summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2023-11-02 21:01:16 +0100
committerFxQnLr <[email protected]>2023-11-02 21:01:16 +0100
commitf4d3d921460b606a9ff6686c9bb9a79bf546f264 (patch)
tree13c41a8dc306b0c16a3f7e1aa2ffc100c6b2edf3
parent8fab2e7c3a38a91c8f5549b639e7f2ac4ae1a420 (diff)
downloadwebol-cli-f4d3d921460b606a9ff6686c9bb9a79bf546f264.tar
webol-cli-f4d3d921460b606a9ff6686c9bb9a79bf546f264.tar.gz
webol-cli-f4d3d921460b606a9ff6686c9bb9a79bf546f264.zip
baseline ping
-rw-r--r--Cargo.lock308
-rw-r--r--Cargo.toml4
-rw-r--r--src/main.rs48
-rw-r--r--src/requests/device.rs42
-rw-r--r--src/requests/start.rs73
-rw-r--r--webol-cli.toml2
6 files changed, 404 insertions, 73 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b2c6d30..3337e1e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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]]
@@ -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"
@@ -234,6 +240,19 @@ dependencies = [
234] 240]
235 241
236[[package]] 242[[package]]
243name = "console"
244version = "0.15.7"
245source = "registry+https://github.com/rust-lang/crates.io-index"
246checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8"
247dependencies = [
248 "encode_unicode",
249 "lazy_static",
250 "libc",
251 "unicode-width",
252 "windows-sys 0.45.0",
253]
254
255[[package]]
237name = "core-foundation" 256name = "core-foundation"
238version = "0.9.3" 257version = "0.9.3"
239source = "registry+https://github.com/rust-lang/crates.io-index" 258source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -269,6 +288,12 @@ dependencies = [
269] 288]
270 289
271[[package]] 290[[package]]
291name = "data-encoding"
292version = "2.4.0"
293source = "registry+https://github.com/rust-lang/crates.io-index"
294checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
295
296[[package]]
272name = "digest" 297name = "digest"
273version = "0.10.7" 298version = "0.10.7"
274source = "registry+https://github.com/rust-lang/crates.io-index" 299source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -296,7 +321,7 @@ dependencies = [
296 "libc", 321 "libc",
297 "option-ext", 322 "option-ext",
298 "redox_users", 323 "redox_users",
299 "windows-sys", 324 "windows-sys 0.48.0",
300] 325]
301 326
302[[package]] 327[[package]]
@@ -306,6 +331,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
306checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" 331checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257"
307 332
308[[package]] 333[[package]]
334name = "encode_unicode"
335version = "0.3.6"
336source = "registry+https://github.com/rust-lang/crates.io-index"
337checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
338
339[[package]]
309name = "encoding_rs" 340name = "encoding_rs"
310version = "0.8.33" 341version = "0.8.33"
311source = "registry+https://github.com/rust-lang/crates.io-index" 342source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -321,7 +352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
321checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" 352checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860"
322dependencies = [ 353dependencies = [
323 "libc", 354 "libc",
324 "windows-sys", 355 "windows-sys 0.48.0",
325] 356]
326 357
327[[package]] 358[[package]]
@@ -371,36 +402,49 @@ dependencies = [
371 402
372[[package]] 403[[package]]
373name = "futures-core" 404name = "futures-core"
374version = "0.3.28" 405version = "0.3.29"
375source = "registry+https://github.com/rust-lang/crates.io-index" 406source = "registry+https://github.com/rust-lang/crates.io-index"
376checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" 407checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c"
377 408
378[[package]] 409[[package]]
379name = "futures-io" 410name = "futures-io"
380version = "0.3.28" 411version = "0.3.29"
381source = "registry+https://github.com/rust-lang/crates.io-index" 412source = "registry+https://github.com/rust-lang/crates.io-index"
382checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" 413checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa"
414
415[[package]]
416name = "futures-macro"
417version = "0.3.29"
418source = "registry+https://github.com/rust-lang/crates.io-index"
419checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb"
420dependencies = [
421 "proc-macro2",
422 "quote",
423 "syn",
424]
383 425
384[[package]] 426[[package]]
385name = "futures-sink" 427name = "futures-sink"
386version = "0.3.28" 428version = "0.3.29"
387source = "registry+https://github.com/rust-lang/crates.io-index" 429source = "registry+https://github.com/rust-lang/crates.io-index"
388checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" 430checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817"
389 431
390[[package]] 432[[package]]
391name = "futures-task" 433name = "futures-task"
392version = "0.3.28" 434version = "0.3.29"
393source = "registry+https://github.com/rust-lang/crates.io-index" 435source = "registry+https://github.com/rust-lang/crates.io-index"
394checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" 436checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2"
395 437
396[[package]] 438[[package]]
397name = "futures-util" 439name = "futures-util"
398version = "0.3.28" 440version = "0.3.29"
399source = "registry+https://github.com/rust-lang/crates.io-index" 441source = "registry+https://github.com/rust-lang/crates.io-index"
400checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" 442checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104"
401dependencies = [ 443dependencies = [
402 "futures-core", 444 "futures-core",
403 "futures-io", 445 "futures-io",
446 "futures-macro",
447 "futures-sink",
404 "futures-task", 448 "futures-task",
405 "memchr", 449 "memchr",
406 "pin-project-lite", 450 "pin-project-lite",
@@ -567,6 +611,28 @@ dependencies = [
567] 611]
568 612
569[[package]] 613[[package]]
614name = "indicatif"
615version = "0.17.7"
616source = "registry+https://github.com/rust-lang/crates.io-index"
617checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25"
618dependencies = [
619 "console",
620 "instant",
621 "number_prefix",
622 "portable-atomic",
623 "unicode-width",
624]
625
626[[package]]
627name = "instant"
628version = "0.1.12"
629source = "registry+https://github.com/rust-lang/crates.io-index"
630checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
631dependencies = [
632 "cfg-if",
633]
634
635[[package]]
570name = "ipnet" 636name = "ipnet"
571version = "2.8.0" 637version = "2.8.0"
572source = "registry+https://github.com/rust-lang/crates.io-index" 638source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -663,7 +729,7 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
663dependencies = [ 729dependencies = [
664 "libc", 730 "libc",
665 "wasi", 731 "wasi",
666 "windows-sys", 732 "windows-sys 0.48.0",
667] 733]
668 734
669[[package]] 735[[package]]
@@ -705,6 +771,12 @@ dependencies = [
705] 771]
706 772
707[[package]] 773[[package]]
774name = "number_prefix"
775version = "0.4.0"
776source = "registry+https://github.com/rust-lang/crates.io-index"
777checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
778
779[[package]]
708name = "object" 780name = "object"
709version = "0.32.1" 781version = "0.32.1"
710source = "registry+https://github.com/rust-lang/crates.io-index" 782source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -855,6 +927,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
855checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" 927checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
856 928
857[[package]] 929[[package]]
930name = "portable-atomic"
931version = "1.5.1"
932source = "registry+https://github.com/rust-lang/crates.io-index"
933checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b"
934
935[[package]]
936name = "ppv-lite86"
937version = "0.2.17"
938source = "registry+https://github.com/rust-lang/crates.io-index"
939checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
940
941[[package]]
858name = "proc-macro2" 942name = "proc-macro2"
859version = "1.0.69" 943version = "1.0.69"
860source = "registry+https://github.com/rust-lang/crates.io-index" 944source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -873,6 +957,36 @@ dependencies = [
873] 957]
874 958
875[[package]] 959[[package]]
960name = "rand"
961version = "0.8.5"
962source = "registry+https://github.com/rust-lang/crates.io-index"
963checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
964dependencies = [
965 "libc",
966 "rand_chacha",
967 "rand_core",
968]
969
970[[package]]
971name = "rand_chacha"
972version = "0.3.1"
973source = "registry+https://github.com/rust-lang/crates.io-index"
974checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
975dependencies = [
976 "ppv-lite86",
977 "rand_core",
978]
979
980[[package]]
981name = "rand_core"
982version = "0.6.4"
983source = "registry+https://github.com/rust-lang/crates.io-index"
984checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
985dependencies = [
986 "getrandom",
987]
988
989[[package]]
876name = "redox_syscall" 990name = "redox_syscall"
877version = "0.2.16" 991version = "0.2.16"
878source = "registry+https://github.com/rust-lang/crates.io-index" 992source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -976,7 +1090,7 @@ dependencies = [
976 "errno", 1090 "errno",
977 "libc", 1091 "libc",
978 "linux-raw-sys", 1092 "linux-raw-sys",
979 "windows-sys", 1093 "windows-sys 0.48.0",
980] 1094]
981 1095
982[[package]] 1096[[package]]
@@ -991,7 +1105,7 @@ version = "0.1.22"
991source = "registry+https://github.com/rust-lang/crates.io-index" 1105source = "registry+https://github.com/rust-lang/crates.io-index"
992checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" 1106checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88"
993dependencies = [ 1107dependencies = [
994 "windows-sys", 1108 "windows-sys 0.48.0",
995] 1109]
996 1110
997[[package]] 1111[[package]]
@@ -1061,6 +1175,17 @@ dependencies = [
1061] 1175]
1062 1176
1063[[package]] 1177[[package]]
1178name = "sha1"
1179version = "0.10.6"
1180source = "registry+https://github.com/rust-lang/crates.io-index"
1181checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
1182dependencies = [
1183 "cfg-if",
1184 "cpufeatures",
1185 "digest",
1186]
1187
1188[[package]]
1064name = "sha2" 1189name = "sha2"
1065version = "0.10.8" 1190version = "0.10.8"
1066source = "registry+https://github.com/rust-lang/crates.io-index" 1191source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1097,7 +1222,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1097checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" 1222checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"
1098dependencies = [ 1223dependencies = [
1099 "libc", 1224 "libc",
1100 "windows-sys", 1225 "windows-sys 0.48.0",
1101] 1226]
1102 1227
1103[[package]] 1228[[package]]
@@ -1148,7 +1273,7 @@ dependencies = [
1148 "fastrand", 1273 "fastrand",
1149 "redox_syscall 0.3.5", 1274 "redox_syscall 0.3.5",
1150 "rustix", 1275 "rustix",
1151 "windows-sys", 1276 "windows-sys 0.48.0",
1152] 1277]
1153 1278
1154[[package]] 1279[[package]]
@@ -1199,7 +1324,19 @@ dependencies = [
1199 "num_cpus", 1324 "num_cpus",
1200 "pin-project-lite", 1325 "pin-project-lite",
1201 "socket2 0.5.5", 1326 "socket2 0.5.5",
1202 "windows-sys", 1327 "tokio-macros",
1328 "windows-sys 0.48.0",
1329]
1330
1331[[package]]
1332name = "tokio-macros"
1333version = "2.1.0"
1334source = "registry+https://github.com/rust-lang/crates.io-index"
1335checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
1336dependencies = [
1337 "proc-macro2",
1338 "quote",
1339 "syn",
1203] 1340]
1204 1341
1205[[package]] 1342[[package]]
@@ -1213,6 +1350,18 @@ dependencies = [
1213] 1350]
1214 1351
1215[[package]] 1352[[package]]
1353name = "tokio-tungstenite"
1354version = "0.20.1"
1355source = "registry+https://github.com/rust-lang/crates.io-index"
1356checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c"
1357dependencies = [
1358 "futures-util",
1359 "log",
1360 "tokio",
1361 "tungstenite",
1362]
1363
1364[[package]]
1216name = "tokio-util" 1365name = "tokio-util"
1217version = "0.7.9" 1366version = "0.7.9"
1218source = "registry+https://github.com/rust-lang/crates.io-index" 1367source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1267,6 +1416,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1267checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" 1416checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
1268 1417
1269[[package]] 1418[[package]]
1419name = "tungstenite"
1420version = "0.20.1"
1421source = "registry+https://github.com/rust-lang/crates.io-index"
1422checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9"
1423dependencies = [
1424 "byteorder",
1425 "bytes",
1426 "data-encoding",
1427 "http",
1428 "httparse",
1429 "log",
1430 "rand",
1431 "sha1",
1432 "thiserror",
1433 "url",
1434 "utf-8",
1435]
1436
1437[[package]]
1270name = "typenum" 1438name = "typenum"
1271version = "1.17.0" 1439version = "1.17.0"
1272source = "registry+https://github.com/rust-lang/crates.io-index" 1440source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1300,6 +1468,12 @@ dependencies = [
1300] 1468]
1301 1469
1302[[package]] 1470[[package]]
1471name = "unicode-width"
1472version = "0.1.11"
1473source = "registry+https://github.com/rust-lang/crates.io-index"
1474checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
1475
1476[[package]]
1303name = "url" 1477name = "url"
1304version = "2.4.1" 1478version = "2.4.1"
1305source = "registry+https://github.com/rust-lang/crates.io-index" 1479source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1311,6 +1485,12 @@ dependencies = [
1311] 1485]
1312 1486
1313[[package]] 1487[[package]]
1488name = "utf-8"
1489version = "0.7.6"
1490source = "registry+https://github.com/rust-lang/crates.io-index"
1491checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
1492
1493[[package]]
1314name = "utf8parse" 1494name = "utf8parse"
1315version = "0.2.1" 1495version = "0.2.1"
1316source = "registry+https://github.com/rust-lang/crates.io-index" 1496source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1426,10 +1606,14 @@ dependencies = [
1426 "clap", 1606 "clap",
1427 "config", 1607 "config",
1428 "dirs", 1608 "dirs",
1609 "futures-util",
1610 "indicatif",
1429 "once_cell", 1611 "once_cell",
1430 "reqwest", 1612 "reqwest",
1431 "serde", 1613 "serde",
1432 "serde_json", 1614 "serde_json",
1615 "tokio",
1616 "tokio-tungstenite",
1433] 1617]
1434 1618
1435[[package]] 1619[[package]]
@@ -1456,11 +1640,35 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
1456 1640
1457[[package]] 1641[[package]]
1458name = "windows-sys" 1642name = "windows-sys"
1643version = "0.45.0"
1644source = "registry+https://github.com/rust-lang/crates.io-index"
1645checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
1646dependencies = [
1647 "windows-targets 0.42.2",
1648]
1649
1650[[package]]
1651name = "windows-sys"
1459version = "0.48.0" 1652version = "0.48.0"
1460source = "registry+https://github.com/rust-lang/crates.io-index" 1653source = "registry+https://github.com/rust-lang/crates.io-index"
1461checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 1654checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
1462dependencies = [ 1655dependencies = [
1463 "windows-targets", 1656 "windows-targets 0.48.5",
1657]
1658
1659[[package]]
1660name = "windows-targets"
1661version = "0.42.2"
1662source = "registry+https://github.com/rust-lang/crates.io-index"
1663checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
1664dependencies = [
1665 "windows_aarch64_gnullvm 0.42.2",
1666 "windows_aarch64_msvc 0.42.2",
1667 "windows_i686_gnu 0.42.2",
1668 "windows_i686_msvc 0.42.2",
1669 "windows_x86_64_gnu 0.42.2",
1670 "windows_x86_64_gnullvm 0.42.2",
1671 "windows_x86_64_msvc 0.42.2",
1464] 1672]
1465 1673
1466[[package]] 1674[[package]]
@@ -1469,53 +1677,95 @@ version = "0.48.5"
1469source = "registry+https://github.com/rust-lang/crates.io-index" 1677source = "registry+https://github.com/rust-lang/crates.io-index"
1470checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 1678checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
1471dependencies = [ 1679dependencies = [
1472 "windows_aarch64_gnullvm", 1680 "windows_aarch64_gnullvm 0.48.5",
1473 "windows_aarch64_msvc", 1681 "windows_aarch64_msvc 0.48.5",
1474 "windows_i686_gnu", 1682 "windows_i686_gnu 0.48.5",
1475 "windows_i686_msvc", 1683 "windows_i686_msvc 0.48.5",
1476 "windows_x86_64_gnu", 1684 "windows_x86_64_gnu 0.48.5",
1477 "windows_x86_64_gnullvm", 1685 "windows_x86_64_gnullvm 0.48.5",
1478 "windows_x86_64_msvc", 1686 "windows_x86_64_msvc 0.48.5",
1479] 1687]
1480 1688
1481[[package]] 1689[[package]]
1482name = "windows_aarch64_gnullvm" 1690name = "windows_aarch64_gnullvm"
1691version = "0.42.2"
1692source = "registry+https://github.com/rust-lang/crates.io-index"
1693checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
1694
1695[[package]]
1696name = "windows_aarch64_gnullvm"
1483version = "0.48.5" 1697version = "0.48.5"
1484source = "registry+https://github.com/rust-lang/crates.io-index" 1698source = "registry+https://github.com/rust-lang/crates.io-index"
1485checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 1699checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
1486 1700
1487[[package]] 1701[[package]]
1488name = "windows_aarch64_msvc" 1702name = "windows_aarch64_msvc"
1703version = "0.42.2"
1704source = "registry+https://github.com/rust-lang/crates.io-index"
1705checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
1706
1707[[package]]
1708name = "windows_aarch64_msvc"
1489version = "0.48.5" 1709version = "0.48.5"
1490source = "registry+https://github.com/rust-lang/crates.io-index" 1710source = "registry+https://github.com/rust-lang/crates.io-index"
1491checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 1711checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
1492 1712
1493[[package]] 1713[[package]]
1494name = "windows_i686_gnu" 1714name = "windows_i686_gnu"
1715version = "0.42.2"
1716source = "registry+https://github.com/rust-lang/crates.io-index"
1717checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
1718
1719[[package]]
1720name = "windows_i686_gnu"
1495version = "0.48.5" 1721version = "0.48.5"
1496source = "registry+https://github.com/rust-lang/crates.io-index" 1722source = "registry+https://github.com/rust-lang/crates.io-index"
1497checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 1723checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
1498 1724
1499[[package]] 1725[[package]]
1500name = "windows_i686_msvc" 1726name = "windows_i686_msvc"
1727version = "0.42.2"
1728source = "registry+https://github.com/rust-lang/crates.io-index"
1729checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
1730
1731[[package]]
1732name = "windows_i686_msvc"
1501version = "0.48.5" 1733version = "0.48.5"
1502source = "registry+https://github.com/rust-lang/crates.io-index" 1734source = "registry+https://github.com/rust-lang/crates.io-index"
1503checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 1735checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
1504 1736
1505[[package]] 1737[[package]]
1506name = "windows_x86_64_gnu" 1738name = "windows_x86_64_gnu"
1739version = "0.42.2"
1740source = "registry+https://github.com/rust-lang/crates.io-index"
1741checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
1742
1743[[package]]
1744name = "windows_x86_64_gnu"
1507version = "0.48.5" 1745version = "0.48.5"
1508source = "registry+https://github.com/rust-lang/crates.io-index" 1746source = "registry+https://github.com/rust-lang/crates.io-index"
1509checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 1747checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
1510 1748
1511[[package]] 1749[[package]]
1512name = "windows_x86_64_gnullvm" 1750name = "windows_x86_64_gnullvm"
1751version = "0.42.2"
1752source = "registry+https://github.com/rust-lang/crates.io-index"
1753checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
1754
1755[[package]]
1756name = "windows_x86_64_gnullvm"
1513version = "0.48.5" 1757version = "0.48.5"
1514source = "registry+https://github.com/rust-lang/crates.io-index" 1758source = "registry+https://github.com/rust-lang/crates.io-index"
1515checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 1759checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
1516 1760
1517[[package]] 1761[[package]]
1518name = "windows_x86_64_msvc" 1762name = "windows_x86_64_msvc"
1763version = "0.42.2"
1764source = "registry+https://github.com/rust-lang/crates.io-index"
1765checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
1766
1767[[package]]
1768name = "windows_x86_64_msvc"
1519version = "0.48.5" 1769version = "0.48.5"
1520source = "registry+https://github.com/rust-lang/crates.io-index" 1770source = "registry+https://github.com/rust-lang/crates.io-index"
1521checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 1771checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
@@ -1527,7 +1777,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1527checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" 1777checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
1528dependencies = [ 1778dependencies = [
1529 "cfg-if", 1779 "cfg-if",
1530 "windows-sys", 1780 "windows-sys 0.48.0",
1531] 1781]
1532 1782
1533[[package]] 1783[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 69d6f98..2ea0f27 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,11 @@ path = "src/main.rs"
13clap = { version = "4.4.6", features = ["derive"] } 13clap = { version = "4.4.6", features = ["derive"] }
14config = "0.13.3" 14config = "0.13.3"
15dirs = "5.0.1" 15dirs = "5.0.1"
16futures-util = "0.3.29"
17indicatif = "0.17.7"
16once_cell = "1.18.0" 18once_cell = "1.18.0"
17reqwest = { version = "0.11.22", features = ["blocking"] } 19reqwest = { version = "0.11.22", features = ["blocking"] }
18serde = "1.0.189" 20serde = "1.0.189"
19serde_json = "1.0.107" 21serde_json = "1.0.107"
22tokio = { version = "1.33.0", features = ["macros", "rt-multi-thread", "io-std"] }
23tokio-tungstenite = "0.20.1"
diff --git a/src/main.rs b/src/main.rs
index ab7e476..3e1388b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,5 @@
1use std::fmt::Display;
2
1use clap::{Parser, Subcommand}; 3use clap::{Parser, Subcommand};
2use config::SETTINGS; 4use config::SETTINGS;
3use error::CliError; 5use error::CliError;
@@ -21,7 +23,9 @@ struct Args {
21enum Commands { 23enum Commands {
22 Start { 24 Start {
23 /// id of the device 25 /// id of the device
24 id: String 26 id: String,
27 #[arg(short, long)]
28 ping: Option<bool>
25 }, 29 },
26 Device { 30 Device {
27 #[command(subcommand)] 31 #[command(subcommand)]
@@ -34,7 +38,8 @@ enum DeviceCmd {
34 Add { 38 Add {
35 id: String, 39 id: String,
36 mac: String, 40 mac: String,
37 broadcast_addr: String 41 broadcast_addr: String,
42 ip: String
38 }, 43 },
39 Get { 44 Get {
40 id: String, 45 id: String,
@@ -42,27 +47,29 @@ enum DeviceCmd {
42 Edit { 47 Edit {
43 id: String, 48 id: String,
44 mac: String, 49 mac: String,
45 broadcast_addr: String 50 broadcast_addr: String,
51 ip: String
46 }, 52 },
47} 53}
48 54
49fn main() -> Result<(), CliError> { 55#[tokio::main]
56async fn main() -> Result<(), CliError> {
50 let cli = Args::parse(); 57 let cli = Args::parse();
51 58
52 match cli.commands { 59 match cli.commands {
53 Commands::Start { id } => { 60 Commands::Start { id, ping } => {
54 start(id)?; 61 start(id, ping.unwrap_or(true)).await?;
55 }, 62 },
56 Commands::Device { devicecmd } => { 63 Commands::Device { devicecmd } => {
57 match devicecmd { 64 match devicecmd {
58 DeviceCmd::Add { id, mac, broadcast_addr } => { 65 DeviceCmd::Add { id, mac, broadcast_addr, ip } => {
59 device::put(id, mac, broadcast_addr)?; 66 device::put(id, mac, broadcast_addr, ip).await?;
60 }, 67 },
61 DeviceCmd::Get { id } => { 68 DeviceCmd::Get { id } => {
62 device::get(id)?; 69 device::get(id).await?;
63 }, 70 },
64 DeviceCmd::Edit { id, mac, broadcast_addr } => { 71 DeviceCmd::Edit { id, mac, broadcast_addr, ip } => {
65 device::post(id, mac, broadcast_addr)?; 72 device::post(id, mac, broadcast_addr, ip).await?;
66 }, 73 },
67 } 74 }
68 } 75 }
@@ -87,14 +94,29 @@ fn default_headers() -> Result<HeaderMap, CliError> {
87 Ok(map) 94 Ok(map)
88} 95}
89 96
90fn format_url(path: &str) -> Result<String, CliError> { 97fn format_url(path: &str, protocol: Protocols) -> Result<String, CliError> {
91 Ok(format!( 98 Ok(format!(
92 "{}/{}", 99 "{}://{}/{}",
100 protocol,
93 SETTINGS.get_string("server").map_err(CliError::Config)?, 101 SETTINGS.get_string("server").map_err(CliError::Config)?,
94 path 102 path
95 )) 103 ))
96} 104}
97 105
106enum Protocols {
107 Http,
108 Websocket,
109}
110
111impl Display for Protocols {
112 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
113 match self {
114 Self::Http => f.write_str("http"),
115 Self::Websocket => f.write_str("ws")
116 }
117 }
118}
119
98#[derive(Debug, Deserialize)] 120#[derive(Debug, Deserialize)]
99struct ErrorResponse { 121struct ErrorResponse {
100 error: String 122 error: String
diff --git a/src/requests/device.rs b/src/requests/device.rs
index 525745a..f7754a4 100644
--- a/src/requests/device.rs
+++ b/src/requests/device.rs
@@ -1,55 +1,63 @@
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 res = reqwest::Client::new()
5 .put(format_url("device")?) 5 .put(format_url("device", Protocols::Http)?)
6 .headers(default_headers()?) 6 .headers(default_headers()?)
7 .body( 7 .body(
8 format!( 8 format!(
9 r#"{{"id": "{}", "mac": "{}", "broadcast_addr": "{}"}}"#, 9 r#"{{"id": "{}", "mac": "{}", "broadcast_addr": "{}", "ip": "{}"}}"#,
10 id, 10 id,
11 mac, 11 mac,
12 broadcast_addr 12 broadcast_addr,
13 ip
13 ) 14 )
14 ) 15 )
15 .send() 16 .send()
17 .await
16 .map_err(CliError::Reqwest)? 18 .map_err(CliError::Reqwest)?
17 .text(); 19 .text()
20 .await;
18 21
19 println!("{:?}", res); 22 println!("{:?}", res);
20 Ok(()) 23 Ok(())
21} 24}
22 25
23pub fn get(id: String) -> Result<(), CliError> { 26pub async fn get(id: String) -> Result<(), CliError> {
24 let res = reqwest::blocking::Client::new() 27 let res = reqwest::Client::new()
25 .get(format_url("device")?) 28 .get(format_url("device", Protocols::Http)?)
26 .headers(default_headers()?) 29 .headers(default_headers()?)
27 .body( 30 .body(
28 format!(r#"{{"id": "{}"}}"#, id) 31 format!(r#"{{"id": "{}"}}"#, id)
29 ) 32 )
30 .send() 33 .send()
34 .await
31 .map_err(CliError::Reqwest)? 35 .map_err(CliError::Reqwest)?
32 .text(); 36 .text()
37 .await;
33 38
34 println!("{:?}", res); 39 println!("{:?}", res);
35 Ok(()) 40 Ok(())
36} 41}
37 42
38pub fn post(id: String, mac: String, broadcast_addr: String) -> Result<(), CliError> { 43pub async fn post(id: String, mac: String, broadcast_addr: String, ip: String) -> Result<(), CliError> {
39 let res = reqwest::blocking::Client::new() 44 let res = reqwest::Client::new()
40 .post(format_url("device")?) 45 .post(format_url("device", Protocols::Http)?)
41 .headers(default_headers()?) 46 .headers(default_headers()?)
42 .body( 47 .body(
43 format!( 48 format!(
44 r#"{{"id": "{}", "mac": "{}", "broadcast_addr": "{}"}}"#, 49 r#"{{"id": "{}", "mac": "{}", "broadcast_addr": "{}", "ip": "{}"}}"#,
45 id, 50 id,
46 mac, 51 mac,
47 broadcast_addr 52 broadcast_addr,
53 ip
48 ) 54 )
49 ) 55 )
50 .send() 56 .send()
57 .await
51 .map_err(CliError::Reqwest)? 58 .map_err(CliError::Reqwest)?
52 .text(); 59 .text()
60 .await;
53 61
54 println!("{:?}", res); 62 println!("{:?}", res);
55 Ok(()) 63 Ok(())
diff --git a/src/requests/start.rs b/src/requests/start.rs
index 30f65b9..d0c4411 100644
--- a/src/requests/start.rs
+++ b/src/requests/start.rs
@@ -1,37 +1,57 @@
1use std::time::Duration;
2
3use futures_util::{StreamExt, SinkExt};
4use indicatif::{ProgressBar, ProgressStyle};
1use reqwest::StatusCode; 5use reqwest::StatusCode;
2use serde::Deserialize; 6use serde::Deserialize;
7use tokio_tungstenite::{connect_async, tungstenite::Message};
3 8
4use crate::{config::SETTINGS, error::CliError, default_headers, ErrorResponse}; 9use crate::{error::CliError, default_headers, ErrorResponse, format_url, Protocols};
5 10
6pub fn start(id: String) -> Result<(), CliError> { 11pub async fn start(id: String, ping: bool) -> Result<(), CliError> {
7 let res = reqwest::blocking::Client::new() 12
8 .post( 13 let send_start = ProgressBar::new(1);
9 format!( 14
10 "{}/start", 15 // TODO: calculate average start-time on server
11 SETTINGS.get_string("server").map_err(CliError::Config)? 16 send_start.set_style(
12 ) 17 ProgressStyle::with_template("{spinner:.green} ({elapsed}) {wide_msg}")
13 ) 18 .unwrap()
19 .tick_chars("|/-\\\\")
20 );
21
22 let url = format_url("start", Protocols::Http)?;
23
24 send_start.set_message(format!("connect to {}", url));
25 send_start.enable_steady_tick(Duration::from_millis(125));
26
27 let res = reqwest::Client::new()
28 .post(url)
14 .headers(default_headers()?) 29 .headers(default_headers()?)
15 .body( 30 .body(
16 format!(r#"{{"id": "{}"}}"#, id) 31 format!(r#"{{"id": "{}", "ping": {}}}"#, id, ping)
17 ) 32 )
18 .send() 33 .send()
34 .await
19 .map_err(CliError::Reqwest)?; 35 .map_err(CliError::Reqwest)?;
20 36
21 match res.status() { 37 match res.status() {
22 StatusCode::OK => { 38 StatusCode::OK => {
23 let body = serde_json::from_str::<StartResponse>( 39 let body = serde_json::from_str::<StartResponse>(
24 &res.text().map_err(CliError::Reqwest)? 40 &res.text().await.map_err(CliError::Reqwest)?
25 ) 41 )
26 .map_err(CliError::Serde)?; 42 .map_err(CliError::Serde)?;
27 43
28 if body.boot { 44 if body.boot {
29 println!("successfully started {}", body.id); 45 send_start.println("connected, sent start packet");
46 }
47
48 if ping {
49 send_start.println(status_socket(body.uuid, &send_start).await?.to_string());
30 } 50 }
31 }, 51 },
32 _ => { 52 _ => {
33 let body = serde_json::from_str::<ErrorResponse>( 53 let body = serde_json::from_str::<ErrorResponse>(
34 &res.text().map_err(CliError::Reqwest)? 54 &res.text().await.map_err(CliError::Reqwest)?
35 ) 55 )
36 .map_err(CliError::Serde)?; 56 .map_err(CliError::Serde)?;
37 57
@@ -42,8 +62,35 @@ pub fn start(id: String) -> Result<(), CliError> {
42 Ok(()) 62 Ok(())
43} 63}
44 64
65async fn status_socket(uuid: String, pb: &ProgressBar) -> Result<bool, CliError> {
66 pb.set_message("setup websocket");
67
68 let (mut ws_stream, _response) = connect_async(format_url("status", Protocols::Websocket)?)
69 .await
70 .expect("Failed to connect");
71 pb.println("connected to websocket");
72
73 pb.set_message("send uuid message");
74 ws_stream.send(Message::Text(uuid)).await.unwrap();
75 pb.println("sent uuid message");
76
77 pb.set_message("wait for message");
78 let msg = ws_stream.next().await.unwrap();
79
80 pb.println(format!("msg: {:?}", msg));
81
82 ws_stream.close(None).await.unwrap();
83 pb.println("connection closed");
84 // TODO: Check for correct UUID and timeout
85 pb.set_message("verifying message");
86 if msg.is_ok() { return Ok(true) }
87
88 Ok(false)
89}
90
45#[derive(Debug, Deserialize)] 91#[derive(Debug, Deserialize)]
46struct StartResponse { 92struct StartResponse {
47 boot: bool, 93 boot: bool,
48 id: String, 94 id: String,
95 uuid: String,
49} 96}
diff --git a/webol-cli.toml b/webol-cli.toml
index 3eabc97..7ffb99d 100644
--- a/webol-cli.toml
+++ b/webol-cli.toml
@@ -1,2 +1,2 @@
1server = "http://localhost:7229" 1server = "192.168.178.28:7229"
2key = "aaa" 2key = "aaa"