From cde1ccb6f7d6d915155869732c33c0afddbb2027 Mon Sep 17 00:00:00 2001 From: Revertron Date: Sat, 3 Apr 2021 21:09:55 +0200 Subject: [PATCH] Added a profound error message in case DNS servers could not bind. --- src/dns/server.rs | 6 ++++-- src/main.rs | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dns/server.rs b/src/dns/server.rs index aa165f1..5fdb655 100644 --- a/src/dns/server.rs +++ b/src/dns/server.rs @@ -181,7 +181,8 @@ impl DnsServer for DnsUdpServer { /// This method takes ownership of the server, preventing the method from being called multiple times. fn run_server(self) -> Result<()> { // Bind the socket - let socket = UdpSocket::bind(self.context.dns_listen.as_str())?; + let socket = UdpSocket::bind(self.context.dns_listen.as_str()) + .expect(&format!("Cannot start DNS server on {}! Change listen address in config!", self.context.dns_listen.as_str())); // Spawn threads for handling requests for thread_id in 0..self.thread_count { @@ -302,7 +303,8 @@ impl DnsTcpServer { impl DnsServer for DnsTcpServer { fn run_server(mut self) -> Result<()> { - let socket = TcpListener::bind(self.context.dns_listen.as_str())?; + let socket = TcpListener::bind(self.context.dns_listen.as_str()) + .expect(&format!("Cannot start DNS server on {}! Change listen address in config!", self.context.dns_listen.as_str())); // Spawn threads for handling requests, and create the channels for thread_id in 0..self.thread_count { diff --git a/src/main.rs b/src/main.rs index 8d8c807..c8b2640 100644 --- a/src/main.rs +++ b/src/main.rs @@ -69,11 +69,10 @@ fn main() { if let Some(settings) = Settings::load(&path) { let string = toml::to_string(&settings).unwrap(); println!("{}", &string); - return; } else { println!("Error loading config for upgrade!"); - return; } + return; } };