summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
Diffstat (limited to '6')
-rw-r--r--6/firewall.pl6
-rw-r--r--6/main.pl6
2 files changed, 10 insertions, 2 deletions
diff --git a/6/firewall.pl b/6/firewall.pl
index d76e2d1..b2ae64a 100644
--- a/6/firewall.pl
+++ b/6/firewall.pl
@@ -4,6 +4,7 @@
:- module(firewall, [
fw_rule/2,
+ warning/1,
retract_all_from/1]).
:- use_module(hosts, [
@@ -11,7 +12,10 @@
:- dynamic fw_rule/2.
-rule_is_from(fw_rule(_, Attr), From) :- Attr.from=From.
+warning(Msg) :-
+ fw_rule(Host, Attr),
+ \+ (_{from:_} :< Attr),
+ format(string(Msg), "Missing 'from' on fw_rule for host '~w', ~w", [Host, Attr]).
rules_from(From, Rules) :-
findall(fw_rule(Host, Attr), (fw_rule(Host, Attr), Attr.from=From), Rules).
diff --git a/6/main.pl b/6/main.pl
index 5256ac0..dc525bb 100644
--- a/6/main.pl
+++ b/6/main.pl
@@ -9,7 +9,10 @@ print_warnings([W|Ws]) :- format("Warning: ~w~n", [W]), print_warnings(Ws).
print_warnings :-
findall(W, bgp:warning(W), BgpWs),
findall(W, firewall:warning(W), FwWs),
- concat(BgpWs, FwWs, Ws),
+ append(BgpWs, FwWs, Ws),
+ writeln(BgpWs),
+ writeln(FwWs),
+ writeln(Ws),
length(Ws, L),
( L > 0
->format("Found ~w warning(s):~n", [L]),
@@ -18,6 +21,7 @@ print_warnings :-
).
main :-
+ print_warnings,
bgp:create_firewall(),
bgp:bird_config(BirdDict),
yaml_write(current_output, BirdDict).