]> Cypherpunks repositories - gostls13.git/commitdiff
net: reference the correct RFCs and sections for IP.IsPrivate
author6543 <6543@obermui.de>
Sun, 11 Apr 2021 04:37:47 +0000 (04:37 +0000)
committerEmmanuel Odeke <emmanuel@orijtech.com>
Sun, 11 Apr 2021 15:56:20 +0000 (15:56 +0000)
Properly cite RFC 1918 Section 3 for ipv4,
and RFC 4193 Section 8 for ipv6 comments.

Updates #29146

Change-Id: I8a2df0d7bef50444294bb3301fe09fb09f21ffaf
GitHub-Last-Rev: b0341791c0c4a2f47fcea65a7ab3877afbe2040a
GitHub-Pull-Request: golang/go#45500
Reviewed-on: https://go-review.googlesource.com/c/go/+/309249
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>

src/net/ip.go

index da51dab800b8ece3c50268f5a25bbd068af9f9dc..047726976184d904b325470323963341b84d86e5 100644 (file)
@@ -132,9 +132,9 @@ func (ip IP) IsLoopback() bool {
 // RFC 1918 (IPv4 addresses) and RFC 4193 (IPv6 addresses).
 func (ip IP) IsPrivate() bool {
        if ip4 := ip.To4(); ip4 != nil {
-               // Following RFC 4193, Section 3. Local IPv6 Unicast Addresses which says:
+               // Following RFC 1918, Section 3. Private Address Space which says:
                //   The Internet Assigned Numbers Authority (IANA) has reserved the
-               //   following three blocks of the IPv4 address space for private internets:
+               //   following three blocks of the IP address space for private internets:
                //     10.0.0.0        -   10.255.255.255  (10/8 prefix)
                //     172.16.0.0      -   172.31.255.255  (172.16/12 prefix)
                //     192.168.0.0     -   192.168.255.255 (192.168/16 prefix)
@@ -142,10 +142,8 @@ func (ip IP) IsPrivate() bool {
                        (ip4[0] == 172 && ip4[1]&0xf0 == 16) ||
                        (ip4[0] == 192 && ip4[1] == 168)
        }
-       // Following RFC 4193, Section 3. Private Address Space which says:
-       //   The Internet Assigned Numbers Authority (IANA) has reserved the
-       //   following block of the IPv6 address space for local internets:
-       //     FC00::  -  FDFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF (FC00::/7 prefix)
+       // Following RFC 4193, Section 8. IANA Considerations which says:
+       //   The IANA has assigned the FC00::/7 prefix to "Unique Local Unicast".
        return len(ip) == IPv6len && ip[0]&0xfe == 0xfc
 }