From bb92e6eaa9bca36d9f1e356a2f578d22c98af22f Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 29 Jan 2021 10:14:38 +0100 Subject: IO: Making input and output files have the same format. --- .../resources/io/trygvis/rules/wireguard/wireguard.drl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl') 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, -- cgit v1.2.3