It would be easy now that we have node fact to accept both IP and CIDR in the "equal" field of IP match.
Something like:
final case class NodeCriterionMatcherIpaddress(extractor: CoreNodeFact => Chunk[Cidr[IpAddress]])
extends NodeCriterionOrderedValueMatcher[Cidr[IpAddress]] {
override def parseNum(value: String): Option[Cidr[IpAddress]] = Cidr.fromString(value).orElse(IpAddress.fromString(value).map(ip => Cidr(ip, 32)))
override def serialise(a: Cidr[IpAddress]): String = a.toString()
val order: Ordering[Cidr[IpAddress]] = Ordering.String.on(_.toString())
implicit val ser: Cidr[IpAddress] => String = serialise _
override def matches(n: CoreNodeFact, comparator: CriterionComparator, value: String): IOResult[Boolean] = {
comparator match {
case Equals =>
tryMatches(
value,
a =>
MatchHolder[Cidr[IpAddress]](DebugInfo(Equals.id, Some(value)), extractor(n), _.exists(ip => a.contains(ip.address)))
)
case _ => super.matches(n, comparator, value)
}
}
}
// and in Node comparator, and other relevant places:
ObjectCriterion(
OC_NODE,
Chunk(
...
Criterion(A_LIST_OF_IP, NodeIpListComparator, NodeCriterionMatcherIpaddress(_.ipAddresses.flatMap(ip => Cidr.fromString(ip.inet +"/32")))),
...
)
),
(needs to be done for ipV4 and ipV6)