diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2023-11-15 11:33:39 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2023-11-15 11:33:39 +0100 |
commit | 0d90828fb0fddb525ab07ccc19b7f7f870efcd14 (patch) | |
tree | d183f567d084ec5c74c0e186d4cf62c802bcfe55 | |
parent | 2c76aa98d5fe49f57c94bde4cbe2ba5ca1ff338a (diff) | |
download | prolog-firewall-0d90828fb0fddb525ab07ccc19b7f7f870efcd14.tar.gz prolog-firewall-0d90828fb0fddb525ab07ccc19b7f7f870efcd14.tar.bz2 prolog-firewall-0d90828fb0fddb525ab07ccc19b7f7f870efcd14.tar.xz prolog-firewall-0d90828fb0fddb525ab07ccc19b7f7f870efcd14.zip |
wip
-rw-r--r-- | 6/firewall.pl | 6 | ||||
-rw-r--r-- | 6/main.pl | 6 |
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). @@ -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). |