mirror of
https://github.com/oddlama/nixos-extra-modules.git
synced 2025-10-10 22:00:39 +02:00
fix: lib.net.cidr.host performs type-appropriate bounds check
This commit is contained in:
parent
5cc4cb34fb
commit
12b9f46b00
1 changed files with 6 additions and 2 deletions
|
@ -67,9 +67,13 @@ in
|
||||||
i: n:
|
i: n:
|
||||||
let
|
let
|
||||||
cap = libNet.net.cidr.capacity n;
|
cap = libNet.net.cidr.capacity n;
|
||||||
|
intCheck = builtins.isInt i -> (i >= (-cap) && i < cap);
|
||||||
|
ipCheck = libNet.net.types.ip.check i -> ((libNet.net.types.ip-in n).check result);
|
||||||
|
|
||||||
|
result = libNet.net.cidr.host i n;
|
||||||
in
|
in
|
||||||
assert assertMsg (i >= (-cap) && i < cap) "The host ${toString i} lies outside of ${n}";
|
assert assertMsg (ipCheck && intCheck) "The host ${toString i} lies outside of ${n}";
|
||||||
libNet.net.cidr.host i n;
|
result;
|
||||||
# hostCidr :: (ip | mac | integer) -> cidr -> cidr
|
# hostCidr :: (ip | mac | integer) -> cidr -> cidr
|
||||||
#
|
#
|
||||||
# Returns the nth host in the given cidr range (like cidr.host)
|
# Returns the nth host in the given cidr range (like cidr.host)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue