mirror of
https://github.com/webmin/webmin.git
synced 2025-07-20 16:48:46 +00:00
Add jails status and actions 1/2 #1623
This commit is contained in:
BIN
fail2ban/images/status.gif
Normal file
BIN
fail2ban/images/status.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
@ -28,14 +28,14 @@ if ($err) {
|
||||
|
||||
# Show category icons
|
||||
my @links = ( "list_filters.cgi", "list_actions.cgi",
|
||||
"list_jails.cgi", "edit_config.cgi",
|
||||
"edit_manual.cgi", );
|
||||
"list_jails.cgi", "list_status.cgi",
|
||||
"edit_config.cgi", "edit_manual.cgi", );
|
||||
my @titles = ( $text{'filters_title'}, $text{'actions_title'},
|
||||
$text{'jails_title'}, $text{'config_title'},
|
||||
$text{'manual_title'}, );
|
||||
$text{'jails_title'}, $text{'status_title'},
|
||||
$text{'config_title'}, $text{'manual_title'}, );
|
||||
my @icons = ( "images/filters.gif", "images/actions.gif",
|
||||
"images/jails.gif", "images/config.gif",
|
||||
"images/manual.gif", );
|
||||
"images/jails.gif", "images/status.gif",
|
||||
"images/config.gif", "images/manual.gif", );
|
||||
&icons_table(\@links, \@titles, \@icons, 5);
|
||||
|
||||
# Show start / stop buttons
|
||||
|
@ -170,6 +170,18 @@ manual_efile=Selected file is not part of the Fail2Ban configuration!
|
||||
manual_err=Failed to edit config file
|
||||
manual_edata=No config file contents entered
|
||||
|
||||
status_title=Jails Status And Actions
|
||||
status_title2=Jails Status
|
||||
status_head_jail_name=Jail name
|
||||
status_head_currently_failed=Currently failed
|
||||
status_head_total_failed=Total failed
|
||||
status_head_currently_banned=Currently banned
|
||||
status_head_total_banned=Total banned
|
||||
status_head_banned_ip_list=Banned IP list
|
||||
status_jail_unblock=Unblock All IPs for Selected Jails
|
||||
status_jail_block=Permanently Block All IPs in Banned List for Selected Jails
|
||||
status_jail_noactive=There are no active jails enabled yet.
|
||||
|
||||
syslog_logtarget=Fail2Ban action log
|
||||
|
||||
__norefs=1
|
||||
|
61
fail2ban/list_status.cgi
Executable file
61
fail2ban/list_status.cgi
Executable file
@ -0,0 +1,61 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Show a list of all defined actions
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
require './fail2ban-lib.pl';
|
||||
our (%in, %text, %config);
|
||||
|
||||
&ui_print_header(undef, $text{'status_title2'}, "");
|
||||
|
||||
my $out = &backquote_logged("$config{'client_cmd'} status 2>&1 </dev/null");
|
||||
my ($jail_list) = $out =~ /jail\s+list:\s*(.*)/im;
|
||||
my @jails = split(/,\s*/, $jail_list);
|
||||
if (@jails) {
|
||||
my $tdc = "style=\"text-align: center\"";
|
||||
my @links = ( &select_all_link("jail"),
|
||||
&select_invert_link("jail") );
|
||||
my $head;
|
||||
foreach my $jail (@jails) {
|
||||
my $fh = 'cmdjail';
|
||||
my $cmd = "$config{'client_cmd'} status ".quotemeta($jail);
|
||||
my $jcmd = "$cmd 2>&1 </dev/null";
|
||||
my @head = (undef, $text{"status_head_jail_name"});
|
||||
my @body = (&ui_link("edit_jail.cgi?name=".urlize($jail), " <tt>".&html_escape($jail)."</tt>"));
|
||||
&open_execute_command($fh, $jcmd, 1);
|
||||
while(<$fh>) {
|
||||
if (/-\s+(.*):\s*(.*)/) {
|
||||
my $col = $1;
|
||||
my $val = $2;
|
||||
$col = lc($col);
|
||||
$col =~ s/\s/_/g;
|
||||
if ($col !~ /journal_matches/) {
|
||||
push(@head, $text{"status_head_$col"});
|
||||
if ($col =~ /banned_ip_list/) {
|
||||
my @ips = split(/\s+/, $val);
|
||||
$val =~ s/\s+/<br>/g;
|
||||
}
|
||||
push(@body, $val);
|
||||
}
|
||||
}
|
||||
}
|
||||
close($fh);
|
||||
if (!$head++) {
|
||||
print &ui_form_start("unblock_jail.cgi", "post");
|
||||
print &ui_links_row(\@links);
|
||||
print &ui_columns_start(\@head);
|
||||
}
|
||||
print &ui_checked_columns_row(\@body, ['width=5', undef, $tdc, $tdc, $tdc, $tdc], "jail", $jail);
|
||||
}
|
||||
if ($head) {
|
||||
print &ui_columns_end();
|
||||
print &ui_links_row(\@links);
|
||||
print &ui_form_end([ [ 'unblock', $text{'status_jail_unblock'} ],
|
||||
[ 'permblock', $text{'status_jail_block'} ] ]);
|
||||
};
|
||||
}
|
||||
else {
|
||||
print $text{'status_jail_noactive'};
|
||||
}
|
||||
|
||||
&ui_print_footer("", $text{'index_return'});
|
Reference in New Issue
Block a user