Skip to content

Commit 27b2201

Browse files
committed
Reject the reserved block as not global
1 parent db837d0 commit 27b2201

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libstd/net/ip.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ impl Ipv4Addr {
121121
}
122122

123123
/// Returns true if the address appears to be globally routable.
124+
/// See [iana-ipv4-special-registry][ipv4-sr].
125+
/// [ipv4-sr]: http://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
124126
///
125127
/// The following return false:
126128
///
@@ -131,7 +133,8 @@ impl Ipv4Addr {
131133
/// - test addresses used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24)
132134
pub fn is_global(&self) -> bool {
133135
!self.is_private() && !self.is_loopback() && !self.is_link_local() &&
134-
!self.is_broadcast() && !self.is_documentation() && !self.is_unspecified()
136+
!self.is_broadcast() && !self.is_documentation() && !self.is_unspecified() &&
137+
!self.is_this_network()
135138
}
136139

137140
/// Returns true if this is a multicast address.

0 commit comments

Comments
 (0)