1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-30 18:37:45 +00:00

Begin adding save data bank

This commit is contained in:
Joshua Goins 2025-04-22 18:46:04 -04:00
parent 2a6c9ee76c
commit d89a976c78
4 changed files with 67 additions and 0 deletions

View file

@ -14,6 +14,10 @@ launcher.ffxiv.localhost:80 {
reverse_proxy :5802
}
config-dl.ffxiv.localhost:80 {
reverse_proxy :5803
}
frontier.ffxiv.localhost:80 {
reverse_proxy :5857
}

View file

@ -10,4 +10,5 @@ cargo run -q --package kawari --features oodle --bin kawari-web &
cargo run -q --package kawari --features oodle --bin kawari-lobby &
cargo run -q --package kawari --features oodle --bin kawari-world &
cargo run -q --package kawari --features oodle --bin kawari-launcher &
cargo run -q --package kawari --features oodle --bin kawari-savedatabank &
wait

View file

@ -0,0 +1,32 @@
use kawari::RECEIVE_BUFFER_SIZE;
use kawari::config::get_config;
use tokio::io::AsyncReadExt;
use tokio::net::TcpListener;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let config = get_config();
let addr = config.save_data_bank.get_socketaddr();
let listener = TcpListener::bind(addr).await.unwrap();
tracing::info!("Server started on {addr}");
loop {
let (mut socket, _) = listener.accept().await.unwrap();
tokio::spawn(async move {
loop {
let mut buf = vec![0; RECEIVE_BUFFER_SIZE];
let n = socket.read(&mut buf).await.expect("Failed to read data!");
if n != 0 {
dbg!(buf);
}
}
});
}
}

View file

@ -289,6 +289,32 @@ impl LauncherConfig {
}
}
/// Configuration for the save data bank server.
#[derive(Serialize, Deserialize)]
pub struct SaveDataBankConfig {
pub port: u16,
pub listen_address: String,
}
impl Default for SaveDataBankConfig {
fn default() -> Self {
Self {
port: 5803,
listen_address: "127.0.0.1".to_string(),
}
}
}
impl SaveDataBankConfig {
/// Returns the configured IP address & port as a `SocketAddr`.
pub fn get_socketaddr(&self) -> SocketAddr {
SocketAddr::from((
IpAddr::from_str(&self.listen_address).expect("Invalid IP address format in config!"),
self.port,
))
}
}
/// Global and all-encompassing config.
/// Settings that affect all servers belong here.
#[derive(Serialize, Deserialize)]
@ -323,6 +349,9 @@ pub struct Config {
#[serde(default)]
pub launcher: LauncherConfig,
#[serde(default)]
pub save_data_bank: SaveDataBankConfig,
/// Enable various packet debug functions. This will clutter your working directory!
#[serde(default)]
pub packet_debugging: bool,
@ -341,6 +370,7 @@ impl Default for Config {
web: WebConfig::default(),
world: WorldConfig::default(),
launcher: LauncherConfig::default(),
save_data_bank: SaveDataBankConfig::default(),
packet_debugging: false,
}
}