-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
lib.network: first/last and next addresses in a network #322004
base: master
Are you sure you want to change the base?
lib.network: first/last and next addresses in a network #322004
Conversation
0a70fc2
to
a1c1375
Compare
|
||
- [addr] An IPv6 address with optional prefix length. | ||
*/ | ||
fromString = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of modifying fromString
, we should have something like lib.ipv6.firstAddress
and lib.ipv6.lastAddress
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, can you explain roughly how you want to use the library? From my point of view, I expect something like fromString <addr>
and then the user takes whatever data they need from the returned attr set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's fair, esp. since if we implement it correctly the values are lazily evaluated, which means it doesn't really increase the cost. But I still think we should expose the function to end users because it's more ergonomic to call lib.ipv6.lastAddress "f00::c0ffee/64"
vs (lib.ipv6.fromString "f00::c0ffee/64").lastAddress
. There will also be functions in the future that aren't really incorporatable into fromString
, for example imagine something like lib.ipv6.arithmetic "f00::c0ffee/64" (-50)
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/showcase-nixpkgs-network-library/48897/1 |
a1c1375
to
59063ec
Compare
59063ec
to
1ceb72f
Compare
767e9ea
to
d2ff8fc
Compare
d2ff8fc
to
6865016
Compare
Add ipv6 ipv6Addr and ipv6AddrAttrs types. Add ipv6.isValidIpStr function to be used as the ipv6Addr type checker. Add mkNetworkingOption that uses `coercedTo` function to convert string IP to parsed attr set ipv6AddrAttrs. Change the design of `ipv6.fromString` function. It used to be created to return an attrset of data like `nextAddr`, `firstAddr`, etc. But now it returns an attrset with a string representation of the address (default and Cidr) and contains an internal representation. That way, other future functions like `nextAddr` can easily take such type and create a new one, because there is no need to reparse the string.
README.md explains the design and purpose of the network library. At the time of writing, IPv4 functionality is not yet merged.
Add functions to calculate first and last addresses. Add unit tests.
Add a functions to calculate the next address from the specified or null. Add unit tests.
6865016
to
ac56c45
Compare
Description of changes
Depends on #318712 and #326765
bitwise operations.
Mentor: @Janik-Haag
Things done
Add a 👍 reaction to pull requests you find important.