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

.broadcast() returns IPv4('0.0.0.2') for IPv6('::2/128') #73

Open
jn0 opened this issue Nov 30, 2020 · 3 comments
Open

.broadcast() returns IPv4('0.0.0.2') for IPv6('::2/128') #73

jn0 opened this issue Nov 30, 2020 · 3 comments
Labels

Comments

@jn0
Copy link

jn0 commented Nov 30, 2020

return IP(IPint.broadcast(self))

missing IP version propagation as compared to
return IP(IPint.net(self), ipversion=self._ipversion)

Reproduce with:

import IPy; print(IPy.IP('::3/128').broadcast().version()) # 4

In general, I'd prefer to have .first_address() and .last_address() methods as IPv6 address has no "broadcast" part.

// random losses of edits observed //

@autocracy
Copy link
Owner

So I should raise an error on .broadcast() when it's v6?

IPRange[0] and IPRange[-1] I think will provide you with first and last. I'll look later.

@jn0
Copy link
Author

jn0 commented Dec 2, 2020

So I should raise an error on .broadcast() when it's v6?

I think, no. It will break lots of code. As a first mitigation I'd propose to pass the version info (like in .net() method).

Please, keep in mind that, for instance, https://github.com/irrdnet/irrd makes heavy use of .net()/.broadcast() (yepp, instead of ip[0]/ip[-1]) and is a production code (not mine 😄 )

@autocracy
Copy link
Owner

I think you're generally right here. Patch encouraged, otherwise I'll code it up next time I get nudged to do a release for other reasons.

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

No branches or pull requests

2 participants