2 # Show all firewall rules
4 require './ipfilter-lib.pl';
7 # Make sure the ipf command is installed
8 $cmd = &missing_firewall_commands();
10 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
12 &ui_config_link('index_ecmd',
13 [ "<tt>$cmd</tt>", undef ]));
16 # Get the version number
17 $vout = `$config{'ipf'} -V 2>&1`;
18 if ($vout =~ /IP\s+Filter:\s+v?(\S+)/i) {
21 open(VERSION, ">$module_config_directory/version");
22 print VERSION $ipf_version,"\n";
24 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
25 &help_search_link("ipf", "man", "doc", "google"),
27 &text('index_version', $ipf_version));
29 # See if enabled at boot
30 $atboot = &check_firewall_init();
32 # Get the saved and active rules
33 $live = &get_live_config();
34 $rules = &get_config();
36 if (!-r $config{'ipf_conf'} && @$live) {
37 # Offer to save existing rules
38 print &text('index_existing', scalar(@$live),
39 "<tt>$config{'ipf_conf'}</tt>"),"<p>\n";
40 print &ui_form_start("convert.cgi");
41 print "<center>",&ui_submit($text{'index_saveex'}),"<p>\n";
42 print &ui_checkbox("atboot", 1, $text{'index_atboot'},
44 print "</center>",&ui_form_end(),"<p>\n";
46 print "<table border width=100%>\n";
47 print "<tr $tb><td><b>$text{'index_headerex'}</b></td></tr>\n";
48 print "<tr $cb> <td><pre>";
49 foreach $dir ("i", "o") {
50 open(OUT, "$config{'ipfstat'} -$dir |");
52 print &html_escape($_);
56 print "</pre></td> </tr></table>\n";
58 elsif (@$rules && !$in{'reset'}) {
60 print &ui_form_start("edit_rule.cgi");
61 local @widths = ( "width=10", "width=5%", "width=10%", undef );
62 push(@widths, undef) if ($config{'view_condition'});
63 push(@widths, undef) if ($config{'view_comment'});
64 push(@widths, "width=5%", "width=5%");
65 @links = ( &select_all_link("d", 0),
66 &select_invert_link("d", 0) );
67 print &ui_links_row(\@links);
68 print &ui_columns_start([ "",
69 $text{'index_active'},
70 $text{'index_action'},
72 $config{'view_condition'} ?
73 ( $text{'index_desc'} ) : ( ),
74 $config{'view_comment'} ?
75 ( $text{'index_cmt'} ) : ( ),
77 $text{'index_radd'} ], 100, 0,
79 foreach $r (@$rules) {
80 local ($mover, $adder);
81 if ($r eq $rules->[@$rules-1]) {
82 $mover .= "<img src=images/gap.gif>";
85 $mover .= "<a href='move.cgi?idx=$r->{'index'}&".
87 "images/down.gif border=0></a>";
89 if ($r eq $rules->[0]) {
90 $mover .= "<img src=images/gap.gif>";
93 $mover .= "<a href='move.cgi?idx=$r->{'index'}&".
94 "up=1'><img src=images/up.gif ".
97 $adder .= "<a href='edit_rule.cgi?new=1&".
98 "after=$r->{'index'}'>".
99 "<img src=images/after.gif border=0></a>";
100 $adder .= "<a href='edit_rule.cgi?new=1&".
101 "before=$r->{'index'}'>".
102 "<img src=images/before.gif border=0></a>";
104 local $ls = "<a href='edit_rule.cgi?idx=$r->{'index'}'>";
106 local $act = $amap{int($r->{'num'})};
107 print &ui_checked_columns_row(
108 [ $ls.($r->{'active'} ? $text{'yes'} :
109 "<font color=#ff0000>$text{'no'}</font>").$le,
110 $ls.($text{'action_'.$r->{'action'}} ||
111 uc($r->{'action'})).$le,
112 $ls.$text{'dir_'.$r->{'dir'}}.$le,
113 $config{'view_condition'} ?
114 ( &describe_rule($r) ) : ( ),
115 $config{'view_comment'} ?
116 ( $r->{'cmt'} || "<br>" ) : ( ),
119 \@widths, "d", $r->{'index'});
121 print &ui_columns_end();
122 print &ui_links_row(\@links);
124 # Buttons to delete and add
125 print "<table width=100%><tr>\n";
126 print "<td align=left>",
127 &ui_submit($text{'index_delete'}, "delsel"),"</td>\n";
128 print "<td align=right>",
129 &ui_submit($text{'index_add2'}, "new"),"</td>\n";
130 print "</tr></table>\n";
131 print &ui_form_end();
135 $natrules = &get_ipnat_config();
136 print &ui_form_start("edit_nat.cgi");
138 local @widths = ( "width=10", "width=5%", "width=10%", undef );
139 push(@widths, undef) if ($config{'view_condition'});
140 push(@widths, undef) if ($config{'view_comment'});
141 push(@widths, "width=5%", "width=5%");
142 print &select_all_link("d", 1),"\n";
143 print &select_invert_link("d", 1),"<br>\n";
144 print &ui_columns_start([ "",
145 $text{'index_active'},
146 $text{'index_nataction'},
147 $config{'view_condition'} ?
148 ( $text{'index_natfrom'},
149 $text{'index_natto'} ) : ( ),
150 $config{'view_comment'} ?
151 ( $text{'index_cmt'} ) : ( ),
152 $text{'index_move'} ], 100, 0,
154 foreach $r (@$natrules) {
155 local ($mover, $adder);
156 if ($r eq $natrules->[@$natrules-1]) {
157 $mover .= "<img src=images/gap.gif>";
160 $mover .= "<a href='natmove.cgi?idx=$r->{'index'}&".
162 "images/down.gif border=0></a>";
164 if ($r eq $natrules->[0]) {
165 $mover .= "<img src=images/gap.gif>";
168 $mover .= "<a href='natmove.cgi?idx=$r->{'index'}&".
169 "up=1'><img src=images/up.gif ".
173 local $ls = "<a href='edit_nat.cgi?idx=$r->{'index'}'>";
175 print &ui_columns_row(
176 [ &ui_checkbox("d", $r->{'index'}, "", 0),
177 $ls.($r->{'active'} ? $text{'yes'} :
178 "<font color=#ff0000>$text{'no'}</font>").$le,
179 $ls.($text{'action_'.$r->{'action'}} ||
180 uc($r->{'action'})).$le,
181 $config{'view_condition'} ?
182 ( &describe_from($r), &describe_to($r) ) : ( ),
183 $config{'view_comment'} ?
184 ( $r->{'cmt'} || "<br>" ) : ( ),
188 print &ui_columns_end();
189 print &select_all_link("d", 1),"\n";
190 print &select_invert_link("d", 1),"<br>\n";
191 print "<table width=100%><tr>\n";
192 print "<td align=left>",
193 &ui_submit($text{'index_delete'}, "delsel"),"</td>\n";
194 print "<td align=right>",
195 &ui_submit($text{'index_add3'}, "newmap"),"\n",
196 &ui_submit($text{'index_add4'}, "newrdr"),"</td>\n";
197 print "</tr></table>\n";
200 print "<b>$text{'index_natnone'}</b><p>\n";
201 print "<table width=100%><tr>\n";
202 print "<td align=right>",
203 &ui_submit($text{'index_add3'}, "newmap"),"\n",
204 &ui_submit($text{'index_add4'}, "newrdr"),"</td>\n";
205 print "</tr></table>\n";
207 print &ui_form_end();
209 # Show buttons to apply configuration and start at boot
212 print &ui_buttons_start();
213 if (&foreign_check("servers")) {
214 @servers = &list_cluster_servers();
216 print &ui_buttons_row("apply.cgi", $text{'index_apply'},
217 @servers ? $text{'index_applydesc2'}
218 : $text{'index_applydesc'});
219 print &ui_buttons_row("unapply.cgi", $text{'index_unapply'},
220 $text{'index_unapplydesc'});
221 print &ui_buttons_row("bootup.cgi", $text{'index_boot'},
222 $text{'index_bootdesc'}, undef,
223 &ui_radio("boot", $atboot == 2 ? 1 : 0,
224 [ [ 1, $text{'yes'} ],
225 [ 0, $text{'no'} ] ]));
226 print &ui_buttons_row("index.cgi", $text{'index_reset'},
227 $text{'index_resetdesc'}, undef,
228 &ui_hidden("reset", 1));
229 # Show button for cluster page
230 if (&foreign_check("servers")) {
231 &foreign_require("servers", "servers-lib.pl");
232 @allservers = grep { $_->{'user'} }
233 &servers::list_servers();
236 print &ui_buttons_row("cluster.cgi", $text{'index_cluster'},
237 $text{'index_clusterdesc'});
239 print &ui_buttons_end();
242 # Offer to setup simple firewall
243 print &text($in{'reset'} ? 'index_rsetup' : 'index_setup',
244 "<tt>$ipfw_file</tt>"),"<p>\n";
245 print &ui_form_start("setup.cgi");
246 print &ui_hidden("reset", $in{'reset'});
247 print "<center><table><tr><td>\n";
248 print &ui_oneradio("auto", 0, $text{'index_auto0'}, 1),"<p>\n";
249 foreach $a (1 .. 4) {
250 print &ui_oneradio("auto", $a, $text{'index_auto'.$a}, 0)," ",
251 &interface_choice("iface".$a, undef, 1),"<p>\n";
253 print "</td></tr></table>\n";
254 print &ui_submit($text{'index_auto'}),"<p>\n";
255 print &ui_checkbox("atboot", 1, $text{'index_atboot'},
257 print "</center>",&ui_form_end(),"\n";
260 &ui_print_footer("/", $text{'index'});