//! 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::() { 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."); }