diff options
| author | Arne Dußin | 2021-01-27 14:01:50 +0100 |
|---|---|---|
| committer | Arne Dußin | 2021-02-02 22:16:15 +0100 |
| commit | f92e9f6f07b1e3834c2ca58ce3510734819d08e4 (patch) | |
| tree | 20e3d3afce342a56ae98f6c20491482ccd2b5c6b /src/server_main.rs | |
| parent | c60a6d07efb120724b308e29e8e70f27c87c952d (diff) | |
| download | graf_karto-f92e9f6f07b1e3834c2ca58ce3510734819d08e4.tar.gz graf_karto-f92e9f6f07b1e3834c2ca58ce3510734819d08e4.zip | |
Rework graf karto to fit the client/server structure
Diffstat (limited to 'src/server_main.rs')
| -rw-r--r-- | src/server_main.rs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/server_main.rs b/src/server_main.rs index e69de29..d9832fd 100644 --- a/src/server_main.rs +++ b/src/server_main.rs @@ -0,0 +1,65 @@ +//! Dedicated server for graf_karto. Starts only the backend that the client relies on and allows +//! connections from the outside if possible. + +#![allow(dead_code)] +#![warn(missing_docs)] + +#[macro_use] +extern crate log; + +pub mod math; +pub mod net; +pub mod server; +pub mod stable_vec; +pub mod transformable; +pub mod world; + +use clap::{App, Arg}; +pub use server::*; + +fn main() { + println!( + "Graf Karto dedicated server version: {}", + clap::crate_version!() + ); + + let default_port = DEFAULT_PORT.to_string(); + let matches = App::new("Graf Karto") + .version(clap::crate_version!()) + .author(clap::crate_authors!()) + .about(clap::crate_description!()) + .arg( + Arg::with_name("port") + .short("p") + .value_name("SERVER_PORT") + .help("Set the port the should listen on.") + .default_value(&default_port), + ) + .arg( + Arg::with_name("ipv4") + .short("v4") + .help("Use virgin IPv4 instead of chad IPv6.. you monster"), + ) + .get_matches(); + + let use_ipv4 = matches.is_present("ipv4"); + let port = match matches + .value_of("port") + .expect("No port found, eventhough it should have a default value") + .parse::<u16>() + { + Ok(port) => port, + Err(e) => { + error!("Not a valid server port: {:?}", e); + warn!("Using default port {}", DEFAULT_PORT); + DEFAULT_PORT + } + }; + + let server_handle = server::start_with_port(port, use_ipv4) + .expect("Unable to start server. Make sure the port you want to bind it on is free."); + + server_handle + .join() + .expect("Server did not shut down correctly."); +} |
