Browse Source

move patch/login main.rs files up a level

pbs
jake 5 years ago
parent
commit
f294781934
  1. 9
      Cargo.toml
  2. 1
      src/entity/gateway/inmemory.rs
  3. 4
      src/lib.rs
  4. 18
      src/login/character.rs
  5. 14
      src/login/login.rs
  6. 2
      src/login/mod.rs
  7. 20
      src/login_main.rs
  8. 1
      src/patch/mod.rs
  9. 5
      src/patch/patch.rs
  10. 7
      src/patch_main.rs

9
Cargo.toml

@ -4,13 +4,18 @@ version = "0.1.0"
authors = ["Jake Probst <jake.probst@gmail.com>"] authors = ["Jake Probst <jake.probst@gmail.com>"]
edition = "2018" edition = "2018"
[[bin]]
name = "everything"
path = "src/main.rs"
[[bin]] [[bin]]
name = "patch" name = "patch"
path = "src/patch/main.rs"
path = "src/patch_main.rs"
[[bin]] [[bin]]
name = "login" name = "login"
path = "src/login/main.rs"
path = "src/login_main.rs"
[dependencies] [dependencies]
libpso = { git = "http://git.sharnoth.com/jake/libpso" } libpso = { git = "http://git.sharnoth.com/jake/libpso" }

1
src/entity/gateway/inmemory.rs

