Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert IPv4 mapped IPv6 subnet masks to 4 bytes from 16 bytes (using the last 4 bytes) #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

damilola-bello
Copy link

@yl2chen
Currently, you can't add IPv4 mapped IPv6 networks.

For example, If you try insert ::ffff:d1ad:35a7/128, a nil network will be inserted. This uses ipV4Ranger (as it is stored as IPv4 address internally), but the mask isn't converted and remains 16 bytes. Hence you have something like this 209.173.53.167/128 instead of 209.173.53.167/32.

func (n Network) Masked(ones int) Network {
mask := net.CIDRMask(ones, len(n.Number)*BitsPerUint32)
return NewNetwork(net.IPNet{
IP: n.IP.Mask(mask),
Mask: mask,
})
}

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 91.327% when pulling 6ba34bb on aterlo:master into e434ea7 on yl2chen:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants