summaryrefslogtreecommitdiffstats
path: root/src/bin/server/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/server/main.rs')
-rw-r--r--src/bin/server/main.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/bin/server/main.rs b/src/bin/server/main.rs
index 8dba415..2770387 100644
--- a/src/bin/server/main.rs
+++ b/src/bin/server/main.rs
@@ -8,6 +8,25 @@ use std::thread;
8 8
9fn main() { 9fn main() {
10 let args = args::parse_args(); 10 let args = args::parse_args();
11
12 if args.init {
13 match zagan_bet::server::setup::init_identity(std::path::Path::new("."), "localhost") {
14 Ok(report) => {
15 println!("TLS identity created:");
16 println!(" {} (PKCS#12, empty password)", report.identity.display());
17 println!(" {} (private key)", report.key.display());
18 println!(" {} (certificate)", report.cert.display());
19 println!("\nStart the server with:\n cargo run --bin server");
20 println!("Clients will trust this certificate on first contact.");
21 }
22 Err(error) => {
23 eprintln!("TLS setup failed:\n{error}");
24 std::process::exit(1);
25 }
26 }
27 return;
28 }
29
11 let listener = match TcpListener::bind(format!("{}:{}", args.ip, args.port)) { 30 let listener = match TcpListener::bind(format!("{}:{}", args.ip, args.port)) {
12 Ok(l) => l, 31 Ok(l) => l,
13 Err(e) => { 32 Err(e) => {
@@ -16,7 +35,7 @@ fn main() {
16 } 35 }
17 }; 36 };
18 37
19 let tls = match tls::TlsServer::new("identity.p12", "key.pem", args.unsafe_mode) { 38 let tls = match tls::TlsServer::new("identity.p12") {
20 Ok(t) => Arc::new(t), 39 Ok(t) => Arc::new(t),
21 Err(e) => { 40 Err(e) => {
22 eprintln!("Failed to initialize TLS: {}", e); 41 eprintln!("Failed to initialize TLS: {}", e);