diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-04 21:33:29 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-04 21:33:29 +0100 |
commit | a7de9a63f77faac8c535d1ab340bb5046f3955fd (patch) | |
tree | 780d42e58a353594310feebef45926d136c9e4da /src/main/resources/io | |
parent | 4dcc43061d05f14ceddbb9f3a0c43ab908b89a4b (diff) | |
download | rules-sandbox-a7de9a63f77faac8c535d1ab340bb5046f3955fd.tar.gz rules-sandbox-a7de9a63f77faac8c535d1ab340bb5046f3955fd.tar.bz2 rules-sandbox-a7de9a63f77faac8c535d1ab340bb5046f3955fd.tar.xz rules-sandbox-a7de9a63f77faac8c535d1ab340bb5046f3955fd.zip |
VPN work.
Finding all connections for a VPN host.
Diffstat (limited to 'src/main/resources/io')
-rw-r--r-- | src/main/resources/io/trygvis/rules/acme/vpn.drl | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/main/resources/io/trygvis/rules/acme/vpn.drl b/src/main/resources/io/trygvis/rules/acme/vpn.drl index cfdbef9..082ecc0 100644 --- a/src/main/resources/io/trygvis/rules/acme/vpn.drl +++ b/src/main/resources/io/trygvis/rules/acme/vpn.drl @@ -1,8 +1,10 @@ package io.trygvis.rules.acme; +import java.util.ArrayList import io.trygvis.rules.machine.Machine; import io.trygvis.rules.dns.DnsEntry; -import io.trygvis.rules.acme.AcmeServer; +import io.trygvis.rules.acme.AcmeServer +import io.trygvis.rules.acme.WgHost; dialect "mvel" @@ -13,7 +15,6 @@ end declare WgHost name : String -// machine : Machine net : String publicName : String netToNetIp : String @@ -38,8 +39,9 @@ when $host : WgHost(publicName == null) $m : Machine(name == $host.name, fqdn != null) then - $host.publicName = $m.fqdn; - update($host) + modify($host) { + publicName = $m.fqdn + } end rule "Make DNS entries for all VPN hosts" @@ -50,3 +52,16 @@ then var fqdn = "%s.%s".formatted($h.name, $net.domain); insert(DnsEntry.a(fqdn)) end + +rule "Connect VPN nodes" + salience -1 +when + $h : WgHost() + $others : ArrayList() + from collect(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); + } +end |