summaryrefslogtreecommitdiff
path: root/module/ri-wireguard/src/main
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2021-02-03 09:03:21 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2021-02-03 09:03:21 +0100
commit36f184d736a636c8e0418e5620e661292a8a9b93 (patch)
tree59cbe8e6acb16472cec8898395ec38eb7d353ccb /module/ri-wireguard/src/main
parent1182531ed31ccff36e26121ae0cc5b3243669317 (diff)
downloadrules-sandbox-36f184d736a636c8e0418e5620e661292a8a9b93.tar.gz
rules-sandbox-36f184d736a636c8e0418e5620e661292a8a9b93.tar.bz2
rules-sandbox-36f184d736a636c8e0418e5620e661292a8a9b93.tar.xz
rules-sandbox-36f184d736a636c8e0418e5620e661292a8a9b93.zip
Making the wireguard module a kjar.
Diffstat (limited to 'module/ri-wireguard/src/main')
-rw-r--r--module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl19
1 files changed, 10 insertions, 9 deletions
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(