Skip to content

net: IPv6 network does not contain IPv4 to IPv6 translated addresses #37597

@pixelbender

Description

@pixelbender

What version of Go are you using (go version)?

1.14

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

All operating system and processor architectures

What did you do?

https://play.golang.org/p/IN-TOcROQnr

// "8.8.8.8" translated to IPv6, same as net.ParseIP("8.8.8.8")
ip := net.ParseIP("0:0:0:0:0:ffff:808:808")

_, ipv4, _ := net.ParseCIDR("0.0.0.0/0")
fmt.Println(ipv4.Contains(ip)) // true

_, ipv6, _ := net.ParseCIDR("::/0")
fmt.Println(ipv6.Contains(ip)) // why it says false?

_, translated, _ := net.ParseCIDR("::ffff:0:0/96")
fmt.Println(translated.Contains(ip)) // true

What did you expect to see?

true
true
true

What did you see instead?

true
false
true

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions