From 5fd8987eb9e0658efcdb7e4e0d9815e86cab6479 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Tue, 4 Feb 2020 12:54:16 +0000 Subject: [PATCH] More easily expandable list of 'special' addresses that show binding warning --- mixnode/src/commands/run.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mixnode/src/commands/run.rs b/mixnode/src/commands/run.rs index 666e4f0c49..788de52ad3 100644 --- a/mixnode/src/commands/run.rs +++ b/mixnode/src/commands/run.rs @@ -73,6 +73,10 @@ fn show_binding_warning(address: String) { println!("\n##### WARNING #####\n"); } +fn special_addresses() -> Vec<&'static str> { + vec!["localhost", "127.0.0.1", "0.0.0.0", "::1", "[::1]"] +} + pub fn execute(matches: &ArgMatches) { let id = matches.value_of("id").unwrap(); @@ -85,10 +89,7 @@ pub fn execute(matches: &ArgMatches) { config = override_config(config, matches); let listening_ip_string = config.get_listening_address().ip().to_string(); - if listening_ip_string == "localhost" - || listening_ip_string == "127.0.0.1" - || listening_ip_string == "0.0.0.0" - { + if special_addresses().contains(&listening_ip_string.as_ref()) { show_binding_warning(listening_ip_string); }