diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-29 10:14:38 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-29 10:14:38 +0100 |
commit | bb92e6eaa9bca36d9f1e356a2f578d22c98af22f (patch) | |
tree | 6507fa866d5a4ee0f45500e8143c12638aafc07a /module/ri-wireguard/src | |
parent | d167fc9b40a83187c657f3a048f19ac56f529af3 (diff) | |
download | rules-sandbox-bb92e6eaa9bca36d9f1e356a2f578d22c98af22f.tar.gz rules-sandbox-bb92e6eaa9bca36d9f1e356a2f578d22c98af22f.tar.bz2 rules-sandbox-bb92e6eaa9bca36d9f1e356a2f578d22c98af22f.tar.xz rules-sandbox-bb92e6eaa9bca36d9f1e356a2f578d22c98af22f.zip |
IO: Making input and output files have the same format.
Diffstat (limited to 'module/ri-wireguard/src')
-rw-r--r-- | module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl | 16 |
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, |