summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--out/phase-1.yaml60
-rw-r--r--out/vpn0.yaml60
-rw-r--r--src/main/java/io/trygvis/rules/network/Ipv4Cidr.java2
-rw-r--r--src/main/resources/io/trygvis/rules/acme/vpn.drl27
4 files changed, 141 insertions, 8 deletions
diff --git a/out/phase-1.yaml b/out/phase-1.yaml
index b582087..c9974d0 100644
--- a/out/phase-1.yaml
+++ b/out/phase-1.yaml
@@ -30,6 +30,66 @@ data:
name: "acme-3"
fqdn: "acme-3.machine.acme.com"
---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-1"
+ to: "acme-2"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-1"
+ to: "acme-3"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-2"
+ to: "acme-1"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-2"
+ to: "acme-3"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-3"
+ to: "acme-1"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-3"
+ to: "acme-2"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-1"
+ to: "acme-1"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-1"
+ to: "acme-2"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-1"
+ to: "acme-3"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-2"
+ to: "acme-1"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-2"
+ to: "acme-2"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-2"
+ to: "acme-3"
+---
type: "io.trygvis.rules.acme.WgHost"
data:
name: "acme-1"
diff --git a/out/vpn0.yaml b/out/vpn0.yaml
index 3fc6836..bf5aee6 100644
--- a/out/vpn0.yaml
+++ b/out/vpn0.yaml
@@ -1,4 +1,64 @@
---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-1"
+ to: "acme-2"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-1"
+ to: "acme-3"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-2"
+ to: "acme-1"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-2"
+ to: "acme-3"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-3"
+ to: "acme-1"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "acme-3"
+ to: "acme-2"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-1"
+ to: "acme-1"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-1"
+ to: "acme-2"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-1"
+ to: "acme-3"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-2"
+ to: "acme-1"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-2"
+ to: "acme-2"
+---
+type: "io.trygvis.rules.acme.WgConnection"
+data:
+ host: "ws-2"
+ to: "acme-3"
+---
type: "io.trygvis.rules.acme.WgHost"
data:
name: "acme-1"
diff --git a/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java b/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java
index 6e1dde9..e69cd02 100644
--- a/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java
+++ b/src/main/java/io/trygvis/rules/network/Ipv4Cidr.java
@@ -6,8 +6,6 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/src/main/resources/io/trygvis/rules/acme/vpn.drl b/src/main/resources/io/trygvis/rules/acme/vpn.drl
index 0f0b3c8..456cbae 100644
--- a/src/main/resources/io/trygvis/rules/acme/vpn.drl
+++ b/src/main/resources/io/trygvis/rules/acme/vpn.drl
@@ -71,15 +71,30 @@ then
insert(DnsEntry.a(fqdn))
end
+declare WgConnection
+ host : String
+ to : String
+end
+
rule "Connect VPN nodes"
salience -1
when
$h : WgHost()
- $others : ArrayList()
- from collect(WgHost(publicName != null, name != $h.name))
+ $other : WgHost(publicName != null, name != $h.name)
then
- System.out.printf("Connection from %s%n", $h.name);
- for (WgHost host : $others) {
- System.out.printf(" %s%n", host.name);
- }
+ insert(new WgConnection($h.name, $other.name))
end
+
+//declare AllocatedIp
+// owner : Object
+// ip : Ipv4Address
+//end
+//
+//rule "Assign IP"
+//when
+// $host : WgHost()
+// $ip : Ipv4Address()
+//then
+// var allocation = new AllocatedIp($host, $ip);
+// insert(allocation)
+//end