mirror of
https://github.com/webmin/webmin.git
synced 2026-09-20 04:20:39 +01:00
firewall6: bug fixes and pager
This commit is contained in:
@@ -4,3 +4,4 @@ view_condition=1
|
||||
cluster_mode=1
|
||||
comment_mod=0
|
||||
force_init=0
|
||||
perpage=50
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
line0=Configurable options,11
|
||||
perpage=Number of rules to display per page,3,50
|
||||
view_condition=Display condition in rules list?,1,1-Yes,0-No
|
||||
view_comment=Display comment in rules list?,1,1-Yes,0-No
|
||||
comment_mod=Store comments as,1,0-# comments in save file,1---comment option
|
||||
|
||||
@@ -99,7 +99,7 @@ if (($table->{'name'} eq 'nat' && $rule->{'chain'} ne 'POSTROUTING') &&
|
||||
($rtofrom, $rtoto) = split(/\-/, $rule->{'to-ports'}->[1]);
|
||||
}
|
||||
print &ui_table_row($text{'edit_rtoports'},
|
||||
&ui_radio("rtodef", rtofrom eq "" ? 1 : 0,
|
||||
&ui_radio("rtodef", $rtofrom eq "" ? 1 : 0,
|
||||
[ [ 1, $text{'default'} ],
|
||||
[ 0, &text('edit_prange',
|
||||
&ui_textbox("rtofrom", $rtofrom, 6),
|
||||
@@ -125,7 +125,7 @@ if (($table->{'name'} eq 'nat' && $rule->{'chain'} ne 'POSTROUTING') &&
|
||||
&can_jump("DNAT")) {
|
||||
if ($rule->{'j'}->[1] eq 'DNAT') {
|
||||
if ($rule->{'to-destination'}->[1] =~
|
||||
/^([0-9\.]+)(\-([0-9\.]+))?(:(\d+)(\-(\d+))?)?$/) {
|
||||
/^\[([0-9A-Fa-f:]+)](\-([0-9A-Fa-f:]+))?(:(\d+)(\-(\d+))?)?$/) {
|
||||
$dipfrom = $1;
|
||||
$dipto = $3;
|
||||
$dpfrom = $5;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
BEGIN { push(@INC, ".."); };
|
||||
use WebminCore;
|
||||
&init_config();
|
||||
$config{'perpage'} ||= 50; # a value of 0 can cause problems
|
||||
if ($config{'save_file'}) {
|
||||
# Force use of a different save file, and webmin's functions
|
||||
$ip6tables_save_file = $config{'save_file'};
|
||||
|
||||
@@ -181,6 +181,35 @@ else {
|
||||
print "<form action=save_policy.cgi>\n";
|
||||
print &ui_hidden("table", $in{'table'});
|
||||
print &ui_hidden("chain", $c);
|
||||
|
||||
if (@rules > $config{'perpage'}) {
|
||||
# Need to show arrows
|
||||
print "<center>\n";
|
||||
$s = int($in{'start'});
|
||||
$e = $in{'start'} + $config{'perpage'} - 1;
|
||||
$e = @rules-1 if ($e >= @rules);
|
||||
if ($s) {
|
||||
print &ui_link("?start=".
|
||||
($s - $config{'perpage'}),
|
||||
"<img src=/images/left.gif border=0 align=middle>");
|
||||
}
|
||||
print "<font size=+1>",&text('index_position', $s+1, $e+1,
|
||||
scalar(@rules)),"</font>\n";
|
||||
if ($e < @rules-1) {
|
||||
print &ui_link("?start=".
|
||||
($s + $config{'perpage'}),
|
||||
"<img src=/images/right.gif border=0 align=middle>");
|
||||
}
|
||||
print "</center>\n";
|
||||
}
|
||||
else {
|
||||
# Can show them all
|
||||
$s = 0;
|
||||
$e = @rules - 1;
|
||||
}
|
||||
|
||||
@rules = @rules[$s..$e];
|
||||
|
||||
if (@rules) {
|
||||
@links = ( &select_all_link("d", $form),
|
||||
&select_invert_link("d", $form) );
|
||||
|
||||
@@ -73,6 +73,7 @@ index_reset=Reset Firewall
|
||||
index_resetdesc=Click this button to clear all existing firewall rules and set up new rules for a basic initial configuration.
|
||||
index_cluster=Cluster Servers
|
||||
index_clusterdesc=Click this button to set up additional Webmin servers to which the firewall configuration will be automatically copied.
|
||||
index_position=Rules $1 to $2 of $3
|
||||
|
||||
desc_p=protocol is $1
|
||||
desc_p!=protocol is not $1
|
||||
|
||||
@@ -73,6 +73,7 @@ index_reset=Reset Firewall
|
||||
index_resetdesc=Click this button to clear all existing firewall rules and set up new rules for a basic initial configuration.
|
||||
index_cluster=Cluster Servers
|
||||
index_clusterdesc=Click this button to set up additional Webmin servers to which the firewall configuration will be automatically copied.
|
||||
index_position=Rules $1 to $2 of $3
|
||||
|
||||
desc_p=protocol is $1
|
||||
desc_p!=protocol is not $1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/local/bin/perl
|
||||
#!/usr/bin/perl
|
||||
# save_rule.cgi
|
||||
# Save, create or delete a rule in a chain
|
||||
|
||||
@@ -89,12 +89,12 @@ else {
|
||||
}
|
||||
if ($table->{'name'} eq 'nat' && $rule->{'chain'} ne 'POSTROUTING') {
|
||||
if ($rule->{'j'}->[1] eq 'DNAT' && !$in{'dnatdef'}) {
|
||||
!$in{'dipfrom'} || &check_ipaddress($in{'dipfrom'}) ||
|
||||
!$in{'dipfrom'} || &check_ip6address($in{'dipfrom'}) ||
|
||||
&error($text{'save_edipfrom'});
|
||||
!$in{'dipto'} || &check_ipaddress($in{'dipto'}) ||
|
||||
!$in{'dipto'} || &check_ip6address($in{'dipto'}) ||
|
||||
&error($text{'save_edipto'});
|
||||
local $v = $in{'dipfrom'};
|
||||
$v .= "-".$in{'dipto'} if ($in{'dipto'});
|
||||
local $v = "[".$in{'dipfrom'}."]";
|
||||
$v .= "-[".$in{'dipto'}."]" if ($in{'dipto'});
|
||||
if ($in{'dpfrom'} ne '') {
|
||||
$in{'dpfrom'} =~ /^\d+$/ ||
|
||||
&error($text{'save_edpfrom'});
|
||||
@@ -117,9 +117,9 @@ else {
|
||||
$rule->{'chain'} ne 'OUTPUT') {
|
||||
if ($rule->{'j'}->[1] eq 'SNAT' && !$in{'snatdef'}) {
|
||||
(!$in{'sipfrom'} && !$in{'sipto'}) ||
|
||||
&check_ipaddress($in{'sipfrom'}) ||
|
||||
&check_ip6address($in{'sipfrom'}) ||
|
||||
&error($text{'save_esipfrom'});
|
||||
!$in{'sipto'} || &check_ipaddress($in{'sipto'}) ||
|
||||
!$in{'sipto'} || &check_ip6address($in{'sipto'}) ||
|
||||
&error($text{'save_esipto'});
|
||||
local $v = $in{'sipfrom'};
|
||||
$v .= "-".$in{'sipto'} if ($in{'sipto'});
|
||||
@@ -411,7 +411,7 @@ foreach my $w (split(/,/, $_[0])) {
|
||||
my $ok = &to_ipaddress($w) ||
|
||||
$w =~ /^([0-9\.]+)\/([0-9\.]+)$/ &&
|
||||
&to_ipaddress("$1") &&
|
||||
(&check_ipaddress("$2") || ($2 =~ /^\d+$/ && $2 <= 32));
|
||||
(&check_ip6address("$2") || ($2 =~ /^\d+$/ && $2 <= 32));
|
||||
return 1 if (!$ok);
|
||||
}
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user