diff options
author | FxQnLr <[email protected]> | 2024-04-10 12:06:45 +0200 |
---|---|---|
committer | FxQnLr <[email protected]> | 2024-04-10 12:06:45 +0200 |
commit | 352dd535e0386d899e816ac5f597e583d1ade768 (patch) | |
tree | 064522c02fb30b3804ee399fd2e77a3e10c3f289 | |
parent | 23aa75439c3ee60e22ce183853516ca3cdd13ff4 (diff) | |
download | webol-cli-352dd535e0386d899e816ac5f597e583d1ade768.tar webol-cli-352dd535e0386d899e816ac5f597e583d1ade768.tar.gz webol-cli-352dd535e0386d899e816ac5f597e583d1ade768.zip |
Closes #8. 0.4.0 seems to work
-rw-r--r-- | Cargo.lock | 103 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/config.rs | 22 | ||||
-rw-r--r-- | src/main.rs | 15 | ||||
-rw-r--r-- | src/requests/device.rs | 7 | ||||
-rw-r--r-- | src/requests/start.rs | 8 |
6 files changed, 76 insertions, 81 deletions
@@ -527,17 +527,17 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" | |||
527 | 527 | ||
528 | [[package]] | 528 | [[package]] |
529 | name = "h2" | 529 | name = "h2" |
530 | version = "0.3.21" | 530 | version = "0.3.26" |
531 | source = "registry+https://github.com/rust-lang/crates.io-index" | 531 | source = "registry+https://github.com/rust-lang/crates.io-index" |
532 | checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" | 532 | checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" |
533 | dependencies = [ | 533 | dependencies = [ |
534 | "bytes", | 534 | "bytes", |
535 | "fnv", | 535 | "fnv", |
536 | "futures-core", | 536 | "futures-core", |
537 | "futures-sink", | 537 | "futures-sink", |
538 | "futures-util", | 538 | "futures-util", |
539 | "http 0.2.10", | 539 | "http 0.2.12", |
540 | "indexmap 1.9.3", | 540 | "indexmap", |
541 | "slab", | 541 | "slab", |
542 | "tokio", | 542 | "tokio", |
543 | "tokio-util", | 543 | "tokio-util", |
@@ -546,12 +546,6 @@ dependencies = [ | |||
546 | 546 | ||
547 | [[package]] | 547 | [[package]] |
548 | name = "hashbrown" | 548 | name = "hashbrown" |
549 | version = "0.12.3" | ||
550 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
551 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" | ||
552 | |||
553 | [[package]] | ||
554 | name = "hashbrown" | ||
555 | version = "0.13.2" | 549 | version = "0.13.2" |
556 | source = "registry+https://github.com/rust-lang/crates.io-index" | 550 | source = "registry+https://github.com/rust-lang/crates.io-index" |
557 | checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" | 551 | checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" |
@@ -576,9 +570,9 @@ checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" | |||
576 | 570 | ||
577 | [[package]] | 571 | [[package]] |
578 | name = "http" | 572 | name = "http" |
579 | version = "0.2.10" | 573 | version = "0.2.12" |
580 | source = "registry+https://github.com/rust-lang/crates.io-index" | 574 | source = "registry+https://github.com/rust-lang/crates.io-index" |
581 | checksum = "f95b9abcae896730d42b78e09c155ed4ddf82c07b4de772c64aee5b2d8b7c150" | 575 | checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" |
582 | dependencies = [ | 576 | dependencies = [ |
583 | "bytes", | 577 | "bytes", |
584 | "fnv", | 578 | "fnv", |
@@ -598,12 +592,12 @@ dependencies = [ | |||
598 | 592 | ||
599 | [[package]] | 593 | [[package]] |
600 | name = "http-body" | 594 | name = "http-body" |
601 | version = "0.4.5" | 595 | version = "0.4.6" |
602 | source = "registry+https://github.com/rust-lang/crates.io-index" | 596 | source = "registry+https://github.com/rust-lang/crates.io-index" |
603 | checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" | 597 | checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" |
604 | dependencies = [ | 598 | dependencies = [ |
605 | "bytes", | 599 | "bytes", |
606 | "http 0.2.10", | 600 | "http 0.2.12", |
607 | "pin-project-lite", | 601 | "pin-project-lite", |
608 | ] | 602 | ] |
609 | 603 | ||
@@ -621,22 +615,22 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" | |||
621 | 615 | ||
622 | [[package]] | 616 | [[package]] |
623 | name = "hyper" | 617 | name = "hyper" |
624 | version = "0.14.27" | 618 | version = "0.14.28" |
625 | source = "registry+https://github.com/rust-lang/crates.io-index" | 619 | source = "registry+https://github.com/rust-lang/crates.io-index" |
626 | checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" | 620 | checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" |
627 | dependencies = [ | 621 | dependencies = [ |
628 | "bytes", | 622 | "bytes", |
629 | "futures-channel", | 623 | "futures-channel", |
630 | "futures-core", | 624 | "futures-core", |
631 | "futures-util", | 625 | "futures-util", |
632 | "h2", | 626 | "h2", |
633 | "http 0.2.10", | 627 | "http 0.2.12", |
634 | "http-body", | 628 | "http-body", |
635 | "httparse", | 629 | "httparse", |
636 | "httpdate", | 630 | "httpdate", |
637 | "itoa", | 631 | "itoa", |
638 | "pin-project-lite", | 632 | "pin-project-lite", |
639 | "socket2 0.4.10", | 633 | "socket2", |
640 | "tokio", | 634 | "tokio", |
641 | "tower-service", | 635 | "tower-service", |
642 | "tracing", | 636 | "tracing", |
@@ -668,16 +662,6 @@ dependencies = [ | |||
668 | 662 | ||
669 | [[package]] | 663 | [[package]] |
670 | name = "indexmap" | 664 | name = "indexmap" |
671 | version = "1.9.3" | ||
672 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
673 | checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" | ||
674 | dependencies = [ | ||
675 | "autocfg", | ||
676 | "hashbrown 0.12.3", | ||
677 | ] | ||
678 | |||
679 | [[package]] | ||
680 | name = "indexmap" | ||
681 | version = "2.2.3" | 665 | version = "2.2.3" |
682 | source = "registry+https://github.com/rust-lang/crates.io-index" | 666 | source = "registry+https://github.com/rust-lang/crates.io-index" |
683 | checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" | 667 | checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" |
@@ -1095,9 +1079,9 @@ dependencies = [ | |||
1095 | 1079 | ||
1096 | [[package]] | 1080 | [[package]] |
1097 | name = "reqwest" | 1081 | name = "reqwest" |
1098 | version = "0.11.22" | 1082 | version = "0.11.27" |
1099 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1083 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1100 | checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" | 1084 | checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" |
1101 | dependencies = [ | 1085 | dependencies = [ |
1102 | "base64", | 1086 | "base64", |
1103 | "bytes", | 1087 | "bytes", |
@@ -1105,7 +1089,7 @@ dependencies = [ | |||
1105 | "futures-core", | 1089 | "futures-core", |
1106 | "futures-util", | 1090 | "futures-util", |
1107 | "h2", | 1091 | "h2", |
1108 | "http 0.2.10", | 1092 | "http 0.2.12", |
1109 | "http-body", | 1093 | "http-body", |
1110 | "hyper", | 1094 | "hyper", |
1111 | "hyper-tls", | 1095 | "hyper-tls", |
@@ -1117,9 +1101,11 @@ dependencies = [ | |||
1117 | "once_cell", | 1101 | "once_cell", |
1118 | "percent-encoding", | 1102 | "percent-encoding", |
1119 | "pin-project-lite", | 1103 | "pin-project-lite", |
1104 | "rustls-pemfile", | ||
1120 | "serde", | 1105 | "serde", |
1121 | "serde_json", | 1106 | "serde_json", |
1122 | "serde_urlencoded", | 1107 | "serde_urlencoded", |
1108 | "sync_wrapper", | ||
1123 | "system-configuration", | 1109 | "system-configuration", |
1124 | "tokio", | 1110 | "tokio", |
1125 | "tokio-native-tls", | 1111 | "tokio-native-tls", |
@@ -1173,6 +1159,15 @@ dependencies = [ | |||
1173 | ] | 1159 | ] |
1174 | 1160 | ||
1175 | [[package]] | 1161 | [[package]] |
1162 | name = "rustls-pemfile" | ||
1163 | version = "1.0.4" | ||
1164 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1165 | checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" | ||
1166 | dependencies = [ | ||
1167 | "base64", | ||
1168 | ] | ||
1169 | |||
1170 | [[package]] | ||
1176 | name = "ryu" | 1171 | name = "ryu" |
1177 | version = "1.0.15" | 1172 | version = "1.0.15" |
1178 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1173 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1295,16 +1290,6 @@ dependencies = [ | |||
1295 | 1290 | ||
1296 | [[package]] | 1291 | [[package]] |
1297 | name = "socket2" | 1292 | name = "socket2" |
1298 | version = "0.4.10" | ||
1299 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1300 | checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" | ||
1301 | dependencies = [ | ||
1302 | "libc", | ||
1303 | "winapi", | ||
1304 | ] | ||
1305 | |||
1306 | [[package]] | ||
1307 | name = "socket2" | ||
1308 | version = "0.5.5" | 1293 | version = "0.5.5" |
1309 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1294 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1310 | checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" | 1295 | checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" |
@@ -1331,6 +1316,12 @@ dependencies = [ | |||
1331 | ] | 1316 | ] |
1332 | 1317 | ||
1333 | [[package]] | 1318 | [[package]] |
1319 | name = "sync_wrapper" | ||
1320 | version = "0.1.2" | ||
1321 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1322 | checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" | ||
1323 | |||
1324 | [[package]] | ||
1334 | name = "system-configuration" | 1325 | name = "system-configuration" |
1335 | version = "0.5.1" | 1326 | version = "0.5.1" |
1336 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1327 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1420,7 +1411,7 @@ dependencies = [ | |||
1420 | "mio", | 1411 | "mio", |
1421 | "num_cpus", | 1412 | "num_cpus", |
1422 | "pin-project-lite", | 1413 | "pin-project-lite", |
1423 | "socket2 0.5.5", | 1414 | "socket2", |
1424 | "tokio-macros", | 1415 | "tokio-macros", |
1425 | "windows-sys 0.48.0", | 1416 | "windows-sys 0.48.0", |
1426 | ] | 1417 | ] |
@@ -1499,7 +1490,7 @@ version = "0.22.6" | |||
1499 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1490 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1500 | checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" | 1491 | checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" |
1501 | dependencies = [ | 1492 | dependencies = [ |
1502 | "indexmap 2.2.3", | 1493 | "indexmap", |
1503 | "serde", | 1494 | "serde", |
1504 | "serde_spanned", | 1495 | "serde_spanned", |
1505 | "toml_datetime", | 1496 | "toml_datetime", |
@@ -1729,7 +1720,7 @@ dependencies = [ | |||
1729 | 1720 | ||
1730 | [[package]] | 1721 | [[package]] |
1731 | name = "webol-cli" | 1722 | name = "webol-cli" |
1732 | version = "0.2.0" | 1723 | version = "0.3.0" |
1733 | dependencies = [ | 1724 | dependencies = [ |
1734 | "anyhow", | 1725 | "anyhow", |
1735 | "clap", | 1726 | "clap", |
@@ -1747,28 +1738,6 @@ dependencies = [ | |||
1747 | ] | 1738 | ] |
1748 | 1739 | ||
1749 | [[package]] | 1740 | [[package]] |
1750 | name = "winapi" | ||
1751 | version = "0.3.9" | ||
1752 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1753 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" | ||
1754 | dependencies = [ | ||
1755 | "winapi-i686-pc-windows-gnu", | ||
1756 | "winapi-x86_64-pc-windows-gnu", | ||
1757 | ] | ||
1758 | |||
1759 | [[package]] | ||
1760 | name = "winapi-i686-pc-windows-gnu" | ||
1761 | version = "0.4.0" | ||
1762 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1763 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" | ||
1764 | |||
1765 | [[package]] | ||
1766 | name = "winapi-x86_64-pc-windows-gnu" | ||
1767 | version = "0.4.0" | ||
1768 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1769 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" | ||
1770 | |||
1771 | [[package]] | ||
1772 | name = "windows-sys" | 1741 | name = "windows-sys" |
1773 | version = "0.45.0" | 1742 | version = "0.45.0" |
1774 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1743 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1,6 +1,6 @@ | |||
1 | [package] | 1 | [package] |
2 | name = "webol-cli" | 2 | name = "webol-cli" |
3 | version = "0.2.0" | 3 | version = "0.3.0" |
4 | edition = "2021" | 4 | edition = "2021" |
5 | 5 | ||
6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
diff --git a/src/config.rs b/src/config.rs index 769269c..01ab097 100644 --- a/src/config.rs +++ b/src/config.rs | |||
@@ -2,8 +2,20 @@ use serde::Deserialize; | |||
2 | 2 | ||
3 | #[derive(Deserialize)] | 3 | #[derive(Deserialize)] |
4 | pub struct Config { | 4 | pub struct Config { |
5 | pub apikey: String, | ||
6 | pub server: String, | 5 | pub server: String, |
6 | pub auth: Auth, | ||
7 | } | ||
8 | |||
9 | #[derive(Deserialize)] | ||
10 | pub struct Auth { | ||
11 | pub method: Method, | ||
12 | pub secret: String, | ||
13 | } | ||
14 | |||
15 | #[derive(PartialEq, Eq, Deserialize)] | ||
16 | pub enum Method { | ||
17 | None, | ||
18 | Key, | ||
7 | } | 19 | } |
8 | 20 | ||
9 | impl Config { | 21 | impl Config { |
@@ -12,9 +24,15 @@ impl Config { | |||
12 | 24 | ||
13 | let builder = config::Config::builder(); | 25 | let builder = config::Config::builder(); |
14 | 26 | ||
27 | let builder = builder | ||
28 | .set_default("auth.method", "none")? | ||
29 | .set_default("auth.secret", "")?; | ||
30 | |||
15 | let builder = if let Some(conf) = config_dir { | 31 | let builder = if let Some(conf) = config_dir { |
16 | let dir = conf.to_string_lossy(); | 32 | let dir = conf.to_string_lossy(); |
17 | builder.add_source(config::File::with_name(format!("{dir}/webol-cli").as_str()).required(false)) | 33 | builder.add_source( |
34 | config::File::with_name(format!("{dir}/webol-cli").as_str()).required(false), | ||
35 | ) | ||
18 | } else { | 36 | } else { |
19 | println!("!No config dir found"); | 37 | println!("!No config dir found"); |
20 | builder | 38 | builder |
diff --git a/src/main.rs b/src/main.rs index 5a0931d..2726a5e 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -3,6 +3,7 @@ use std::{fmt::Display, time::Duration}; | |||
3 | use crate::config::Config; | 3 | use crate::config::Config; |
4 | use clap::{Command, CommandFactory, Parser, Subcommand}; | 4 | use clap::{Command, CommandFactory, Parser, Subcommand}; |
5 | use clap_complete::{generate, Generator, Shell}; | 5 | use clap_complete::{generate, Generator, Shell}; |
6 | use config::Method; | ||
6 | use error::Error; | 7 | use error::Error; |
7 | use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; | 8 | use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; |
8 | use requests::{device, start::start}; | 9 | use requests::{device, start::start}; |
@@ -117,13 +118,21 @@ fn default_headers(config: &Config) -> Result<HeaderMap, Error> { | |||
117 | let mut map = HeaderMap::new(); | 118 | let mut map = HeaderMap::new(); |
118 | map.append("Accept-Content", HeaderValue::from_str("application/json")?); | 119 | map.append("Accept-Content", HeaderValue::from_str("application/json")?); |
119 | map.append("Content-Type", HeaderValue::from_str("application/json")?); | 120 | map.append("Content-Type", HeaderValue::from_str("application/json")?); |
120 | map.append("Authorization", HeaderValue::from_str(&config.apikey)?); | 121 | if config.auth.method != Method::None { |
122 | map.append("Authorization", HeaderValue::from_str(&config.auth.secret)?); | ||
123 | |||
124 | } | ||
121 | 125 | ||
122 | Ok(map) | 126 | Ok(map) |
123 | } | 127 | } |
124 | 128 | ||
125 | fn format_url(config: &Config, path: &str, protocol: &Protocols) -> String { | 129 | fn format_url(config: &Config, path: &str, protocol: &Protocols, id: Option<&str>) -> String { |
126 | format!("{}://{}/{}", protocol, config.server, path) | 130 | if let Some(id) = id { |
131 | format!("{}://{}/{}/{}", protocol, config.server, path, id) | ||
132 | |||
133 | } else { | ||
134 | format!("{}://{}/{}", protocol, config.server, path) | ||
135 | } | ||
127 | } | 136 | } |
128 | 137 | ||
129 | async fn check_success(res: Response) -> Result<String, Error> { | 138 | async fn check_success(res: Response) -> Result<String, Error> { |
diff --git a/src/requests/device.rs b/src/requests/device.rs index 7583406..2606579 100644 --- a/src/requests/device.rs +++ b/src/requests/device.rs | |||
@@ -7,7 +7,7 @@ pub async fn put( | |||
7 | broadcast_addr: String, | 7 | broadcast_addr: String, |
8 | ip: String, | 8 | ip: String, |
9 | ) -> Result<(), Error> { | 9 | ) -> Result<(), Error> { |
10 | let url = format_url(config, "device", &Protocols::Http); | 10 | let url = format_url(config, "device", &Protocols::Http, None); |
11 | println!("{url}"); | 11 | println!("{url}"); |
12 | let res = reqwest::Client::new() | 12 | let res = reqwest::Client::new() |
13 | .put(url) | 13 | .put(url) |
@@ -25,9 +25,8 @@ pub async fn put( | |||
25 | 25 | ||
26 | pub async fn get(config: &Config, id: String) -> Result<(), Error> { | 26 | pub async fn get(config: &Config, id: String) -> Result<(), Error> { |
27 | let res = reqwest::Client::new() | 27 | let res = reqwest::Client::new() |
28 | .get(format_url(config, "device", &Protocols::Http)) | 28 | .get(format_url(config, "device", &Protocols::Http, Some(&id))) |
29 | .headers(default_headers(config)?) | 29 | .headers(default_headers(config)?) |
30 | .body(format!(r#"{{"id": "{id}"}}"#)) | ||
31 | .send() | 30 | .send() |
32 | .await?; | 31 | .await?; |
33 | 32 | ||
@@ -44,7 +43,7 @@ pub async fn post( | |||
44 | ip: String, | 43 | ip: String, |
45 | ) -> Result<(), Error> { | 44 | ) -> Result<(), Error> { |
46 | let res = reqwest::Client::new() | 45 | let res = reqwest::Client::new() |
47 | .post(format_url(config, "device", &Protocols::Http)) | 46 | .post(format_url(config, "device", &Protocols::Http, None)) |
48 | .headers(default_headers(config)?) | 47 | .headers(default_headers(config)?) |
49 | .body(format!( | 48 | .body(format!( |
50 | r#"{{"id": "{id}", "mac": "{mac}", "broadcast_addr": "{broadcast_addr}", "ip": "{ip}"}}"#, | 49 | r#"{{"id": "{id}", "mac": "{mac}", "broadcast_addr": "{broadcast_addr}", "ip": "{ip}"}}"#, |
diff --git a/src/requests/start.rs b/src/requests/start.rs index 3afbe3a..1ec3ce8 100644 --- a/src/requests/start.rs +++ b/src/requests/start.rs | |||
@@ -17,12 +17,12 @@ pub async fn start(config: &Config, id: String, ping: bool) -> Result<(), Error> | |||
17 | let send_start = MultiProgress::new(); | 17 | let send_start = MultiProgress::new(); |
18 | let overview = add_pb(&send_start, OVERVIEW_STYLE, format!(") start {id}")); | 18 | let overview = add_pb(&send_start, OVERVIEW_STYLE, format!(") start {id}")); |
19 | 19 | ||
20 | let url = format_url(config, "start", &Protocols::Http); | 20 | let url = format_url(config, "start", &Protocols::Http, Some(&id)); |
21 | let connect = add_pb(&send_start, DEFAULT_STYLE, format!("connect to {url}")); | 21 | let connect = add_pb(&send_start, DEFAULT_STYLE, format!("connect to {url}")); |
22 | let res = reqwest::Client::new() | 22 | let res = reqwest::Client::new() |
23 | .post(url) | 23 | .post(url) |
24 | .headers(default_headers(config)?) | 24 | .headers(default_headers(config)?) |
25 | .body(format!(r#"{{"id": "{id}", "ping": {ping}}}"#)) | 25 | .body(format!(r#"{{"ping": {ping}}}"#)) |
26 | .send() | 26 | .send() |
27 | .await?; | 27 | .await?; |
28 | finish_pb(&connect, "connected, got response".to_string(), DONE_STYLE); | 28 | finish_pb(&connect, "connected, got response".to_string(), DONE_STYLE); |
@@ -71,8 +71,8 @@ async fn status_socket( | |||
71 | let ws_pb = add_pb(pb, DEFAULT_STYLE, "connect to websocket".to_string()); | 71 | let ws_pb = add_pb(pb, DEFAULT_STYLE, "connect to websocket".to_string()); |
72 | 72 | ||
73 | let request = Request::builder() | 73 | let request = Request::builder() |
74 | .uri(format_url(config, "status", &Protocols::Websocket)) | 74 | .uri(format_url(config, "status", &Protocols::Websocket, None)) |
75 | .header("Authorization", &config.apikey) | 75 | .header("Authorization", &config.auth.secret) |
76 | .header("sec-websocket-key", "") | 76 | .header("sec-websocket-key", "") |
77 | .header("host", &config.server) | 77 | .header("host", &config.server) |
78 | .header("upgrade", "websocket") | 78 | .header("upgrade", "websocket") |