mirror of
https://github.com/golang/go
synced 2024-11-24 09:30:07 -07:00
net/netip: improve documentation terminology for IPv4-mapped IPv6 addresses
Updates #51834 Change-Id: I07a43457e2e328b51fea8131f7d6d5a4f1de4dc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/394078 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
This commit is contained in:
parent
67d6a51065
commit
153c18a515
@ -456,7 +456,7 @@ func (ip Addr) lessOrEq(ip2 Addr) bool { return ip.Compare(ip2) <= 0 }
|
|||||||
|
|
||||||
// Is4 reports whether ip is an IPv4 address.
|
// Is4 reports whether ip is an IPv4 address.
|
||||||
//
|
//
|
||||||
// It returns false for IP4-mapped IPv6 addresses. See IP.Unmap.
|
// It returns false for IPv4-mapped IPv6 addresses. See IP.Unmap.
|
||||||
func (ip Addr) Is4() bool {
|
func (ip Addr) Is4() bool {
|
||||||
return ip.z == z4
|
return ip.z == z4
|
||||||
}
|
}
|
||||||
@ -675,7 +675,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// As16 returns the IP address in its 16-byte representation.
|
// As16 returns the IP address in its 16-byte representation.
|
||||||
// IPv4 addresses are returned in their IPv4-mapped IPv6 form.
|
// IPv4 addresses are returned as IPv4-mapped IPv6 addresses.
|
||||||
// IPv6 addresses with zones are returned without their zone (use the
|
// IPv6 addresses with zones are returned without their zone (use the
|
||||||
// Zone method to get it).
|
// Zone method to get it).
|
||||||
// The ip zero value returns all zeroes.
|
// The ip zero value returns all zeroes.
|
||||||
@ -758,7 +758,7 @@ func (ip Addr) Prev() Addr {
|
|||||||
// - IPv6 with zone ("fe80:db8::1%eth0")
|
// - IPv6 with zone ("fe80:db8::1%eth0")
|
||||||
//
|
//
|
||||||
// Note that unlike package net's IP.String method,
|
// Note that unlike package net's IP.String method,
|
||||||
// IP4-mapped IPv6 addresses format with a "::ffff:"
|
// IPv4-mapped IPv6 addresses format with a "::ffff:"
|
||||||
// prefix before the dotted quad.
|
// prefix before the dotted quad.
|
||||||
func (ip Addr) String() string {
|
func (ip Addr) String() string {
|
||||||
switch ip.z {
|
switch ip.z {
|
||||||
@ -1380,7 +1380,7 @@ func (p Prefix) Contains(ip Addr) bool {
|
|||||||
//
|
//
|
||||||
// If p and o are of different address families or either have a zero
|
// If p and o are of different address families or either have a zero
|
||||||
// IP, it reports false. Like the Contains method, a prefix with an
|
// IP, it reports false. Like the Contains method, a prefix with an
|
||||||
// IPv4-mapped IPv6 IP is still treated as an IPv6 mask.
|
// IPv4-mapped IPv6 address is still treated as an IPv6 mask.
|
||||||
func (p Prefix) Overlaps(o Prefix) bool {
|
func (p Prefix) Overlaps(o Prefix) bool {
|
||||||
if !p.IsValid() || !o.IsValid() {
|
if !p.IsValid() || !o.IsValid() {
|
||||||
return false
|
return false
|
||||||
|
@ -1757,7 +1757,7 @@ func TestPrefixOverlaps(t *testing.T) {
|
|||||||
{pfx("1::1/128"), pfx("2::2/128"), false},
|
{pfx("1::1/128"), pfx("2::2/128"), false},
|
||||||
{pfx("0100::0/8"), pfx("::1/128"), false},
|
{pfx("0100::0/8"), pfx("::1/128"), false},
|
||||||
|
|
||||||
// IPv4-mapped IPv6 should not overlap with IPv4.
|
// IPv4-mapped IPv6 addresses should not overlap with IPv4.
|
||||||
{PrefixFrom(AddrFrom16(mustIP("1.2.0.0").As16()), 16), pfx("1.2.3.0/24"), false},
|
{PrefixFrom(AddrFrom16(mustIP("1.2.0.0").As16()), 16), pfx("1.2.3.0/24"), false},
|
||||||
|
|
||||||
// Invalid prefixes
|
// Invalid prefixes
|
||||||
|
Loading…
Reference in New Issue
Block a user