summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--module/ri-wireguard/classpath.txt2
-rw-r--r--module/ri-wireguard/pom.xml1
-rw-r--r--module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl19
3 files changed, 12 insertions, 10 deletions
diff --git a/module/ri-wireguard/classpath.txt b/module/ri-wireguard/classpath.txt
index 567c91f..af74a64 100644
--- a/module/ri-wireguard/classpath.txt
+++ b/module/ri-wireguard/classpath.txt
@@ -1,4 +1,4 @@
-io.trygvis.rules-sandbox.module:ri-wireguard:1.0-SNAPSHOT:jar
+io.trygvis.rules-sandbox.module:ri-wireguard:1.0-SNAPSHOT:kjar
com.fasterxml.jackson.core:jackson-annotations:2.12.0:jar
com.fasterxml.jackson.core:jackson-core:2.12.0:jar
com.fasterxml.jackson.core:jackson-databind:2.12.0:jar
diff --git a/module/ri-wireguard/pom.xml b/module/ri-wireguard/pom.xml
index 86c6faa..cc569d7 100644
--- a/module/ri-wireguard/pom.xml
+++ b/module/ri-wireguard/pom.xml
@@ -12,6 +12,7 @@
</parent>
<artifactId>ri-wireguard</artifactId>
+ <packaging>kjar</packaging>
<dependencies>
<dependency>
diff --git a/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl b/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl
index 1c7d251..5630ab6 100644
--- a/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl
+++ b/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl
@@ -1,11 +1,12 @@
package io.trygvis.rules.wireguard;
-import java.util.ArrayList
import io.trygvis.rules.dns.DnsEntry;
import io.trygvis.rules.machine.Machine;
+import io.trygvis.rules.network.IpCalc
import io.trygvis.rules.network.Ipv4Address
import io.trygvis.rules.network.Ipv4Cidr
-import io.trygvis.rules.network.IpCalc
+import java.util.ArrayList
+import java.util.List
import java.util.Map
global io.trygvis.rules.engine.TemplateEngine te;
@@ -53,8 +54,8 @@ rule "Create IP pools" when
// not(Ipv4Cidr(network == Ipv4Cidr.parseCidr($net.linkCidr).network))
then
System.out.println("Creating main IP pools");
- insert(new WgIpPool($net, "link", Ipv4Cidr.parseCidr($net.linkCidr)))
- insert(new WgIpPool($net, "networks", Ipv4Cidr.parseCidr($net.networkCidr)))
+ insert(new WgIpPool($net, "link", Ipv4Cidr.parseCidr($net.getLinkCidr())))
+ insert(new WgIpPool($net, "networks", Ipv4Cidr.parseCidr($net.getNetworkCidr())))
end
rule "WgHost VPN machines"
@@ -63,7 +64,7 @@ when
$wgNet : WgNet(name == "vpn0")
not(WgHost(machine == $machine))
then
- var wgHost = new WgHost();
+ WgHost wgHost = new WgHost();
wgHost.machine = $machine;
wgHost.net = $wgNet;
wgHost.publicName = $machine.fqdn;
@@ -86,7 +87,7 @@ when
$h : WgHost()
not(DnsEntry(fqdn == "%s.%s".formatted($h.machine.name, $h.net.domain), type == "A"))
then
- var fqdn = "%s.%s".formatted($h.machine.name, $h.net.domain);
+ String fqdn = "%s.%s".formatted($h.machine.name, $h.net.domain);
insert(DnsEntry.a(fqdn))
end
@@ -97,7 +98,7 @@ when
$other : WgHost(publicName != null, this != $h)
then
System.out.printf("VPN connection from %s to %s%n", $h.machine.name, $other.machine.name);
- var c = new WgConnection();
+ WgConnection c = new WgConnection();
c.host = $h;
c.to = $other;
insert(c)
@@ -152,10 +153,10 @@ then
"net", $net
));
- var machines = new ArrayList();
+ List machines = new ArrayList();
for (Object o : $hosts) {
WgHost m = (WgHost) o;
- machines.add(m.machine);
+ machines.add(m.getMachine());
}
te.template("wireguard/inventory", "inventory.yml", Map.of(