Skip to content

Commit

Permalink
Reject unspecified and loopback IP from global
Browse files Browse the repository at this point in the history
  • Loading branch information
achanda committed Mar 12, 2016
1 parent 5807fbb commit 534bd19
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libstd/net/ip.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 534bd19

Please sign in to comment.