mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'xMAC94x/update_hyper' into 'master'
Update hyper/axum and dependent crates. See merge request veloren/veloren!4491
This commit is contained in:
commit
0bb07662e2
219
Cargo.lock
generated
219
Cargo.lock
generated
@ -371,7 +371,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "auth-common"
|
||||
version = "0.1.0"
|
||||
source = "git+https://gitlab.com/veloren/auth.git?rev=abb1a705827984e11706d7bb97fb7a459e1e6533#abb1a705827984e11706d7bb97fb7a459e1e6533"
|
||||
source = "git+https://gitlab.com/veloren/auth.git?rev=ae0e16783a9f9041951296885f082308e155db79#ae0e16783a9f9041951296885f082308e155db79"
|
||||
dependencies = [
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
@ -381,14 +381,17 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "authc"
|
||||
version = "1.0.0"
|
||||
source = "git+https://gitlab.com/veloren/auth.git?rev=abb1a705827984e11706d7bb97fb7a459e1e6533#abb1a705827984e11706d7bb97fb7a459e1e6533"
|
||||
source = "git+https://gitlab.com/veloren/auth.git?rev=ae0e16783a9f9041951296885f082308e155db79#ae0e16783a9f9041951296885f082308e155db79"
|
||||
dependencies = [
|
||||
"auth-common",
|
||||
"bytes",
|
||||
"fxhash",
|
||||
"hex",
|
||||
"http",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-rustls",
|
||||
"hyper-util",
|
||||
"rust-argon2",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@ -403,18 +406,19 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
||||
|
||||
[[package]]
|
||||
name = "axum"
|
||||
version = "0.6.20"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
|
||||
checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum-core",
|
||||
"bitflags 1.3.2",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-util",
|
||||
"itoa",
|
||||
"matchit",
|
||||
"memchr",
|
||||
@ -426,28 +430,33 @@ dependencies = [
|
||||
"serde_json",
|
||||
"serde_path_to_error",
|
||||
"serde_urlencoded",
|
||||
"sync_wrapper",
|
||||
"sync_wrapper 1.0.1",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "axum-core"
|
||||
version = "0.3.4"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c"
|
||||
checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"mime",
|
||||
"pin-project-lite",
|
||||
"rustversion",
|
||||
"sync_wrapper 0.1.2",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2758,25 +2767,6 @@ dependencies = [
|
||||
"svg_fmt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"http",
|
||||
"indexmap",
|
||||
"slab",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "2.4.1"
|
||||
@ -2966,9 +2956,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.2.12"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1"
|
||||
checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
@ -2977,12 +2967,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "http-body"
|
||||
version = "0.4.6"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
|
||||
checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body-util"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"http",
|
||||
"http-body",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
@ -3006,42 +3008,60 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.28"
|
||||
version = "1.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80"
|
||||
checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"httparse",
|
||||
"httpdate",
|
||||
"itoa",
|
||||
"pin-project-lite",
|
||||
"socket2",
|
||||
"smallvec",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
"want",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-rustls"
|
||||
version = "0.24.2"
|
||||
version = "0.27.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590"
|
||||
checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"http",
|
||||
"hyper",
|
||||
"log",
|
||||
"rustls 0.21.12",
|
||||
"rustls-native-certs 0.6.3",
|
||||
"hyper-util",
|
||||
"rustls",
|
||||
"rustls-native-certs",
|
||||
"rustls-pki-types",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"pin-project-lite",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4934,11 +4954,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "prometheus-hyper"
|
||||
version = "0.1.5"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18fc98d5705a20b11f8b240c0857167b79852ba469f9faec6df0027e576e676e"
|
||||
checksum = "4599cd06b4c85ba573bf2edf4e5ca5c3f32505ead7fb1f0c7d9a4b90195e1ab1"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-util",
|
||||
"prometheus",
|
||||
"tokio",
|
||||
"tracing",
|
||||
@ -5011,7 +5034,7 @@ dependencies = [
|
||||
"quinn-proto",
|
||||
"quinn-udp",
|
||||
"rustc-hash",
|
||||
"rustls 0.23.8",
|
||||
"rustls",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
@ -5027,7 +5050,7 @@ dependencies = [
|
||||
"rand 0.8.5",
|
||||
"ring",
|
||||
"rustc-hash",
|
||||
"rustls 0.23.8",
|
||||
"rustls",
|
||||
"rustls-platform-verifier",
|
||||
"slab",
|
||||
"thiserror",
|
||||
@ -5546,42 +5569,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.21.12"
|
||||
version = "0.23.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e"
|
||||
dependencies = [
|
||||
"log",
|
||||
"ring",
|
||||
"rustls-webpki 0.101.7",
|
||||
"sct",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.23.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79adb16721f56eb2d843e67676896a61ce7a0fa622dc18d3e372477a029d2740"
|
||||
checksum = "a218f0f6d05669de4eabfb24f31ce802035c952429d037507b4a4a39f0e60c5b"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
"rustls-webpki 0.102.4",
|
||||
"rustls-webpki",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-native-certs"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00"
|
||||
dependencies = [
|
||||
"openssl-probe",
|
||||
"rustls-pemfile 1.0.4",
|
||||
"schannel",
|
||||
"security-framework",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-native-certs"
|
||||
version = "0.7.0"
|
||||
@ -5589,21 +5588,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792"
|
||||
dependencies = [
|
||||
"openssl-probe",
|
||||
"rustls-pemfile 2.1.2",
|
||||
"rustls-pemfile",
|
||||
"rustls-pki-types",
|
||||
"schannel",
|
||||
"security-framework",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pemfile"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pemfile"
|
||||
version = "2.1.2"
|
||||
@ -5631,10 +5621,10 @@ dependencies = [
|
||||
"jni 0.19.0",
|
||||
"log",
|
||||
"once_cell",
|
||||
"rustls 0.23.8",
|
||||
"rustls-native-certs 0.7.0",
|
||||
"rustls",
|
||||
"rustls-native-certs",
|
||||
"rustls-platform-verifier-android",
|
||||
"rustls-webpki 0.102.4",
|
||||
"rustls-webpki",
|
||||
"security-framework",
|
||||
"security-framework-sys",
|
||||
"webpki-roots",
|
||||
@ -5647,16 +5637,6 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84e217e7fdc8466b5b35d30f8c0a30febd29173df4a3a0c2115d306b9c4117ad"
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.101.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.102.4"
|
||||
@ -5768,16 +5748,6 @@ version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "sct"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sctk-adwaita"
|
||||
version = "0.5.4"
|
||||
@ -6442,6 +6412,12 @@ version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
|
||||
|
||||
[[package]]
|
||||
name = "sync_wrapper"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
|
||||
|
||||
[[package]]
|
||||
name = "system-interface"
|
||||
version = "0.27.2"
|
||||
@ -6662,11 +6638,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio-rustls"
|
||||
version = "0.24.1"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
|
||||
checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4"
|
||||
dependencies = [
|
||||
"rustls 0.21.12",
|
||||
"rustls",
|
||||
"rustls-pki-types",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
@ -6681,19 +6658,6 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.11"
|
||||
@ -7118,7 +7082,7 @@ dependencies = [
|
||||
"quinn",
|
||||
"rayon",
|
||||
"ron",
|
||||
"rustls 0.23.8",
|
||||
"rustls",
|
||||
"rustyline",
|
||||
"serde",
|
||||
"specs",
|
||||
@ -7352,7 +7316,7 @@ dependencies = [
|
||||
"quinn",
|
||||
"rand 0.8.5",
|
||||
"rcgen",
|
||||
"rustls 0.23.8",
|
||||
"rustls",
|
||||
"serde",
|
||||
"shellexpand 3.1.0",
|
||||
"socket2",
|
||||
@ -7442,8 +7406,8 @@ dependencies = [
|
||||
"refinery",
|
||||
"ron",
|
||||
"rusqlite",
|
||||
"rustls 0.23.8",
|
||||
"rustls-pemfile 2.1.2",
|
||||
"rustls",
|
||||
"rustls-pemfile",
|
||||
"schnellru",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@ -7491,6 +7455,7 @@ dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
"crossterm",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"lazy_static",
|
||||
"mimalloc",
|
||||
|
@ -138,7 +138,7 @@ tokio = { version = "1.28", default-features = false, features = ["rt"] }
|
||||
tracing = { version = "0.1" }
|
||||
futures-util = { version = "0.3.7", default-features = false }
|
||||
prometheus = { version = "0.13", default-features = false }
|
||||
prometheus-hyper = "0.1.5"
|
||||
prometheus-hyper = "0.2"
|
||||
|
||||
strum = { version = "0.24", features = ["derive"] }
|
||||
enum-map = { version = "2.4" }
|
||||
|
@ -54,7 +54,7 @@ specs = { workspace = true, features = [
|
||||
] }
|
||||
vek = { workspace = true }
|
||||
hashbrown = { workspace = true }
|
||||
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "abb1a705827984e11706d7bb97fb7a459e1e6533" } # xMAC94x/current_master_till_refactored branch
|
||||
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "ae0e16783a9f9041951296885f082308e155db79" } # xMAC94x/current_master_till_refactored branch
|
||||
|
||||
#TODO: put bot in a different crate
|
||||
#bot only
|
||||
|
@ -27,7 +27,9 @@ hot-agent = ["server/hot-agent", "agent"]
|
||||
hot-site = ["server/hot-site", "world"]
|
||||
|
||||
[dependencies]
|
||||
server = { package = "veloren-server", path = "../server", default-features = false, features = ["simd"] }
|
||||
server = { package = "veloren-server", path = "../server", default-features = false, features = [
|
||||
"simd",
|
||||
] }
|
||||
agent = { package = "veloren-server-agent", path = "../server/agent", optional = true }
|
||||
common = { package = "veloren-common", path = "../common" }
|
||||
common-base = { package = "veloren-common-base", path = "../common/base" }
|
||||
@ -52,8 +54,9 @@ rand = { workspace = true }
|
||||
specs = { workspace = true }
|
||||
|
||||
#HTTP
|
||||
axum = { version = "0.6.20" }
|
||||
hyper = "0.14.26"
|
||||
axum = { version = "0.7" }
|
||||
hyper = "1"
|
||||
http-body-util = "0.1"
|
||||
prometheus = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
use axum::{
|
||||
extract::{ConnectInfo, Query, State},
|
||||
extract::{ConnectInfo, Query, Request, State},
|
||||
middleware::Next,
|
||||
response::{IntoResponse, Response},
|
||||
routing::get,
|
||||
Json, Router,
|
||||
};
|
||||
use chrono::DateTime;
|
||||
use hyper::{Request, StatusCode};
|
||||
use hyper::StatusCode;
|
||||
use serde::{Deserialize, Deserializer};
|
||||
use server::chat::ChatCache;
|
||||
use std::{
|
||||
@ -28,10 +28,10 @@ struct IpAddresses {
|
||||
users: Arc<Mutex<HashSet<IpAddr>>>,
|
||||
}
|
||||
|
||||
async fn validate_secret<B>(
|
||||
async fn validate_secret(
|
||||
State(token): State<ChatToken>,
|
||||
req: Request<B>,
|
||||
next: Next<B>,
|
||||
req: Request,
|
||||
next: Next,
|
||||
) -> Result<Response, StatusCode> {
|
||||
// check if this endpoint is disabled
|
||||
let secret_token = token.secret_token.ok_or(StatusCode::METHOD_NOT_ALLOWED)?;
|
||||
@ -50,11 +50,11 @@ async fn validate_secret<B>(
|
||||
}
|
||||
|
||||
/// Logs each new IP address that accesses this API authenticated
|
||||
async fn log_users<B>(
|
||||
async fn log_users(
|
||||
State(ip_addresses): State<IpAddresses>,
|
||||
ConnectInfo(addr): ConnectInfo<SocketAddr>,
|
||||
req: Request<B>,
|
||||
next: Next<B>,
|
||||
req: Request,
|
||||
next: Next,
|
||||
) -> Result<Response, StatusCode> {
|
||||
let mut ip_addresses = ip_addresses.users.lock().await;
|
||||
let ip_addr = addr.ip();
|
||||
|
@ -1,10 +1,11 @@
|
||||
use crate::web::ui::api::UiRequestSender;
|
||||
use axum::{extract::State, response::IntoResponse, routing::get, Router};
|
||||
use axum::{body::Bytes, extract::State, response::IntoResponse, routing::get, Router};
|
||||
use core::{future::Future, ops::Deref};
|
||||
use hyper::{body::Body, header, http, StatusCode};
|
||||
use http_body_util::Full;
|
||||
use hyper::{header, http, StatusCode};
|
||||
use prometheus::{Registry, TextEncoder};
|
||||
use server::chat::ChatCache;
|
||||
use std::net::SocketAddr;
|
||||
use std::{future::IntoFuture, net::SocketAddr};
|
||||
|
||||
mod chat;
|
||||
mod ui;
|
||||
@ -39,11 +40,20 @@ where
|
||||
|
||||
// run it
|
||||
let addr = addr.into();
|
||||
let server =
|
||||
axum::Server::bind(&addr).serve(app.into_make_service_with_connect_info::<SocketAddr>());
|
||||
let server = server.with_graceful_shutdown(shutdown);
|
||||
let listener = tokio::net::TcpListener::bind(addr)
|
||||
.await
|
||||
.expect("can't bind to web-port.");
|
||||
tracing::info!("listening on {}", addr);
|
||||
match server.await {
|
||||
let server = axum::serve(
|
||||
listener,
|
||||
app.into_make_service_with_connect_info::<SocketAddr>(),
|
||||
)
|
||||
.into_future();
|
||||
let res = tokio::select! {
|
||||
res = server => res,
|
||||
_ = shutdown => Ok(()),
|
||||
};
|
||||
match res {
|
||||
Ok(_) => tracing::debug!("webserver shutdown successful"),
|
||||
Err(e) => tracing::error!(?e, "webserver shutdown error"),
|
||||
}
|
||||
@ -61,10 +71,12 @@ async fn metrics(State(registry): State<Registry>) -> Result<impl IntoResponse,
|
||||
.encode(&mf, &mut buffer)
|
||||
.expect("write to vec cannot fail");
|
||||
|
||||
let bytes: Bytes = buffer.into();
|
||||
|
||||
match http::Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.header(header::CONTENT_TYPE, "text/plain; charset=utf-8")
|
||||
.body(Body::from(buffer))
|
||||
.body(Full::new(bytes))
|
||||
{
|
||||
Err(e) => {
|
||||
tracing::warn!(?e, "could not export metrics to HTTP format");
|
||||
|
@ -1,13 +1,13 @@
|
||||
use crate::cli::{Message, MessageReturn};
|
||||
use axum::{
|
||||
extract::{ConnectInfo, State},
|
||||
extract::{ConnectInfo, Request, State},
|
||||
http::header::COOKIE,
|
||||
middleware::Next,
|
||||
response::{IntoResponse, Response},
|
||||
routing::{get, post},
|
||||
Json, Router,
|
||||
};
|
||||
use hyper::{Request, StatusCode};
|
||||
use hyper::StatusCode;
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
@ -30,10 +30,10 @@ struct IpAddresses {
|
||||
users: Arc<Mutex<HashSet<IpAddr>>>,
|
||||
}
|
||||
|
||||
async fn validate_secret<B>(
|
||||
async fn validate_secret(
|
||||
State(token): State<UiApiToken>,
|
||||
req: Request<B>,
|
||||
next: Next<B>,
|
||||
req: Request,
|
||||
next: Next,
|
||||
) -> Result<Response, StatusCode> {
|
||||
let session_cookie = req.headers().get(COOKIE).ok_or(StatusCode::UNAUTHORIZED)?;
|
||||
|
||||
@ -48,11 +48,11 @@ async fn validate_secret<B>(
|
||||
}
|
||||
|
||||
/// Logs each new IP address that accesses this API authenticated
|
||||
async fn log_users<B>(
|
||||
async fn log_users(
|
||||
State(ip_addresses): State<IpAddresses>,
|
||||
ConnectInfo(addr): ConnectInfo<SocketAddr>,
|
||||
req: Request<B>,
|
||||
next: Next<B>,
|
||||
req: Request,
|
||||
next: Next,
|
||||
) -> Result<Response, StatusCode> {
|
||||
let mut ip_addresses = ip_addresses.users.lock().await;
|
||||
let ip_addr = addr.ip();
|
||||
|
@ -66,7 +66,7 @@ rayon = { workspace = true }
|
||||
crossbeam-channel = { workspace = true }
|
||||
prometheus = { workspace = true }
|
||||
portpicker = { git = "https://github.com/xMAC94x/portpicker-rs", rev = "df6b37872f3586ac3b21d08b56c8ec7cd92fb172" }
|
||||
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "abb1a705827984e11706d7bb97fb7a459e1e6533" } # xMAC94x/current_master_till_refactored branch
|
||||
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "ae0e16783a9f9041951296885f082308e155db79" } # xMAC94x/current_master_till_refactored branch
|
||||
enum-map = { workspace = true }
|
||||
noise = { version = "0.7", default-features = false }
|
||||
censor = "0.3"
|
||||
|
@ -2,7 +2,7 @@ use common::{comp::Player, util::GIT_DATE_TIMESTAMP};
|
||||
use common_ecs::{Origin, Phase, System};
|
||||
use lazy_static::lazy_static;
|
||||
use specs::{Read, ReadStorage};
|
||||
use tracing::error;
|
||||
use tracing::warn;
|
||||
use veloren_query_server::proto::ServerInfo;
|
||||
|
||||
use crate::{Settings, Tick};
|
||||
@ -34,16 +34,15 @@ impl<'a> System<'a> for Sys {
|
||||
if let Some(sender) = sender.as_ref()
|
||||
&& tick.0 % INFO_SEND_INTERVAL == 0
|
||||
{
|
||||
tracing::trace!("Updating server info");
|
||||
let count = players.count().try_into().unwrap_or(u16::MAX);
|
||||
if let Err(error) = sender.send(ServerInfo {
|
||||
if let Err(e) = sender.send(ServerInfo {
|
||||
git_hash: *GIT_HASH,
|
||||
git_timestamp: *GIT_DATE_TIMESTAMP,
|
||||
players_count: count,
|
||||
player_cap: settings.max_players,
|
||||
battlemode: settings.gameplay.battle_mode.into(),
|
||||
}) {
|
||||
error!(?error, "Failed to send server info to the query server");
|
||||
warn!(?e, "Failed to send server info to the query server");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -617,6 +617,16 @@ fn get_client_msg_error(
|
||||
localization.get_msg("main-login-failed_sending_request"),
|
||||
e
|
||||
),
|
||||
client::AuthClientError::ResponseError(e) => format!(
|
||||
"{}: {}",
|
||||
localization.get_msg("main-login-failed_sending_request"),
|
||||
e
|
||||
),
|
||||
client::AuthClientError::CertificateLoad(e) => format!(
|
||||
"{}: {}",
|
||||
localization.get_msg("main-login-failed_sending_request"),
|
||||
e
|
||||
),
|
||||
client::AuthClientError::JsonError(e) => format!(
|
||||
"{}: {}",
|
||||
localization.get_msg("main-login-failed_sending_request"),
|
||||
|
Loading…
Reference in New Issue
Block a user