Work on filters page

This commit is contained in:
Jamie Cameron
2014-04-29 22:09:10 -07:00
parent f49083fc8b
commit 68c30fb9fb
3 changed files with 65 additions and 5 deletions

View File

@@ -37,19 +37,42 @@ return $pid;
}
# list_filters()
# Returns a list of all defined filters, each of which is a hash ref of
# options from the [Definition] block
# Returns a list of all defined filter files, each of which contains multiple
# sections like [Definition]
sub list_filters
{
my $dir = "$config{'config_dir'}/filter.d";
my @rv;
foreach my $f (glob("$dir/*.conf")) {
my $conf = &parse_config_file($f);
if (@$conf) {
push(@rv, $conf);
}
}
return @rv;
}
# list_actions()
# Returns a list of all defined action files, each of which contains multiple
# sections like [Definition] and [Init]
sub list_actions
{
my $dir = "$config{'config_dir'}/action.d";
my @rv;
foreach my $f (glob("$dir/*.conf")) {
my $conf = &parse_config_file($f);
if (@$conf) {
push(@rv, $conf);
}
}
return @rv;
}
# list_jails()
# Returns a list of all sections from the jails file
sub list_jails
{
return &parse_config_file("$config{'config_dir'}/jail.conf");
}
# parse_config_file(file)
@@ -101,6 +124,8 @@ close($fh);
return @rv;
}
# split_directive_values(&dir)
# Populate the 'values' field by splitting up the 'value' field
sub split_directive_values
{
my ($dir) = @_;

View File

@@ -1,4 +1,4 @@
index_title=Fail2Ban
index_title=Fail2Ban Intrusion Detector
index_echeck=An error occurred detecting Fail2Ban on this system : $1. Either it is not installed, or the <a href='$2'>module configuration</a> is incorrect.
index_fail2ban=Fail2Ban
index_atboot=Start at boot?
@@ -12,5 +12,13 @@ index_restartdesc=Click this button to apply the current configuration by restar
check_edir=The configuration directory $1 does not exist
check_econf=The configuration file $2 in $1 does not exist
client_cmd=The client command $1 was not found
server_cmd=The server command $1 was not found
check_eclient=The client command $1 was not found
check_eserver=The server command $1 was not found
filters_title=Log Filters
actions_title=Actions
jails_title=Jails
config_title=Global Configuration

27
fail2ban/list_filters.cgi Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/local/bin/perl
# Show a list of all defined filters
use strict;
use warnings;
require './fail2ban-lib.pl';
our (%in, %text);
&ui_print_header(undef, $text{'filters_title'}, "");
my @filters = &list_filters();
print &ui_columns_start([ $text{'filters_name'},
$text{'filters_re'} ]);
foreach my $f (@filters) {
my ($def) = grep { $_->{'name'} eq 'Definition' } @$f;
next if (!$f); # XXX what about default?
my $fail = &find_value("failregex", $f);
my $fname = "XXX";
print &ui_columns_row([
&ui_link("edit_filter.cgi?file=".&urlize($def->{'file'}),
$fname),
&html_escape($fail),
]);
}
print &ui_columns_end();
&ui_print_footer("", $text{'index_return'});