summaryrefslogtreecommitdiff
path: root/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl
diff options
context:
space:
mode:
Diffstat (limited to 'module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl')
-rw-r--r--module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl16
1 files changed, 15 insertions, 1 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 d971696..97d17cb 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
@@ -35,6 +35,7 @@ declare WgHost
end
declare WgConnection
+ name : String
host : WgHost
to : WgHost
end
@@ -93,7 +94,20 @@ when
$other : WgHost(publicName != null, this != $h)
then
System.out.printf("VPN connection from %s to %s%n", $h.machine.name, $other.machine.name);
- insert(new WgConnection($h, $other))
+ var c = new WgConnection();
+ c.host = $h;
+ c.to = $other;
+ insert(c)
+end
+
+rule "Name connections"
+when
+ $c : WgConnection(name == null, host != null, to != null)
+then
+ String n = $c.host.machine.name + "_x_" + $c.to.machine.name;
+ modify($c) {
+ name = n
+ }
end
// This and the next rule needs to use .toString(), the specific objects might be generated multiple times,