summaryrefslogtreecommitdiff
path: root/2.dl
diff options
context:
space:
mode:
Diffstat (limited to '2.dl')
-rw-r--r--2.dl40
1 files changed, 40 insertions, 0 deletions
diff --git a/2.dl b/2.dl
new file mode 100644
index 0000000..ab1c998
--- /dev/null
+++ b/2.dl
@@ -0,0 +1,40 @@
+#lang datalog
+
+edge(a, b). edge(b, c). edge(c, d). edge(d, a).
+path(X, Y) :- edge(X, Y).
+path(X, Y) :- edge(X, Z), path(Z, Y).
+
+public-key(conflatorio, "pk conflatorio").
+public-key(lhn2ix, "pk lhn2ix").
+public-key(knot, "pk knot").
+
+router-link(knot,lhn2ix, "1:1::1").
+router-link(knot,kv24ix, "1:1::2").
+router-link(lhn2ix, knot, "1:2::1").
+router-link(lhn2ix, conflatorio, "1:2::2").
+router-link(conflatorio, lhn2ix, "1:3::1").
+
+% network(R, address, range)
+network(lhn2ix, "1:dbea::", 64).
+network(conflatorio, "1:e5b0::", 64).
+network(knot, "1:f11b::", 64).
+
+host(H) :- router-link(H, B, Ip).
+host(H) :- router-link(A, H, Ip).
+host(H)?
+
+bgp-connection(H, R) :-
+ host(H), host(R),
+ router-link(H, R, IpH),
+ router-link(R, H, IpR).
+
+bgp-connection(H, Remote)?
+
+wg-if(H, R, PK) :- bgp-connection(H, R), public-key(R, PK).
+wg-if(H, R, PK)?
+wg-if-allowed-ips(H, Ip, 128) :- bgp-connection(H, R), router-link(H, R, Ip).
+wg-if-allowed-ips(H, Ip, Range) :- bgp-connection(H, R), network(R, Ip, Range).
+wg-if-allowed-ips(H, Ip, Range)?
+
+bgp-config(H) :- bgp-connection(H, Name).
+bgp-config(H)?