blob: d9832fd9873a5a081f82c3db9e9e4d411ce051bb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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.");
}
|