From 5af81a03eccf051d5b9cc3261521ba2173858543 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 13:14:10 +0300 Subject: [PATCH 01/87] Reformat --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 85aa71662..db85e66fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,7 @@ jobs: package: name: Package builds runs-on: ubuntu-latest - needs: ['build'] + needs: build steps: - name: Combine builds From 155bc303835dbaba9eb69f493e19c3a0d4486cfe Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 13:21:20 +0300 Subject: [PATCH 02/87] Update server CI --- .github/workflows/server.yml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index 1c4201bba..891cb8c41 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -11,38 +11,37 @@ jobs: strategy: matrix: include: - - os: ubuntu-latest + - name: Linux + os: ubuntu-latest target: x86_64-unknown-linux-gnu - name: Linux x64 bin-suffix: "-x64" - - os: ubuntu-latest + - name: Linux Arm64 + os: ubuntu-latest target: aarch64-unknown-linux-gnu - name: Linux arm64 bin-suffix: "-arm64" - - os: windows-latest + - name: Windows + os: windows-latest target: x86_64-pc-windows-msvc - name: Windows x64 bin-suffix: ".exe" steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v4 - - name: Install rust - uses: actions-rs/toolchain@v1 + - name: Setup Rust + uses: dtolnay/rust-toolchain@nightly with: toolchain: nightly target: ${{ matrix.target }} override: true - - name: Add rust target + - name: Add Rust target if: matrix.target != 'aarch64-unknown-linux-gnu' run: rustup target add ${{ matrix.target }} shell: bash - # install cross for arm target - name: Install cross if: matrix.target == 'aarch64-unknown-linux-gnu' run: | @@ -87,8 +86,7 @@ jobs: shell: bash - name: Create artifacts folder - run: | - mkdir -p server/artifacts + run: mkdir -p server/artifacts shell: bash - name: Copy artifacts (Windows) From c5a7c8939892197555895eb404a3121ea68410bc Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 13:26:12 +0300 Subject: [PATCH 03/87] Remove since not needed (gives error if exists) --- server/shared/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/server/shared/src/lib.rs b/server/shared/src/lib.rs index 62a057c0b..8eb120a9c 100644 --- a/server/shared/src/lib.rs +++ b/server/shared/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(const_option)] #![allow( clippy::must_use_candidate, clippy::module_name_repetitions, From b87d4a893a212e4f52161d6369e849a7e24ec37a Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 13:27:06 +0300 Subject: [PATCH 04/87] Remove unused import --- server/central/build.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/central/build.rs b/server/central/build.rs index c8d152ab0..25c393629 100644 --- a/server/central/build.rs +++ b/server/central/build.rs @@ -1,5 +1,3 @@ -use std::env; - fn main() { // trigger recompilation when a new migration is added println!("cargo:rerun-if-changed=migrations"); From 5f889fa96d9eec30228244daf1ada34b16175643 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 13:29:50 +0300 Subject: [PATCH 05/87] Remove --- .github/workflows/server.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index 891cb8c41..347b59747 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -35,7 +35,6 @@ jobs: with: toolchain: nightly target: ${{ matrix.target }} - override: true - name: Add Rust target if: matrix.target != 'aarch64-unknown-linux-gnu' From 9cf7c9238e9da995769b7f84cfd5e87a2241ef68 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 13:37:17 +0300 Subject: [PATCH 06/87] WIP --- .github/dependabot.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..6505cf071 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,34 @@ +version: 2 +updates: + - package-ecosystem: "cargo" + directory: "/server/central" + schedule: + interval: "weekly" + - package-ecosystem: "cargo" + directory: "/server/derive" + schedule: + interval: "weekly" + - package-ecosystem: "cargo" + directory: "/server/esp" + schedule: + interval: "weekly" + - package-ecosystem: "cargo" + directory: "/server/game" + schedule: + interval: "weekly" + - package-ecosystem: "cargo" + directory: "/server/observer-shared" + schedule: + interval: "weekly" + - package-ecosystem: "cargo" + directory: "/server/observer" + schedule: + interval: "weekly" + - package-ecosystem: "cargo" + directory: "/server/shared" + schedule: + interval: "weekly" + - package-ecosystem: "cargo" + directory: "/server" + schedule: + interval: "weekly" From c6318f2102d8919f30eff0285b8861e3436c4b8e Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 13:37:36 +0300 Subject: [PATCH 07/87] Done --- .github/dependabot.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6505cf071..c95d49663 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,32 +3,32 @@ updates: - package-ecosystem: "cargo" directory: "/server/central" schedule: - interval: "weekly" + interval: "daily" - package-ecosystem: "cargo" directory: "/server/derive" schedule: - interval: "weekly" + interval: "daily" - package-ecosystem: "cargo" directory: "/server/esp" schedule: - interval: "weekly" + interval: "daily" - package-ecosystem: "cargo" directory: "/server/game" schedule: - interval: "weekly" + interval: "daily" - package-ecosystem: "cargo" directory: "/server/observer-shared" schedule: - interval: "weekly" + interval: "daily" - package-ecosystem: "cargo" directory: "/server/observer" schedule: - interval: "weekly" + interval: "daily" - package-ecosystem: "cargo" directory: "/server/shared" schedule: - interval: "weekly" + interval: "daily" - package-ecosystem: "cargo" directory: "/server" schedule: - interval: "weekly" + interval: "daily" From a8ac179cfd212a05fd55a9bda9cfe36875de7163 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:40:58 +0000 Subject: [PATCH 08/87] Update async-watcher requirement from 0.2.1 to 0.3.0 in /server Updates the requirements on [async-watcher](https://github.com/justinrubek/async-watcher) to permit the latest version. - [Release notes](https://github.com/justinrubek/async-watcher/releases) - [Changelog](https://github.com/justinrubek/async-watcher/blob/main/CHANGELOG.md) - [Commits](https://github.com/justinrubek/async-watcher/compare/0.2.1...0.3.0) --- updated-dependencies: - dependency-name: async-watcher dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- server/central/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index eac3ebc14..08103ae08 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] globed-shared = { path = "../shared" } -async-watcher = "0.2.1" +async-watcher = "0.3.0" blake2 = "0.10.6" digest = "0.10.7" ipnet = "2.9.0" From 27f4adb18d23bfc06f762e02ffa8de5eed6e4afa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:41:00 +0000 Subject: [PATCH 09/87] Update console-subscriber requirement in /server/game Updates the requirements on [console-subscriber](https://github.com/tokio-rs/console) to permit the latest version. - [Release notes](https://github.com/tokio-rs/console/releases) - [Changelog](https://github.com/tokio-rs/console/blob/main/release-plz.toml) - [Commits](https://github.com/tokio-rs/console/compare/console-subscriber-v0.2.0...console-subscriber-v0.4.1) --- updated-dependencies: - dependency-name: console-subscriber dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- server/game/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/Cargo.toml b/server/game/Cargo.toml index 8d3f50de8..e5986ce57 100644 --- a/server/game/Cargo.toml +++ b/server/game/Cargo.toml @@ -16,7 +16,7 @@ rustc-hash = "1.1.0" serde = { version = "1.0.202", features = ["serde_derive"] } serde_json = "1.0.117" futures-util = "0.3.30" -console-subscriber = { version = "0.2.0", features = ["parking_lot"] } +console-subscriber = { version = "0.4.1", features = ["parking_lot"] } # tokio_tracing = { package = "tokio", version = "1.37.0", features = [ # "full", From 837206acc2e3c5beffabd2f7c6110d1783eb919a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:41:23 +0000 Subject: [PATCH 10/87] Update rustc-hash requirement from 1.1.0 to 2.0.0 in /server Updates the requirements on [rustc-hash](https://github.com/rust-lang/rustc-hash) to permit the latest version. - [Changelog](https://github.com/rust-lang/rustc-hash/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/rustc-hash/compare/v1.2.0...v2.0.0) --- updated-dependencies: - dependency-name: rustc-hash dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- server/game/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/Cargo.toml b/server/game/Cargo.toml index 8d3f50de8..009ede5e1 100644 --- a/server/game/Cargo.toml +++ b/server/game/Cargo.toml @@ -12,7 +12,7 @@ esp = { path = "../esp" } alloca = "0.4.0" ctrlc = "3.4.4" -rustc-hash = "1.1.0" +rustc-hash = "2.0.0" serde = { version = "1.0.202", features = ["serde_derive"] } serde_json = "1.0.117" futures-util = "0.3.30" From 198a54688f5f7d69f5b64c04f5990211106f3d2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:41:36 +0000 Subject: [PATCH 11/87] Update rocket_db_pools requirement from 0.1.0 to 0.2.0 in /server Updates the requirements on [rocket_db_pools](https://github.com/rwf2/Rocket) to permit the latest version. - [Release notes](https://github.com/rwf2/Rocket/releases) - [Changelog](https://github.com/rwf2/Rocket/blob/master/CHANGELOG.md) - [Commits](https://github.com/rwf2/Rocket/compare/v0.1.0...v0.2.0) --- updated-dependencies: - dependency-name: rocket_db_pools dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- server/central/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index eac3ebc14..dba629801 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -18,7 +18,7 @@ serde_json = "1.0.117" tokio = { version = "1.37.0", features = ["full"] } json_comments = "0.2.2" rocket = { version = "0.5.0", features = ["json"] } -rocket_db_pools = { version = "0.1.0", features = ["sqlx_sqlite"] } +rocket_db_pools = { version = "0.2.0", features = ["sqlx_sqlite"] } sqlx = { version = "0.7.4", features = ["migrate"] } rocket_cors = "0.6.0" const_format = "0.2.32" From ec16470d0e277eb72a0d943d8184cc7930aecee2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:42:16 +0000 Subject: [PATCH 12/87] Update egui requirement from 0.27.2 to 0.29.1 in /server/observer Updates the requirements on [egui](https://github.com/emilk/egui) to permit the latest version. - [Release notes](https://github.com/emilk/egui/releases) - [Changelog](https://github.com/emilk/egui/blob/master/CHANGELOG.md) - [Commits](https://github.com/emilk/egui/compare/0.27.2...0.29.1) --- updated-dependencies: - dependency-name: egui dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- server/observer/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/observer/Cargo.toml b/server/observer/Cargo.toml index 52ad33599..107b3e2ed 100644 --- a/server/observer/Cargo.toml +++ b/server/observer/Cargo.toml @@ -8,4 +8,4 @@ globed-shared = { path = "../shared" } globed-derive = { path = "../derive" } observer-shared = { path = "../observer-shared" } esp = { path = "../esp" } -egui = "0.27.2" +egui = "0.29.1" From 625e0067f4330d78352095c664642639d5eb0c00 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:42:31 +0000 Subject: [PATCH 13/87] Update base64 requirement from 0.21.7 to 0.22.1 in /server/shared Updates the requirements on [base64](https://github.com/marshallpierce/rust-base64) to permit the latest version. - [Changelog](https://github.com/marshallpierce/rust-base64/blob/master/RELEASE-NOTES.md) - [Commits](https://github.com/marshallpierce/rust-base64/compare/v0.21.7...v0.22.1) --- updated-dependencies: - dependency-name: base64 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- server/shared/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shared/Cargo.toml b/server/shared/Cargo.toml index 7cceb673d..2025e19fd 100644 --- a/server/shared/Cargo.toml +++ b/server/shared/Cargo.toml @@ -10,7 +10,7 @@ esp = { path = "../esp" } globed-derive = { path = "../derive" } anyhow = "1.0.83" -base64 = "0.21.7" +base64 = "0.22.1" colored = "2.1.0" crypto_box = { version = "0.9.1", features = ["std", "chacha20"] } hmac = "0.12.1" From c556b8e7377d76ecd45b0b7fcc868dae2238cf66 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 14:51:18 +0300 Subject: [PATCH 14/87] Update Cargo.toml --- server/central/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index dba629801..afcdc4dd7 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -23,3 +23,4 @@ sqlx = { version = "0.7.4", features = ["migrate"] } rocket_cors = "0.6.0" const_format = "0.2.32" hex = "0.4.3" +libsqlite3-sys = "0.30.1" From 01603e11aefea21f37ba17122ad1688a4f9a180a Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:00:10 +0300 Subject: [PATCH 15/87] Update CMakeLists --- CMakeLists.txt | 183 +++++++------------------------------------------ 1 file changed, 25 insertions(+), 158 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ca6bfed3..2b927bf33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,79 +1,55 @@ cmake_minimum_required(VERSION 3.21) + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_VISIBILITY_PRESET hidden) project(globed2 VERSION 1.0.1) -# set ios archs if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS") - message(STATUS "building for ios") + message(STATUS "Building for iOS") unset(CMAKE_OSX_ARCHITECTURES) set(CMAKE_OSX_ARCHITECTURES "arm64") set(CMAKE_OSX_DEPLOYMENT_TARGET "14.0") - set(CMAKE_SYSTEM_NAME "iOS") else() - message(STATUS "building for mac") + message(STATUS "Building for macOS") set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64") endif() option(GLOBED_OSS_BUILD "Open source build that does not require closed-source dependencies" OFF) option(GLOBED_NATIVE_ARCH "Native architecture build" OFF) -# on windows use precompiled, on other platforms compile libsodium if (WIN32) option(GLOBED_COMPILE_LIBS "Don't use precompiled libraries and compile manually" OFF) else() option(GLOBED_COMPILE_LIBS "Don't use precompiled libraries and compile manually" ON) endif() -# check if compiler is clang if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(GLOBED_IS_CLANG ON) else() set(GLOBED_IS_CLANG OFF) endif() -# check if it's clang-cl or clang if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") set(GLOBED_IS_CLANG_CL OFF) else() set(GLOBED_IS_CLANG_CL ON) endif() - -# Check for debug build option(ENABLE_DEBUG "Debug mode" OFF) option(GLOBED_RELEASE "Release build" OFF) -if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR "${CMAKE_BUILD_TYPE}asdf" STREQUAL "asdf" OR ENABLE_DEBUG) +if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR ENABLE_DEBUG) set(GLOBED_IS_DEBUG ON) endif() -# Debug/Release options if (GLOBED_IS_DEBUG) - add_compile_definitions(GLOBED_DEBUG=1) - add_compile_definitions(GEODE_DEBUG=1) - add_compile_definitions(ASP_ENABLE_DEBUG=1) - - # # turn on asan - # if (GLOBED_IS_CLANG) - # if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libs/stl_asan.lib") - # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") - # set(GLOBED_LINK_TO_ASAN ON) - # endif() - - # # no omit frame pointer - # if (NOT GLOBED_IS_CLANG_CL) - # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer") - # endif() - # endif() + add_compile_definitions(GLOBED_DEBUG=1 GEODE_DEBUG=1 ASP_ENABLE_DEBUG=1) elseif (GLOBED_RELEASE) - # Enable LTO in release (2.5x less binary size, costs only a few extra seconds of build time) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) endif() -# add thingies depending on the current system if (ANDROID) file(GLOB_RECURSE OS_SOURCES "src/platform/os/android/*.cpp" "src/platform/arch/arm/*.cpp") elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "iOS") @@ -86,27 +62,25 @@ else() message(FATAL_ERROR "Unsupported operating system") endif() -# source files file(GLOB_RECURSE SOURCES - src/audio/*.cpp - src/crypto/*.cpp - src/data/*.cpp + src/audio/*.cpp + src/crypto/*.cpp + src/data/*.cpp src/globed/*.cpp - src/game/*.cpp - src/hooks/*.cpp - src/managers/*.cpp - src/net/*.cpp - src/ui/*.cpp - src/util/*.cpp - src/main.cpp + src/game/*.cpp + src/hooks/*.cpp + src/managers/*.cpp + src/net/*.cpp + src/ui/*.cpp + src/util/*.cpp + src/main.cpp ${OS_SOURCES} ) add_library(${PROJECT_NAME} SHARED ${SOURCES}) -# Windows - do stuff if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - add_compile_definitions(WIN32_LEAN_AND_MEAN=1) # geode moment + add_compile_definitions(WIN32_LEAN_AND_MEAN=1) if (NOT MSVC) set(GLOBED_WINDOWS_CLANG ON) endif() @@ -116,13 +90,8 @@ if (GLOBED_RELEASE) target_compile_definitions(${PROJECT_NAME} PRIVATE GLOBED_RELEASE=1) endif() -# export some symbols target_compile_definitions(${PROJECT_NAME} PRIVATE GLOBED_EXPORTING) -if (CMAKE_HOST_SYSTEM MATCHES "Linux" AND CMAKE_SYSTEM_NAME STREQUAL "Windows") - target_compile_definitions(${PROJECT_NAME} PRIVATE GLOBED_LINUX_COMPILATION=1) -endif() - if (NOT DEFINED ENV{GEODE_SDK}) message(FATAL_ERROR "Unable to find Geode SDK! Please define GEODE_SDK environment variable to point to Geode") else() @@ -131,64 +100,41 @@ endif() add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode) -# done so you can include root files with target_include_directories(${PROJECT_NAME} PRIVATE src/) target_include_directories(${PROJECT_NAME} PRIVATE libs/) -# our favorite libraries -CPMAddPackage("gh:dankmeme01/uibuilder#c30755a") +CPMAddPackage("gh:camila314/uibuilder#3d10e3d") CPMAddPackage( NAME Boost VERSION 1.86.0 URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.7z URL_HASH SHA256=ee6e0793b5ec7d13e7181ec05d3b1aaa23615947295080e4b9930324488e078f - OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_INCLUDE_LIBRARIES describe\\\;stacktrace\\\;thread" # escape with \\\; + OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_INCLUDE_LIBRARIES describe\\\;stacktrace\\\;thread" ) CPMAddPackage("gh:dankmeme01/asp2#6720133") -# asp defines -if (WIN32) - if (GLOBED_IS_DEBUG) - # debug - target_compile_definitions(asp PRIVATE _HAS_ITERATOR_DEBUGGING=0) - endif() - - # thingy - target_compile_definitions(asp PRIVATE ASP_ENABLE_FORMAT=1) - target_compile_definitions(${PROJECT_NAME} PRIVATE ASP_ENABLE_FORMAT=1) +if (WIN32 AND GLOBED_IS_DEBUG) + target_compile_definitions(asp PRIVATE _HAS_ITERATOR_DEBUGGING=0) endif() +target_compile_definitions(asp PRIVATE ASP_ENABLE_FORMAT=1) +target_compile_definitions(${PROJECT_NAME} PRIVATE ASP_ENABLE_FORMAT=1) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/globed-codegen") target_include_directories("${PROJECT_NAME}" PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/globed-codegen") - include(cmake/baked_resources_gen.cmake) generate_baked_resources_header("${CMAKE_CURRENT_SOURCE_DIR}/embedded-resources.json" "${CMAKE_CURRENT_BINARY_DIR}/globed-codegen/embedded_resources.hpp") if (GLOBED_NATIVE_ARCH) - # Apply native architecture add_compile_options("-march=native") endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options(${PROJECT_NAME} PRIVATE "-Wno-deprecated-declarations") - # target_compile_options(${PROJECT_NAME} PRIVATE "-ftime-trace") - # target_compile_options(asp PRIVATE "-ftime-trace") - # if (WIN32) - # target_compile_options(${PROJECT_NAME} PRIVATE "-Wno-vla-cxx-extension") - # endif() endif() target_link_libraries(${PROJECT_NAME} UIBuilder Boost::describe Boost::thread asp) -# if (GLOBED_LINK_TO_ASAN) -# target_link_libraries( -# ${PROJECT_NAME} -# "${CMAKE_CURRENT_SOURCE_DIR}/libs/stl_asan.lib" -# "${CMAKE_CURRENT_SOURCE_DIR}/libs/clang_rt.asan_dynamic-x86_64.lib" -# "${CMAKE_CURRENT_SOURCE_DIR}/libs/clang_rt.asan_dynamic_runtime_thunk-x86_64.lib" -# ) -# endif() - if (GLOBED_IS_DEBUG) target_link_libraries(${PROJECT_NAME} Boost::stacktrace) endif() @@ -197,14 +143,12 @@ if (GLOBED_COMPILE_LIBS) CPMAddPackage("gh:dankmeme01/libsodium-cmake#226abba") CPMAddPackage("gh:xiph/opus#v1.5.2") - # disable some warnings if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options(sodium PRIVATE "-Wno-inaccessible-base" "-Wno-pointer-sign" "-Wno-user-defined-warnings") endif() target_link_libraries(${PROJECT_NAME} sodium opus) else() - # download headers (binaries based off of 1.0.20 too) CPMAddPackage( NAME sodium GIT_REPOSITORY "https://github.com/jedisct1/libsodium.git" @@ -219,7 +163,6 @@ else() add_library(sodium STATIC IMPORTED) set_target_properties(sodium PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/libs/sodium/libsodium.lib") - add_library(opus STATIC IMPORTED) set_target_properties(opus PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/libs/opus/opus.lib") @@ -227,92 +170,16 @@ else() target_include_directories(${PROJECT_NAME} PRIVATE "${sodium_SOURCE_DIR}/src/libsodium/include") target_include_directories(${PROJECT_NAME} PRIVATE "${opus_SOURCE_DIR}/include") - set(SODIUM_VERSION_IN "${CMAKE_CURRENT_SOURCE_DIR}/libs/sodium/version.h") - set(SODIUM_VERSION_OUT "${sodium_SOURCE_DIR}/src/libsodium/include/sodium/") - - if (NOT EXISTS "${SODIUM_VERSION_OUT}/version.h") - message(STATUS "Copied version.h to ${SODIUM_VERSION_OUT}") - file(COPY "${SODIUM_VERSION_IN}" DESTINATION "${SODIUM_VERSION_OUT}") - else() - file(READ "${SODIUM_VERSION_IN}" CONTENT_IN) - file(READ "${SODIUM_VERSION_OUT}/version.h" CONTENT_OUT) - - if (NOT "${CONTENT_IN}" STREQUAL "${CONTENT_OUT}") - message(STATUS "Copied version.h to ${SODIUM_VERSION_OUT}") - file(COPY "${SODIUM_VERSION_IN}" DESTINATION "${SODIUM_VERSION_OUT}") - endif() - endif() - target_link_libraries(${PROJECT_NAME} sodium opus) endif() -# Windows - link to winsock and wmi if (WIN32) - target_link_libraries(${PROJECT_NAME} ws2_32) + target_link_libraries(${PROJECT_NAME} ws2_32 crypt32) endif() -# Apple - link to iokit if (APPLE) find_library(IOKIT_LIBRARY IOKit) target_link_libraries(${PROJECT_NAME} ${IOKIT_LIBRARY}) endif() -# link to libcurl - -CPMAddPackage( - NAME curl - GIT_REPOSITORY "https://github.com/curl/curl.git" - GIT_TAG "curl-8_11_0" - DOWNLOAD_ONLY YES -) - -add_library(curl STATIC IMPORTED) - -if (ANDROID) - if (ANDROID_ABI STREQUAL "arm64-v8a") - set(LIB_PLATFORM "android64") - else() - set(LIB_PLATFORM "android32") - endif() -elseif (WIN32) - set(LIB_PLATFORM "win64") -else() - set(LIB_PLATFORM "macos") -endif() - -target_compile_definitions(${PROJECT_NAME} PRIVATE CURL_STATICLIB=1) - -# we are kinda leeching off of geode but we can always snatch those libraries in the future -if (WIN32) - set_target_properties(curl PROPERTIES IMPORTED_LOCATION "$ENV{GEODE_SDK}/loader/include/link/${LIB_PLATFORM}/libcurl.lib") -else() - set_target_properties(curl PROPERTIES IMPORTED_LOCATION "$ENV{GEODE_SDK}/loader/include/link/${LIB_PLATFORM}/libcurl.a") -endif() - -target_include_directories(${PROJECT_NAME} PRIVATE "${curl_SOURCE_DIR}/include") - -target_link_libraries(${PROJECT_NAME} curl) - -# mac needs this for curl -if (APPLE) - target_link_libraries(${PROJECT_NAME} z) -elseif (WIN32) - # windows needs this ig? - target_link_libraries(${PROJECT_NAME} crypt32) -endif() - - -# link to bb -if (GLOBED_OSS_BUILD) - message(STATUS "Building open-source version, not linking to bb") - target_compile_definitions(${PROJECT_NAME} PRIVATE GLOBED_OSS_BUILD=1) -else() - if (WIN32) - target_link_libraries(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/libs/bb/bb.lib") - target_link_libraries(${PROJECT_NAME} ntdll.lib userenv.lib runtimeobject.lib Iphlpapi.lib) - else () - target_link_libraries(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/libs/bb/bb-${LIB_PLATFORM}.a") - endif() -endif() - -setup_geode_mod(${PROJECT_NAME}) +set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) From ad0e245d683eca8e4788b2a753b651321454f291 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:06:16 +0300 Subject: [PATCH 16/87] oops --- CMakeLists.txt | 183 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 158 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b927bf33..1ca6bfed3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,55 +1,79 @@ cmake_minimum_required(VERSION 3.21) - set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_VISIBILITY_PRESET hidden) project(globed2 VERSION 1.0.1) +# set ios archs if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS") - message(STATUS "Building for iOS") + message(STATUS "building for ios") unset(CMAKE_OSX_ARCHITECTURES) set(CMAKE_OSX_ARCHITECTURES "arm64") set(CMAKE_OSX_DEPLOYMENT_TARGET "14.0") + set(CMAKE_SYSTEM_NAME "iOS") else() - message(STATUS "Building for macOS") + message(STATUS "building for mac") set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64") endif() option(GLOBED_OSS_BUILD "Open source build that does not require closed-source dependencies" OFF) option(GLOBED_NATIVE_ARCH "Native architecture build" OFF) +# on windows use precompiled, on other platforms compile libsodium if (WIN32) option(GLOBED_COMPILE_LIBS "Don't use precompiled libraries and compile manually" OFF) else() option(GLOBED_COMPILE_LIBS "Don't use precompiled libraries and compile manually" ON) endif() +# check if compiler is clang if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(GLOBED_IS_CLANG ON) else() set(GLOBED_IS_CLANG OFF) endif() +# check if it's clang-cl or clang if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") set(GLOBED_IS_CLANG_CL OFF) else() set(GLOBED_IS_CLANG_CL ON) endif() + +# Check for debug build option(ENABLE_DEBUG "Debug mode" OFF) option(GLOBED_RELEASE "Release build" OFF) -if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR ENABLE_DEBUG) +if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR "${CMAKE_BUILD_TYPE}asdf" STREQUAL "asdf" OR ENABLE_DEBUG) set(GLOBED_IS_DEBUG ON) endif() +# Debug/Release options if (GLOBED_IS_DEBUG) - add_compile_definitions(GLOBED_DEBUG=1 GEODE_DEBUG=1 ASP_ENABLE_DEBUG=1) + add_compile_definitions(GLOBED_DEBUG=1) + add_compile_definitions(GEODE_DEBUG=1) + add_compile_definitions(ASP_ENABLE_DEBUG=1) + + # # turn on asan + # if (GLOBED_IS_CLANG) + # if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libs/stl_asan.lib") + # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") + # set(GLOBED_LINK_TO_ASAN ON) + # endif() + + # # no omit frame pointer + # if (NOT GLOBED_IS_CLANG_CL) + # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer") + # endif() + # endif() elseif (GLOBED_RELEASE) + # Enable LTO in release (2.5x less binary size, costs only a few extra seconds of build time) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) endif() +# add thingies depending on the current system if (ANDROID) file(GLOB_RECURSE OS_SOURCES "src/platform/os/android/*.cpp" "src/platform/arch/arm/*.cpp") elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "iOS") @@ -62,25 +86,27 @@ else() message(FATAL_ERROR "Unsupported operating system") endif() +# source files file(GLOB_RECURSE SOURCES - src/audio/*.cpp - src/crypto/*.cpp - src/data/*.cpp + src/audio/*.cpp + src/crypto/*.cpp + src/data/*.cpp src/globed/*.cpp - src/game/*.cpp - src/hooks/*.cpp - src/managers/*.cpp - src/net/*.cpp - src/ui/*.cpp - src/util/*.cpp - src/main.cpp + src/game/*.cpp + src/hooks/*.cpp + src/managers/*.cpp + src/net/*.cpp + src/ui/*.cpp + src/util/*.cpp + src/main.cpp ${OS_SOURCES} ) add_library(${PROJECT_NAME} SHARED ${SOURCES}) +# Windows - do stuff if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - add_compile_definitions(WIN32_LEAN_AND_MEAN=1) + add_compile_definitions(WIN32_LEAN_AND_MEAN=1) # geode moment if (NOT MSVC) set(GLOBED_WINDOWS_CLANG ON) endif() @@ -90,8 +116,13 @@ if (GLOBED_RELEASE) target_compile_definitions(${PROJECT_NAME} PRIVATE GLOBED_RELEASE=1) endif() +# export some symbols target_compile_definitions(${PROJECT_NAME} PRIVATE GLOBED_EXPORTING) +if (CMAKE_HOST_SYSTEM MATCHES "Linux" AND CMAKE_SYSTEM_NAME STREQUAL "Windows") + target_compile_definitions(${PROJECT_NAME} PRIVATE GLOBED_LINUX_COMPILATION=1) +endif() + if (NOT DEFINED ENV{GEODE_SDK}) message(FATAL_ERROR "Unable to find Geode SDK! Please define GEODE_SDK environment variable to point to Geode") else() @@ -100,41 +131,64 @@ endif() add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode) +# done so you can include root files with target_include_directories(${PROJECT_NAME} PRIVATE src/) target_include_directories(${PROJECT_NAME} PRIVATE libs/) -CPMAddPackage("gh:camila314/uibuilder#3d10e3d") +# our favorite libraries +CPMAddPackage("gh:dankmeme01/uibuilder#c30755a") CPMAddPackage( NAME Boost VERSION 1.86.0 URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.7z URL_HASH SHA256=ee6e0793b5ec7d13e7181ec05d3b1aaa23615947295080e4b9930324488e078f - OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_INCLUDE_LIBRARIES describe\\\;stacktrace\\\;thread" + OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_INCLUDE_LIBRARIES describe\\\;stacktrace\\\;thread" # escape with \\\; ) CPMAddPackage("gh:dankmeme01/asp2#6720133") -if (WIN32 AND GLOBED_IS_DEBUG) - target_compile_definitions(asp PRIVATE _HAS_ITERATOR_DEBUGGING=0) -endif() +# asp defines +if (WIN32) + if (GLOBED_IS_DEBUG) + # debug + target_compile_definitions(asp PRIVATE _HAS_ITERATOR_DEBUGGING=0) + endif() -target_compile_definitions(asp PRIVATE ASP_ENABLE_FORMAT=1) -target_compile_definitions(${PROJECT_NAME} PRIVATE ASP_ENABLE_FORMAT=1) + # thingy + target_compile_definitions(asp PRIVATE ASP_ENABLE_FORMAT=1) + target_compile_definitions(${PROJECT_NAME} PRIVATE ASP_ENABLE_FORMAT=1) +endif() file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/globed-codegen") target_include_directories("${PROJECT_NAME}" PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/globed-codegen") + include(cmake/baked_resources_gen.cmake) generate_baked_resources_header("${CMAKE_CURRENT_SOURCE_DIR}/embedded-resources.json" "${CMAKE_CURRENT_BINARY_DIR}/globed-codegen/embedded_resources.hpp") if (GLOBED_NATIVE_ARCH) + # Apply native architecture add_compile_options("-march=native") endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options(${PROJECT_NAME} PRIVATE "-Wno-deprecated-declarations") + # target_compile_options(${PROJECT_NAME} PRIVATE "-ftime-trace") + # target_compile_options(asp PRIVATE "-ftime-trace") + # if (WIN32) + # target_compile_options(${PROJECT_NAME} PRIVATE "-Wno-vla-cxx-extension") + # endif() endif() target_link_libraries(${PROJECT_NAME} UIBuilder Boost::describe Boost::thread asp) +# if (GLOBED_LINK_TO_ASAN) +# target_link_libraries( +# ${PROJECT_NAME} +# "${CMAKE_CURRENT_SOURCE_DIR}/libs/stl_asan.lib" +# "${CMAKE_CURRENT_SOURCE_DIR}/libs/clang_rt.asan_dynamic-x86_64.lib" +# "${CMAKE_CURRENT_SOURCE_DIR}/libs/clang_rt.asan_dynamic_runtime_thunk-x86_64.lib" +# ) +# endif() + if (GLOBED_IS_DEBUG) target_link_libraries(${PROJECT_NAME} Boost::stacktrace) endif() @@ -143,12 +197,14 @@ if (GLOBED_COMPILE_LIBS) CPMAddPackage("gh:dankmeme01/libsodium-cmake#226abba") CPMAddPackage("gh:xiph/opus#v1.5.2") + # disable some warnings if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options(sodium PRIVATE "-Wno-inaccessible-base" "-Wno-pointer-sign" "-Wno-user-defined-warnings") endif() target_link_libraries(${PROJECT_NAME} sodium opus) else() + # download headers (binaries based off of 1.0.20 too) CPMAddPackage( NAME sodium GIT_REPOSITORY "https://github.com/jedisct1/libsodium.git" @@ -163,6 +219,7 @@ else() add_library(sodium STATIC IMPORTED) set_target_properties(sodium PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/libs/sodium/libsodium.lib") + add_library(opus STATIC IMPORTED) set_target_properties(opus PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/libs/opus/opus.lib") @@ -170,16 +227,92 @@ else() target_include_directories(${PROJECT_NAME} PRIVATE "${sodium_SOURCE_DIR}/src/libsodium/include") target_include_directories(${PROJECT_NAME} PRIVATE "${opus_SOURCE_DIR}/include") + set(SODIUM_VERSION_IN "${CMAKE_CURRENT_SOURCE_DIR}/libs/sodium/version.h") + set(SODIUM_VERSION_OUT "${sodium_SOURCE_DIR}/src/libsodium/include/sodium/") + + if (NOT EXISTS "${SODIUM_VERSION_OUT}/version.h") + message(STATUS "Copied version.h to ${SODIUM_VERSION_OUT}") + file(COPY "${SODIUM_VERSION_IN}" DESTINATION "${SODIUM_VERSION_OUT}") + else() + file(READ "${SODIUM_VERSION_IN}" CONTENT_IN) + file(READ "${SODIUM_VERSION_OUT}/version.h" CONTENT_OUT) + + if (NOT "${CONTENT_IN}" STREQUAL "${CONTENT_OUT}") + message(STATUS "Copied version.h to ${SODIUM_VERSION_OUT}") + file(COPY "${SODIUM_VERSION_IN}" DESTINATION "${SODIUM_VERSION_OUT}") + endif() + endif() + target_link_libraries(${PROJECT_NAME} sodium opus) endif() +# Windows - link to winsock and wmi if (WIN32) - target_link_libraries(${PROJECT_NAME} ws2_32 crypt32) + target_link_libraries(${PROJECT_NAME} ws2_32) endif() +# Apple - link to iokit if (APPLE) find_library(IOKIT_LIBRARY IOKit) target_link_libraries(${PROJECT_NAME} ${IOKIT_LIBRARY}) endif() -set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) +# link to libcurl + +CPMAddPackage( + NAME curl + GIT_REPOSITORY "https://github.com/curl/curl.git" + GIT_TAG "curl-8_11_0" + DOWNLOAD_ONLY YES +) + +add_library(curl STATIC IMPORTED) + +if (ANDROID) + if (ANDROID_ABI STREQUAL "arm64-v8a") + set(LIB_PLATFORM "android64") + else() + set(LIB_PLATFORM "android32") + endif() +elseif (WIN32) + set(LIB_PLATFORM "win64") +else() + set(LIB_PLATFORM "macos") +endif() + +target_compile_definitions(${PROJECT_NAME} PRIVATE CURL_STATICLIB=1) + +# we are kinda leeching off of geode but we can always snatch those libraries in the future +if (WIN32) + set_target_properties(curl PROPERTIES IMPORTED_LOCATION "$ENV{GEODE_SDK}/loader/include/link/${LIB_PLATFORM}/libcurl.lib") +else() + set_target_properties(curl PROPERTIES IMPORTED_LOCATION "$ENV{GEODE_SDK}/loader/include/link/${LIB_PLATFORM}/libcurl.a") +endif() + +target_include_directories(${PROJECT_NAME} PRIVATE "${curl_SOURCE_DIR}/include") + +target_link_libraries(${PROJECT_NAME} curl) + +# mac needs this for curl +if (APPLE) + target_link_libraries(${PROJECT_NAME} z) +elseif (WIN32) + # windows needs this ig? + target_link_libraries(${PROJECT_NAME} crypt32) +endif() + + +# link to bb +if (GLOBED_OSS_BUILD) + message(STATUS "Building open-source version, not linking to bb") + target_compile_definitions(${PROJECT_NAME} PRIVATE GLOBED_OSS_BUILD=1) +else() + if (WIN32) + target_link_libraries(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/libs/bb/bb.lib") + target_link_libraries(${PROJECT_NAME} ntdll.lib userenv.lib runtimeobject.lib Iphlpapi.lib) + else () + target_link_libraries(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/libs/bb/bb-${LIB_PLATFORM}.a") + endif() +endif() + +setup_geode_mod(${PROJECT_NAME}) From 2149619cf9c9d2831febd14711a5d60cda8f1e24 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:08:43 +0300 Subject: [PATCH 17/87] fix? --- server/central/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index 42ca5942b..c1e8287af 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -23,4 +23,4 @@ sqlx = { version = "0.7.4", features = ["migrate"] } rocket_cors = "0.6.0" const_format = "0.2.32" hex = "0.4.3" -libsqlite3-sys = "0.30.1" +libsqlite3-sys = "^0.30.1" From 86825abb5b3d9e2c639a738d8ed9e2c953e72c37 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:16:30 +0300 Subject: [PATCH 18/87] Update libs --- server/central/Cargo.toml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index c1e8287af..619e7c91e 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "globed-central-server" version = "1.4.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -9,18 +9,18 @@ edition = "2021" globed-shared = { path = "../shared" } async-watcher = "0.3.0" -blake2 = "0.10.6" -digest = "0.10.7" -ipnet = "2.9.0" +blake2 = "0.11.0-pre.4" +digest = "0.11.0-pre.9" +ipnet = "2.10.1" iprange = "0.6.7" -serde = { version = "1.0.202", features = ["serde_derive"] } -serde_json = "1.0.117" -tokio = { version = "1.37.0", features = ["full"] } +serde = { version = "1.0.215", features = ["serde_derive"] } +serde_json = "1.0.133" +tokio = { version = "1.41.1", features = ["full"] } json_comments = "0.2.2" -rocket = { version = "0.5.0", features = ["json"] } +rocket = { version = "0.5.1", features = ["json"] } rocket_db_pools = { version = "0.2.0", features = ["sqlx_sqlite"] } -sqlx = { version = "0.7.4", features = ["migrate"] } +sqlx = { version = "0.8.2", features = ["migrate"] } rocket_cors = "0.6.0" -const_format = "0.2.32" +const_format = "0.2.33" hex = "0.4.3" -libsqlite3-sys = "^0.30.1" +rusqlite = { version = "0.32.0", features = ["bundled"] } From a6da229c665a1e5372a801ebc6ed05b9079cecfb Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:17:49 +0300 Subject: [PATCH 19/87] update --- server/derive/Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/derive/Cargo.toml b/server/derive/Cargo.toml index 1793f8c02..854ecd8c5 100644 --- a/server/derive/Cargo.toml +++ b/server/derive/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" proc-macro = true [dependencies] -darling = "0.20.9" -proc-macro2 = "1.0.82" -quote = "1.0.36" -syn = { version = "2.0.63", features = ["full"] } +darling = "0.20.10" +proc-macro2 = "1.0.92" +quote = "1.0.37" +syn = { version = "2.0.89", features = ["full"] } From 5889a364fc8110046eee6e5fb031afaf2c2464a9 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:18:03 +0300 Subject: [PATCH 20/87] Update Cargo.toml --- server/derive/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/derive/Cargo.toml b/server/derive/Cargo.toml index 854ecd8c5..331660c2b 100644 --- a/server/derive/Cargo.toml +++ b/server/derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "globed-derive" version = "1.0.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 118c475b3563e43b6c4d913ebb42591886596af6 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:19:23 +0300 Subject: [PATCH 21/87] Update Cargo.toml --- server/esp/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/esp/Cargo.toml b/server/esp/Cargo.toml index cf20b3e67..e8648fc5e 100644 --- a/server/esp/Cargo.toml +++ b/server/esp/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "esp" version = "1.0.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] simd-adler32 = { version = "0.3.7", default-features = false } -bytebuffer = "2.2.0" -crc32fast = "1.4.0" +bytebuffer = "2.3.0" +crc32fast = "1.4.2" [dev-dependencies] globed-derive = { path = "../derive" } From bc67734bec7a309bd5d333645101494fac07b941 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:22:03 +0300 Subject: [PATCH 22/87] Update Cargo.toml --- server/game/Cargo.toml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/game/Cargo.toml b/server/game/Cargo.toml index f4fcf29ad..e03d0036a 100644 --- a/server/game/Cargo.toml +++ b/server/game/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "globed-game-server" version = "1.4.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -11,18 +11,18 @@ globed-derive = { path = "../derive" } esp = { path = "../esp" } alloca = "0.4.0" -ctrlc = "3.4.4" +ctrlc = "3.4.5" rustc-hash = "2.0.0" -serde = { version = "1.0.202", features = ["serde_derive"] } -serde_json = "1.0.117" -futures-util = "0.3.30" +serde = { version = "1.0.215", features = ["serde_derive"] } +serde_json = "1.0.133" +futures-util = "0.3.31" console-subscriber = { version = "0.4.1", features = ["parking_lot"] } -# tokio_tracing = { package = "tokio", version = "1.37.0", features = [ +# tokio_tracing = { package = "tokio", version = "1.41.1", features = [ # "full", # "tracing", # ], optional = true } -tokio = { version = "1.37.0", features = ["full"], optional = true } +tokio = { version = "1.41.1", features = ["full"], optional = true } aho-corasick = "1.1.3" [dev-dependencies] From 5a6524735423d6510d81aee9746fdee3f4c9a308 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:22:12 +0300 Subject: [PATCH 23/87] Update Cargo.toml --- server/observer-shared/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/observer-shared/Cargo.toml b/server/observer-shared/Cargo.toml index 6343d11d0..5a11969f8 100644 --- a/server/observer-shared/Cargo.toml +++ b/server/observer-shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "observer-shared" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] From 264cdcded6866a3ce4ef805c46951b66f0fc6c2b Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:22:35 +0300 Subject: [PATCH 24/87] Update Cargo.toml --- server/observer/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/observer/Cargo.toml b/server/observer/Cargo.toml index 107b3e2ed..00332dc33 100644 --- a/server/observer/Cargo.toml +++ b/server/observer/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "observer" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] globed-shared = { path = "../shared" } From f4f6231ade94c4e8aa6ce86336c6438ad7e2b893 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:26:31 +0300 Subject: [PATCH 25/87] Update Cargo.toml --- server/shared/Cargo.toml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/server/shared/Cargo.toml b/server/shared/Cargo.toml index 2025e19fd..7cbb1e351 100644 --- a/server/shared/Cargo.toml +++ b/server/shared/Cargo.toml @@ -1,29 +1,27 @@ [package] name = "globed-shared" version = "1.0.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +edition = "2024" [dependencies] esp = { path = "../esp" } globed-derive = { path = "../derive" } -anyhow = "1.0.83" +nyhow = "1.0.93" base64 = "0.22.1" colored = "2.1.0" crypto_box = { version = "0.9.1", features = ["std", "chacha20"] } -hmac = "0.12.1" -log = { version = "0.4.21" } +hmac = "0.13.0-pre.4" +log = "0.4.22" nohash-hasher = "0.2.0" -parking_lot = "0.12.2" -rand = "0.8.5" -reqwest = { version = "0.12.4", default-features = false, features = [ +parking_lot = "0.12.3" +rand = "0.9.0-beta.0" +reqwest = { version = "0.12.9", default-features = false, features = [ "rustls-tls", ] } -sha2 = "0.10.8" +sha2 = "0.11.0-pre.4" time = { version = "0.3.36", features = ["formatting"] } -serde = { version = "1.0.202", features = ["derive"] } +serde = { version = "1.0.215", features = ["derive"] } crypto_secretbox = { version = "0.1.1", features = ["chacha20"] } -serde_json = "1.0.120" -argon2 = "0.5.3" +serde_json = "1.0.133" +argon2 = "0.6.0-pre.1" From 334b101158a1cc85e636babe59cd18aa75d0ee05 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:26:38 +0300 Subject: [PATCH 26/87] Update Cargo.toml --- server/central/Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index 619e7c91e..928fcad24 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -3,8 +3,6 @@ name = "globed-central-server" version = "1.4.0" edition = "2024" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] globed-shared = { path = "../shared" } From c61ea361630d6b4a41b14921a179c5bcf1344edc Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:26:46 +0300 Subject: [PATCH 27/87] Update Cargo.toml --- server/derive/Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/derive/Cargo.toml b/server/derive/Cargo.toml index 331660c2b..de13b5db1 100644 --- a/server/derive/Cargo.toml +++ b/server/derive/Cargo.toml @@ -3,8 +3,6 @@ name = "globed-derive" version = "1.0.0" edition = "2024" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [lib] proc-macro = true From fd45af4bf980027633a36353d76c9d191cccecd6 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:26:54 +0300 Subject: [PATCH 28/87] Update Cargo.toml --- server/esp/Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/esp/Cargo.toml b/server/esp/Cargo.toml index e8648fc5e..6a0347252 100644 --- a/server/esp/Cargo.toml +++ b/server/esp/Cargo.toml @@ -3,8 +3,6 @@ name = "esp" version = "1.0.0" edition = "2024" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] simd-adler32 = { version = "0.3.7", default-features = false } bytebuffer = "2.3.0" From 433388ad75f2f3abe4d09d46645a25b7cba7d646 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:27:08 +0300 Subject: [PATCH 29/87] Update Cargo.toml --- server/game/Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/game/Cargo.toml b/server/game/Cargo.toml index e03d0036a..37eae71fd 100644 --- a/server/game/Cargo.toml +++ b/server/game/Cargo.toml @@ -3,8 +3,6 @@ name = "globed-game-server" version = "1.4.0" edition = "2024" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] globed-shared = { path = "../shared" } globed-derive = { path = "../derive" } From 06e3c917028979cfbef175a6d7f06e62ce490ebd Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:30:39 +0300 Subject: [PATCH 30/87] Update Cargo.toml --- server/central/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index 928fcad24..07aba8aa1 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -21,4 +21,4 @@ sqlx = { version = "0.8.2", features = ["migrate"] } rocket_cors = "0.6.0" const_format = "0.2.33" hex = "0.4.3" -rusqlite = { version = "0.32.0", features = ["bundled"] } +libsqlite3-sys = "0.30.1" From 589d26c0558b87122f70f9353c53aa9dc492f037 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:35:03 +0300 Subject: [PATCH 31/87] Update Cargo.toml --- server/central/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index 07aba8aa1..1ae70851c 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -21,4 +21,4 @@ sqlx = { version = "0.8.2", features = ["migrate"] } rocket_cors = "0.6.0" const_format = "0.2.33" hex = "0.4.3" -libsqlite3-sys = "0.30.1" +libsqlite3-sys = "0.25.1" From 8efd1ccf048704c5e92465acefdcdb14eef9dfb7 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:36:45 +0300 Subject: [PATCH 32/87] Update Cargo.toml --- server/shared/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shared/Cargo.toml b/server/shared/Cargo.toml index 7cbb1e351..4d43cb9db 100644 --- a/server/shared/Cargo.toml +++ b/server/shared/Cargo.toml @@ -7,7 +7,7 @@ edition = "2024" esp = { path = "../esp" } globed-derive = { path = "../derive" } -nyhow = "1.0.93" +anyhow = "1.0.93" base64 = "0.22.1" colored = "2.1.0" crypto_box = { version = "0.9.1", features = ["std", "chacha20"] } From 593e78920629e34597d2c1157f856e9a8bd56967 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:41:39 +0300 Subject: [PATCH 33/87] Update Cargo.toml --- server/central/Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index 1ae70851c..5ca06ae80 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -21,4 +21,5 @@ sqlx = { version = "0.8.2", features = ["migrate"] } rocket_cors = "0.6.0" const_format = "0.2.33" hex = "0.4.3" -libsqlite3-sys = "0.25.1" +libsqlite3-sys = { version = "0.25.1", links = sqlx } +libsqlite3-sys = { version = "0.30.1", links = sqlite3 } From cf75e143f8228161bde6320ae631f454b1d22098 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:42:35 +0300 Subject: [PATCH 34/87] Update Cargo.toml --- server/central/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index 5ca06ae80..fae51ca37 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -21,5 +21,5 @@ sqlx = { version = "0.8.2", features = ["migrate"] } rocket_cors = "0.6.0" const_format = "0.2.33" hex = "0.4.3" -libsqlite3-sys = { version = "0.25.1", links = sqlx } -libsqlite3-sys = { version = "0.30.1", links = sqlite3 } +libsqlite3-sys = { version = "0.25.1", links = "sqlx" } +libsqlite3-sys = { version = "0.30.1", links = "sqlite3" } From 33b1c08cd6642a034f2aee3f45c383905c577055 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:43:44 +0300 Subject: [PATCH 35/87] Update Cargo.toml --- server/central/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index fae51ca37..b84c1aeb7 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -22,4 +22,3 @@ rocket_cors = "0.6.0" const_format = "0.2.33" hex = "0.4.3" libsqlite3-sys = { version = "0.25.1", links = "sqlx" } -libsqlite3-sys = { version = "0.30.1", links = "sqlite3" } From e3eb4021c38797711db71b68e1857700c9475b89 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:47:30 +0300 Subject: [PATCH 36/87] Update Cargo.toml --- server/central/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index b84c1aeb7..b84076abb 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -17,8 +17,7 @@ tokio = { version = "1.41.1", features = ["full"] } json_comments = "0.2.2" rocket = { version = "0.5.1", features = ["json"] } rocket_db_pools = { version = "0.2.0", features = ["sqlx_sqlite"] } -sqlx = { version = "0.8.2", features = ["migrate"] } +sqlx = { version = "0.6.3", features = ["migrate"] } rocket_cors = "0.6.0" const_format = "0.2.33" hex = "0.4.3" -libsqlite3-sys = { version = "0.25.1", links = "sqlx" } From e981178a850034c9c1ceafe204c06f6302335f04 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:54:18 +0300 Subject: [PATCH 37/87] try fxi --- server/derive/src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/derive/src/lib.rs b/server/derive/src/lib.rs index c3d7eb390..2d45e238e 100644 --- a/server/derive/src/lib.rs +++ b/server/derive/src/lib.rs @@ -25,7 +25,7 @@ pub fn derive_encodable(input: TokenStream) -> TokenStream { let struct_name = &input.ident; let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); - let gen = match &input.data { + let otherGen = match &input.data { Data::Struct(data) if let Some(bit_attrs) = bit_attrs => { encode::for_bit_struct(data, bit_attrs, struct_name, &impl_generics, &ty_generics, where_clause) } @@ -39,7 +39,7 @@ pub fn derive_encodable(input: TokenStream) -> TokenStream { } }; - gen.into() + otherGen.into() } /// Implements `Decodable` for the given type, allowing you to deserialize it from a `ByteReader`/`ByteBuffer`. @@ -54,7 +54,7 @@ pub fn derive_decodable(input: TokenStream) -> TokenStream { let struct_name = &input.ident; - let gen = match &input.data { + let otherGen = match &input.data { Data::Struct(data) if let Some(bit_attrs) = bit_attrs => decode::for_bit_struct(data, bit_attrs, struct_name), Data::Struct(data) => decode::for_struct(data, struct_name), Data::Enum(data) => decode::for_enum(data, struct_name, &get_enum_repr_type(&input)), @@ -66,7 +66,7 @@ pub fn derive_decodable(input: TokenStream) -> TokenStream { } }; - gen.into() + otherGen.into() } /// Implements `StaticSize` for the given type, allowing you to compute the encoded size of the value at compile time. @@ -111,14 +111,14 @@ pub fn derive_static_size(input: TokenStream) -> TokenStream { } }; - let gen = quote! { + let otherGen = quote! { impl StaticSize for #struct_name { const ENCODED_SIZE: usize = #encoded_size; } }; // Return the generated implementation as a TokenStream - gen.into() + otherGen.into() } /// Implements `DynamicSize` for the given type, allowing you to compute the encoded size of the value at runtime. @@ -190,7 +190,7 @@ pub fn derive_dynamic_size(input: TokenStream) -> TokenStream { } }; - let gen = quote! { + let otherGen = quote! { impl #impl_generics DynamicSize for #struct_name #ty_generics #where_clause { #[inline] fn encoded_size(&self) -> usize { @@ -200,7 +200,7 @@ pub fn derive_dynamic_size(input: TokenStream) -> TokenStream { }; // Return the generated implementation as a TokenStream - gen.into() + otherGen.into() } /// Implements `Packet`, `PacketMetadata` and the function `const fn header() -> PacketHeader` for the given struct. From 4b0a169712a6b616087da35f263cf435a950a4fe Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 15:59:19 +0300 Subject: [PATCH 38/87] fix --- server/shared/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shared/src/lib.rs b/server/shared/src/lib.rs index 8eb120a9c..071ebfe5f 100644 --- a/server/shared/src/lib.rs +++ b/server/shared/src/lib.rs @@ -58,7 +58,7 @@ pub const DEFAULT_CENTRAL_SERVER_PORT: u16 = 4201; pub const DEFAULT_GAME_SERVER_PORT: u16 = 4202; pub fn generate_alphanum_string(n: usize) -> String { - rand::thread_rng().sample_iter(&Alphanumeric).take(n).map(char::from).collect() + rand::rng().sample_iter(&Alphanumeric).take(n).map(char::from).collect() } pub fn get_log_level(env_var: &str) -> Option { From 3d28688cb6d005e7a208085fa3f73787b95da4ac Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:07:32 +0300 Subject: [PATCH 39/87] Update fast_string.rs --- server/esp/src/types/fast_string.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/esp/src/types/fast_string.rs b/server/esp/src/types/fast_string.rs index 9f726f2fe..5a0a0878b 100644 --- a/server/esp/src/types/fast_string.rs +++ b/server/esp/src/types/fast_string.rs @@ -295,7 +295,7 @@ impl FastString { /// Converts the string to a `&str`, bypassing utf-8 validation checks #[inline] - pub unsafe fn to_str_unchecked(&self) -> &str { + pub const unsafe fn to_str_unchecked(&self) -> &str { std::str::from_utf8_unchecked(self.as_bytes()) } From 3ec902c11a0969f261c9792474382e78d3a75f5e Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:09:27 +0300 Subject: [PATCH 40/87] Update fast_string.rs --- server/esp/src/types/fast_string.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/esp/src/types/fast_string.rs b/server/esp/src/types/fast_string.rs index 5a0a0878b..9f726f2fe 100644 --- a/server/esp/src/types/fast_string.rs +++ b/server/esp/src/types/fast_string.rs @@ -295,7 +295,7 @@ impl FastString { /// Converts the string to a `&str`, bypassing utf-8 validation checks #[inline] - pub const unsafe fn to_str_unchecked(&self) -> &str { + pub unsafe fn to_str_unchecked(&self) -> &str { std::str::from_utf8_unchecked(self.as_bytes()) } From 1fdb933e2997e27421493b42551d9a4893e787c5 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:14:13 +0300 Subject: [PATCH 41/87] should work now --- server/shared/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shared/src/lib.rs b/server/shared/src/lib.rs index 071ebfe5f..605a53120 100644 --- a/server/shared/src/lib.rs +++ b/server/shared/src/lib.rs @@ -8,7 +8,7 @@ use esp::{Decodable, DynamicSize, Encodable, StaticSize}; pub use globed_derive::{Decodable, DynamicSize, Encodable, StaticSize}; -use rand::{distributions::Alphanumeric, Rng}; +use rand::distributions::{Alphanumeric, Rng}; // import reexports pub use nohash_hasher::{IntMap, IntSet}; From dd8dd988f3a98bdce2c1b01b36d3d864a478eac1 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:16:04 +0300 Subject: [PATCH 42/87] pls work --- server/shared/src/token_issuer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/shared/src/token_issuer.rs b/server/shared/src/token_issuer.rs index ab59c86d6..13ad4b8f1 100644 --- a/server/shared/src/token_issuer.rs +++ b/server/shared/src/token_issuer.rs @@ -41,7 +41,7 @@ impl Display for TokenValidationFailure { impl TokenIssuer { pub fn new(secret_key: &str, expiration_period: Duration) -> Self { let skey_bytes = secret_key.as_bytes(); - let hmac = Hmac::::new_from_slice(skey_bytes).unwrap(); + let hmac = HmacSha256::new_from_slice(skey_bytes).unwrap(); Self { hmac, expiration_period } } @@ -49,7 +49,7 @@ impl TokenIssuer { /// Change the secret key of this token issuer. pub fn set_secret_key(&mut self, secret_key: &str) { let skey_bytes = secret_key.as_bytes(); - let hmac = Hmac::::new_from_slice(skey_bytes).unwrap(); + let hmac = HmacSha256::new_from_slice(skey_bytes).unwrap(); self.hmac = hmac; } From aae7f78bf369593b24bec0a23f38d4323276ed8d Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:20:40 +0300 Subject: [PATCH 43/87] PLEASE WORK. --- server/shared/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shared/src/lib.rs b/server/shared/src/lib.rs index 605a53120..78b6c0814 100644 --- a/server/shared/src/lib.rs +++ b/server/shared/src/lib.rs @@ -8,7 +8,7 @@ use esp::{Decodable, DynamicSize, Encodable, StaticSize}; pub use globed_derive::{Decodable, DynamicSize, Encodable, StaticSize}; -use rand::distributions::{Alphanumeric, Rng}; +use rand::distributions::Alphanumeric; // import reexports pub use nohash_hasher::{IntMap, IntSet}; From c46b21a134df2b7c44fd6046d63aa12c8ecf47ad Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:21:18 +0300 Subject: [PATCH 44/87] oopsiees --- server/shared/src/token_issuer.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/shared/src/token_issuer.rs b/server/shared/src/token_issuer.rs index 13ad4b8f1..ec9786af1 100644 --- a/server/shared/src/token_issuer.rs +++ b/server/shared/src/token_issuer.rs @@ -20,6 +20,8 @@ pub enum TokenValidationFailure { InvalidSignature, // signature does not match } +type HmacSha256 = Hmac; + impl TokenValidationFailure { pub const fn error_message(&self) -> &'static str { match self { From 608c92ccb1ef89567ae34f4237789dbff0cd0dca Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:22:17 +0300 Subject: [PATCH 45/87] should workkk nowwwww --- server/shared/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/server/shared/src/lib.rs b/server/shared/src/lib.rs index 78b6c0814..0db12f1c3 100644 --- a/server/shared/src/lib.rs +++ b/server/shared/src/lib.rs @@ -9,6 +9,7 @@ use esp::{Decodable, DynamicSize, Encodable, StaticSize}; pub use globed_derive::{Decodable, DynamicSize, Encodable, StaticSize}; use rand::distributions::Alphanumeric; +use rand::{Rng, thread_rng}; // import reexports pub use nohash_hasher::{IntMap, IntSet}; From 3a3ed10601a19b2e1b484774a903b777e50fba64 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:26:08 +0300 Subject: [PATCH 46/87] oops --- server/shared/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/shared/src/lib.rs b/server/shared/src/lib.rs index 0db12f1c3..b28e01822 100644 --- a/server/shared/src/lib.rs +++ b/server/shared/src/lib.rs @@ -8,9 +8,11 @@ use esp::{Decodable, DynamicSize, Encodable, StaticSize}; pub use globed_derive::{Decodable, DynamicSize, Encodable, StaticSize}; -use rand::distributions::Alphanumeric; +use rand::distr::{Alphanumeric, Rng}; use rand::{Rng, thread_rng}; +pub struct Alphanumeric; + // import reexports pub use nohash_hasher::{IntMap, IntSet}; pub use parking_lot::{ @@ -30,6 +32,7 @@ pub use rand; pub use reqwest; pub use sha2; pub use time; +pub use digest; // our reexports pub use crypto::*; pub use data::*; From f185a41f934f3394468173aafe6888ccd032da6e Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:26:45 +0300 Subject: [PATCH 47/87] fixes --- server/shared/src/token_issuer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shared/src/token_issuer.rs b/server/shared/src/token_issuer.rs index ec9786af1..193b62e76 100644 --- a/server/shared/src/token_issuer.rs +++ b/server/shared/src/token_issuer.rs @@ -4,7 +4,7 @@ use std::{ }; use base64::{engine::general_purpose as b64e, Engine}; -use hmac::{Hmac, Mac}; +use hmac::{Hmac, KeyInit, Mac}; use sha2::Sha256; pub struct TokenIssuer { From 87a66e1ee8dec473964783366ecda06a94173737 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:30:02 +0300 Subject: [PATCH 48/87] naother fix --- server/shared/src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/server/shared/src/lib.rs b/server/shared/src/lib.rs index b28e01822..333e35509 100644 --- a/server/shared/src/lib.rs +++ b/server/shared/src/lib.rs @@ -8,11 +8,9 @@ use esp::{Decodable, DynamicSize, Encodable, StaticSize}; pub use globed_derive::{Decodable, DynamicSize, Encodable, StaticSize}; -use rand::distr::{Alphanumeric, Rng}; +use rand::distr::Alphanumeric; use rand::{Rng, thread_rng}; -pub struct Alphanumeric; - // import reexports pub use nohash_hasher::{IntMap, IntSet}; pub use parking_lot::{ @@ -32,7 +30,6 @@ pub use rand; pub use reqwest; pub use sha2; pub use time; -pub use digest; // our reexports pub use crypto::*; pub use data::*; From 4cd52e52598b16c7f8beb9adf48a0daf05117a57 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:32:31 +0300 Subject: [PATCH 49/87] Update lib.rs --- server/derive/src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/derive/src/lib.rs b/server/derive/src/lib.rs index 2d45e238e..511d17749 100644 --- a/server/derive/src/lib.rs +++ b/server/derive/src/lib.rs @@ -25,7 +25,7 @@ pub fn derive_encodable(input: TokenStream) -> TokenStream { let struct_name = &input.ident; let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); - let otherGen = match &input.data { + let other_gen = match &input.data { Data::Struct(data) if let Some(bit_attrs) = bit_attrs => { encode::for_bit_struct(data, bit_attrs, struct_name, &impl_generics, &ty_generics, where_clause) } @@ -39,7 +39,7 @@ pub fn derive_encodable(input: TokenStream) -> TokenStream { } }; - otherGen.into() + other_gen.into() } /// Implements `Decodable` for the given type, allowing you to deserialize it from a `ByteReader`/`ByteBuffer`. @@ -54,7 +54,7 @@ pub fn derive_decodable(input: TokenStream) -> TokenStream { let struct_name = &input.ident; - let otherGen = match &input.data { + let other_gen = match &input.data { Data::Struct(data) if let Some(bit_attrs) = bit_attrs => decode::for_bit_struct(data, bit_attrs, struct_name), Data::Struct(data) => decode::for_struct(data, struct_name), Data::Enum(data) => decode::for_enum(data, struct_name, &get_enum_repr_type(&input)), @@ -66,7 +66,7 @@ pub fn derive_decodable(input: TokenStream) -> TokenStream { } }; - otherGen.into() + other_gen.into() } /// Implements `StaticSize` for the given type, allowing you to compute the encoded size of the value at compile time. @@ -111,14 +111,14 @@ pub fn derive_static_size(input: TokenStream) -> TokenStream { } }; - let otherGen = quote! { + let other_gen = quote! { impl StaticSize for #struct_name { const ENCODED_SIZE: usize = #encoded_size; } }; // Return the generated implementation as a TokenStream - otherGen.into() + other_gen.into() } /// Implements `DynamicSize` for the given type, allowing you to compute the encoded size of the value at runtime. @@ -190,7 +190,7 @@ pub fn derive_dynamic_size(input: TokenStream) -> TokenStream { } }; - let otherGen = quote! { + let other_gen = quote! { impl #impl_generics DynamicSize for #struct_name #ty_generics #where_clause { #[inline] fn encoded_size(&self) -> usize { @@ -200,7 +200,7 @@ pub fn derive_dynamic_size(input: TokenStream) -> TokenStream { }; // Return the generated implementation as a TokenStream - otherGen.into() + other_gen.into() } /// Implements `Packet`, `PacketMetadata` and the function `const fn header() -> PacketHeader` for the given struct. From e869a4999cd14cb3be6b1f17d22ed6db9aa9a1c8 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:33:05 +0300 Subject: [PATCH 50/87] Update socket.rs --- server/game/src/client/socket.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/client/socket.rs b/server/game/src/client/socket.rs index a697c32eb..201df2818 100644 --- a/server/game/src/client/socket.rs +++ b/server/game/src/client/socket.rs @@ -431,7 +431,7 @@ impl ClientSocket { let mut vec = vec![0u8; self.mtu]; let mut buf = FastByteBuffer::new(&mut vec[..]); - let unique_id: u32 = globed_shared::rand::thread_rng().gen(); + let unique_id: u32 = globed_shared::rand::thread_rng().other_gen(); // // ok let chunk_size = self.mtu - 8; From a32d94fb1bc6b8bf9403676884290b4c514a9660 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:34:00 +0300 Subject: [PATCH 51/87] Update unauthorized.rs --- server/game/src/client/unauthorized.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/client/unauthorized.rs b/server/game/src/client/unauthorized.rs index 7bc83e9cb..881da722e 100644 --- a/server/game/src/client/unauthorized.rs +++ b/server/game/src/client/unauthorized.rs @@ -81,7 +81,7 @@ impl UnauthorizedThread { socket: LockfreeMutCell::new(ClientSocket::new(socket, peer, 0, game_server)), connection_state: AtomicClientThreadState::default(), - secret_key: rand::thread_rng().gen(), + secret_key: rand::thread_rng().other_gen(), protocol_version: AtomicU16::new(0), account_id: AtomicI32::new(0), From e7e44915d5b9e250af470c8f50b0c8567bc38c89 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:34:35 +0300 Subject: [PATCH 52/87] fix --- server/game/src/client/thread.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/client/thread.rs b/server/game/src/client/thread.rs index cf8923a9a..6d2a62e6d 100644 --- a/server/game/src/client/thread.rs +++ b/server/game/src/client/thread.rs @@ -300,7 +300,7 @@ impl ClientThread { warn!("[{} @ {}] {}", self.account_id.load(Ordering::Relaxed), self.get_tcp_peer(), error); } - PacketHandlingError::IOError(ref e) => { + &PacketHandlingError::IOError(ref e) => { if !should_ignore_error(e) { warn!("[{} @ {}] {}", self.account_id.load(Ordering::Relaxed), self.get_tcp_peer(), e); } From dcf2a433c9e8fa0b5558baa854b6d2f7b5223182 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:40:34 +0300 Subject: [PATCH 53/87] Update socket.rs --- server/game/src/client/socket.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/client/socket.rs b/server/game/src/client/socket.rs index 201df2818..a697c32eb 100644 --- a/server/game/src/client/socket.rs +++ b/server/game/src/client/socket.rs @@ -431,7 +431,7 @@ impl ClientSocket { let mut vec = vec![0u8; self.mtu]; let mut buf = FastByteBuffer::new(&mut vec[..]); - let unique_id: u32 = globed_shared::rand::thread_rng().other_gen(); + let unique_id: u32 = globed_shared::rand::thread_rng().gen(); // // ok let chunk_size = self.mtu - 8; From 84c19012be8ed9fdd871c7dacb752670832923c0 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 16:40:54 +0300 Subject: [PATCH 54/87] Update unauthorized.rs --- server/game/src/client/unauthorized.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/client/unauthorized.rs b/server/game/src/client/unauthorized.rs index 881da722e..7bc83e9cb 100644 --- a/server/game/src/client/unauthorized.rs +++ b/server/game/src/client/unauthorized.rs @@ -81,7 +81,7 @@ impl UnauthorizedThread { socket: LockfreeMutCell::new(ClientSocket::new(socket, peer, 0, game_server)), connection_state: AtomicClientThreadState::default(), - secret_key: rand::thread_rng().other_gen(), + secret_key: rand::thread_rng().gen(), protocol_version: AtomicU16::new(0), account_id: AtomicI32::new(0), From b9559ee3e633d64af6b73a8b7cf907a4d5e6101f Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 17:33:48 +0300 Subject: [PATCH 55/87] Update unauthorized.rs --- server/game/src/client/unauthorized.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/client/unauthorized.rs b/server/game/src/client/unauthorized.rs index 7bc83e9cb..bc2c58039 100644 --- a/server/game/src/client/unauthorized.rs +++ b/server/game/src/client/unauthorized.rs @@ -81,7 +81,7 @@ impl UnauthorizedThread { socket: LockfreeMutCell::new(ClientSocket::new(socket, peer, 0, game_server)), connection_state: AtomicClientThreadState::default(), - secret_key: rand::thread_rng().gen(), + secret_key: rand::thread_rng().random(), protocol_version: AtomicU16::new(0), account_id: AtomicI32::new(0), From 7e45bb27036ac80925d2e9d0d7cb01421cea63f9 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:07:33 +0300 Subject: [PATCH 56/87] Update socket.rs --- server/game/src/client/socket.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/client/socket.rs b/server/game/src/client/socket.rs index a697c32eb..829f6cf45 100644 --- a/server/game/src/client/socket.rs +++ b/server/game/src/client/socket.rs @@ -431,7 +431,7 @@ impl ClientSocket { let mut vec = vec![0u8; self.mtu]; let mut buf = FastByteBuffer::new(&mut vec[..]); - let unique_id: u32 = globed_shared::rand::thread_rng().gen(); + let unique_id: u32 = globed_shared::rand::rng().random(); // // ok let chunk_size = self.mtu - 8; From 6b3751bcff95ecb95ee7d616dcc9123cb62d2e64 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:13:06 +0300 Subject: [PATCH 57/87] Update Cargo.toml --- server/central/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index b84076abb..e6b4dea77 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -17,7 +17,7 @@ tokio = { version = "1.41.1", features = ["full"] } json_comments = "0.2.2" rocket = { version = "0.5.1", features = ["json"] } rocket_db_pools = { version = "0.2.0", features = ["sqlx_sqlite"] } -sqlx = { version = "0.6.3", features = ["migrate"] } +sqlx = { version = "0.6.3", features = [ "runtime-tokio" ] } rocket_cors = "0.6.0" const_format = "0.2.33" hex = "0.4.3" From 9df0554fe7a6311fadd65be4819c733780ba5f2f Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:17:19 +0300 Subject: [PATCH 58/87] i suck --- server/central/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index e6b4dea77..0a20f78ae 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -17,7 +17,7 @@ tokio = { version = "1.41.1", features = ["full"] } json_comments = "0.2.2" rocket = { version = "0.5.1", features = ["json"] } rocket_db_pools = { version = "0.2.0", features = ["sqlx_sqlite"] } -sqlx = { version = "0.6.3", features = [ "runtime-tokio" ] } +sqlx = { version = "0.6.3", features = [ "runtime-tokio-native-tls" ] } rocket_cors = "0.6.0" const_format = "0.2.33" hex = "0.4.3" From 449c29a0f366f30cf798c10d104afe2f4ab7dd05 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:19:33 +0300 Subject: [PATCH 59/87] warning fix --- server/esp/src/types/fast_string.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/esp/src/types/fast_string.rs b/server/esp/src/types/fast_string.rs index 9f726f2fe..a175eb91e 100644 --- a/server/esp/src/types/fast_string.rs +++ b/server/esp/src/types/fast_string.rs @@ -295,8 +295,8 @@ impl FastString { /// Converts the string to a `&str`, bypassing utf-8 validation checks #[inline] - pub unsafe fn to_str_unchecked(&self) -> &str { - std::str::from_utf8_unchecked(self.as_bytes()) + pub fn to_str_unchecked(&self) -> &str { + unsafe std::str::from_utf8_unchecked(self.as_bytes()) } /// Converts the string to a `&str`, returns """ if utf-8 validation fails From 3853352687b57886b465f6091c04f625d2f426d8 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:20:49 +0300 Subject: [PATCH 60/87] fix warn --- server/esp/src/types/inline_string.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/esp/src/types/inline_string.rs b/server/esp/src/types/inline_string.rs index 17a0ff77c..713260169 100644 --- a/server/esp/src/types/inline_string.rs +++ b/server/esp/src/types/inline_string.rs @@ -119,7 +119,7 @@ impl InlineString { /// Converts this string to a string slice, without doing any UTF-8 checks. /// If the string is not a valid UTF-8 string, the behavior is undefined. #[inline] - pub unsafe fn to_str_unchecked(&self) -> &str { + pub fn to_str_unchecked(&self) -> &str { // in debug mode we still do a sanity check, a panic will indicate a *massive* logic error somewhere in the code. #[cfg(debug_assertions)] let ret = self @@ -127,7 +127,7 @@ impl InlineString { .expect("Attempted to unsafely convert a non-UTF-8 InlineString into a string slice"); #[cfg(not(debug_assertions))] - let ret = std::str::from_utf8_unchecked(&self.buffer[..self.len()]); + let ret = unsafe std::str::from_utf8_unchecked(&self.buffer[..self.len()]); ret } From 0df67cf53b009157310a486a2331efe17fda4151 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:22:39 +0300 Subject: [PATCH 61/87] fix warning --- server/shared/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shared/src/lib.rs b/server/shared/src/lib.rs index 333e35509..9bb31c6ea 100644 --- a/server/shared/src/lib.rs +++ b/server/shared/src/lib.rs @@ -9,7 +9,7 @@ use esp::{Decodable, DynamicSize, Encodable, StaticSize}; pub use globed_derive::{Decodable, DynamicSize, Encodable, StaticSize}; use rand::distr::Alphanumeric; -use rand::{Rng, thread_rng}; +use rand::prelude::*; // import reexports pub use nohash_hasher::{IntMap, IntSet}; From c93caa6697f9a618cb1ed7c18363307453bca8b7 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:24:02 +0300 Subject: [PATCH 62/87] Update unauthorized.rs --- server/game/src/client/unauthorized.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/client/unauthorized.rs b/server/game/src/client/unauthorized.rs index bc2c58039..72c577d9a 100644 --- a/server/game/src/client/unauthorized.rs +++ b/server/game/src/client/unauthorized.rs @@ -81,7 +81,7 @@ impl UnauthorizedThread { socket: LockfreeMutCell::new(ClientSocket::new(socket, peer, 0, game_server)), connection_state: AtomicClientThreadState::default(), - secret_key: rand::thread_rng().random(), + secret_key: rand::rng().random(), protocol_version: AtomicU16::new(0), account_id: AtomicI32::new(0), From 45aa84d07528b20dbc715c5a881b8969e523c275 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:24:29 +0300 Subject: [PATCH 63/87] Update room.rs --- server/game/src/managers/room.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/game/src/managers/room.rs b/server/game/src/managers/room.rs index 069d5d596..97a188309 100644 --- a/server/game/src/managers/room.rs +++ b/server/game/src/managers/room.rs @@ -244,9 +244,9 @@ impl RoomManager { pub fn create_room(&self, account_id: i32, name: InlineString<32>, password: InlineString<16>, settings: RoomSettings) -> Arc { let rooms = self.rooms.lock(); - // in case we accidentally generate an existing room id, keep looping until we find a suitable id + // in case we accidentally erate an existing room id, keep looping until we find a suitable id let room_id = loop { - let room_id = rand::thread_rng().gen_range(ROOM_ID_START..ROOM_ID_END); + let room_id = rand::rng().random_range(ROOM_ID_START..ROOM_ID_END); if !rooms.contains_key(&room_id) { break room_id; } From 2ae2c1b4eb164d6401a92f37cccd217c8d6a1c4f Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:25:29 +0300 Subject: [PATCH 64/87] Update channel.rs --- server/game/src/util/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/util/channel.rs b/server/game/src/util/channel.rs index b16beac08..4902a7e6a 100644 --- a/server/game/src/util/channel.rs +++ b/server/game/src/util/channel.rs @@ -33,7 +33,7 @@ impl TokioChannel { /// Safety: is guaranteed to be safe as long as you don't call it from multiple threads at once. pub async unsafe fn recv(&self) -> Result { - let chan = self.rx.get_mut(); + let chan = unsafe self.rx.get_mut(); chan.recv().await.ok_or(SenderDropped) } } From eac1191e615682dc1d63a51e50e0cce2d179d0a9 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:25:52 +0300 Subject: [PATCH 65/87] Update channel.rs --- server/game/src/util/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/util/channel.rs b/server/game/src/util/channel.rs index 4902a7e6a..f02098d93 100644 --- a/server/game/src/util/channel.rs +++ b/server/game/src/util/channel.rs @@ -32,7 +32,7 @@ impl TokioChannel { } /// Safety: is guaranteed to be safe as long as you don't call it from multiple threads at once. - pub async unsafe fn recv(&self) -> Result { + pub async fn recv(&self) -> Result { let chan = unsafe self.rx.get_mut(); chan.recv().await.ok_or(SenderDropped) } From cd7b5c2879141527f96544bb02a4f2d9fa6f5a1f Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:26:27 +0300 Subject: [PATCH 66/87] Update lockfreemutcell.rs --- server/game/src/util/lockfreemutcell.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/game/src/util/lockfreemutcell.rs b/server/game/src/util/lockfreemutcell.rs index 90bc2f43c..5b0240bca 100644 --- a/server/game/src/util/lockfreemutcell.rs +++ b/server/game/src/util/lockfreemutcell.rs @@ -13,8 +13,8 @@ impl LockfreeMutCell { } } - pub unsafe fn get(&self) -> &T { - &*self.cell.get() + pub fn get(&self) -> &T { + unsafe &*self.cell.get() } /// We trust you have received the usual lecture from the local System From a93bb15ffd043e94ab8ab992187edfda4c896dd2 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:27:11 +0300 Subject: [PATCH 67/87] unsure abt this one --- server/game/src/util/lockfreemutcell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/game/src/util/lockfreemutcell.rs b/server/game/src/util/lockfreemutcell.rs index 5b0240bca..df60f2aac 100644 --- a/server/game/src/util/lockfreemutcell.rs +++ b/server/game/src/util/lockfreemutcell.rs @@ -26,11 +26,11 @@ impl LockfreeMutCell { /// /// #3) With great power comes great responsibility. #[allow(clippy::mut_from_ref)] - pub unsafe fn get_mut(&self) -> &mut T { + pub fn get_mut(&self) -> &mut T { &mut *self.cell.get() } - pub unsafe fn swap(&self, new: T) -> T { - std::mem::replace(self.get_mut(), new) + pub fn swap(&self, new: T) -> T { + std::mem::replace(unsafe self.get_mut(), new) } } From 1e049ce887a510d518e0483e80823e7e01590271 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:36:45 +0300 Subject: [PATCH 68/87] fix --- server/esp/src/types/fast_string.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/esp/src/types/fast_string.rs b/server/esp/src/types/fast_string.rs index a175eb91e..aa4b9c605 100644 --- a/server/esp/src/types/fast_string.rs +++ b/server/esp/src/types/fast_string.rs @@ -296,7 +296,7 @@ impl FastString { /// Converts the string to a `&str`, bypassing utf-8 validation checks #[inline] pub fn to_str_unchecked(&self) -> &str { - unsafe std::str::from_utf8_unchecked(self.as_bytes()) + unsafe { std::str::from_utf8_unchecked(self.as_bytes()) } } /// Converts the string to a `&str`, returns """ if utf-8 validation fails From dbe10149c79cc57811cc55395b9a594a72b690d3 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:37:13 +0300 Subject: [PATCH 69/87] fix --- server/esp/src/types/inline_string.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/esp/src/types/inline_string.rs b/server/esp/src/types/inline_string.rs index 713260169..de1e97824 100644 --- a/server/esp/src/types/inline_string.rs +++ b/server/esp/src/types/inline_string.rs @@ -127,7 +127,7 @@ impl InlineString { .expect("Attempted to unsafely convert a non-UTF-8 InlineString into a string slice"); #[cfg(not(debug_assertions))] - let ret = unsafe std::str::from_utf8_unchecked(&self.buffer[..self.len()]); + let ret = unsafe { std::str::from_utf8_unchecked(&self.buffer[..self.len()]) }; ret } From 653ee50eb1bffac3825edbb6e608cb924f60ad19 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:38:57 +0300 Subject: [PATCH 70/87] [skip ci] comment fix --- server/game/src/managers/room.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/managers/room.rs b/server/game/src/managers/room.rs index 97a188309..be8a1ad6f 100644 --- a/server/game/src/managers/room.rs +++ b/server/game/src/managers/room.rs @@ -244,7 +244,7 @@ impl RoomManager { pub fn create_room(&self, account_id: i32, name: InlineString<32>, password: InlineString<16>, settings: RoomSettings) -> Arc { let rooms = self.rooms.lock(); - // in case we accidentally erate an existing room id, keep looping until we find a suitable id + // in case we accidentally generate an existing room id, keep looping until we find a suitable id let room_id = loop { let room_id = rand::rng().random_range(ROOM_ID_START..ROOM_ID_END); if !rooms.contains_key(&room_id) { From 768816e7090b022e0ccc85ded29d1aa02560e367 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:45:05 +0300 Subject: [PATCH 71/87] fixup --- server/game/src/util/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/util/channel.rs b/server/game/src/util/channel.rs index f02098d93..ac25e1d6b 100644 --- a/server/game/src/util/channel.rs +++ b/server/game/src/util/channel.rs @@ -33,7 +33,7 @@ impl TokioChannel { /// Safety: is guaranteed to be safe as long as you don't call it from multiple threads at once. pub async fn recv(&self) -> Result { - let chan = unsafe self.rx.get_mut(); + let chan = unsafe { self.rx.get_mut() }; chan.recv().await.ok_or(SenderDropped) } } From 0b19157d377f6eadffaf09c695998f12c964ed92 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:46:57 +0300 Subject: [PATCH 72/87] Update lockfreemutcell.rs --- server/game/src/util/lockfreemutcell.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/game/src/util/lockfreemutcell.rs b/server/game/src/util/lockfreemutcell.rs index df60f2aac..18170bbff 100644 --- a/server/game/src/util/lockfreemutcell.rs +++ b/server/game/src/util/lockfreemutcell.rs @@ -14,7 +14,7 @@ impl LockfreeMutCell { } pub fn get(&self) -> &T { - unsafe &*self.cell.get() + unsafe { &*self.cell.get() } } /// We trust you have received the usual lecture from the local System @@ -31,6 +31,6 @@ impl LockfreeMutCell { } pub fn swap(&self, new: T) -> T { - std::mem::replace(unsafe self.get_mut(), new) + std::mem::replace(unsafe { self.get_mut() }, new) } } From 678166242f240ddd58b16399c9a8150f78628bb3 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 18:50:02 +0300 Subject: [PATCH 73/87] Update thread.rs --- server/game/src/client/thread.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/game/src/client/thread.rs b/server/game/src/client/thread.rs index 6d2a62e6d..23646ceff 100644 --- a/server/game/src/client/thread.rs +++ b/server/game/src/client/thread.rs @@ -169,7 +169,7 @@ impl ClientThread { async fn poll_for_tcp_data(&self) -> Result { // safety: we trust this function is not called from the oustide - let sock = unsafe { self.socket.get_mut() }; + let sock = self.socket.get_mut(); sock.poll_for_tcp_data().await } @@ -276,7 +276,7 @@ impl ClientThread { /// get the tcp address of the connected peer. do not call this from another clientthread fn get_tcp_peer(&self) -> SocketAddrV4 { // safety: we trust this function is not called from the oustide - unsafe { self.socket.get() }.tcp_peer + self.socket.get().tcp_peer } // the error printing is different in release and debug. some errors have higher severity than others. @@ -361,13 +361,13 @@ impl ClientThread { } // safety: only we can access the rate limiters of our user. - let block = !unsafe { self.voice_rate_limiter.get_mut().try_tick() }; + let block = !self.voice_rate_limiter.get_mut().try_tick(); if block { return false; } } else { // if rate limiting is disabled, do not block - let block = !self.chat_rate_limiter.as_ref().map_or(true, |x| unsafe { x.get_mut().try_tick() }); + let block = !self.chat_rate_limiter.as_ref().map_or(true, |x| x.get_mut().try_tick()); if block { return false; @@ -380,7 +380,7 @@ impl ClientThread { #[inline] async fn recv_and_handle(&self, message_size: usize) -> Result<()> { // safety: only we can receive data from our client. - let socket = unsafe { self.socket.get_mut() }; + let socket = self.socket.get_mut(); socket.recv_and_handle(message_size, async |buf| self.handle_packet(buf).await).await } @@ -424,7 +424,7 @@ impl ClientThread { // if we are ratelimited, just discard the packet. // safety: only we can use this ratelimiter. - if !unsafe { self.rate_limiter.get_mut() }.try_tick() { + if !self.rate_limiter.get_mut().try_tick() { return Err(PacketHandlingError::Ratelimited); } @@ -447,7 +447,7 @@ impl ClientThread { // decrypt the packet in-place if encrypted if header.encrypted { - data = unsafe { self.socket.get_mut() }.decrypt(message)?; + data = self.socket.get_mut().decrypt(message)?; } match header.packet_id { @@ -510,12 +510,12 @@ impl ClientThread { #[inline] async fn send_packet_static(&self, packet: &P) -> Result<()> { - unsafe { self.socket.get_mut() }.send_packet_static(packet).await + self.socket.get_mut().send_packet_static(packet).await } #[inline] async fn send_packet_dynamic(&self, packet: &P) -> Result<()> { - unsafe { self.socket.get_mut() }.send_packet_dynamic(packet).await + self.socket.get_mut().send_packet_dynamic(packet).await } #[inline] @@ -529,7 +529,7 @@ impl ClientThread { where F: FnOnce(&mut FastByteBuffer), { - unsafe { self.socket.get_mut() } + self.socket.get_mut() .send_packet_alloca_with::(packet_size, encode_fn) .await } From 08268b9a2d0d272741c74d60f92bcdcd8179a6a5 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 19:18:55 +0300 Subject: [PATCH 74/87] Update unauthorized.rs --- server/game/src/client/unauthorized.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/game/src/client/unauthorized.rs b/server/game/src/client/unauthorized.rs index 72c577d9a..8e9775d18 100644 --- a/server/game/src/client/unauthorized.rs +++ b/server/game/src/client/unauthorized.rs @@ -345,7 +345,7 @@ impl UnauthorizedThread { ); } - unsafe { self.socket.get_mut() }.set_mtu(packet.fragmentation_limit as usize); + unsafe self.socket.get_mut().set_mtu(packet.fragmentation_limit as usize); if packet.account_id <= 0 || packet.user_id <= 0 { let message = Cow::Owned(format!( @@ -560,7 +560,7 @@ impl UnauthorizedThread { /// otherwise always invokes undefined behavior. #[allow(clippy::mut_from_ref)] fn get_socket(&self) -> &mut ClientSocket { - unsafe { self.socket.get_mut() } + unsafe self.socket.get_mut() } /// get the tcp address of the connected peer. do not call this from another clientthread From 9a811eb93ff2715d14cac1e0615d54725d96679f Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 19:20:26 +0300 Subject: [PATCH 75/87] Update server.rs --- server/game/src/server.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/game/src/server.rs b/server/game/src/server.rs index f15181d4f..84483e48c 100644 --- a/server/game/src/server.rs +++ b/server/game/src/server.rs @@ -317,7 +317,7 @@ impl GameServer { let thread = Arc::into_inner(thread).expect("failed to unwrap unauthorized thread"); // safety: the thread no longer runs and we are the only ones who can access the socket - let socket = unsafe { thread.socket.get() }; + let socket = thread.socket.get(); let udp_peer = socket.udp_peer.expect("upgraded thread has no udp peer assigned"); debug!("upgrading thread (new peer: tcp {}, udp {})", socket.tcp_peer, udp_peer); @@ -338,7 +338,7 @@ impl GameServer { let mut clients = self.clients.lock(); // safety: this is pretty unsafe // TODO - let udp_peer = unsafe { thread.socket.get() }.udp_peer.expect("no udp peer in established thread"); + let udp_peer = thread.socket.get().udp_peer.expect("no udp peer in established thread"); clients.remove(&udp_peer); } @@ -388,7 +388,7 @@ impl GameServer { }; // safety: the thread no longer runs and we are the only ones who can access the socket - let socket = unsafe { socket.get_mut() }; + let socket = socket.get_mut(); let _ = socket.shutdown().await; #[cfg(debug_assertions)] From 8a1a2b02e267109ac810996fba58093d93cc8835 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 19:21:11 +0300 Subject: [PATCH 76/87] Update lockfreemutcell.rs --- server/game/src/util/lockfreemutcell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/util/lockfreemutcell.rs b/server/game/src/util/lockfreemutcell.rs index 18170bbff..1b21d9146 100644 --- a/server/game/src/util/lockfreemutcell.rs +++ b/server/game/src/util/lockfreemutcell.rs @@ -27,7 +27,7 @@ impl LockfreeMutCell { /// #3) With great power comes great responsibility. #[allow(clippy::mut_from_ref)] pub fn get_mut(&self) -> &mut T { - &mut *self.cell.get() + &mut unsafe { *self.cell.get() } } pub fn swap(&self, new: T) -> T { From 2c609612bd317842422b13ff13fb57570dfe128e Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 19:22:36 +0300 Subject: [PATCH 77/87] Update lockfreemutcell.rs --- server/game/src/util/lockfreemutcell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/util/lockfreemutcell.rs b/server/game/src/util/lockfreemutcell.rs index 1b21d9146..542347f87 100644 --- a/server/game/src/util/lockfreemutcell.rs +++ b/server/game/src/util/lockfreemutcell.rs @@ -31,6 +31,6 @@ impl LockfreeMutCell { } pub fn swap(&self, new: T) -> T { - std::mem::replace(unsafe { self.get_mut() }, new) + std::mem::replace(self.get_mut(), new) } } From c822119335799c6be6c7f5da6f73505c92228d46 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 19:32:11 +0300 Subject: [PATCH 78/87] unsafe fixes --- server/game/src/client/unauthorized.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/game/src/client/unauthorized.rs b/server/game/src/client/unauthorized.rs index 8e9775d18..c02a9673c 100644 --- a/server/game/src/client/unauthorized.rs +++ b/server/game/src/client/unauthorized.rs @@ -345,7 +345,7 @@ impl UnauthorizedThread { ); } - unsafe self.socket.get_mut().set_mtu(packet.fragmentation_limit as usize); + unsafe { self.socket.get_mut().set_mtu(packet.fragmentation_limit as usize) }; if packet.account_id <= 0 || packet.user_id <= 0 { let message = Cow::Owned(format!( @@ -560,7 +560,7 @@ impl UnauthorizedThread { /// otherwise always invokes undefined behavior. #[allow(clippy::mut_from_ref)] fn get_socket(&self) -> &mut ClientSocket { - unsafe self.socket.get_mut() + unsafe { self.socket.get_mut() } } /// get the tcp address of the connected peer. do not call this from another clientthread From fff55f955ce0436e2d92bd4d465e4f714b205196 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 19:32:43 +0300 Subject: [PATCH 79/87] Update channel.rs --- server/game/src/util/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/util/channel.rs b/server/game/src/util/channel.rs index ac25e1d6b..4e9e881b0 100644 --- a/server/game/src/util/channel.rs +++ b/server/game/src/util/channel.rs @@ -33,7 +33,7 @@ impl TokioChannel { /// Safety: is guaranteed to be safe as long as you don't call it from multiple threads at once. pub async fn recv(&self) -> Result { - let chan = unsafe { self.rx.get_mut() }; + let chan = self.rx.get_mut(); chan.recv().await.ok_or(SenderDropped) } } From 17f3c5afba9581f6dfccd7ee5b25cbc139529712 Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 19:33:23 +0300 Subject: [PATCH 80/87] my bad --- server/game/src/util/lockfreemutcell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/game/src/util/lockfreemutcell.rs b/server/game/src/util/lockfreemutcell.rs index 542347f87..17a2169e9 100644 --- a/server/game/src/util/lockfreemutcell.rs +++ b/server/game/src/util/lockfreemutcell.rs @@ -27,7 +27,7 @@ impl LockfreeMutCell { /// #3) With great power comes great responsibility. #[allow(clippy::mut_from_ref)] pub fn get_mut(&self) -> &mut T { - &mut unsafe { *self.cell.get() } + unsafe { &mut *self.cell.get() } } pub fn swap(&self, new: T) -> T { From d3d215931a2396af63d2d2ec106977183767b1fc Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 19:38:35 +0300 Subject: [PATCH 81/87] Update game_pinger.rs --- server/central/src/game_pinger.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/central/src/game_pinger.rs b/server/central/src/game_pinger.rs index 973d077c0..24aa6861e 100644 --- a/server/central/src/game_pinger.rs +++ b/server/central/src/game_pinger.rs @@ -62,7 +62,7 @@ impl GameServerPinger { // ping packet LOL let mut buffer = ByteBuffer::new(); - let ping_id = rand::thread_rng().gen(); + let ping_id = rand::rng().random(); buffer.write_u16(10000); buffer.write_bool(false); buffer.write_u32(ping_id); From b01f42a81adae20bd57ab3a22f8a68e18ec11fab Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 19:45:03 +0300 Subject: [PATCH 82/87] rand fix --- server/central/src/state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/central/src/state.rs b/server/central/src/state.rs index 72c97a68d..db73b6efc 100644 --- a/server/central/src/state.rs +++ b/server/central/src/state.rs @@ -16,7 +16,7 @@ use globed_shared::{ crypto_box::aead::{generic_array::GenericArray, AeadMutInPlace}, crypto_secretbox::{KeyInit, XSalsa20Poly1305}, hmac::Hmac, - rand::{self, distributions::Alphanumeric, rngs::OsRng, Rng, RngCore}, + rand::prelude::*, reqwest, sha2::Sha256, TokenIssuer, From b9c43cc38c629a6673c9598fc1b19737df1f7aac Mon Sep 17 00:00:00 2001 From: larzie Date: Thu, 28 Nov 2024 19:46:48 +0300 Subject: [PATCH 83/87] done lol --- server/central/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index 0a20f78ae..fead0e181 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -17,7 +17,7 @@ tokio = { version = "1.41.1", features = ["full"] } json_comments = "0.2.2" rocket = { version = "0.5.1", features = ["json"] } rocket_db_pools = { version = "0.2.0", features = ["sqlx_sqlite"] } -sqlx = { version = "0.6.3", features = [ "runtime-tokio-native-tls" ] } +sqlx = { version = "0.6.3", features = ["migrate", "runtime-tokio-rustls"] } rocket_cors = "0.6.0" const_format = "0.2.33" hex = "0.4.3" From d6adce0e54ccd36a85616a44c2199bc4d10bc2e3 Mon Sep 17 00:00:00 2001 From: dankmeme01 <42031238+dankmeme01@users.noreply.github.com> Date: Fri, 29 Nov 2024 04:51:20 +0100 Subject: [PATCH 84/87] undo the unsafe changes and remove other thing --- .github/dependabot.yml | 8 ------- .github/workflows/server.yml | 2 +- ...d88c790e4d1591c109fea75e876ec0985a636.json | 12 ---------- ...3c5bf5b5188bc1dcc59cf82ce48e545d5b202.json | 12 ---------- ...8366f1eeb4092c19b9d26d36a64bfa1699f09.json | 12 ---------- ...a195453bfbe65cb946cd8947d258bbdc211a2.json | 12 ---------- ...2f3f2c76702a2b652c1117dbf26a7e87a145c.json | 12 ---------- ...19559d6b3a7c1129a958c63cd01cbde85d92a.json | 12 ---------- ...fdb1de0bee79e44a3abf777f24dc0c109f6ce.json | 12 ---------- ...c46156940b543d9eac2fb849db447bf70e1c7.json | 12 ---------- ...ff9dff12b8af3b967fde7d25b365913d8a38b.json | 12 ---------- ...470873eca6efbd365fc0d9bb18526b03376ba.json | 12 ---------- ...c8582c892d97cbbe2d00d1adc94f98e4dde4b.json | 12 ---------- ...f5e2b2084855e6f390c2479eba67b80282cee.json | 20 ----------------- server/esp/src/types/fast_string.rs | 2 +- server/esp/src/types/inline_string.rs | 2 +- server/game/src/client/thread.rs | 22 +++++++++---------- server/game/src/server.rs | 15 +++++++------ server/game/src/util/channel.rs | 4 ++-- server/game/src/util/lockfreemutcell.rs | 8 +++---- 20 files changed, 28 insertions(+), 187 deletions(-) delete mode 100644 server/central/.sqlx/query-02fa43600c4eff4f86ddbc97992d88c790e4d1591c109fea75e876ec0985a636.json delete mode 100644 server/central/.sqlx/query-1ff089a40bff1d9a3ddcc0749213c5bf5b5188bc1dcc59cf82ce48e545d5b202.json delete mode 100644 server/central/.sqlx/query-376106953cd01f83c2b238bf4fc8366f1eeb4092c19b9d26d36a64bfa1699f09.json delete mode 100644 server/central/.sqlx/query-4337dcb463e9d99e77db62fccb0a195453bfbe65cb946cd8947d258bbdc211a2.json delete mode 100644 server/central/.sqlx/query-4baf83134ee0bba1b75ef59967b2f3f2c76702a2b652c1117dbf26a7e87a145c.json delete mode 100644 server/central/.sqlx/query-6a88f2c9a00b65da29e7d1d9ae619559d6b3a7c1129a958c63cd01cbde85d92a.json delete mode 100644 server/central/.sqlx/query-895e830e224326e0e5ef6bfc270fdb1de0bee79e44a3abf777f24dc0c109f6ce.json delete mode 100644 server/central/.sqlx/query-a5d1f830c3e857f94bcaf864f8ec46156940b543d9eac2fb849db447bf70e1c7.json delete mode 100644 server/central/.sqlx/query-ac970b41481290e1551ef4583b4ff9dff12b8af3b967fde7d25b365913d8a38b.json delete mode 100644 server/central/.sqlx/query-cf94857754d165844cbf1152671470873eca6efbd365fc0d9bb18526b03376ba.json delete mode 100644 server/central/.sqlx/query-f5d8599ac03d46ece0e7521bb7fc8582c892d97cbbe2d00d1adc94f98e4dde4b.json delete mode 100644 server/central/.sqlx/query-f965a50418d0ec1f71c3fea4a82f5e2b2084855e6f390c2479eba67b80282cee.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c95d49663..fd11b04c9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -16,14 +16,6 @@ updates: directory: "/server/game" schedule: interval: "daily" - - package-ecosystem: "cargo" - directory: "/server/observer-shared" - schedule: - interval: "daily" - - package-ecosystem: "cargo" - directory: "/server/observer" - schedule: - interval: "daily" - package-ecosystem: "cargo" directory: "/server/shared" schedule: diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index 347b59747..a2756d0ac 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -16,7 +16,7 @@ jobs: target: x86_64-unknown-linux-gnu bin-suffix: "-x64" - - name: Linux Arm64 + - name: Linux ARM64 os: ubuntu-latest target: aarch64-unknown-linux-gnu bin-suffix: "-arm64" diff --git a/server/central/.sqlx/query-02fa43600c4eff4f86ddbc97992d88c790e4d1591c109fea75e876ec0985a636.json b/server/central/.sqlx/query-02fa43600c4eff4f86ddbc97992d88c790e4d1591c109fea75e876ec0985a636.json deleted file mode 100644 index 06f4e7979..000000000 --- a/server/central/.sqlx/query-02fa43600c4eff4f86ddbc97992d88c790e4d1591c109fea75e876ec0985a636.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE users SET active_mute = NULL WHERE account_id = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 1 - }, - "nullable": [] - }, - "hash": "02fa43600c4eff4f86ddbc97992d88c790e4d1591c109fea75e876ec0985a636" -} diff --git a/server/central/.sqlx/query-1ff089a40bff1d9a3ddcc0749213c5bf5b5188bc1dcc59cf82ce48e545d5b202.json b/server/central/.sqlx/query-1ff089a40bff1d9a3ddcc0749213c5bf5b5188bc1dcc59cf82ce48e545d5b202.json deleted file mode 100644 index fa0701aad..000000000 --- a/server/central/.sqlx/query-1ff089a40bff1d9a3ddcc0749213c5bf5b5188bc1dcc59cf82ce48e545d5b202.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE users SET user_name = ? WHERE account_id = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - }, - "hash": "1ff089a40bff1d9a3ddcc0749213c5bf5b5188bc1dcc59cf82ce48e545d5b202" -} diff --git a/server/central/.sqlx/query-376106953cd01f83c2b238bf4fc8366f1eeb4092c19b9d26d36a64bfa1699f09.json b/server/central/.sqlx/query-376106953cd01f83c2b238bf4fc8366f1eeb4092c19b9d26d36a64bfa1699f09.json deleted file mode 100644 index b78bb0fd0..000000000 --- a/server/central/.sqlx/query-376106953cd01f83c2b238bf4fc8366f1eeb4092c19b9d26d36a64bfa1699f09.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE users SET user_roles = ? WHERE account_id = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - }, - "hash": "376106953cd01f83c2b238bf4fc8366f1eeb4092c19b9d26d36a64bfa1699f09" -} diff --git a/server/central/.sqlx/query-4337dcb463e9d99e77db62fccb0a195453bfbe65cb946cd8947d258bbdc211a2.json b/server/central/.sqlx/query-4337dcb463e9d99e77db62fccb0a195453bfbe65cb946cd8947d258bbdc211a2.json deleted file mode 100644 index 275059df3..000000000 --- a/server/central/.sqlx/query-4337dcb463e9d99e77db62fccb0a195453bfbe65cb946cd8947d258bbdc211a2.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE users SET admin_password_hash = ? WHERE account_id = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - }, - "hash": "4337dcb463e9d99e77db62fccb0a195453bfbe65cb946cd8947d258bbdc211a2" -} diff --git a/server/central/.sqlx/query-4baf83134ee0bba1b75ef59967b2f3f2c76702a2b652c1117dbf26a7e87a145c.json b/server/central/.sqlx/query-4baf83134ee0bba1b75ef59967b2f3f2c76702a2b652c1117dbf26a7e87a145c.json deleted file mode 100644 index b1517d433..000000000 --- a/server/central/.sqlx/query-4baf83134ee0bba1b75ef59967b2f3f2c76702a2b652c1117dbf26a7e87a145c.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE punishments SET reason = ?, expires_at = ? WHERE punishment_id = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 3 - }, - "nullable": [] - }, - "hash": "4baf83134ee0bba1b75ef59967b2f3f2c76702a2b652c1117dbf26a7e87a145c" -} diff --git a/server/central/.sqlx/query-6a88f2c9a00b65da29e7d1d9ae619559d6b3a7c1129a958c63cd01cbde85d92a.json b/server/central/.sqlx/query-6a88f2c9a00b65da29e7d1d9ae619559d6b3a7c1129a958c63cd01cbde85d92a.json deleted file mode 100644 index 3e87b5f57..000000000 --- a/server/central/.sqlx/query-6a88f2c9a00b65da29e7d1d9ae619559d6b3a7c1129a958c63cd01cbde85d92a.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE users SET name_color = ? WHERE account_id = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - }, - "hash": "6a88f2c9a00b65da29e7d1d9ae619559d6b3a7c1129a958c63cd01cbde85d92a" -} diff --git a/server/central/.sqlx/query-895e830e224326e0e5ef6bfc270fdb1de0bee79e44a3abf777f24dc0c109f6ce.json b/server/central/.sqlx/query-895e830e224326e0e5ef6bfc270fdb1de0bee79e44a3abf777f24dc0c109f6ce.json deleted file mode 100644 index 307131db0..000000000 --- a/server/central/.sqlx/query-895e830e224326e0e5ef6bfc270fdb1de0bee79e44a3abf777f24dc0c109f6ce.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE users SET active_ban = NULL WHERE account_id = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 1 - }, - "nullable": [] - }, - "hash": "895e830e224326e0e5ef6bfc270fdb1de0bee79e44a3abf777f24dc0c109f6ce" -} diff --git a/server/central/.sqlx/query-a5d1f830c3e857f94bcaf864f8ec46156940b543d9eac2fb849db447bf70e1c7.json b/server/central/.sqlx/query-a5d1f830c3e857f94bcaf864f8ec46156940b543d9eac2fb849db447bf70e1c7.json deleted file mode 100644 index ac1d6b975..000000000 --- a/server/central/.sqlx/query-a5d1f830c3e857f94bcaf864f8ec46156940b543d9eac2fb849db447bf70e1c7.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE users SET active_mute = ? WHERE account_id = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - }, - "hash": "a5d1f830c3e857f94bcaf864f8ec46156940b543d9eac2fb849db447bf70e1c7" -} diff --git a/server/central/.sqlx/query-ac970b41481290e1551ef4583b4ff9dff12b8af3b967fde7d25b365913d8a38b.json b/server/central/.sqlx/query-ac970b41481290e1551ef4583b4ff9dff12b8af3b967fde7d25b365913d8a38b.json deleted file mode 100644 index 231d54e27..000000000 --- a/server/central/.sqlx/query-ac970b41481290e1551ef4583b4ff9dff12b8af3b967fde7d25b365913d8a38b.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE users SET active_ban = ? WHERE account_id = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - }, - "hash": "ac970b41481290e1551ef4583b4ff9dff12b8af3b967fde7d25b365913d8a38b" -} diff --git a/server/central/.sqlx/query-cf94857754d165844cbf1152671470873eca6efbd365fc0d9bb18526b03376ba.json b/server/central/.sqlx/query-cf94857754d165844cbf1152671470873eca6efbd365fc0d9bb18526b03376ba.json deleted file mode 100644 index 1a11a1340..000000000 --- a/server/central/.sqlx/query-cf94857754d165844cbf1152671470873eca6efbd365fc0d9bb18526b03376ba.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "INSERT INTO users (account_id) VALUES (?) ON CONFLICT DO NOTHING", - "describe": { - "columns": [], - "parameters": { - "Right": 1 - }, - "nullable": [] - }, - "hash": "cf94857754d165844cbf1152671470873eca6efbd365fc0d9bb18526b03376ba" -} diff --git a/server/central/.sqlx/query-f5d8599ac03d46ece0e7521bb7fc8582c892d97cbbe2d00d1adc94f98e4dde4b.json b/server/central/.sqlx/query-f5d8599ac03d46ece0e7521bb7fc8582c892d97cbbe2d00d1adc94f98e4dde4b.json deleted file mode 100644 index c5565b8ac..000000000 --- a/server/central/.sqlx/query-f5d8599ac03d46ece0e7521bb7fc8582c892d97cbbe2d00d1adc94f98e4dde4b.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "UPDATE users SET is_whitelisted = ? WHERE account_id = ?", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - }, - "hash": "f5d8599ac03d46ece0e7521bb7fc8582c892d97cbbe2d00d1adc94f98e4dde4b" -} diff --git a/server/central/.sqlx/query-f965a50418d0ec1f71c3fea4a82f5e2b2084855e6f390c2479eba67b80282cee.json b/server/central/.sqlx/query-f965a50418d0ec1f71c3fea4a82f5e2b2084855e6f390c2479eba67b80282cee.json deleted file mode 100644 index 4a1d54cbe..000000000 --- a/server/central/.sqlx/query-f965a50418d0ec1f71c3fea4a82f5e2b2084855e6f390c2479eba67b80282cee.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "db_name": "SQLite", - "query": "INSERT INTO punishments (account_id, type, reason, expires_at, issued_at, issued_by) VALUES (?, ?, ?, ?, ?, ?) RETURNING punishment_id", - "describe": { - "columns": [ - { - "name": "punishment_id", - "ordinal": 0, - "type_info": "Int64" - } - ], - "parameters": { - "Right": 6 - }, - "nullable": [ - false - ] - }, - "hash": "f965a50418d0ec1f71c3fea4a82f5e2b2084855e6f390c2479eba67b80282cee" -} diff --git a/server/esp/src/types/fast_string.rs b/server/esp/src/types/fast_string.rs index aa4b9c605..ddcaa00b0 100644 --- a/server/esp/src/types/fast_string.rs +++ b/server/esp/src/types/fast_string.rs @@ -295,7 +295,7 @@ impl FastString { /// Converts the string to a `&str`, bypassing utf-8 validation checks #[inline] - pub fn to_str_unchecked(&self) -> &str { + pub unsafe fn to_str_unchecked(&self) -> &str { unsafe { std::str::from_utf8_unchecked(self.as_bytes()) } } diff --git a/server/esp/src/types/inline_string.rs b/server/esp/src/types/inline_string.rs index de1e97824..031710059 100644 --- a/server/esp/src/types/inline_string.rs +++ b/server/esp/src/types/inline_string.rs @@ -119,7 +119,7 @@ impl InlineString { /// Converts this string to a string slice, without doing any UTF-8 checks. /// If the string is not a valid UTF-8 string, the behavior is undefined. #[inline] - pub fn to_str_unchecked(&self) -> &str { + pub unsafe fn to_str_unchecked(&self) -> &str { // in debug mode we still do a sanity check, a panic will indicate a *massive* logic error somewhere in the code. #[cfg(debug_assertions)] let ret = self diff --git a/server/game/src/client/thread.rs b/server/game/src/client/thread.rs index 23646ceff..415346aad 100644 --- a/server/game/src/client/thread.rs +++ b/server/game/src/client/thread.rs @@ -3,8 +3,8 @@ use std::{ collections::VecDeque, net::SocketAddrV4, sync::{ - atomic::{AtomicBool, AtomicI32, AtomicU16, AtomicU32, Ordering}, Arc, + atomic::{AtomicBool, AtomicI32, AtomicU16, AtomicU32, Ordering}, }, time::Duration, }; @@ -17,7 +17,7 @@ use crate::{ }, }; use esp::ByteReader; -use globed_shared::{logger::*, should_ignore_error, ServerUserEntry, SyncMutex}; +use globed_shared::{ServerUserEntry, SyncMutex, logger::*, should_ignore_error}; use handlers::game::MAX_VOICE_PACKET_SIZE; use tokio::time::Instant; @@ -169,7 +169,7 @@ impl ClientThread { async fn poll_for_tcp_data(&self) -> Result { // safety: we trust this function is not called from the oustide - let sock = self.socket.get_mut(); + let sock = unsafe { self.socket.get_mut() }; sock.poll_for_tcp_data().await } @@ -361,13 +361,13 @@ impl ClientThread { } // safety: only we can access the rate limiters of our user. - let block = !self.voice_rate_limiter.get_mut().try_tick(); + let block = !unsafe { self.voice_rate_limiter.get_mut().try_tick() }; if block { return false; } } else { // if rate limiting is disabled, do not block - let block = !self.chat_rate_limiter.as_ref().map_or(true, |x| x.get_mut().try_tick()); + let block = !self.chat_rate_limiter.as_ref().map_or(true, |x| unsafe { x.get_mut().try_tick() }); if block { return false; @@ -380,7 +380,7 @@ impl ClientThread { #[inline] async fn recv_and_handle(&self, message_size: usize) -> Result<()> { // safety: only we can receive data from our client. - let socket = self.socket.get_mut(); + let socket = unsafe { self.socket.get_mut() }; socket.recv_and_handle(message_size, async |buf| self.handle_packet(buf).await).await } @@ -424,7 +424,7 @@ impl ClientThread { // if we are ratelimited, just discard the packet. // safety: only we can use this ratelimiter. - if !self.rate_limiter.get_mut().try_tick() { + if !unsafe { self.rate_limiter.get_mut() }.try_tick() { return Err(PacketHandlingError::Ratelimited); } @@ -447,7 +447,7 @@ impl ClientThread { // decrypt the packet in-place if encrypted if header.encrypted { - data = self.socket.get_mut().decrypt(message)?; + data = unsafe { self.socket.get_mut().decrypt(message)? }; } match header.packet_id { @@ -510,12 +510,12 @@ impl ClientThread { #[inline] async fn send_packet_static(&self, packet: &P) -> Result<()> { - self.socket.get_mut().send_packet_static(packet).await + unsafe { self.socket.get_mut() }.send_packet_static(packet).await } #[inline] async fn send_packet_dynamic(&self, packet: &P) -> Result<()> { - self.socket.get_mut().send_packet_dynamic(packet).await + unsafe { self.socket.get_mut() }.send_packet_dynamic(packet).await } #[inline] @@ -529,7 +529,7 @@ impl ClientThread { where F: FnOnce(&mut FastByteBuffer), { - self.socket.get_mut() + unsafe { self.socket.get_mut() } .send_packet_alloca_with::(packet_size, encode_fn) .await } diff --git a/server/game/src/server.rs b/server/game/src/server.rs index 84483e48c..4eff873f9 100644 --- a/server/game/src/server.rs +++ b/server/game/src/server.rs @@ -1,16 +1,17 @@ use std::{ collections::VecDeque, net::{SocketAddr, SocketAddrV4}, - sync::{atomic::Ordering, Arc}, + sync::{Arc, atomic::Ordering}, time::Duration, }; use globed_shared::{ + ServerUserEntry, SyncMutex, anyhow::{self, anyhow, bail}, - crypto_box::{aead::OsRng, PublicKey, SecretKey}, + crypto_box::{PublicKey, SecretKey, aead::OsRng}, esp::ByteBufferExtWrite as _, logger::*, - should_ignore_error, ServerUserEntry, SyncMutex, + should_ignore_error, }; use rustc_hash::FxHashMap; use tokio::{ @@ -33,7 +34,7 @@ use crate::{ use crate::{ bridge::{self, CentralBridge}, - client::{thread::ClientThreadOutcome, unauthorized::UnauthorizedThread, ClientThread, ServerThreadMessage, UnauthorizedThreadOutcome}, + client::{ClientThread, ServerThreadMessage, UnauthorizedThreadOutcome, thread::ClientThreadOutcome, unauthorized::UnauthorizedThread}, data::*, state::ServerState, }; @@ -317,7 +318,7 @@ impl GameServer { let thread = Arc::into_inner(thread).expect("failed to unwrap unauthorized thread"); // safety: the thread no longer runs and we are the only ones who can access the socket - let socket = thread.socket.get(); + let socket = unsafe { thread.socket.get() }; let udp_peer = socket.udp_peer.expect("upgraded thread has no udp peer assigned"); debug!("upgrading thread (new peer: tcp {}, udp {})", socket.tcp_peer, udp_peer); @@ -338,7 +339,7 @@ impl GameServer { let mut clients = self.clients.lock(); // safety: this is pretty unsafe // TODO - let udp_peer = thread.socket.get().udp_peer.expect("no udp peer in established thread"); + let udp_peer = unsafe { thread.socket.get() }.udp_peer.expect("no udp peer in established thread"); clients.remove(&udp_peer); } @@ -388,7 +389,7 @@ impl GameServer { }; // safety: the thread no longer runs and we are the only ones who can access the socket - let socket = socket.get_mut(); + let socket = unsafe { socket.get_mut() }; let _ = socket.shutdown().await; #[cfg(debug_assertions)] diff --git a/server/game/src/util/channel.rs b/server/game/src/util/channel.rs index 4e9e881b0..9be930c5a 100644 --- a/server/game/src/util/channel.rs +++ b/server/game/src/util/channel.rs @@ -32,8 +32,8 @@ impl TokioChannel { } /// Safety: is guaranteed to be safe as long as you don't call it from multiple threads at once. - pub async fn recv(&self) -> Result { - let chan = self.rx.get_mut(); + pub async unsafe fn recv(&self) -> Result { + let chan = unsafe { self.rx.get_mut() }; chan.recv().await.ok_or(SenderDropped) } } diff --git a/server/game/src/util/lockfreemutcell.rs b/server/game/src/util/lockfreemutcell.rs index 17a2169e9..0842bd968 100644 --- a/server/game/src/util/lockfreemutcell.rs +++ b/server/game/src/util/lockfreemutcell.rs @@ -13,7 +13,7 @@ impl LockfreeMutCell { } } - pub fn get(&self) -> &T { + pub unsafe fn get(&self) -> &T { unsafe { &*self.cell.get() } } @@ -26,11 +26,11 @@ impl LockfreeMutCell { /// /// #3) With great power comes great responsibility. #[allow(clippy::mut_from_ref)] - pub fn get_mut(&self) -> &mut T { + pub unsafe fn get_mut(&self) -> &mut T { unsafe { &mut *self.cell.get() } } - pub fn swap(&self, new: T) -> T { - std::mem::replace(self.get_mut(), new) + pub unsafe fn swap(&self, new: T) -> T { + std::mem::replace(unsafe { self.get_mut() }, new) } } From 7b0883c5ef8594b91d837d834f26603b971d9a95 Mon Sep 17 00:00:00 2001 From: dankmeme01 <42031238+dankmeme01@users.noreply.github.com> Date: Sun, 1 Dec 2024 13:47:04 +0100 Subject: [PATCH 85/87] fix minor issues and bump deps --- server/central/src/web/routes/auth.rs | 10 +++++----- server/central/src/web/routes/meta.rs | 9 ++++----- server/derive/Cargo.toml | 2 +- server/game/Cargo.toml | 2 +- server/game/src/client/thread.rs | 4 ++-- server/shared/Cargo.toml | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/server/central/src/web/routes/auth.rs b/server/central/src/web/routes/auth.rs index f70ba2194..a72a1df1f 100644 --- a/server/central/src/web/routes/auth.rs +++ b/server/central/src/web/routes/auth.rs @@ -1,15 +1,15 @@ use std::{net::IpAddr, time::SystemTime}; -use digest::KeyInit; -use rocket::{post, State}; +use rocket::{State, post}; use serde::Deserialize; use globed_shared::{ + MIN_CLIENT_VERSION, anyhow::{self, anyhow}, - base64::{engine::general_purpose as b64e, Engine as _}, + base64::{Engine as _, engine::general_purpose as b64e}, crypto_box::aead::Aead, + crypto_secretbox::{KeyInit, XSalsa20Poly1305}, logger::*, - MIN_CLIENT_VERSION, }; use super::*; @@ -229,7 +229,7 @@ fn decrypt_trust_token(token: &str, key: &str) -> WebResult> { let mut key_arr = [0u8; 32]; key_arr.copy_from_slice(&key); - let cipher = globed_shared::crypto_secretbox::XSalsa20Poly1305::new((&key_arr).into()); + let cipher = XSalsa20Poly1305::new((&key_arr).into()); let nonce = encrypted[..24].into(); let ciphertext = &encrypted[24..]; diff --git a/server/central/src/web/routes/meta.rs b/server/central/src/web/routes/meta.rs index 087ab9720..1223c8547 100644 --- a/server/central/src/web/routes/meta.rs +++ b/server/central/src/web/routes/meta.rs @@ -1,17 +1,16 @@ use std::sync::OnceLock; use globed_shared::{ - base64::{engine::general_purpose as b64e, Engine as _}, + MAX_SUPPORTED_PROTOCOL, MIN_CLIENT_VERSION, MIN_GD_VERSION, MIN_SUPPORTED_PROTOCOL, SERVER_MAGIC, + base64::{Engine as _, engine::general_purpose as b64e}, esp::{ByteBuffer, ByteBufferExt, ByteBufferExtWrite}, rand::{self, Rng}, - MAX_SUPPORTED_PROTOCOL, MIN_CLIENT_VERSION, MIN_GD_VERSION, MIN_SUPPORTED_PROTOCOL, SERVER_MAGIC, }; use rocket::{ - get, + State, get, http::{ContentType, Status}, serde::json::Json, - State, }; use serde::Serialize; @@ -76,7 +75,7 @@ pub fn versioncheck(gd: &str, globed: &str, protocol: u16) -> WebResult (Status, (ContentType, String)) { - if rand::thread_rng().gen_ratio(1, 0xaa) { + if rand::rng().random_ratio(1, 0xaa) { return _check(); } diff --git a/server/derive/Cargo.toml b/server/derive/Cargo.toml index de13b5db1..68a45441d 100644 --- a/server/derive/Cargo.toml +++ b/server/derive/Cargo.toml @@ -10,4 +10,4 @@ proc-macro = true darling = "0.20.10" proc-macro2 = "1.0.92" quote = "1.0.37" -syn = { version = "2.0.89", features = ["full"] } +syn = { version = "2.0.90", features = ["full"] } diff --git a/server/game/Cargo.toml b/server/game/Cargo.toml index 37eae71fd..f95187e44 100644 --- a/server/game/Cargo.toml +++ b/server/game/Cargo.toml @@ -10,7 +10,7 @@ esp = { path = "../esp" } alloca = "0.4.0" ctrlc = "3.4.5" -rustc-hash = "2.0.0" +rustc-hash = "2.1.0" serde = { version = "1.0.215", features = ["serde_derive"] } serde_json = "1.0.133" futures-util = "0.3.31" diff --git a/server/game/src/client/thread.rs b/server/game/src/client/thread.rs index 415346aad..1c9d2b053 100644 --- a/server/game/src/client/thread.rs +++ b/server/game/src/client/thread.rs @@ -276,7 +276,7 @@ impl ClientThread { /// get the tcp address of the connected peer. do not call this from another clientthread fn get_tcp_peer(&self) -> SocketAddrV4 { // safety: we trust this function is not called from the oustide - self.socket.get().tcp_peer + unsafe { self.socket.get() }.tcp_peer } // the error printing is different in release and debug. some errors have higher severity than others. @@ -300,7 +300,7 @@ impl ClientThread { warn!("[{} @ {}] {}", self.account_id.load(Ordering::Relaxed), self.get_tcp_peer(), error); } - &PacketHandlingError::IOError(ref e) => { + PacketHandlingError::IOError(e) => { if !should_ignore_error(e) { warn!("[{} @ {}] {}", self.account_id.load(Ordering::Relaxed), self.get_tcp_peer(), e); } diff --git a/server/shared/Cargo.toml b/server/shared/Cargo.toml index 4d43cb9db..78b3727c2 100644 --- a/server/shared/Cargo.toml +++ b/server/shared/Cargo.toml @@ -15,7 +15,7 @@ hmac = "0.13.0-pre.4" log = "0.4.22" nohash-hasher = "0.2.0" parking_lot = "0.12.3" -rand = "0.9.0-beta.0" +rand = "0.9.0-beta.1" reqwest = { version = "0.12.9", default-features = false, features = [ "rustls-tls", ] } From 8dcfc39d6efc0d24a4b39b931b479ee627061843 Mon Sep 17 00:00:00 2001 From: dankmeme01 <42031238+dankmeme01@users.noreply.github.com> Date: Sun, 1 Dec 2024 13:52:17 +0100 Subject: [PATCH 86/87] fix KeyInit compile errors --- ...d88c790e4d1591c109fea75e876ec0985a636.json | 12 +++++++ ...3c5bf5b5188bc1dcc59cf82ce48e545d5b202.json | 12 +++++++ ...8366f1eeb4092c19b9d26d36a64bfa1699f09.json | 12 +++++++ ...a195453bfbe65cb946cd8947d258bbdc211a2.json | 12 +++++++ ...2f3f2c76702a2b652c1117dbf26a7e87a145c.json | 12 +++++++ ...19559d6b3a7c1129a958c63cd01cbde85d92a.json | 12 +++++++ ...fdb1de0bee79e44a3abf777f24dc0c109f6ce.json | 12 +++++++ ...c46156940b543d9eac2fb849db447bf70e1c7.json | 12 +++++++ ...ff9dff12b8af3b967fde7d25b365913d8a38b.json | 12 +++++++ ...470873eca6efbd365fc0d9bb18526b03376ba.json | 12 +++++++ ...c8582c892d97cbbe2d00d1adc94f98e4dde4b.json | 12 +++++++ ...f5e2b2084855e6f390c2479eba67b80282cee.json | 20 +++++++++++ server/central/Cargo.toml | 5 ++- server/central/src/state.rs | 36 +++++++++---------- server/central/src/web/routes/user.rs | 7 ++-- 15 files changed, 176 insertions(+), 24 deletions(-) create mode 100644 server/central/.sqlx/query-02fa43600c4eff4f86ddbc97992d88c790e4d1591c109fea75e876ec0985a636.json create mode 100644 server/central/.sqlx/query-1ff089a40bff1d9a3ddcc0749213c5bf5b5188bc1dcc59cf82ce48e545d5b202.json create mode 100644 server/central/.sqlx/query-376106953cd01f83c2b238bf4fc8366f1eeb4092c19b9d26d36a64bfa1699f09.json create mode 100644 server/central/.sqlx/query-4337dcb463e9d99e77db62fccb0a195453bfbe65cb946cd8947d258bbdc211a2.json create mode 100644 server/central/.sqlx/query-4baf83134ee0bba1b75ef59967b2f3f2c76702a2b652c1117dbf26a7e87a145c.json create mode 100644 server/central/.sqlx/query-6a88f2c9a00b65da29e7d1d9ae619559d6b3a7c1129a958c63cd01cbde85d92a.json create mode 100644 server/central/.sqlx/query-895e830e224326e0e5ef6bfc270fdb1de0bee79e44a3abf777f24dc0c109f6ce.json create mode 100644 server/central/.sqlx/query-a5d1f830c3e857f94bcaf864f8ec46156940b543d9eac2fb849db447bf70e1c7.json create mode 100644 server/central/.sqlx/query-ac970b41481290e1551ef4583b4ff9dff12b8af3b967fde7d25b365913d8a38b.json create mode 100644 server/central/.sqlx/query-cf94857754d165844cbf1152671470873eca6efbd365fc0d9bb18526b03376ba.json create mode 100644 server/central/.sqlx/query-f5d8599ac03d46ece0e7521bb7fc8582c892d97cbbe2d00d1adc94f98e4dde4b.json create mode 100644 server/central/.sqlx/query-f965a50418d0ec1f71c3fea4a82f5e2b2084855e6f390c2479eba67b80282cee.json diff --git a/server/central/.sqlx/query-02fa43600c4eff4f86ddbc97992d88c790e4d1591c109fea75e876ec0985a636.json b/server/central/.sqlx/query-02fa43600c4eff4f86ddbc97992d88c790e4d1591c109fea75e876ec0985a636.json new file mode 100644 index 000000000..06f4e7979 --- /dev/null +++ b/server/central/.sqlx/query-02fa43600c4eff4f86ddbc97992d88c790e4d1591c109fea75e876ec0985a636.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE users SET active_mute = NULL WHERE account_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + }, + "hash": "02fa43600c4eff4f86ddbc97992d88c790e4d1591c109fea75e876ec0985a636" +} diff --git a/server/central/.sqlx/query-1ff089a40bff1d9a3ddcc0749213c5bf5b5188bc1dcc59cf82ce48e545d5b202.json b/server/central/.sqlx/query-1ff089a40bff1d9a3ddcc0749213c5bf5b5188bc1dcc59cf82ce48e545d5b202.json new file mode 100644 index 000000000..fa0701aad --- /dev/null +++ b/server/central/.sqlx/query-1ff089a40bff1d9a3ddcc0749213c5bf5b5188bc1dcc59cf82ce48e545d5b202.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE users SET user_name = ? WHERE account_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "1ff089a40bff1d9a3ddcc0749213c5bf5b5188bc1dcc59cf82ce48e545d5b202" +} diff --git a/server/central/.sqlx/query-376106953cd01f83c2b238bf4fc8366f1eeb4092c19b9d26d36a64bfa1699f09.json b/server/central/.sqlx/query-376106953cd01f83c2b238bf4fc8366f1eeb4092c19b9d26d36a64bfa1699f09.json new file mode 100644 index 000000000..b78bb0fd0 --- /dev/null +++ b/server/central/.sqlx/query-376106953cd01f83c2b238bf4fc8366f1eeb4092c19b9d26d36a64bfa1699f09.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE users SET user_roles = ? WHERE account_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "376106953cd01f83c2b238bf4fc8366f1eeb4092c19b9d26d36a64bfa1699f09" +} diff --git a/server/central/.sqlx/query-4337dcb463e9d99e77db62fccb0a195453bfbe65cb946cd8947d258bbdc211a2.json b/server/central/.sqlx/query-4337dcb463e9d99e77db62fccb0a195453bfbe65cb946cd8947d258bbdc211a2.json new file mode 100644 index 000000000..275059df3 --- /dev/null +++ b/server/central/.sqlx/query-4337dcb463e9d99e77db62fccb0a195453bfbe65cb946cd8947d258bbdc211a2.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE users SET admin_password_hash = ? WHERE account_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "4337dcb463e9d99e77db62fccb0a195453bfbe65cb946cd8947d258bbdc211a2" +} diff --git a/server/central/.sqlx/query-4baf83134ee0bba1b75ef59967b2f3f2c76702a2b652c1117dbf26a7e87a145c.json b/server/central/.sqlx/query-4baf83134ee0bba1b75ef59967b2f3f2c76702a2b652c1117dbf26a7e87a145c.json new file mode 100644 index 000000000..b1517d433 --- /dev/null +++ b/server/central/.sqlx/query-4baf83134ee0bba1b75ef59967b2f3f2c76702a2b652c1117dbf26a7e87a145c.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE punishments SET reason = ?, expires_at = ? WHERE punishment_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 3 + }, + "nullable": [] + }, + "hash": "4baf83134ee0bba1b75ef59967b2f3f2c76702a2b652c1117dbf26a7e87a145c" +} diff --git a/server/central/.sqlx/query-6a88f2c9a00b65da29e7d1d9ae619559d6b3a7c1129a958c63cd01cbde85d92a.json b/server/central/.sqlx/query-6a88f2c9a00b65da29e7d1d9ae619559d6b3a7c1129a958c63cd01cbde85d92a.json new file mode 100644 index 000000000..3e87b5f57 --- /dev/null +++ b/server/central/.sqlx/query-6a88f2c9a00b65da29e7d1d9ae619559d6b3a7c1129a958c63cd01cbde85d92a.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE users SET name_color = ? WHERE account_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "6a88f2c9a00b65da29e7d1d9ae619559d6b3a7c1129a958c63cd01cbde85d92a" +} diff --git a/server/central/.sqlx/query-895e830e224326e0e5ef6bfc270fdb1de0bee79e44a3abf777f24dc0c109f6ce.json b/server/central/.sqlx/query-895e830e224326e0e5ef6bfc270fdb1de0bee79e44a3abf777f24dc0c109f6ce.json new file mode 100644 index 000000000..307131db0 --- /dev/null +++ b/server/central/.sqlx/query-895e830e224326e0e5ef6bfc270fdb1de0bee79e44a3abf777f24dc0c109f6ce.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE users SET active_ban = NULL WHERE account_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + }, + "hash": "895e830e224326e0e5ef6bfc270fdb1de0bee79e44a3abf777f24dc0c109f6ce" +} diff --git a/server/central/.sqlx/query-a5d1f830c3e857f94bcaf864f8ec46156940b543d9eac2fb849db447bf70e1c7.json b/server/central/.sqlx/query-a5d1f830c3e857f94bcaf864f8ec46156940b543d9eac2fb849db447bf70e1c7.json new file mode 100644 index 000000000..ac1d6b975 --- /dev/null +++ b/server/central/.sqlx/query-a5d1f830c3e857f94bcaf864f8ec46156940b543d9eac2fb849db447bf70e1c7.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE users SET active_mute = ? WHERE account_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "a5d1f830c3e857f94bcaf864f8ec46156940b543d9eac2fb849db447bf70e1c7" +} diff --git a/server/central/.sqlx/query-ac970b41481290e1551ef4583b4ff9dff12b8af3b967fde7d25b365913d8a38b.json b/server/central/.sqlx/query-ac970b41481290e1551ef4583b4ff9dff12b8af3b967fde7d25b365913d8a38b.json new file mode 100644 index 000000000..231d54e27 --- /dev/null +++ b/server/central/.sqlx/query-ac970b41481290e1551ef4583b4ff9dff12b8af3b967fde7d25b365913d8a38b.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE users SET active_ban = ? WHERE account_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "ac970b41481290e1551ef4583b4ff9dff12b8af3b967fde7d25b365913d8a38b" +} diff --git a/server/central/.sqlx/query-cf94857754d165844cbf1152671470873eca6efbd365fc0d9bb18526b03376ba.json b/server/central/.sqlx/query-cf94857754d165844cbf1152671470873eca6efbd365fc0d9bb18526b03376ba.json new file mode 100644 index 000000000..1a11a1340 --- /dev/null +++ b/server/central/.sqlx/query-cf94857754d165844cbf1152671470873eca6efbd365fc0d9bb18526b03376ba.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "INSERT INTO users (account_id) VALUES (?) ON CONFLICT DO NOTHING", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + }, + "hash": "cf94857754d165844cbf1152671470873eca6efbd365fc0d9bb18526b03376ba" +} diff --git a/server/central/.sqlx/query-f5d8599ac03d46ece0e7521bb7fc8582c892d97cbbe2d00d1adc94f98e4dde4b.json b/server/central/.sqlx/query-f5d8599ac03d46ece0e7521bb7fc8582c892d97cbbe2d00d1adc94f98e4dde4b.json new file mode 100644 index 000000000..c5565b8ac --- /dev/null +++ b/server/central/.sqlx/query-f5d8599ac03d46ece0e7521bb7fc8582c892d97cbbe2d00d1adc94f98e4dde4b.json @@ -0,0 +1,12 @@ +{ + "db_name": "SQLite", + "query": "UPDATE users SET is_whitelisted = ? WHERE account_id = ?", + "describe": { + "columns": [], + "parameters": { + "Right": 2 + }, + "nullable": [] + }, + "hash": "f5d8599ac03d46ece0e7521bb7fc8582c892d97cbbe2d00d1adc94f98e4dde4b" +} diff --git a/server/central/.sqlx/query-f965a50418d0ec1f71c3fea4a82f5e2b2084855e6f390c2479eba67b80282cee.json b/server/central/.sqlx/query-f965a50418d0ec1f71c3fea4a82f5e2b2084855e6f390c2479eba67b80282cee.json new file mode 100644 index 000000000..4a1d54cbe --- /dev/null +++ b/server/central/.sqlx/query-f965a50418d0ec1f71c3fea4a82f5e2b2084855e6f390c2479eba67b80282cee.json @@ -0,0 +1,20 @@ +{ + "db_name": "SQLite", + "query": "INSERT INTO punishments (account_id, type, reason, expires_at, issued_at, issued_by) VALUES (?, ?, ?, ?, ?, ?) RETURNING punishment_id", + "describe": { + "columns": [ + { + "name": "punishment_id", + "ordinal": 0, + "type_info": "Int64" + } + ], + "parameters": { + "Right": 6 + }, + "nullable": [ + false + ] + }, + "hash": "f965a50418d0ec1f71c3fea4a82f5e2b2084855e6f390c2479eba67b80282cee" +} diff --git a/server/central/Cargo.toml b/server/central/Cargo.toml index fead0e181..e3dc37e27 100644 --- a/server/central/Cargo.toml +++ b/server/central/Cargo.toml @@ -17,7 +17,10 @@ tokio = { version = "1.41.1", features = ["full"] } json_comments = "0.2.2" rocket = { version = "0.5.1", features = ["json"] } rocket_db_pools = { version = "0.2.0", features = ["sqlx_sqlite"] } -sqlx = { version = "0.6.3", features = ["migrate", "runtime-tokio-rustls"] } +sqlx = { version = "^0.7.0", features = [ # TODO: rocket_db_pools is broken in sqlx 0.8.x + "migrate", + "runtime-tokio-rustls", +] } rocket_cors = "0.6.0" const_format = "0.2.33" hex = "0.4.3" diff --git a/server/central/src/state.rs b/server/central/src/state.rs index db73b6efc..d9998bdf8 100644 --- a/server/central/src/state.rs +++ b/server/central/src/state.rs @@ -4,28 +4,27 @@ use std::{ net::IpAddr, path::PathBuf, sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }, time::{Duration, SystemTime}, }; use globed_shared::{ - anyhow, - base64::{engine::general_purpose::STANDARD as b64e, Engine}, - crypto_box::aead::{generic_array::GenericArray, AeadMutInPlace}, - crypto_secretbox::{KeyInit, XSalsa20Poly1305}, + TokenIssuer, anyhow, + base64::{Engine, engine::general_purpose::STANDARD as b64e}, + crypto_box::aead::{AeadMutInPlace, generic_array::GenericArray}, + crypto_secretbox::{KeyInit as _, XSalsa20Poly1305}, hmac::Hmac, - rand::prelude::*, + rand::{self, distr::Alphanumeric, prelude::*}, reqwest, sha2::Sha256, - TokenIssuer, }; use tokio::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard}; use crate::{config::ServerConfig, db::GlobedDb, game_pinger::GameServerPinger, verifier::AccountVerifier}; use blake2::{Blake2b, Digest}; -use digest::consts::U32; +use digest::{KeyInit as _, consts::U32}; #[derive(Clone)] pub struct ActiveChallenge { @@ -63,7 +62,7 @@ impl ServerStateData { let hmac = Hmac::::new_from_slice(skey_bytes).unwrap(); let mut challenge_pubkey = GenericArray::::default(); - OsRng.fill_bytes(&mut challenge_pubkey); + rand::rng().fill_bytes(&mut challenge_pubkey); let challenge_box = XSalsa20Poly1305::new(&challenge_pubkey); let token_expiry = Duration::from_secs(config.token_expiry); @@ -97,10 +96,10 @@ impl ServerStateData { ip_address: IpAddr, current_time: SystemTime, ) -> anyhow::Result { - let answer: String = rand::thread_rng().sample_iter(&Alphanumeric).take(16).map(char::from).collect(); + let answer: String = rand::rng().sample_iter(&Alphanumeric).take(16).map(char::from).collect(); let mut nonce = [0u8; XSalsa20Poly1305::NONCE_SIZE]; - OsRng.fill_bytes(&mut nonce); + rand::rng().fill_bytes(&mut nonce); let nonce_start = 0usize; let mac_start = nonce_start + XSalsa20Poly1305::NONCE_SIZE; @@ -223,15 +222,12 @@ impl ServerStateData { lowercase.hash(&mut hasher); let hash = hasher.finish(); - self.last_logins.insert( - hash, - LoginEntry { - account_id, - name: name.to_owned(), - time: SystemTime::now(), - link_code, - }, - ); + self.last_logins.insert(hash, LoginEntry { + account_id, + name: name.to_owned(), + time: SystemTime::now(), + link_code, + }); } pub fn remove_login_code(&mut self, name: &str) { diff --git a/server/central/src/web/routes/user.rs b/server/central/src/web/routes/user.rs index 73698966f..446a40c1f 100644 --- a/server/central/src/web/routes/user.rs +++ b/server/central/src/web/routes/user.rs @@ -1,11 +1,12 @@ use globed_shared::{ + ServerUserEntry, UserLoginData, UserLoginResponse, data::*, logger::debug, rand::{self, Rng}, - warn, ServerUserEntry, UserLoginData, UserLoginResponse, + warn, }; -use rocket::{get, post, serde::json::Json, State}; +use rocket::{State, get, post, serde::json::Json}; use serde::{Deserialize, Serialize}; use crate::{db::GlobedDb, state::ServerState, web::*}; @@ -188,7 +189,7 @@ pub async fn user_login( unauthorized!("invalid gameserver credentials"); } - let link_code = rand::thread_rng().gen_range(1000..10_000); + let link_code = rand::rng().random_range(1000..10_000); // store login attempt state.state_write().await.put_login(&userdata.0.name, userdata.0.account_id, link_code); From 28b78bfa0aeefb4a2bbcffb5cfb2cba641e89bc2 Mon Sep 17 00:00:00 2001 From: dankmeme01 <42031238+dankmeme01@users.noreply.github.com> Date: Sun, 1 Dec 2024 13:54:17 +0100 Subject: [PATCH 87/87] fix clippy warnings --- server/central/src/main.rs | 9 ++++----- server/central/src/web/routes/auth.rs | 2 +- server/esp/src/common.rs | 12 ++++-------- server/esp/src/lib.rs | 4 ++-- server/game/src/bridge.rs | 9 +++++---- server/game/src/data/mod.rs | 6 +++--- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/server/central/src/main.rs b/server/central/src/main.rs index 4fbe13b23..80990edb9 100644 --- a/server/central/src/main.rs +++ b/server/central/src/main.rs @@ -16,14 +16,13 @@ use std::{ time::Duration, }; -use async_watcher::{notify::RecursiveMode, AsyncDebouncer}; +use async_watcher::{AsyncDebouncer, notify::RecursiveMode}; use config::ServerConfig; use db::GlobedDb; use game_pinger::GameServerPinger; use globed_shared::{ - get_log_level, - logger::{error, info, log, warn, Logger}, - LogLevelFilter, + LogLevelFilter, get_log_level, + logger::{Logger, error, info, log, warn}, }; use rocket::catchers; use rocket_db_pools::Database; @@ -62,7 +61,7 @@ async fn main() -> Result<(), Box> { // create Rocket.toml if it doesn't exist let rocket_toml = std::env::var("ROCKET_CONFIG").map_or_else(|_| std::env::current_dir().unwrap().join("Rocket.toml"), PathBuf::from); - if !rocket_toml.file_name().is_some_and(|x| x == "Rocket.toml") || !rocket_toml.parent().is_some_and(Path::exists) { + if rocket_toml.file_name().is_none_or(|x| x != "Rocket.toml") || !rocket_toml.parent().is_some_and(Path::exists) { error!("invalid value for ROCKET_CONFIG"); warn!("hint: the filename must be 'Rocket.toml' and the parent folder must exist on the disk"); abort_misconfig(); diff --git a/server/central/src/web/routes/auth.rs b/server/central/src/web/routes/auth.rs index a72a1df1f..64c253f72 100644 --- a/server/central/src/web/routes/auth.rs +++ b/server/central/src/web/routes/auth.rs @@ -320,7 +320,7 @@ pub async fn challenge_verify( // verify trust token let trust_token = if let Ok(sm_key) = std::env::var("GLOBED_GS_SECURE_MODE_KEY") { if let Some(trust_token) = &post_data.0.trust_token { - let decrypted = String::from_utf8(decrypt_trust_token(&trust_token, &sm_key)?)?; + let decrypted = String::from_utf8(decrypt_trust_token(trust_token, &sm_key)?)?; if let Some((s_value, token_rest)) = decrypted.split_once('|') { if s_value != challenge.value { unauthorized!("security check failed: trust token value mismatch"); diff --git a/server/esp/src/common.rs b/server/esp/src/common.rs index c5648f220..20864aa94 100644 --- a/server/esp/src/common.rs +++ b/server/esp/src/common.rs @@ -10,11 +10,7 @@ use std::{ // this is bizarre const fn constmax(a: usize, b: usize) -> usize { - if a >= b { - a - } else { - b - } + if a >= b { a } else { b } } macro_rules! impl_primitive { @@ -153,7 +149,7 @@ where /* Cow<'a, T> */ -impl<'a, T: ?Sized + ToOwned> Encodable for Cow<'a, T> +impl Encodable for Cow<'_, T> where ::Owned: Encodable, T: Encodable, @@ -175,7 +171,7 @@ where } } -impl<'a, T: ?Sized + ToOwned> Decodable for Cow<'a, T> +impl Decodable for Cow<'_, T> where ::Owned: Decodable, T: Decodable, @@ -189,7 +185,7 @@ where } } -impl<'a, T: ?Sized + ToOwned> DynamicSize for Cow<'a, T> +impl DynamicSize for Cow<'_, T> where ::Owned: DynamicSize, T: DynamicSize, diff --git a/server/esp/src/lib.rs b/server/esp/src/lib.rs index 51d0ecdae..3023b3679 100644 --- a/server/esp/src/lib.rs +++ b/server/esp/src/lib.rs @@ -439,7 +439,7 @@ impl ByteBufferExtWrite for ByteBuffer { impl_extwrite!(encode); } -impl<'a> ByteBufferExtWrite for FastByteBuffer<'a> { +impl ByteBufferExtWrite for FastByteBuffer<'_> { impl_extwrite!(encode_fast); } @@ -447,7 +447,7 @@ impl ByteBufferExtRead for ByteBuffer { impl_extread!(decode); } -impl<'a> ByteBufferExtRead for ByteReader<'a> { +impl ByteBufferExtRead for ByteReader<'_> { impl_extread!(decode_from_reader); } diff --git a/server/game/src/bridge.rs b/server/game/src/bridge.rs index 67ec35b0d..fcdc2fa9f 100644 --- a/server/game/src/bridge.rs +++ b/server/game/src/bridge.rs @@ -7,14 +7,14 @@ use std::{ }; use esp::{ - size_of_types, ByteBuffer, ByteBufferExt, ByteBufferExtRead, ByteBufferExtWrite, ByteReader, Decodable, DecodeError, DynamicSize, Encodable, - FastVec, StaticSize, + ByteBuffer, ByteBufferExt, ByteBufferExtRead, ByteBufferExtWrite, ByteReader, Decodable, DecodeError, DynamicSize, Encodable, FastVec, + StaticSize, size_of_types, }; use globed_derive::{DynamicSize, Encodable}; use globed_shared::{ + GameServerBootData, MAX_SUPPORTED_PROTOCOL, SERVER_MAGIC, SERVER_MAGIC_LEN, ServerUserEntry, SyncMutex, TokenIssuer, UserLoginResponse, data::*, reqwest::{self, Response, StatusCode}, - GameServerBootData, ServerUserEntry, SyncMutex, TokenIssuer, UserLoginResponse, MAX_SUPPORTED_PROTOCOL, SERVER_MAGIC, SERVER_MAGIC_LEN, }; use crate::webhook::{self, *}; @@ -160,7 +160,7 @@ impl CentralBridge { // verify that the magic bytes match let valid_magic = reader .read_value_array::() - .map_or(false, |magic| magic.iter().eq(SERVER_MAGIC.iter())); + .is_ok_and(|magic| magic.iter().eq(SERVER_MAGIC.iter())); if !valid_magic { let txt = String::from_utf8(reader.as_bytes().to_vec()).unwrap_or_else(|_| "".to_owned()); @@ -377,6 +377,7 @@ impl CentralBridge { Ok(()) } + #[allow(clippy::too_many_arguments)] pub async fn send_webhook_message_for_action( &self, action: &AdminUserAction, diff --git a/server/game/src/data/mod.rs b/server/game/src/data/mod.rs index 2a107a32c..84b50ce05 100644 --- a/server/game/src/data/mod.rs +++ b/server/game/src/data/mod.rs @@ -6,9 +6,9 @@ pub use esp::*; pub use globed_derive::*; pub use globed_shared::MAX_NAME_SIZE; +pub use v_current::VERSION as CURRENT_PROTOCOL; pub use v_current::packets; pub use v_current::types; -pub use v_current::VERSION as CURRENT_PROTOCOL; pub use packets::*; pub use types::*; @@ -39,7 +39,7 @@ impl ByteBufferExtRead2 for ByteBuffer { } } -impl<'a> ByteBufferExtRead2 for ByteReader<'a> { +impl ByteBufferExtRead2 for ByteReader<'_> { #[inline] fn read_packet_header(&mut self) -> DecodeResult { self.read_value() @@ -73,7 +73,7 @@ impl ByteBufferExtWrite2 for ByteBuffer { } } -impl<'a> ByteBufferExtWrite2 for FastByteBuffer<'a> { +impl ByteBufferExtWrite2 for FastByteBuffer<'_> { #[inline] fn write_packet_header(&mut self) { self.write_value(&PacketHeader::from_packet::());