diff --git a/nftables/acl_security.pl b/nftables/acl_security.pl index eedad70c9..51b413480 100644 --- a/nftables/acl_security.pl +++ b/nftables/acl_security.pl @@ -36,10 +36,13 @@ print ui_table_row( foreach my $a ( qw(view active create setup chains sets rules raw delete - apply bootup import clear quick manual) + apply bootup import clear quick quick_ip quick_port + quick_service quick_forward manual) ) { - print ui_table_row($text{'acl_'.$a}, ui_yesno_radio($a, $o->{$a})); + my $enabled = $o->{$a}; + $enabled = $o->{'quick'} if ($a =~ /^quick_/ && !defined($enabled)); + print ui_table_row($text{'acl_'.$a}, ui_yesno_radio($a, $enabled)); } } @@ -58,7 +61,8 @@ else { } foreach my $a ( qw(view active create setup chains sets rules raw delete - apply bootup import clear quick manual) + apply bootup import clear quick quick_ip quick_port + quick_service quick_forward manual) ) { $_[0]->{$a} = $in{$a} || 0; diff --git a/nftables/defaultacl b/nftables/defaultacl index 0547aaebb..721cfe05b 100644 --- a/nftables/defaultacl +++ b/nftables/defaultacl @@ -13,4 +13,8 @@ bootup=1 import=1 clear=1 quick=1 +quick_ip=1 +quick_port=1 +quick_service=1 +quick_forward=1 manual=1 diff --git a/nftables/edit_rule.cgi b/nftables/edit_rule.cgi index 3b1a82e9f..1bf2a1371 100755 --- a/nftables/edit_rule.cgi +++ b/nftables/edit_rule.cgi @@ -32,6 +32,8 @@ my $saddr_val; my $daddr_val; my $sport_val; my $dport_val; +my $nat_addr_val; +my $nat_port_val; my @addr_set_opts; my @port_set_opts; my %set_families; @@ -99,6 +101,8 @@ $saddr_val = $saddr_set ? "" : $rule->{'saddr'}; $daddr_val = $daddr_set ? "" : $rule->{'daddr'}; $sport_val = $sport_set ? "" : $rule->{'sport'}; $dport_val = $dport_set ? "" : $rule->{'dport'}; +$nat_addr_val = $rule->{'nat_addr'}; +$nat_port_val = $rule->{'nat_port'}; @addr_set_opts = (["", $text{'edit_set_none'}]); @port_set_opts = (["", $text{'edit_set_none'}]); @@ -198,20 +202,39 @@ print ui_table_row( ); # Action +my $show_nat_actions = + ($chain_def && (($chain_def->{'type'} || '') eq 'nat')) || + ($action_sel && $action_sel =~ /^(redirect|dnat)$/); +my @action_opts = ( + ["accept", $text{'index_accept'}], + ["drop", $text{'index_drop'}], + ["reject", $text{'index_reject'}], + ["return", $text{'edit_return'}], +); +push(@action_opts, + ["redirect", $text{'edit_redirect_action'}], + ["dnat", $text{'edit_dnat_action'}]) + if ($show_nat_actions); +push(@action_opts, + ["jump", $text{'edit_jump_action'}], + ["goto", $text{'edit_goto_action'}]); print ui_table_row( hlink($text{'edit_action'}, "action"), - ui_select( - "action", - $action_sel, - [ - ["accept", $text{'index_accept'}], - ["drop", $text{'index_drop'}], - ["reject", $text{'index_reject'}], - ["return", $text{'edit_return'}], - ["jump", $text{'edit_jump_action'}], - ["goto", $text{'edit_goto_action'}], - ] - ) + ui_select("action", $action_sel, \@action_opts) +); + +my $nat_show = $action_sel && $action_sel =~ /^(redirect|dnat)$/; +my $nat_addr_style = $action_sel && $action_sel eq 'dnat' ? "" : " style='display:none'"; +my $nat_port_style = $nat_show ? "" : " style='display:none'"; +print ui_table_row( + hlink($text{'edit_nat_addr'}, "nat_addr"), + ui_textbox("nat_addr", $nat_addr_val, 30), + undef, undef, ["id='nftables_nat_addr_row'".$nat_addr_style] +); +print ui_table_row( + hlink($text{'edit_nat_port'}, "nat_port"), + ui_textbox("nat_port", $nat_port_val, 10), + undef, undef, ["id='nftables_nat_port_row'".$nat_port_style] ); # Addresses @@ -400,6 +423,9 @@ my $icmpv6_js = js_array(@icmpv6_types); my $icmp_any = $text{'edit_proto_any'}; $icmp_any =~ s/\\/\\\\/g; $icmp_any =~ s/"/\\"/g; +my $table_family = $table->{'family'} || ''; +$table_family =~ s/\\/\\\\/g; +$table_family =~ s/"/\\"/g; my $set_fam_js = js_object(%set_families); print "