From 534bd19d25fd2211140d12540116eafd96aacc09 Mon Sep 17 00:00:00 2001 From: Abhishek Chanda Date: Sat, 12 Mar 2016 02:13:40 -0800 Subject: [PATCH] Reject unspecified and loopback IP from global --- src/libstd/net/ip.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 9c8ff44c7043f..bb688ab484ad3 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -371,10 +371,12 @@ impl Ipv6Addr { /// - the link-local addresses /// - the (deprecated) site-local addresses /// - unique local addresses + /// - the unspecified address pub fn is_unicast_global(&self) -> bool { !self.is_multicast() && !self.is_loopback() && !self.is_unicast_link_local() && !self.is_unicast_site_local() && !self.is_unique_local() + && !self.is_unspecified() } /// Returns the address's multicast scope if the address is multicast. @@ -768,7 +770,7 @@ mod tests { // unspec loopbk uniqlo global unill unisl uniglo mscope check("::", - true, false, false, true, false, false, true, None); + true, false, false, false, false, false, false, None); check("::1", false, true, false, false, false, false, false, None); check("::0.0.0.2",