@ -8,6 +8,7 @@ use libpso::character::settings;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
#[derive(Clone)]
pub struct InMemoryGateway { pub struct InMemoryGateway {
users: Arc<Mutex<HashMap<u32, UserAccount>>>, users: Arc<Mutex<HashMap<u32, UserAccount>>>,
user_settings: Arc<Mutex<HashMap<u32, UserSettings>>>, user_settings: Arc<Mutex<HashMap<u32, UserSettings>>>,

4
src/lib.rs

@ -1,4 +0,0 @@
#![feature(const_generics)]
pub mod common;
pub mod entity;

18
src/login/character.rs

@ -8,15 +8,15 @@ use libpso::packet::login::*;
use libpso::{PacketParseError, PSOPacket}; use libpso::{PacketParseError, PSOPacket};
use libpso::crypto::bb::PSOBBCipher; use libpso::crypto::bb::PSOBBCipher;
use elseware::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY};
use elseware::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId};
use elseware::{utf8_to_array, utf8_to_utf16_array};
use crate::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY};
use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId};
use crate::{utf8_to_array, utf8_to_utf16_array};
use elseware::entity::gateway::EntityGateway;
use elseware::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
use elseware::entity::character::Character;
use crate::entity::gateway::EntityGateway;
use crate::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
use crate::entity::character::Character;
use crate::login::get_login_status;
use crate::login::login::get_login_status;
pub const CHARACTER_PORT: u16 = 12001; pub const CHARACTER_PORT: u16 = 12001;
@ -182,7 +182,7 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
}) })
} }
fn send_ship_list(&mut self, id: ClientId, pkt: &Login) -> Result<Vec<SendCharacterPacket>, CharacterError> {
fn send_ship_list(&mut self, _id: ClientId, _pkt: &Login) -> Result<Vec<SendCharacterPacket>, CharacterError> {
Ok(vec![SendCharacterPacket::Timestamp(Timestamp::new(chrono::Utc::now())), Ok(vec![SendCharacterPacket::Timestamp(Timestamp::new(chrono::Utc::now())),
SendCharacterPacket::ShipList(ShipList { SendCharacterPacket::ShipList(ShipList {
flag: 0, flag: 0,
@ -420,7 +420,7 @@ impl<EG: EntityGateway> ServerState for CharacterServerState<EG> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use elseware::entity::account::UserSettings;
use crate::entity::account::UserSettings;
use libpso::character::settings; use libpso::character::settings;
use std::time::SystemTime; use std::time::SystemTime;

14
src/login/login.rs

@ -9,14 +9,12 @@ use libpso::packet::login::*;
use libpso::{PacketParseError, PSOPacket}; use libpso::{PacketParseError, PSOPacket};
use libpso::crypto::bb::PSOBBCipher; use libpso::crypto::bb::PSOBBCipher;
use elseware::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY};
use elseware::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId};
use elseware::common::util::array_to_utf8;
use crate::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY};
use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId};
use crate::common::util::array_to_utf8;
//use crate::dataaccess::EntityGateway;
//use crate::entities::UserAccount;
use elseware::entity::gateway::EntityGateway;
use elseware::entity::account::UserAccount;
use crate::entity::gateway::EntityGateway;
use crate::entity::account::UserAccount;
pub const LOGIN_PORT: u16 = 12000; pub const LOGIN_PORT: u16 = 12000;
@ -88,7 +86,7 @@ impl<EG: EntityGateway> LoginServerState<EG> {
let ip = net::Ipv4Addr::new(127,0,0,1); let ip = net::Ipv4Addr::new(127,0,0,1);
let ip = u32::from_ne_bytes(ip.octets()); let ip = u32::from_ne_bytes(ip.octets());
vec![response, vec![response,
SendLoginPacket::RedirectClient(RedirectClient::new(ip, crate::character::CHARACTER_PORT))]
SendLoginPacket::RedirectClient(RedirectClient::new(ip, crate::login::character::CHARACTER_PORT))]
}, },
Err(err) => { Err(err) => {
vec![SendLoginPacket::LoginResponse(LoginResponse::by_status(err, pkt.security_data))] vec![SendLoginPacket::LoginResponse(LoginResponse::by_status(err, pkt.security_data))]

2
src/login/mod.rs

@ -0,0 +1,2 @@
pub mod login;
pub mod character;

20
src/login/main.rs → src/login_main.rs

@ -1,5 +1,8 @@
#![feature(const_generics)]
mod common;
mod login; mod login;
mod character;
mod entity;
use std::thread; use std::thread;
use std::collections::HashMap; use std::collections::HashMap;
@ -10,13 +13,12 @@ use libpso::character::settings;
use libpso::character::character as pso_character; use libpso::character::character as pso_character;
use libpso::character::guildcard; use libpso::character::guildcard;
use elseware::entity::gateway::EntityGateway;
use elseware::entity::account::{UserAccount, UserSettings, GuildCardData};
use elseware::entity::character::Character;
use elseware::utf8_to_utf16_array;
use entity::gateway::EntityGateway;
use entity::account::{UserAccount, UserSettings, GuildCardData};
use entity::character::Character;
use login::LoginServerState;
use character::CharacterServerState;
use login::login::LoginServerState;
use login::character::CharacterServerState;
use std::time::SystemTime; use std::time::SystemTime;
@ -97,11 +99,11 @@ fn main() {
let auth_thread = thread::spawn(|| { let auth_thread = thread::spawn(|| {
let auth_state = LoginServerState::new(LoginStubData::new()); let auth_state = LoginServerState::new(LoginStubData::new());
elseware::common::mainloop::mainloop(auth_state, login::LOGIN_PORT);
common::mainloop::mainloop(auth_state, login::login::LOGIN_PORT);
}); });
let char_thread = thread::spawn(|| { let char_thread = thread::spawn(|| {
let char_state = CharacterServerState::new(LoginStubData::new()); let char_state = CharacterServerState::new(LoginStubData::new());
elseware::common::mainloop::mainloop(char_state, character::CHARACTER_PORT);
common::mainloop::mainloop(char_state, login::character::CHARACTER_PORT);
}); });
auth_thread.join().unwrap(); auth_thread.join().unwrap();

1
src/patch/mod.rs

@ -0,0 +1 @@
pub mod patch;

5
src/patch/patch.rs

@ -8,8 +8,9 @@ use crc::{crc32, Hasher32};
use libpso::{PacketParseError, PSOPacket}; use libpso::{PacketParseError, PSOPacket};
use libpso::packet::patch::*; use libpso::packet::patch::*;
use libpso::crypto::pc::PSOPCCipher; use libpso::crypto::pc::PSOPCCipher;
use elseware::common::network::{PacketNetworkError};
use elseware::common::serverstate::{RecvServerPacket, SendServerPacket, ServerState, OnConnect, ClientId};
use crate::common::network::{PacketNetworkError};
use crate::common::serverstate::{RecvServerPacket, SendServerPacket, ServerState, OnConnect, ClientId};
pub const PATCH_PORT: u16 = 11000; pub const PATCH_PORT: u16 = 11000;

7
src/patch/main.rs → src/patch_main.rs

@ -1,5 +1,8 @@
#![feature(const_generics)]
mod common;
mod patch; mod patch;
use patch::{PatchServerState, PatchTreeIterItem, generate_patch_tree, PATCH_PORT};
use crate::patch::patch::{PatchServerState, PatchTreeIterItem, generate_patch_tree, PATCH_PORT};
fn main() { fn main() {
println!("[patch] starting server"); println!("[patch] starting server");
@ -30,7 +33,7 @@ fn main() {
} }
let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup); let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup);
elseware::common::mainloop::mainloop(patch_state, PATCH_PORT);
common::mainloop::mainloop(patch_state, PATCH_PORT);
println!("[patch] exiting..."); println!("[patch] exiting...");
} }
Loading…
Cancel
Save