5
0
mirror of git://git.proxmox.com/git/pve-docs.git synced 2025-01-03 01:17:49 +03:00
pve-docs/gen-pve-firewall-macros-adoc.pl

37 lines
967 B
Perl
Executable File

#!/usr/bin/perl
use lib '.';
use strict;
use warnings;
use PVE::Firewall;
my ($pve_fw_parsed_macros, $pve_fw_macro_descr) = PVE::Firewall::get_macros();
#use Data::Dumper;
#print Dumper($pve_fw_macro_descr);
#print Dumper($pve_fw_parsed_macros);
foreach my $name (sort keys %$pve_fw_parsed_macros) {
my $descr = $pve_fw_macro_descr->{$name};
die "no description for macro '$name'" if !defined($descr);
print "[horizontal]\n'$name':: $descr\n\n";
print "[width=\"100%\",options=\"header\"]\n" .
"|===========================================================\n" .
"|Action|proto|dport|sport\n";
my $rules = $pve_fw_parsed_macros->{$name};
foreach my $rule (@$rules) {
print "|$rule->{action}|";
print (($rule->{proto} || '') . '|');
print (($rule->{dport} || '') . '|');
print (($rule->{sport} || '') . "\n");
}
print "|===========================================================\n";
print "\n";
}