diff --git a/.github/release-body.md b/.github/release-body.md index ecce178..fbae9de 100644 --- a/.github/release-body.md +++ b/.github/release-body.md @@ -1,5 +1,14 @@ -## Bug fix +## Release ☆ ~('▽^人) -Fixed error (failed to verify) when authenticating via Mojang +> [!CAUTION] +> **Update your Config.toml according to the example in the repository!** -**Full Changelog**: https://github.com/shiroyashik/sculptor/compare/v0.2.2...v0.2.3 \ No newline at end of file +What's added: +- Ability to change authentication providers; +- Display information about Sculptor in MOTD; +- Checking updates for Sculptor (displayed in CLI at startup) and for Figura (reported in mod UI); +- Saving log files in a separate directory; +- User bans and Minecraft blacklist parser; +- Implemented a special API for backend manipulation by third-party software. + +**Full Changelog**: https://github.com/shiroyashik/sculptor/compare/v0.2.3...v0.3.0 \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index d050139..30007b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1502,7 +1502,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sculptor" -version = "0.3.0-dev" +version = "0.3.0" dependencies = [ "anyhow", "axum", diff --git a/Cargo.toml b/Cargo.toml index 785662b..7b3c3d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sculptor" authors = ["Shiroyashik "] -version = "0.3.0-dev" +version = "0.3.0" edition = "2021" publish = false diff --git a/Config.example.toml b/Config.example.toml index 8799d34..9b85f10 100644 --- a/Config.example.toml +++ b/Config.example.toml @@ -70,10 +70,10 @@ special = [0,0,0,1,0,0] # 6 pride = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # 25 ## With advancedUsers you can set additional parameters -# [advancedUsers.your uuid here] +# [advancedUsers.your-uuid-here] # username = "Your_username_here" # banned = true -# special = [0,1,0,0,0,0] # and set badges what you want! :D -# pride = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] +# special = [0,1,0,0,0,0] # Set badges what you want! :D +# pride = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] # Check out note.txt for reference -## you can create an unlimited number of "advancedUsers" for any users. \ No newline at end of file +## you can create an unlimited number of "advancedUsers" for any players. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1fd1aa6..b6b92ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.78.0-alpine3.20 as builder +FROM rust:1.80.1-alpine3.20 as builder WORKDIR /build diff --git a/docker-compose.example.yml b/docker-compose.example.yml index bbe70e5..9d59b6c 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -16,6 +16,9 @@ services: - ./Config.toml:/app/Config.toml:ro - ./avatars:/app/avatars - ./logs:/app/logs + # You can specify the path to the server folder + # for Sculptor to use the ban list from it + # - ./minecraft-server:/app/mc environment: - RUST_LOG=info ## Recommended for use with reverse proxy. diff --git a/note.txt b/note.txt index 1bbdfe6..7e356b0 100644 --- a/note.txt +++ b/note.txt @@ -1,4 +1,4 @@ -Коды ошибок WebSocket из Figura +WebSocket close codes from Figura 1000 Normal Closure 1001 Going Away 1002 Protocol Error @@ -20,12 +20,12 @@ 4002 Too Many Connections Special badges -1 Разработчик -2 Член персонала официального сервера -3 Победитель контеста -4 Спасибо за поддержку -5 Переводчик -6 Художник текстур мода +1 Разработчик | Figura Developer! +2 Член персонала официального сервера | Official Figura Discord Staff! +3 Победитель контеста | Figura contest winner! GG! +4 Спасибо за поддержку | Thank you for supporting the Figura mod! +5 Переводчик | Figura mod Translator! +6 Художник текстур мода | Figura mod Texture Artist! Pride badges 1 Агендерный diff --git a/src/api/v1/mod.rs b/src/api/v1/mod.rs index 79ac318..3d061aa 100644 --- a/src/api/v1/mod.rs +++ b/src/api/v1/mod.rs @@ -12,6 +12,8 @@ pub fn router() -> Router { .route("/raw", post(http2ws::raw)) .route("/sub/raw", post(http2ws::sub_raw)) .route("/user/create", post(users::create_user)) + .route("/user/:uuid/ban", post(users::ban)) + .route("/user/:uuid/unban", post(users::unban)) .route("/avatar/:uuid", put(avatars::upload_avatar).layer(DefaultBodyLimit::disable())) .route("/avatar/:uuid", delete(avatars::delete_avatar)) } \ No newline at end of file diff --git a/src/api/v1/users.rs b/src/api/v1/users.rs index 5ebe62b..b020227 100644 --- a/src/api/v1/users.rs +++ b/src/api/v1/users.rs @@ -1,8 +1,9 @@ use axum::{ - extract::State, + extract::{Path, State}, Json }; -use tracing::debug; +use tracing::{debug, info}; +use uuid::Uuid; use crate::{auth::{Token, Userinfo}, ApiResult, AppState}; @@ -17,4 +18,30 @@ pub(super) async fn create_user( state.user_manager.insert_user(json.uuid, json); Ok("ok") +} + +pub(super) async fn ban( + Token(token): Token, + State(state): State, + Path(uuid): Path +) -> ApiResult<&'static str> { + state.config.read().await.clone().verify_token(&token)?; + + info!("Trying ban user: {uuid}"); + + state.user_manager.ban(&Userinfo { uuid: uuid, banned: true, ..Default::default() }); + Ok("ok") +} + +pub(super) async fn unban( + Token(token): Token, + State(state): State, + Path(uuid): Path +) -> ApiResult<&'static str> { + state.config.read().await.clone().verify_token(&token)?; + + info!("Trying unban user: {uuid}"); + + state.user_manager.unban(&uuid); + Ok("ok") } \ No newline at end of file