| Server IP : 37.9.174.138 / Your IP : 216.73.216.117 Web Server : Apache System : Linux vps6.backend.sk 6.12.100+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.100-1 (2026-07-30) x86_64 User : ftpuser ( 1001) PHP Version : 8.4.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/nftables/ |
Upload File : |
#!/usr/bin/perl
# manage_ip.cgi
# Quickly allow or block an IP/CIDR in the selected table
require './nftables-lib.pl'; ## no critic
use strict;
use warnings;
our (%in, %text);
ReadParse();
assert_quick_acl('ip');
my $action = $in{'allow'} ? 'allow' : $in{'block'} ? 'block' : '';
error_setup(
$action eq 'allow'
? $text{'quick_allow_err'}
: $text{'quick_block_err'}
);
my @tables = get_nftables_save();
my $table_idx = $in{'table'};
my $table;
if (defined($in{'table_family'}) && defined($in{'table_name'})) {
for (my $i = 0 ; $i <= $#tables ; $i++) {
if ($tables[$i]->{'family'} eq $in{'table_family'} &&
$tables[$i]->{'name'} eq $in{'table_name'})
{
$table_idx = $i;
$table = $tables[$i];
last;
}
}
}
else {
$table = $tables[$table_idx];
}
$table || error($text{'quick_etable'});
assert_table_acl($table);
my $err = add_quick_ip_rule($table, $in{'ip'}, $action);
error($err) if ($err);
$err = save_table_configuration($table, @tables);
error(text('quick_failed', $err)) if ($err);
# Quick allow/block is expected to affect the live firewall immediately.
$err = apply_restore();
error(text('quick_failed', $err)) if ($err);
webmin_log($action, "ip", $in{'ip'},
{'table' => $table->{'name'}, 'family' => $table->{'family'}});
my $redir = "index.cgi?table_family=".
urlize($table->{'family'}).
"&table_name=".
urlize($table->{'name'});
$redir .= "&view=".urlize($in{'view'})
if (($in{'view'} || '') =~ /^(chains|sets)$/);
redirect($redir);