Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update server CI, dependencies and change to Rust 2024 edition #256

Merged
merged 93 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
5af81a0
Reformat
larziwau Nov 28, 2024
155bc30
Update server CI
larziwau Nov 28, 2024
c5a7c89
Remove since not needed (gives error if exists)
larziwau Nov 28, 2024
b87d4a8
Remove unused import
larziwau Nov 28, 2024
5f889fa
Remove
larziwau Nov 28, 2024
9cf7c92
WIP
larziwau Nov 28, 2024
c6318f2
Done
larziwau Nov 28, 2024
a8ac179
Update async-watcher requirement from 0.2.1 to 0.3.0 in /server
dependabot[bot] Nov 28, 2024
27f4adb
Update console-subscriber requirement in /server/game
dependabot[bot] Nov 28, 2024
837206a
Update rustc-hash requirement from 1.1.0 to 2.0.0 in /server
dependabot[bot] Nov 28, 2024
198a546
Update rocket_db_pools requirement from 0.1.0 to 0.2.0 in /server
dependabot[bot] Nov 28, 2024
ec16470
Update egui requirement from 0.27.2 to 0.29.1 in /server/observer
dependabot[bot] Nov 28, 2024
625e006
Update base64 requirement from 0.21.7 to 0.22.1 in /server/shared
dependabot[bot] Nov 28, 2024
6834dfa
Merge pull request #13 from larziwau/dependabot/cargo/server/shared/b…
larziwau Nov 28, 2024
7215c31
Merge pull request #12 from larziwau/dependabot/cargo/server/observer…
larziwau Nov 28, 2024
6db760c
Merge pull request #11 from larziwau/dependabot/cargo/server/rocket_d…
larziwau Nov 28, 2024
4d8dd54
Merge pull request #10 from larziwau/dependabot/cargo/server/rustc-ha…
larziwau Nov 28, 2024
c556b8e
Update Cargo.toml
larziwau Nov 28, 2024
01603e1
Update CMakeLists
larziwau Nov 28, 2024
ad0e245
oops
larziwau Nov 28, 2024
90dac77
Merge pull request #9 from larziwau/dependabot/cargo/server/game/cons…
larziwau Nov 28, 2024
5b743df
Merge pull request #8 from larziwau/dependabot/cargo/server/async-wat…
larziwau Nov 28, 2024
2149619
fix?
larziwau Nov 28, 2024
86825ab
Update libs
larziwau Nov 28, 2024
a6da229
update
larziwau Nov 28, 2024
5889a36
Update Cargo.toml
larziwau Nov 28, 2024
118c475
Update Cargo.toml
larziwau Nov 28, 2024
bc67734
Update Cargo.toml
larziwau Nov 28, 2024
5a65247
Update Cargo.toml
larziwau Nov 28, 2024
264cdcd
Update Cargo.toml
larziwau Nov 28, 2024
f4f6231
Update Cargo.toml
larziwau Nov 28, 2024
334b101
Update Cargo.toml
larziwau Nov 28, 2024
c61ea36
Update Cargo.toml
larziwau Nov 28, 2024
fd45af4
Update Cargo.toml
larziwau Nov 28, 2024
433388a
Update Cargo.toml
larziwau Nov 28, 2024
06e3c91
Update Cargo.toml
larziwau Nov 28, 2024
589d26c
Update Cargo.toml
larziwau Nov 28, 2024
8efd1cc
Update Cargo.toml
larziwau Nov 28, 2024
593e789
Update Cargo.toml
larziwau Nov 28, 2024
cf75e14
Update Cargo.toml
larziwau Nov 28, 2024
33b1c08
Update Cargo.toml
larziwau Nov 28, 2024
e3eb402
Update Cargo.toml
larziwau Nov 28, 2024
e981178
try fxi
larziwau Nov 28, 2024
4b0a169
fix
larziwau Nov 28, 2024
3d28688
Update fast_string.rs
larziwau Nov 28, 2024
3ec902c
Update fast_string.rs
larziwau Nov 28, 2024
1fdb933
should work now
larziwau Nov 28, 2024
dd8dd98
pls work
larziwau Nov 28, 2024
aae7f78
PLEASE WORK.
larziwau Nov 28, 2024
c46b21a
oopsiees
larziwau Nov 28, 2024
608c92c
should workkk nowwwww
larziwau Nov 28, 2024
3a3ed10
oops
larziwau Nov 28, 2024
f185a41
fixes
larziwau Nov 28, 2024
87a66e1
naother fix
larziwau Nov 28, 2024
4cd52e5
Update lib.rs
larziwau Nov 28, 2024
e869a49
Update socket.rs
larziwau Nov 28, 2024
a32d94f
Update unauthorized.rs
larziwau Nov 28, 2024
e7e4491
fix
larziwau Nov 28, 2024
dcf2a43
Update socket.rs
larziwau Nov 28, 2024
84c1901
Update unauthorized.rs
larziwau Nov 28, 2024
b9559ee
Update unauthorized.rs
larziwau Nov 28, 2024
7e45bb2
Update socket.rs
larziwau Nov 28, 2024
6b3751b
Update Cargo.toml
larziwau Nov 28, 2024
9df0554
i suck
larziwau Nov 28, 2024
449c29a
warning fix
larziwau Nov 28, 2024
3853352
fix warn
larziwau Nov 28, 2024
0df67cf
fix warning
larziwau Nov 28, 2024
c93caa6
Update unauthorized.rs
larziwau Nov 28, 2024
45aa84d
Update room.rs
larziwau Nov 28, 2024
2ae2c1b
Update channel.rs
larziwau Nov 28, 2024
eac1191
Update channel.rs
larziwau Nov 28, 2024
cd7b5c2
Update lockfreemutcell.rs
larziwau Nov 28, 2024
a93bb15
unsure abt this one
larziwau Nov 28, 2024
1e049ce
fix
larziwau Nov 28, 2024
dbe1014
fix
larziwau Nov 28, 2024
653ee50
[skip ci] comment fix
larziwau Nov 28, 2024
768816e
fixup
larziwau Nov 28, 2024
0b19157
Update lockfreemutcell.rs
larziwau Nov 28, 2024
6781662
Update thread.rs
larziwau Nov 28, 2024
08268b9
Update unauthorized.rs
larziwau Nov 28, 2024
9a811eb
Update server.rs
larziwau Nov 28, 2024
8a1a2b0
Update lockfreemutcell.rs
larziwau Nov 28, 2024
2c60961
Update lockfreemutcell.rs
larziwau Nov 28, 2024
c822119
unsafe fixes
larziwau Nov 28, 2024
fff55f9
Update channel.rs
larziwau Nov 28, 2024
17f3c5a
my bad
larziwau Nov 28, 2024
d3d2159
Update game_pinger.rs
larziwau Nov 28, 2024
b01f42a
rand fix
larziwau Nov 28, 2024
b9c43cc
done lol
larziwau Nov 28, 2024
d6adce0
undo the unsafe changes and remove other thing
dankmeme01 Nov 29, 2024
7b0883c
fix minor issues and bump deps
dankmeme01 Dec 1, 2024
8dcfc39
fix KeyInit compile errors
dankmeme01 Dec 1, 2024
28b78bf
fix clippy warnings
dankmeme01 Dec 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/server/central"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/server/derive"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/server/esp"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/server/game"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/server/shared"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/server"
schedule:
interval: "daily"
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
package:
name: Package builds
runs-on: ubuntu-latest
needs: ['build']
needs: build

