You are given:
T
as a string, e.g.
"10.0.0.0/16"
.
"allow"
or
"deny"
.
"a.b.c.d/x"
.
Interpretation of rules when applied in order to the target CIDR T:
T
as the "remaining" region.
"allow"
and its CIDR overlaps with the current remaining region of
T
, we
remove
("cancel") the overlapping subset from the remaining region. (Think of this as: the allowed portion is handled elsewhere and is thus removed from what remains to be canceled.)
"deny"
and its CIDR has
any
overlap with the current remaining region of
T
, we immediately return
false
(because a deny rule applies somewhere inside
T
).
T
is completely empty (i.e., all IPs in
T
have been canceled out by
allow
rules without any deny overlap), then return
true
. Otherwise, return
false
.
Task:
Implement a function that, given T and the list of (type, CIDR) rules, returns a boolean indicating whether T can be fully canceled by the rules under the above semantics.
Clarifications and requirements:
a.b.c.d/x
describes all addresses sharing the first
x
bits with
a.b.c.d
.
T
may split into multiple disjoint CIDR ranges after applying some allow rules; you must handle such splitting correctly.