From 36f184d736a636c8e0418e5620e661292a8a9b93 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 3 Feb 2021 09:03:21 +0100 Subject: Making the wireguard module a kjar. --- module/ri-wireguard/classpath.txt | 2 +- module/ri-wireguard/pom.xml | 1 + .../io/trygvis/rules/wireguard/wireguard.drl | 19 ++++++++++--------- 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 @@ ri-wireguard + kjar 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( -- cgit v1.2.3