steps:
- name: Combine builds
Expand Down
27 changes: 12 additions & 15 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,36 @@ 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: |
Expand Down Expand Up @@ -87,8 +85,7 @@ jobs:
shell: bash

- name: Create artifacts folder
run: |
mkdir -p server/artifacts
run: mkdir -p server/artifacts
shell: bash

- name: Copy artifacts (Windows)
Expand Down
29 changes: 15 additions & 14 deletions server/central/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
[package]
name = "globed-central-server"
version = "1.4.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
edition = "2024"

[dependencies]
globed-shared = { path = "../shared" }

async-watcher = "0.2.1"
blake2 = "0.10.6"
digest = "0.10.7"
ipnet = "2.9.0"
async-watcher = "0.3.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_db_pools = { version = "0.1.0", features = ["sqlx_sqlite"] }
sqlx = { version = "0.7.4", features = ["migrate"] }
rocket = { version = "0.5.1", features = ["json"] }
rocket_db_pools = { version = "0.2.0", features = ["sqlx_sqlite"] }
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.32"
const_format = "0.2.33"
hex = "0.4.3"
2 changes: 0 additions & 2 deletions server/central/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::env;

fn main() {
// trigger recompilation when a new migration is added
println!("cargo:rerun-if-changed=migrations");
Expand Down
2 changes: 1 addition & 1 deletion server/central/src/game_pinger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions server/central/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,7 +61,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
// 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();
Expand Down
36 changes: 16 additions & 20 deletions server/central/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{self, distributions::Alphanumeric, rngs::OsRng, Rng, RngCore},
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 {
Expand Down Expand Up @@ -63,7 +62,7 @@ impl ServerStateData {

let hmac = Hmac::<Sha256>::new_from_slice(skey_bytes).unwrap();
let mut challenge_pubkey = GenericArray::<u8, U32>::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);
Expand Down Expand Up @@ -97,10 +96,10 @@ impl ServerStateData {
ip_address: IpAddr,
current_time: SystemTime,
) -> anyhow::Result<String> {
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;
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions server/central/src/web/routes/auth.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -229,7 +229,7 @@ fn decrypt_trust_token(token: &str, key: &str) -> WebResult<Vec<u8>> {
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..];

Expand Down Expand Up @@ -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");
Expand Down
9 changes: 4 additions & 5 deletions server/central/src/web/routes/meta.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -76,7 +75,7 @@ pub fn versioncheck(gd: &str, globed: &str, protocol: u16) -> WebResult<Json<Ver

#[get("/")]
pub fn index() -> (Status, (ContentType, String)) {
if rand::thread_rng().gen_ratio(1, 0xaa) {
if rand::rng().random_ratio(1, 0xaa) {
return _check();
}

Expand Down
7 changes: 4 additions & 3 deletions server/central/src/web/routes/user.rs
Original file line number Diff line number Diff line change
@@ -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::*};
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 5 additions & 7 deletions server/derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
[package]
name = "globed-derive"
version = "1.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
edition = "2024"

[lib]
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.90", features = ["full"] }
Loading