From bd2208922ea6a0486074c72a57b01d7df368f885 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 6 Jan 2021 09:12:56 +0100 Subject: Generating IP addresses. --- src/main/resources/io/trygvis/rules/acme/vpn.drl | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/main/resources/io/trygvis/rules') diff --git a/src/main/resources/io/trygvis/rules/acme/vpn.drl b/src/main/resources/io/trygvis/rules/acme/vpn.drl index 90cdce2..0f0b3c8 100644 --- a/src/main/resources/io/trygvis/rules/acme/vpn.drl +++ b/src/main/resources/io/trygvis/rules/acme/vpn.drl @@ -4,13 +4,30 @@ import java.util.ArrayList import io.trygvis.rules.machine.Machine; import io.trygvis.rules.dns.DnsEntry; import io.trygvis.rules.acme.AcmeServer -import io.trygvis.rules.acme.WgHost; +import io.trygvis.rules.network.Ipv4Address +import io.trygvis.rules.network.Ipv4Cidr dialect "mvel" declare WgNet - name : String - domain : String + name : String + domain : String + linkCidr : String + networkCidr : String +end + +rule "Create link network" when + $net : WgNet() + not(Ipv4Cidr(network == IpCalc.cidr($net.linkCidr).network)) +then + insert(IpCalc.cidr($net.linkCidr)) +end + +rule "Create link network addresses" when + $cidr : Ipv4Cidr() + $addresses : Ipv4Address() from $cidr.addresses +then + insert($addresses) end declare WgHost -- cgit v1.2.3