diff options
-rw-r--r-- | Cargo.lock | 77 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | src/config.rs | 1 | ||||
-rw-r--r-- | src/main.rs | 27 |
5 files changed, 94 insertions, 18 deletions
@@ -27,6 +27,21 @@ dependencies = [ | |||
27 | ] | 27 | ] |
28 | 28 | ||
29 | [[package]] | 29 | [[package]] |
30 | name = "android-tzdata" | ||
31 | version = "0.1.1" | ||
32 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
33 | checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" | ||
34 | |||
35 | [[package]] | ||
36 | name = "android_system_properties" | ||
37 | version = "0.1.5" | ||
38 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
39 | checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" | ||
40 | dependencies = [ | ||
41 | "libc", | ||
42 | ] | ||
43 | |||
44 | [[package]] | ||
30 | name = "arbitrary" | 45 | name = "arbitrary" |
31 | version = "1.3.2" | 46 | version = "1.3.2" |
32 | source = "registry+https://github.com/rust-lang/crates.io-index" | 47 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -204,6 +219,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
204 | checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" | 219 | checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" |
205 | 220 | ||
206 | [[package]] | 221 | [[package]] |
222 | name = "chrono" | ||
223 | version = "0.4.38" | ||
224 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
225 | checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" | ||
226 | dependencies = [ | ||
227 | "android-tzdata", | ||
228 | "iana-time-zone", | ||
229 | "num-traits", | ||
230 | "windows-targets 0.52.5", | ||
231 | ] | ||
232 | |||
233 | [[package]] | ||
207 | name = "color-eyre" | 234 | name = "color-eyre" |
208 | version = "0.6.3" | 235 | version = "0.6.3" |
209 | source = "registry+https://github.com/rust-lang/crates.io-index" | 236 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -280,6 +307,12 @@ dependencies = [ | |||
280 | ] | 307 | ] |
281 | 308 | ||
282 | [[package]] | 309 | [[package]] |
310 | name = "core-foundation-sys" | ||
311 | version = "0.8.6" | ||
312 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
313 | checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" | ||
314 | |||
315 | [[package]] | ||
283 | name = "cpufeatures" | 316 | name = "cpufeatures" |
284 | version = "0.2.12" | 317 | version = "0.2.12" |
285 | source = "registry+https://github.com/rust-lang/crates.io-index" | 318 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -655,6 +688,29 @@ dependencies = [ | |||
655 | ] | 688 | ] |
656 | 689 | ||
657 | [[package]] | 690 | [[package]] |
691 | name = "iana-time-zone" | ||
692 | version = "0.1.60" | ||
693 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
694 | checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" | ||
695 | dependencies = [ | ||
696 | "android_system_properties", | ||
697 | "core-foundation-sys", | ||
698 | "iana-time-zone-haiku", | ||
699 | "js-sys", | ||
700 | "wasm-bindgen", | ||
701 | "windows-core", | ||
702 | ] | ||
703 | |||
704 | [[package]] | ||
705 | name = "iana-time-zone-haiku" | ||
706 | version = "0.1.2" | ||
707 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
708 | checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" | ||
709 | dependencies = [ | ||
710 | "cc", | ||
711 | ] | ||
712 | |||
713 | [[package]] | ||
658 | name = "icu_collections" | 714 | name = "icu_collections" |
659 | version = "1.5.0" | 715 | version = "1.5.0" |
660 | source = "registry+https://github.com/rust-lang/crates.io-index" | 716 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1011,6 +1067,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1011 | checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" | 1067 | checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" |
1012 | 1068 | ||
1013 | [[package]] | 1069 | [[package]] |
1070 | name = "num-traits" | ||
1071 | version = "0.2.19" | ||
1072 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1073 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" | ||
1074 | dependencies = [ | ||
1075 | "autocfg", | ||
1076 | ] | ||
1077 | |||
1078 | [[package]] | ||
1014 | name = "num_cpus" | 1079 | name = "num_cpus" |
1015 | version = "1.16.0" | 1080 | version = "1.16.0" |
1016 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1081 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -2048,6 +2113,7 @@ version = "0.3.18" | |||
2048 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2113 | source = "registry+https://github.com/rust-lang/crates.io-index" |
2049 | checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" | 2114 | checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" |
2050 | dependencies = [ | 2115 | dependencies = [ |
2116 | "chrono", | ||
2051 | "matchers", | 2117 | "matchers", |
2052 | "nu-ansi-term", | 2118 | "nu-ansi-term", |
2053 | "once_cell", | 2119 | "once_cell", |
@@ -2322,7 +2388,7 @@ dependencies = [ | |||
2322 | 2388 | ||
2323 | [[package]] | 2389 | [[package]] |
2324 | name = "webol" | 2390 | name = "webol" |
2325 | version = "0.4.1" | 2391 | version = "0.4.2" |
2326 | dependencies = [ | 2392 | dependencies = [ |
2327 | "axum", | 2393 | "axum", |
2328 | "axum-macros", | 2394 | "axum-macros", |
@@ -2386,6 +2452,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2386 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" | 2452 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" |
2387 | 2453 | ||
2388 | [[package]] | 2454 | [[package]] |
2455 | name = "windows-core" | ||
2456 | version = "0.52.0" | ||
2457 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
2458 | checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" | ||
2459 | dependencies = [ | ||
2460 | "windows-targets 0.52.5", | ||
2461 | ] | ||
2462 | |||
2463 | [[package]] | ||
2389 | name = "windows-sys" | 2464 | name = "windows-sys" |
2390 | version = "0.48.0" | 2465 | version = "0.48.0" |
2391 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2466 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1,6 +1,6 @@ | |||
1 | [package] | 1 | [package] |
2 | name = "webol" | 2 | name = "webol" |
3 | version = "0.4.1" | 3 | version = "0.4.2" |
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 |
@@ -9,7 +9,7 @@ edition = "2021" | |||
9 | axum = { version = "0.7", features = ["ws"] } | 9 | axum = { version = "0.7", features = ["ws"] } |
10 | tokio = { version = "1.38", features = ["macros", "rt-multi-thread"] } | 10 | tokio = { version = "1.38", features = ["macros", "rt-multi-thread"] } |
11 | tracing = "0.1" | 11 | tracing = "0.1" |
12 | tracing-subscriber = { version = "0.3", features = ["env-filter", "local-time", "time"] } | 12 | tracing-subscriber = { version = "0.3", features = ["env-filter", "local-time", "chrono"] } |
13 | time = { version = "0.3", features = ["macros"] } | 13 | time = { version = "0.3", features = ["macros"] } |
14 | serde = { version = "1.0", features = ["derive"] } | 14 | serde = { version = "1.0", features = ["derive"] } |
15 | serde_json = "1.0" | 15 | serde_json = "1.0" |
@@ -5,7 +5,6 @@ Default `config.toml`: | |||
5 | serveraddr = "0.0.0.0:7229" # String | 5 | serveraddr = "0.0.0.0:7229" # String |
6 | pingtimeout = 10 # i64 | 6 | pingtimeout = 10 # i64 |
7 | pingthreshold = 1 # u64 | 7 | pingthreshold = 1 # u64 |
8 | timeoffset = 0 # i8 | ||
9 | 8 | ||
10 | [auth] | 9 | [auth] |
11 | method = "none" # "none"|"key" | 10 | method = "none" # "none"|"key" |
@@ -16,7 +15,7 @@ minimal `docker-compose.yaml`: | |||
16 | ```yaml | 15 | ```yaml |
17 | services: | 16 | services: |
18 | webol: | 17 | webol: |
19 | image: ghcr.io/fxqnlr/webol:0.4.1 | 18 | image: ghcr.io/fxqnlr/webol:latest |
20 | container_name: webol | 19 | container_name: webol |
21 | restart: unless-stopped | 20 | restart: unless-stopped |
22 | volumes: | 21 | volumes: |
diff --git a/src/config.rs b/src/config.rs index 7c91c08..18c3bab 100644 --- a/src/config.rs +++ b/src/config.rs | |||
@@ -8,7 +8,6 @@ pub struct Config { | |||
8 | pub serveraddr: String, | 8 | pub serveraddr: String, |
9 | pub pingtimeout: i64, | 9 | pub pingtimeout: i64, |
10 | pub pingthreshold: u64, | 10 | pub pingthreshold: u64, |
11 | pub timeoffset: i8, | ||
12 | pub auth: Auth, | 11 | pub auth: Auth, |
13 | } | 12 | } |
14 | 13 | ||
diff --git a/src/main.rs b/src/main.rs index 204c318..b550dd8 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -1,5 +1,8 @@ | |||
1 | use crate::{ | 1 | use crate::{ |
2 | config::Config, routes::{device, start, status}, services::ping::{BroadcastCommand, StatusMap}, storage::Device | 2 | config::Config, |
3 | routes::{device, start, status}, | ||
4 | services::ping::{BroadcastCommand, StatusMap}, | ||
5 | storage::Device, | ||
3 | }; | 6 | }; |
4 | use axum::{ | 7 | use axum::{ |
5 | middleware::from_fn_with_state, | 8 | middleware::from_fn_with_state, |
@@ -8,14 +11,9 @@ use axum::{ | |||
8 | }; | 11 | }; |
9 | use dashmap::DashMap; | 12 | use dashmap::DashMap; |
10 | use std::{env, sync::Arc}; | 13 | use std::{env, sync::Arc}; |
11 | use time::UtcOffset; | ||
12 | use tokio::sync::broadcast::{channel, Sender}; | 14 | use tokio::sync::broadcast::{channel, Sender}; |
13 | use tracing::{info, level_filters::LevelFilter, trace}; | 15 | use tracing::{info, level_filters::LevelFilter, trace}; |
14 | use tracing_subscriber::{ | 16 | use tracing_subscriber::{fmt, prelude::*, EnvFilter}; |
15 | fmt::{self, time::OffsetTime}, | ||
16 | prelude::*, | ||
17 | EnvFilter, | ||
18 | }; | ||
19 | use utoipa::{ | 17 | use utoipa::{ |
20 | openapi::security::{ApiKey, ApiKeyValue, SecurityScheme}, | 18 | openapi::security::{ApiKey, ApiKeyValue, SecurityScheme}, |
21 | Modify, OpenApi, | 19 | Modify, OpenApi, |
@@ -24,10 +22,10 @@ use utoipa_swagger_ui::SwaggerUi; | |||
24 | 22 | ||
25 | mod auth; | 23 | mod auth; |
26 | mod config; | 24 | mod config; |
27 | mod storage; | ||
28 | mod error; | 25 | mod error; |
29 | mod routes; | 26 | mod routes; |
30 | mod services; | 27 | mod services; |
28 | mod storage; | ||
31 | mod wol; | 29 | mod wol; |
32 | 30 | ||
33 | #[derive(OpenApi)] | 31 | #[derive(OpenApi)] |
@@ -73,15 +71,20 @@ async fn main() -> color_eyre::eyre::Result<()> { | |||
73 | 71 | ||
74 | let config = Config::load()?; | 72 | let config = Config::load()?; |
75 | 73 | ||
76 | let time_format = | 74 | let writer_time = |
77 | time::macros::format_description!("[year]-[month]-[day] [hour]:[minute]:[second]"); | 75 | tracing_subscriber::fmt::time::ChronoLocal::new("%Y-%m-%d %H:%M:%S%.6f%:z".to_string()); |
78 | let time = OffsetTime::new(UtcOffset::from_hms(config.timeoffset, 0, 0)?, time_format); | 76 | let time = tracing_subscriber::fmt::time::ChronoLocal::new("%Y-%m-%d %H:%M:%S%:z".to_string()); |
79 | 77 | ||
80 | let file_appender = tracing_appender::rolling::daily("logs", "webol.log"); | 78 | let file_appender = tracing_appender::rolling::daily("logs", "webol.log"); |
81 | let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender); | 79 | let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender); |
82 | 80 | ||
83 | tracing_subscriber::registry() | 81 | tracing_subscriber::registry() |
84 | .with(fmt::layer().with_writer(non_blocking).with_ansi(false)) | 82 | .with( |
83 | fmt::layer() | ||
84 | .with_timer(writer_time) | ||
85 | .with_writer(non_blocking) | ||
86 | .with_ansi(false), | ||
87 | ) | ||
85 | .with(fmt::layer().with_timer(time)) | 88 | .with(fmt::layer().with_timer(time)) |
86 | .with( | 89 | .with( |
87 | EnvFilter::builder() | 90 | EnvFilter::builder() |