diff --git a/Cargo.toml b/Cargo.toml index a1eba71..19347e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ members = [ "stats", "trade", "patch_server", + "login_server", ] [workspace.dependencies] @@ -37,6 +38,7 @@ drops = { path = "./drops" } trade = { path = "./trade" } room = { path = "./room" } patch_server = { path = "./patch_server" } +login_server = { path = "./login_server" } libpso = { git = "http://git.sharnoth.com/jake/libpso" } @@ -83,6 +85,7 @@ drops = { workspace = true } trade = { workspace = true } room = { workspace = true } patch_server = { workspace = true } +login_server = { workspace = true } libpso = { workspace = true } diff --git a/login_server/Cargo.toml b/login_server/Cargo.toml new file mode 100644 index 0000000..8ce2441 --- /dev/null +++ b/login_server/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "login_server" +version = "0.1.0" +edition = "2021" + +[dependencies] +entity = { workspace = true } +networking = { workspace = true } +pktbuilder = { workspace = true } +stats = { workspace = true } + +libpso = { workspace = true } + +async-std = { workspace = true } +async-trait = { workspace = true } +anyhow = { workspace = true } +bcrypt = { workspace = true } +crc = { workspace = true } +thiserror = { workspace = true } +chrono = { workspace = true } +rand= { workspace = true } diff --git a/src/login/character.rs b/login_server/src/character.rs similarity index 99% rename from src/login/character.rs rename to login_server/src/character.rs index 6529f3d..ec9d3d3 100644 --- a/src/login/character.rs +++ b/login_server/src/character.rs @@ -31,7 +31,7 @@ use entity::item::tool::Tool; use entity::item::mag::Mag; use entity::character::{CharacterEntity, NewCharacterEntity, CharacterClass, TechLevel}; -use crate::login::login::{get_login_status}; +use crate::login::get_login_status; use networking::interserver::AuthToken; use pktbuilder::ship::SHIP_MENU_ID; diff --git a/login_server/src/lib.rs b/login_server/src/lib.rs new file mode 100644 index 0000000..0006241 --- /dev/null +++ b/login_server/src/lib.rs @@ -0,0 +1,2 @@ +pub mod login; +pub mod character; diff --git a/src/login/login.rs b/login_server/src/login.rs similarity index 98% rename from src/login/login.rs rename to login_server/src/login.rs index cdc32d9..70bb5a4 100644 --- a/src/login/login.rs +++ b/login_server/src/login.rs @@ -83,21 +83,13 @@ pub async fn get_login_status(entity_gateway: &mut impl EntityGateway, pkt: &Log pub fn check_if_already_online(user: UserAccountEntity) -> Result { Ok(user) - /* - if user.is_currently_online() { - Err(AccountStatus::PayUp) -} - else { - Ok(user) -} - */ } #[derive(Clone)] pub struct LoginServerState { character_server_ip: net::Ipv4Addr, entity_gateway: EG, - clients: HashMap, + clients: HashMap, // TODO: this should be arc/mutex'd? } impl LoginServerState { @@ -119,7 +111,7 @@ impl LoginServerState { let response = SendLoginPacket::LoginResponse(LoginResponse::by_status(AccountStatus::Ok, pkt.session)); let ip = u32::from_ne_bytes(self.character_server_ip.octets()); Ok(vec![response, - SendLoginPacket::RedirectClient(RedirectClient::new(ip, crate::login::character::CHARACTER_PORT))]) + SendLoginPacket::RedirectClient(RedirectClient::new(ip, crate::character::CHARACTER_PORT))]) }, Err(err) => { Ok(vec![SendLoginPacket::LoginResponse(LoginResponse::by_status(err, pkt.session))]) diff --git a/src/bin/login.rs b/src/bin/login.rs index f4c5335..8f8832b 100644 --- a/src/bin/login.rs +++ b/src/bin/login.rs @@ -1,7 +1,7 @@ use log::{info}; use entity::gateway::postgres::PostgresGateway; -use elseware::login::login::LoginServerState; -use elseware::login::character::CharacterServerState; +use login_server::login::LoginServerState; +use login_server::character::CharacterServerState; use networking::interserver::AuthToken; fn main() { @@ -38,17 +38,17 @@ fn main() { let login_state = LoginServerState::new(entity_gateway.clone(), charserv_ip); let login_loop = async_std::task::spawn(async move { - networking::mainloop::run_server(login_state, elseware::login::login::LOGIN_PORT).await; + networking::mainloop::run_server(login_state, login_server::login::LOGIN_PORT).await; }); let char_state = CharacterServerState::new(entity_gateway, AuthToken(shipgate_token)); let sub_char_state = char_state.clone(); let character_loop = async_std::task::spawn(async move { - networking::mainloop::run_server(sub_char_state, elseware::login::character::CHARACTER_PORT).await; + networking::mainloop::run_server(sub_char_state, login_server::character::CHARACTER_PORT).await; }); let inter_character_loop = async_std::task::spawn(async move { - networking::mainloop::run_interserver_listen(char_state, elseware::login::login::COMMUNICATION_PORT).await; + networking::mainloop::run_interserver_listen(char_state, login_server::login::COMMUNICATION_PORT).await; }); info!("[auth/character] starting server"); diff --git a/src/bin/main.rs b/src/bin/main.rs index a61bf7b..e12ad1b 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -2,8 +2,8 @@ use std::net::Ipv4Addr; use log::{info}; use networking::interserver::AuthToken; -use elseware::login::login::LoginServerState; -use elseware::login::character::CharacterServerState; +use login_server::login::LoginServerState; +use login_server::character::CharacterServerState; use patch_server::{PatchServerState, generate_patch_tree, load_config, load_motd}; use elseware::ship::ship::ShipServerStateBuilder; @@ -344,19 +344,19 @@ fn main() { info!("[auth] starting server"); let login_state = LoginServerState::new(entity_gateway.clone(), "127.0.0.1".parse().unwrap()); let login_loop = async_std::task::spawn(async move { - networking::mainloop::run_server(login_state, elseware::login::login::LOGIN_PORT).await; + networking::mainloop::run_server(login_state, login_server::login::LOGIN_PORT).await; }); info!("[character] starting server"); let char_state = CharacterServerState::new(entity_gateway.clone(), AuthToken("".into())); let sub_char_state = char_state.clone(); let character_loop = async_std::task::spawn(async move { - networking::mainloop::run_server(sub_char_state, elseware::login::character::CHARACTER_PORT).await; + networking::mainloop::run_server(sub_char_state, login_server::character::CHARACTER_PORT).await; }); let sub_char_state = char_state.clone(); let inter_character_loop = async_std::task::spawn(async move { - networking::mainloop::run_interserver_listen(sub_char_state, elseware::login::login::COMMUNICATION_PORT).await; + networking::mainloop::run_interserver_listen(sub_char_state, login_server::login::COMMUNICATION_PORT).await; }); info!("[ship] starting servers"); @@ -373,7 +373,7 @@ fn main() { }); let sub_ship_state = ship_state.clone(); let inter_ship_loop1 = async_std::task::spawn(async move { - networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await; + networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), login_server::login::COMMUNICATION_PORT).await; }); let ship_state = ShipServerStateBuilder::default() @@ -389,7 +389,7 @@ fn main() { }); let sub_ship_state = ship_state.clone(); let inter_ship_loop2 = async_std::task::spawn(async move { - networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await; + networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), login_server::login::COMMUNICATION_PORT).await; }); let ship_state = ShipServerStateBuilder::default() @@ -404,7 +404,7 @@ fn main() { }); let sub_ship_state = ship_state.clone(); let inter_ship_loop3 = async_std::task::spawn(async move { - networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), elseware::login::login::COMMUNICATION_PORT).await; + networking::mainloop::run_interserver_connect(sub_ship_state, std::net::Ipv4Addr::new(127, 0, 0, 1), login_server::login::COMMUNICATION_PORT).await; }); futures::future::join_all(vec![patch_loop, login_loop, character_loop, inter_character_loop, diff --git a/src/bin/ship.rs b/src/bin/ship.rs index c021601..cfa50ed 100644 --- a/src/bin/ship.rs +++ b/src/bin/ship.rs @@ -52,7 +52,7 @@ fn main() { networking::mainloop::run_server(sub_ship_state, elseware::ship::ship::SHIP_PORT).await; }); let inter_ship_loop = async_std::task::spawn(async move { - networking::mainloop::run_interserver_connect(ship_state, shipgate_ip, elseware::login::login::COMMUNICATION_PORT).await; + networking::mainloop::run_interserver_connect(ship_state, shipgate_ip, login_server::login::COMMUNICATION_PORT).await; }); info!("[auth/character] starting server"); diff --git a/src/lib.rs b/src/lib.rs index 5436b77..3b52841 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,5 +11,5 @@ extern crate test; //pub mod common; //pub mod entity; //pub mod patch; -pub mod login; +//pub mod login; pub mod ship; diff --git a/src/login/mod.rs b/src/login/mod.rs deleted file mode 100644 index a5b3370..0000000 --- a/src/login/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -#[allow(clippy::module_inception)] -pub mod login; -pub mod character; diff --git a/src/ship/packet/handler/auth.rs b/src/ship/packet/handler/auth.rs index 915da68..891ae6e 100644 --- a/src/ship/packet/handler/auth.rs +++ b/src/ship/packet/handler/auth.rs @@ -2,7 +2,7 @@ use libpso::packet::login::{Login, LoginResponse, AccountStatus, Session}; use libpso::packet::ship::*; use networking::serverstate::ClientId; use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients}; -use crate::login::login::get_login_status; +use login_server::login::get_login_status; use entity::gateway::EntityGateway; use items::state::ItemState; use networking::interserver::ShipMessage;