mirror of
https://github.com/shiroyashik/sculptor.git
synced 2025-12-06 13:01:12 +03:00
Pre-patch 0.2.1 limitations fixed
- Added DefaultBodyLimit control
This commit is contained in:
parent
17cb9bac77
commit
83533919f3
4 changed files with 15 additions and 15 deletions
|
|
@ -5,6 +5,12 @@ services:
|
||||||
# build: .
|
# build: .
|
||||||
image: ghcr.io/shiroyashik/sculptor:latest
|
image: ghcr.io/shiroyashik/sculptor:latest
|
||||||
container_name: sculptor
|
container_name: sculptor
|
||||||
|
healthcheck:
|
||||||
|
test: wget --no-verbose --tries=1 --spider http://sculptor:6665/health || exit 1
|
||||||
|
interval: 5s
|
||||||
|
timeout: 3s
|
||||||
|
retries: 3
|
||||||
|
start_period: 5s
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./Config.toml:/app/Config.toml:ro
|
- ./Config.toml:/app/Config.toml:ro
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ async fn verify(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
) -> String {
|
) -> String {
|
||||||
let server_id = query.id.clone();
|
let server_id = query.id.clone();
|
||||||
let username = state.pending.remove(&server_id).unwrap().1;
|
let username = state.pending.remove(&server_id).unwrap().1; // TODO: Add
|
||||||
if let Some((uuid, auth_system)) = has_joined(&server_id, &username).await.unwrap() {
|
if let Some((uuid, auth_system)) = has_joined(&server_id, &username).await.unwrap() {
|
||||||
info!("[Authorization] {username} logged in using {auth_system:?}");
|
info!("[Authorization] {username} logged in using {auth_system:?}");
|
||||||
let authenticated = state.authenticated;
|
let authenticated = state.authenticated;
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,6 @@ use serde_json::{json, Value};
|
||||||
|
|
||||||
use crate::AppState;
|
use crate::AppState;
|
||||||
|
|
||||||
/// Assert health of the server
|
|
||||||
/// If times out, the server is considered dead, so we can return basically anything
|
|
||||||
pub async fn health_check() -> String {
|
|
||||||
"ok".to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn version() -> Json<Value> {
|
pub async fn version() -> Json<Value> {
|
||||||
Json(json!({
|
Json(json!({
|
||||||
"release": "0.1.4",
|
"release": "0.1.4",
|
||||||
|
|
|
||||||
16
src/main.rs
16
src/main.rs
|
|
@ -1,8 +1,6 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use axum::{
|
use axum::{
|
||||||
middleware::from_extractor,
|
extract::DefaultBodyLimit, middleware::from_extractor, routing::{delete, get, post, put}, Router
|
||||||
routing::{delete, get, post, put},
|
|
||||||
Router,
|
|
||||||
};
|
};
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
@ -94,7 +92,8 @@ pub struct AppState {
|
||||||
config: Arc<Mutex<config::Config>>,
|
config: Arc<Mutex<config::Config>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const LOGGER_ENV: &str = "RUST_LOG";
|
const LOGGER_ENV: &'static str = "RUST_LOG";
|
||||||
|
const SCULPTOR_VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
|
@ -110,7 +109,7 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
let config_file = std::env::var("CONFIG_PATH").unwrap_or_else(|_| "Config.toml".into());
|
let config_file = std::env::var("CONFIG_PATH").unwrap_or_else(|_| "Config.toml".into());
|
||||||
|
|
||||||
info!("The Sculptor v{}", env!("CARGO_PKG_VERSION"));
|
info!("The Sculptor v{}", SCULPTOR_VERSION);
|
||||||
// Config
|
// Config
|
||||||
let config = Arc::new(Mutex::new(config::Config::parse(config_file.clone().into())));
|
let config = Arc::new(Mutex::new(config::Config::parse(config_file.clone().into())));
|
||||||
let listen = config.lock().await.listen.clone();
|
let listen = config.lock().await.listen.clone();
|
||||||
|
|
@ -139,6 +138,7 @@ async fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let max_body_size = state.config.clone().lock().await.limitations.max_avatar_size as usize;
|
||||||
let api = Router::new()
|
let api = Router::new()
|
||||||
.nest("//auth", api_auth::router())
|
.nest("//auth", api_auth::router())
|
||||||
.route("/limits", get(api_info::limits))
|
.route("/limits", get(api_info::limits))
|
||||||
|
|
@ -146,15 +146,15 @@ async fn main() -> Result<()> {
|
||||||
.route("/motd", get(api_info::motd))
|
.route("/motd", get(api_info::motd))
|
||||||
.route("/equip", post(api_profile::equip_avatar))
|
.route("/equip", post(api_profile::equip_avatar))
|
||||||
.route("/:uuid", get(api_profile::user_info))
|
.route("/:uuid", get(api_profile::user_info))
|
||||||
.route("/:uuid/avatar", get(api_profile::download_avatar))
|
.route("/:uuid/avatar", get(api_profile::download_avatar).layer(DefaultBodyLimit::max(max_body_size)))
|
||||||
.route("/avatar", put(api_profile::upload_avatar))
|
.route("/avatar", put(api_profile::upload_avatar).layer(DefaultBodyLimit::max(max_body_size)))
|
||||||
.route("/avatar", delete(api_profile::delete_avatar));
|
.route("/avatar", delete(api_profile::delete_avatar));
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.nest("/api", api)
|
.nest("/api", api)
|
||||||
.route("/api/", get(api_auth::status))
|
.route("/api/", get(api_auth::status))
|
||||||
.route("/ws", get(handler))
|
.route("/ws", get(handler))
|
||||||
.route("/health", get(api_info::health_check))
|
.route("/health", get(|| async { "ok" }))
|
||||||
.route_layer(from_extractor::<api_auth::Token>())
|
.route_layer(from_extractor::<api_auth::Token>())
|
||||||
.with_state(state)
|
.with_state(state)
|
||||||
.layer(TraceLayer::new_for_http().on_request(()));
|
.layer(TraceLayer::new_for_http().on_request(()));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue