Merge pull request #2 from spacekitteh/fix-nethost-typecheck
This commit is contained in:
commit
89958adf3d
1 changed files with 6 additions and 2 deletions
|
@ -67,9 +67,13 @@ in
|
|||
i: n:
|
||||
let
|
||||
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
|
||||
assert assertMsg (i >= (-cap) && i < cap) "The host ${toString i} lies outside of ${n}";
|
||||
libNet.net.cidr.host i n;
|
||||
assert assertMsg (ipCheck && intCheck) "The host ${toString i} lies outside of ${n}";
|
||||
result;
|
||||
# hostCidr :: (ip | mac | integer) -> cidr -> cidr
|
||||
#
|
||||
# Returns the nth host in the given cidr range (like cidr.host)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue