Skip to content

Commit 189c694

Browse files
6543odeke-em
authored andcommitted
net: reference the correct RFCs and sections for IP.IsPrivate
Properly cite RFC 1918 Section 3 for ipv4, and RFC 4193 Section 8 for ipv6 comments. Updates #29146 Change-Id: I8a2df0d7bef50444294bb3301fe09fb09f21ffaf GitHub-Last-Rev: b034179 GitHub-Pull-Request: #45500 Reviewed-on: https://go-review.googlesource.com/c/go/+/309249 Reviewed-by: Emmanuel Odeke <[email protected]> Reviewed-by: Tobias Klauser <[email protected]> Run-TryBot: Emmanuel Odeke <[email protected]>
1 parent 3f4977b commit 189c694

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/net/ip.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,18 @@ func (ip IP) IsLoopback() bool {
132132
// RFC 1918 (IPv4 addresses) and RFC 4193 (IPv6 addresses).
133133
func (ip IP) IsPrivate() bool {
134134
if ip4 := ip.To4(); ip4 != nil {
135-
// Following RFC 4193, Section 3. Local IPv6 Unicast Addresses which says:
135+
// Following RFC 1918, Section 3. Private Address Space which says:
136136
// The Internet Assigned Numbers Authority (IANA) has reserved the
137-
// following three blocks of the IPv4 address space for private internets:
137+
// following three blocks of the IP address space for private internets:
138138
// 10.0.0.0 - 10.255.255.255 (10/8 prefix)
139139
// 172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
140140
// 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
141141
return ip4[0] == 10 ||
142142
(ip4[0] == 172 && ip4[1]&0xf0 == 16) ||
143143
(ip4[0] == 192 && ip4[1] == 168)
144144
}
145-
// Following RFC 4193, Section 3. Private Address Space which says:
146-
// The Internet Assigned Numbers Authority (IANA) has reserved the
147-
// following block of the IPv6 address space for local internets:
148-
// FC00:: - FDFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF (FC00::/7 prefix)
145+
// Following RFC 4193, Section 8. IANA Considerations which says:
146+
// The IANA has assigned the FC00::/7 prefix to "Unique Local Unicast".
149147
return len(ip) == IPv6len && ip[0]&0xfe == 0xfc
150148
}
151149

0 commit comments

Comments
 (0)