Skip to content

Commit

Permalink
Merging patches and fixes from dev
Browse files Browse the repository at this point in the history
Merging patches and fixes from dev
  • Loading branch information
jacobtread authored Mar 13, 2023
2 parents a907ac6 + f4dfd14 commit e477e4f
Show file tree
Hide file tree
Showing 26 changed files with 350 additions and 550 deletions.
219 changes: 109 additions & 110 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ features = ["std", "serde"]

[package]
name = "pocket-relay"
version = "0.3.0"
version = "0.3.1"
description = "Pocket Relay Server"
repository = "https://github.com/PocketRelay/Server"
readme = "README.md"
Expand Down Expand Up @@ -55,7 +55,7 @@ database = { path = "database", package = "pocket-relay-database", version = "^0
rust-embed = { version = "6.4.2", features = ["debug-embed"] }

# Password hashing
argon2 = "0.4"
argon2 = "0.5"

base64ct = { version = "1.5", features = ["alloc"] }
flate2 = { version = "1", features = ["zlib"], default-features = false }
Expand All @@ -65,12 +65,12 @@ ring = "0.16"
dotenvy = "0.15"

# Library for obtaining the local IP address of the device
local-ip-address = "0.5.0"
local-ip-address = "0.5"

thiserror = "1"
validator = { version = "0.16", features = ["derive"] }

interlink = "0.1.2"
interlink = "0.1"
tokio-util = { version = "0.7", features = ["codec"] }
futures = "0.3"

Expand Down Expand Up @@ -105,6 +105,9 @@ version = "1.2.0"
default-features = false
features = ["console_appender", "file_appender"]

[patch.crates-io]
local-ip-address = { git = "https://github.com/jacobtread/local-ip-address.git" }

[profile.release]
strip = true
lto = true
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

[Discord Server (https://discord.gg/yvycWW8RgR)](https://discord.gg/yvycWW8RgR)


> **📌 Update Notice**
> If you are updating from a version lower than 0.3 you will need to
> delete the app.db file before launching or else the server will not
> work

**Pocket Relay** Is a custom implementation of the Mass Effect 3 multiplayer servers all bundled into a easy to use server with a Dashboard for managing accounts and inventories.

With **Pocket Relay** you can play Mass Effect 3 multiplayer offline by yourself, over LAN, or even over WAN as a public server
Expand Down
30 changes: 11 additions & 19 deletions database/src/interfaces/players.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ impl Player {
///
/// `id` The ID of the player
/// `db` The database connection
pub fn all_data<'a>(
pub fn all_data(
id: u32,
db: &'a DatabaseConnection,
) -> impl Future<Output = DbResult<Vec<PlayerData>>> + Send + 'a {
db: &DatabaseConnection,
) -> impl Future<Output = DbResult<Vec<PlayerData>>> + Send + '_ {
player_data::Entity::find()
.filter(player_data::Column::PlayerId.eq(id))
.all(db)
Expand Down Expand Up @@ -214,10 +214,10 @@ impl Player {
///
/// `db` The database instance
/// `id` The ID of the player to find
pub fn by_id<'a>(
db: &'a DatabaseConnection,
pub fn by_id(
db: &DatabaseConnection,
id: u32,
) -> impl Future<Output = DbResult<Option<Player>>> + Send + 'a {
) -> impl Future<Output = DbResult<Option<Player>>> + Send + '_ {
players::Entity::find_by_id(id).one(db)
}

Expand Down Expand Up @@ -250,11 +250,7 @@ impl Player {
///
/// `db` The database connection
/// `password` The new hashed password
pub fn set_password<'a>(
self,
db: &'a DatabaseConnection,
password: String,
) -> DbFuture<'a, Player> {
pub fn set_password(self, db: &DatabaseConnection, password: String) -> DbFuture<'_, Player> {
let mut model = self.into_active_model();
model.password = Set(Some(password));
model.update(db)
Expand All @@ -264,11 +260,7 @@ impl Player {
///
/// `db` The database connection
/// `role` The new role for the player
pub fn set_role<'a>(
self,
db: &'a DatabaseConnection,
role: PlayerRole,
) -> DbFuture<'a, Player> {
pub fn set_role(self, db: &DatabaseConnection, role: PlayerRole) -> DbFuture<'_, Player> {
let mut model = self.into_active_model();
model.role = Set(role);
model.update(db)
Expand All @@ -280,12 +272,12 @@ impl Player {
/// `db` The database connection
/// `username` Optional new username for the player
/// `email` Optional new email for the player
pub fn set_details<'a>(
pub fn set_details(
self,
db: &'a DatabaseConnection,
db: &DatabaseConnection,
username: Option<String>,
email: Option<String>,
) -> DbFuture<'a, Player> {
) -> DbFuture<'_, Player> {
let mut model = self.into_active_model();

if let Some(username) = username {
Expand Down
43 changes: 37 additions & 6 deletions database/src/migration/m20221015_142649_players_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,55 @@ impl MigrationTrait for Migration {
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(Players::Email).string_len(254).not_null())
.col(
ColumnDef::new(Players::Email)
.string_len(254)
.unique_key()
.not_null(),
)
.col(
ColumnDef::new(Players::DisplayName)
.string_len(99)
.not_null(),
)
.col(ColumnDef::new(Players::SessionToken).string_len(254).null())
.col(ColumnDef::new(Players::Origin).boolean().not_null())
.col(ColumnDef::new(Players::Password).string().not_null())
.col(ColumnDef::new(Players::Password).string().null())
.col(
ColumnDef::new(Players::Role)
.tiny_integer()
.default(0)
.not_null(),
)
.to_owned(),
)
.await?;

// Create index for email
manager
.create_index(
Index::create()
.name("idx-pr-email")
.table(Players::Table)
.col(Players::Email)
.unique()
.to_owned(),
)
.await
}

async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// Drop the table
manager
.drop_table(Table::drop().table(Players::Table).to_owned())
.await?;

// Drop the index
manager
.drop_index(
Index::drop()
.name("idx-pr-email")
.table(Players::Table)
.to_owned(),
)
.await
}
}
Expand All @@ -48,7 +80,6 @@ pub enum Players {
Id,
Email,
DisplayName,
SessionToken,
Origin,
Password,
Role,
}
31 changes: 0 additions & 31 deletions database/src/migration/m20230130_174951_remove_session_token.rs

