30 |
$templates{pf} = { |
$templates{pf} = { |
31 |
rules => [ |
rules => [ |
32 |
q( |
q( |
33 |
foreach my $regex (qw(from to proto on)) { |
foreach my $regex ('proto', 'on') { |
34 |
if ($in =~ s/\s*($regex)\s+(\S*)//) { |
if ($in =~ s/\s*$regex\s+(\S*)//) { |
35 |
$atom->{type} = 'VALUES_LIST'; |
$atom->{type} = 'VALUES_LIST'; |
36 |
$atom->{type2} = 'PF_RULE'; |
$atom->{type2} = 'PF_RULE'; |
37 |
$atom->{values}{$regex} = $2; |
push @{$atom->{list}}, {$regex => $1}; |
38 |
} |
} |
39 |
} |
} |
40 |
foreach my $regex ('in|out', 'log', 'pass|block|antispoof|scrub', 'quick', 'keep state', 'all') { |
foreach my $regex ('in|out', 'log', 'pass|block|antispoof|scrub', 'quick', 'keep state', 'all') { |
41 |
if ($in =~ s/\s*($regex)//) { |
if ($in =~ s/\s*($regex)//) { |
42 |
$atom->{type} = 'VALUES_LIST'; |
$atom->{type} = 'VALUES_LIST'; |
43 |
$atom->{type2} = 'PF_RULE'; |
$atom->{type2} = 'PF_RULE'; |
|
$atom->{list} ||= []; |
|
44 |
push @{$atom->{list}}, $1; |
push @{$atom->{list}}, $1; |
45 |
} |
} |
46 |
} |
} |
47 |
if ($in =~ s/\s*port\s+{(.*)}//) { |
foreach my $regex ('from', 'to') { |
48 |
$atom->{type} = 'VALUES_LIST'; |
$atom->{type} = 'VALUES_LIST'; |
49 |
$atom->{type2} = 'PF_RULE'; |
$atom->{type2} = 'PF_RULE'; |
50 |
@{$atom->{port}} = split(/\s*,\s*/, $1); |
if ($in =~ s/\s*$regex\s+(\S*)\s+port\s+{(.*)}//) { |
51 |
} |
push @{$atom->{list}}, {$regex => $1, port => [split(/\s*,\s*/, $2)]}; |
52 |
elsif ($in =~ s/\s*port\s+(\S+)\s+(\S+)//) { |
} |
53 |
$atom->{type} = 'VALUES'; |
elsif ($in =~ s/\s*$regex\s+(\S*)\s+port\s+(\S+)\s+(\S+)//) { |
54 |
$atom->{type2} = 'PF_RULE'; |
push @{$atom->{list}}, {$regex => $1, port => {port => $3, cmp => $2}}; |
55 |
$atom->{values}{port} = $2; |
} |
56 |
$atom->{values}{cmp} = $1; |
elsif ($in =~ s/\s*$regex\s+(\S*)//) { |
57 |
} |
push @{$atom->{list}}, {$regex => $1}; |
58 |
|
} |
59 |
|
} |
60 |
) |
) |
61 |
], |
], |
62 |
comments => [ ['#'] ], |
comments => [ ['#'] ], |