From ce8ba48e201c775f8aff58a6c7d8a4a47ff210cb Mon Sep 17 00:00:00 2001 From: "Y. T. Chung" Date: Tue, 4 Nov 2014 00:58:09 +0800 Subject: [PATCH] fixed a bug --- src/config.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index a9fe92bd..6dd3110f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -238,7 +238,10 @@ impl Config { } if require_local_info { - if o.contains_key(&"local_address".to_string()) && o.contains_key(&"local_port".to_string()) { + let has_local_address = o.contains_key(&"local_address".to_string()); + let has_local_port = o.contains_key(&"local_port".to_string()); + + if has_local_address && has_local_port { config.local = match o.find(&"local_address".to_string()) { Some(local_addr) => { Some(SocketAddr { @@ -251,7 +254,7 @@ impl Config { }, None => None, }; - } else { + } else if has_local_address ^ has_local_port { panic!("You have to provide `local_address` and `local_port` together"); } }