This file was deleted.

43 changes: 0 additions & 43 deletions database/src/migration/m20230205_114724_add_players_role.rs

This file was deleted.

78 changes: 0 additions & 78 deletions database/src/migration/m20230223_190834_remove_origin_flag.rs

This file was deleted.

7 changes: 0 additions & 7 deletions database/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ pub use sea_orm_migration::prelude::*;
mod m20221015_142649_players_table;
mod m20221015_153750_galaxy_at_war_table;
mod m20221222_174733_player_data;
mod m20230130_174951_remove_session_token;
mod m20230205_114724_add_players_role;
mod m20230223_190834_remove_origin_flag;

pub struct Migrator;

#[async_trait::async_trait]
Expand All @@ -16,9 +12,6 @@ impl MigratorTrait for Migrator {
Box::new(m20221015_142649_players_table::Migration),
Box::new(m20221015_153750_galaxy_at_war_table::Migration),
Box::new(m20221222_174733_player_data::Migration),
Box::new(m20230130_174951_remove_session_token::Migration),
Box::new(m20230205_114724_add_players_role::Migration),
Box::new(m20230223_190834_remove_origin_flag::Migration),
]
}
}
4 changes: 2 additions & 2 deletions src/servers/http/routes/gaw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
env,
servers::http::ext::{ErrorStatusCode, Xml},
state::GlobalState,
utils::parsing::parse_player_class,
utils::parsing::PlayerClass,
};
use axum::{
extract::{Path, Query},
Expand Down Expand Up @@ -127,7 +127,7 @@ async fn get_promotions(db: &DatabaseConnection, player: &Player) -> DbResult<u3
.get_classes(db)
.await?
.iter()
.filter_map(|value| parse_player_class(&value.value))
.filter_map(|value| PlayerClass::parse(&value.value))
.map(|value| value.promotions)
.sum())
}
Expand Down
Loading

0 comments on commit e477e4f

Please sign in to comment.