]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - html/cgi-bin/forwardfw.cgi
Forward Firewall: edited p2pblock call in rules.pl
[people/teissler/ipfire-2.x.git] / html / cgi-bin / forwardfw.cgi
CommitLineData
2a81ab0d
AM
1#!/usr/bin/perl
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2012 #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21# #
22# Hi folks! I hope this code is useful for all. I needed something to handle #
23# my VPN Connections in a comfortable way. As a prerequisite i needed #
24# something that makes sure the vpn roadwarrior are able to have a fixed #
25# ip-address. So i developed the ccd extension for the vpn server. #
26# #
27# Now that the ccd extension is ready i am able to develop the main request. #
28# Any feedback is appreciated. #
29# #
30# #
31###############################################################################
32
33use strict;
34no warnings 'uninitialized';
35# enable only the following on debugging purpose
36#use warnings;
37#use CGI::Carp 'fatalsToBrowser';
38
39require '/var/ipfire/general-functions.pl';
40require "${General::swroot}/lang.pl";
41require "${General::swroot}/header.pl";
42require "${General::swroot}/forward/bin/firewall-lib.pl";
43
44unless (-d "${General::swroot}/forward") { system("mkdir ${General::swroot}/forward"); }
45unless (-e "${General::swroot}/forward/settings") { system("touch ${General::swroot}/forward/settings"); }
46unless (-e "${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
47unless (-e "${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
48
49my %fwdfwsettings=();
50my %selected=() ;
51my %defaultNetworks=();
52my %netsettings=();
53my %customhost=();
54my %customgrp=();
55my %customnetworks=();
56my %customservice=();
57my %customservicegrp=();
58my %ccdnet=();
59my %customnetwork=();
60my %ccdhost=();
61my %configfwdfw=();
62my %configinputfw=();
63my %ipsecconf=();
64my %color=();
65my %mainsettings=();
66my %checked=();
67my %icmptypes=();
68my %ovpnsettings=();
69my %ipsecsettings=();
70my %aliases=();
36196d0d 71my @p2ps = ();
2a81ab0d
AM
72my $color;
73my $confignet = "${General::swroot}/fwhosts/customnetworks";
74my $confighost = "${General::swroot}/fwhosts/customhosts";
75my $configgrp = "${General::swroot}/fwhosts/customgroups";
76my $configsrv = "${General::swroot}/fwhosts/customservices";
77my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
78my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
79my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
80my $configipsec = "${General::swroot}/vpn/config";
81my $configipsecrw = "${General::swroot}/vpn/settings";
82my $configfwdfw = "${General::swroot}/forward/config";
83my $configinput = "${General::swroot}/forward/input";
84my $configovpn = "${General::swroot}/ovpn/settings";
36196d0d 85my $p2pfile = "${General::swroot}/forward/p2protocols";
2a81ab0d
AM
86my $errormessage='';
87my $hint='';
88my $ipgrp="${General::swroot}/outgoing/groups";
89
90
91&General::readhash("${General::swroot}/forward/settings", \%fwdfwsettings);
92&General::readhash("${General::swroot}/main/settings", \%mainsettings);
93&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
94
95&Header::showhttpheaders();
96&Header::getcgihash(\%fwdfwsettings);
97&Header::openpage($Lang::tr{'fwdfw menu'}, 1, '');
98&Header::openbigbox('100%', 'center',$errormessage);
99#### ACTION #####
100
101if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'save'})
102{
103 my $MODE = $fwdfwsettings{'POLICY'};
104 %fwdfwsettings = ();
105 $fwdfwsettings{'POLICY'} = "$MODE";
106 &General::writehash("${General::swroot}/forward/settings", \%fwdfwsettings);
107 &reread_rules;
108}
109if ($fwdfwsettings{'ACTION'} eq 'saverule')
110{
111 &General::readhasharray("$configfwdfw", \%configfwdfw);
112 &General::readhasharray("$configinput", \%configinputfw);
113 $errormessage=&checksource;
114 if(!$errormessage){&checktarget;}
115 if(!$errormessage){&checkrule;}
2a81ab0d 116 #check if we change an forward rule to an external access
62fc8511 117 if( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
2a81ab0d
AM
118 $fwdfwsettings{'updatefwrule'}='';
119 $fwdfwsettings{'config'}=$configfwdfw;
120 $fwdfwsettings{'nobase'}='on';
121 &deleterule;
62fc8511
AM
122 &checkcounter(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
123 &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
2a81ab0d 124 }
2a81ab0d 125 #check if we change an external access rule to an forward
62fc8511 126 if( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
2a81ab0d
AM
127 $fwdfwsettings{'updatefwrule'}='';
128 $fwdfwsettings{'config'}=$configinput;
129 $fwdfwsettings{'nobase'}='on';
130 &deleterule;
62fc8511
AM
131 &checkcounter(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
132 &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
2a81ab0d 133 }
2a81ab0d
AM
134 #INPUT part
135 if($fwdfwsettings{'grp2'} eq 'ipfire'){
136 $fwdfwsettings{'chain'} = 'INPUTFW';
137 #check if we have an identical rule already
2da264ec
AM
138 if($fwdfwsettings{'oldrulenumer'} eq $fwdfwsettings{'rulepos'}){
139 foreach my $key (sort keys %configinputfw){
140 if ("$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
141 eq "$configinputfw{$key}[0],$configinputfw{$key}[2],$configinputfw{$key}[3],$configinputfw{$key}[4],$configinputfw{$key}[5],$configinputfw{$key}[6],$configinputfw{$key}[7],$configinputfw{$key}[8],$configinputfw{$key}[9],$configinputfw{$key}[10],$configinputfw{$key}[11],$configinputfw{$key}[12],$configinputfw{$key}[13],$configinputfw{$key}[14],$configinputfw{$key}[15],$configinputfw{$key}[17],$configinputfw{$key}[18],$configinputfw{$key}[19],$configinputfw{$key}[20],$configinputfw{$key}[21],$configinputfw{$key}[22],$configinputfw{$key}[23],$configinputfw{$key}[24],$configinputfw{$key}[25],$configinputfw{$key}[26],$configinputfw{$key}[27]"){
142 $errormessage.=$Lang::tr{'fwdfw err ruleexists'};
02da9f7b
AM
143 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
144 $errormessage='';
145 }
146 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
147 $fwdfwsettings{'nosave'} = 'on';
148 }
2da264ec 149 }
62fc8511 150 }
2da264ec 151 }
992394d5
AM
152 #check if we just close a rule
153 if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} ) {
154 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
155 $errormessage='';
156 $fwdfwsettings{'nosave2'} = 'on';
157 }
158 }
62fc8511
AM
159 &checkcounter($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
160 if ($fwdfwsettings{'nobase'} ne 'on'){
161 &checkcounter($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
162 }
163 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
164 &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
165 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
166 &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
167 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
168 &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
169 }
992394d5
AM
170 if($fwdfwsettings{'nosave2'} ne 'on'){
171 &saverule(\%configinputfw,$configinput);
172 }
2a81ab0d
AM
173 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
174 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
175 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
176 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
177 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
178 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
179 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
180 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
181 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
182 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
183 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
184 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
185 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
186 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
187 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
188 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
189 #print "<br>";
190 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
191 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
192 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
193 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
2a81ab0d
AM
194 }else{
195 $fwdfwsettings{'chain'} = 'FORWARDFW';
2da264ec
AM
196 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
197 #check if we have an identical rule already
198 foreach my $key (sort keys %configfwdfw){
199 if ("$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
200 eq "$configfwdfw{$key}[0],$configfwdfw{$key}[2],$configfwdfw{$key}[3],$configfwdfw{$key}[4],$configfwdfw{$key}[5],$configfwdfw{$key}[6],$configfwdfw{$key}[7],$configfwdfw{$key}[8],$configfwdfw{$key}[9],$configfwdfw{$key}[10],$configfwdfw{$key}[11],$configfwdfw{$key}[12],$configfwdfw{$key}[13],$configfwdfw{$key}[14],$configfwdfw{$key}[15],$configfwdfw{$key}[17],$configfwdfw{$key}[18],$configfwdfw{$key}[19],$configfwdfw{$key}[20],$configfwdfw{$key}[21],$configfwdfw{$key}[22],$configfwdfw{$key}[23],$configfwdfw{$key}[24],$configfwdfw{$key}[25],$configfwdfw{$key}[26],$configfwdfw{$key}[27]"){
201 $errormessage.=$Lang::tr{'fwdfw err ruleexists'};
02da9f7b
AM
202 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
203 $errormessage='';
204 }
205 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
206 $fwdfwsettings{'nosave'} = 'on';
207 }
2da264ec
AM
208 }
209 }
2a81ab0d 210 }
992394d5
AM
211 #check if we just close a rule
212 if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} ) {
213 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
214 $fwdfwsettings{'nosave2'} = 'on';
215 $errormessage='';
216 }
217 }
2a81ab0d
AM
218 #increase counters
219 &checkcounter($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
2a81ab0d 220 &checkcounter($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
2a81ab0d
AM
221 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
222 &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
223 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
224 &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
225 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
226 &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
227 }
2a81ab0d
AM
228 if ($fwdfwsettings{'nobase'} eq 'on'){
229 &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
230 }
992394d5
AM
231 if ($fwdfwsettings{'nosave2'} ne 'on'){
232 &saverule(\%configfwdfw,$configfwdfw);
233 }
2a81ab0d
AM
234 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
235 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
236 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
237 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
238 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
239 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
240 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
241 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
242 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
243 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
244 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
245 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
246 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
247 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
248 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
249 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
250 #print "<br>";
251 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
252 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
253 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
254 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
2a81ab0d
AM
255 }
256 if ($errormessage){
257 &newrule;
258 }else{
992394d5
AM
259 if($fwdfwsettings{'nosave2'} ne 'on'){
260 &rules;
261 }
2a81ab0d
AM
262 &base;
263 }
2a81ab0d
AM
264}
265if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'reset'})
266{
267 &General::readhasharray("$configfwdfw", \%configfwdfw);
268 foreach my $key (sort keys %configfwdfw){
269 &checkcounter($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
270 &checkcounter($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
271 &checkcounter($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
272 }
273 &General::readhasharray("$configinput", \%configinputfw);
274 foreach my $key (sort keys %configinputfw){
275 &checkcounter($configinputfw{$key}[3],$configinputfw{$key}[4],,);
276 &checkcounter($configinputfw{$key}[5],$configinputfw{$key}[6],,);
277 &checkcounter($configinputfw{$key}[14],$configinputfw{$key}[15],,);
278 }
279 $fwdfwsettings{'POLICY'}='MODE0';
280 system("rm ${General::swroot}/forward/config");
281 system("rm ${General::swroot}/forward/input");
2a81ab0d
AM
282 &General::writehash("${General::swroot}/forward/settings", \%fwdfwsettings);
283 unless (-e "${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
284 unless (-e "${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
62fc8511 285 %fwdfwsettings = ();
2a81ab0d
AM
286 &reread_rules;
287
288}
289if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw newrule'})
290{
291 &newrule;
292}
293if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw toggle'})
294{
295 my %togglehash=();
296 &General::readhasharray($fwdfwsettings{'config'}, \%togglehash);
297 foreach my $key (sort keys %togglehash){
298 if ($key eq $fwdfwsettings{'key'}){
299 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
300 }
301 }
302 &General::writehasharray($fwdfwsettings{'config'}, \%togglehash);
303 &rules;
304 &base;
305}
306if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw togglelog'})
307{
308 my %togglehash=();
309 &General::readhasharray($fwdfwsettings{'config'}, \%togglehash);
310 foreach my $key (sort keys %togglehash){
311 if ($key eq $fwdfwsettings{'key'}){
312 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
313 }
314 }
315 &General::writehasharray($fwdfwsettings{'config'}, \%togglehash);
316 &rules;
317 &base;
318}
319if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw reread'})
320{
321 &reread_rules;
322 &base;
323}
324if ($fwdfwsettings{'ACTION'} eq 'editrule')
325{
326 $fwdfwsettings{'updatefwrule'}='on';
327 &newrule;
328}
329if ($fwdfwsettings{'ACTION'} eq 'deleterule')
330{
331 &deleterule;
332}
333if ($fwdfwsettings{'ACTION'} eq 'moveup')
334{
335 &pos_up;
336 &base;
337}
338if ($fwdfwsettings{'ACTION'} eq 'movedown')
339{
340 &pos_down;
341 &base;
342}
343if ($fwdfwsettings{'ACTION'} eq 'copyrule')
344{
345 $fwdfwsettings{'copyfwrule'}='on';
346 #$fwdfwsettings{'updatefwrule'}='on';
347 &newrule;
348}
36196d0d
AM
349if ($fwdfwsettings{'ACTION'} eq 'togglep2p')
350{
351 #$errormessage="Toggle $fwdfwsettings{'P2PROT'}<br>";
352 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
353 @p2ps = <FILE>;
354 close FILE;
355 open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile";
356 foreach my $p2pentry (sort @p2ps)
357 {
358 my @p2pline = split( /\;/, $p2pentry );
359 if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) {
360 if($p2pline[2] eq 'on'){
361 $p2pline[2]='off';
362 }else{
363 $p2pline[2]='on';
364 }
365 }
366 print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
367 }
368 close FILE;
369 &rules;
370 &base;
371}
2a81ab0d
AM
372if ($fwdfwsettings{'ACTION'} eq '')
373{
374 &base;
375}
376### Functions ####
377sub pos_up
378{
379 my %uphash=();
380 my %tmp=();
381 &General::readhasharray($fwdfwsettings{'config'}, \%uphash);
382 foreach my $key (sort keys %uphash){
383 if ($key eq $fwdfwsettings{'key'}) {
384 my $last = $key -1;
385 if (exists $uphash{$last}){
386 #save rule last
387 foreach my $y (0 .. $#{$uphash{$last}}) {
388 $tmp{0}[$y] = $uphash{$last}[$y];
389 }
390 #copy active rule to last
391 foreach my $i (0 .. $#{$uphash{$last}}) {
392 $uphash{$last}[$i] = $uphash{$key}[$i];
393 }
394 #copy saved rule to actual position
395 foreach my $x (0 .. $#{$tmp{0}}) {
396 $uphash{$key}[$x] = $tmp{0}[$x];
397 }
398 }
399 }
400 }
401 &General::writehasharray($fwdfwsettings{'config'}, \%uphash);
402 &rules;
403}
404sub pos_down
405{
406 my %downhash=();
407 my %tmp=();
408 &General::readhasharray($fwdfwsettings{'config'}, \%downhash);
409 foreach my $key (sort keys %downhash){
410 if ($key eq $fwdfwsettings{'key'}) {
411 my $next = $key + 1;
412 if (exists $downhash{$next}){
413 #save rule next
414 foreach my $y (0 .. $#{$downhash{$next}}) {
415 $tmp{0}[$y] = $downhash{$next}[$y];
416 }
417 #copy active rule to next
418 foreach my $i (0 .. $#{$downhash{$next}}) {
419 $downhash{$next}[$i] = $downhash{$key}[$i];
420 }
421 #copy saved rule to actual position
422 foreach my $x (0 .. $#{$tmp{0}}) {
423 $downhash{$key}[$x] = $tmp{0}[$x];
424 }
425 }
426 }
427 }
428 &General::writehasharray($fwdfwsettings{'config'}, \%downhash);
429 &rules;
430}
431sub checkcounter
432{
433 my ($base1,$val1,$base2,$val2) = @_;
434
435 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
436 &dec_counter($confignet,\%customnetwork,$val1);
437 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
438 &dec_counter($confighost,\%customhost,$val1);
439 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
440 &dec_counter($configgrp,\%customgrp,$val1);
441 }elsif($base1 eq 'cust_srv'){
442 &dec_counter($configsrv,\%customservice,$val1);
443 }elsif($base1 eq 'cust_srvgrp'){
444 &dec_counter($configsrvgrp,\%customservicegrp,$val1);
445 }
62fc8511 446
2a81ab0d
AM
447 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
448 &inc_counter($confignet,\%customnetwork,$val2);
449 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
450 &inc_counter($confighost,\%customhost,$val2);
451 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
452 &inc_counter($configgrp,\%customgrp,$val2);
453 }elsif($base2 eq 'cust_srv'){
454 &inc_counter($configsrv,\%customservice,$val2);
455 }elsif($base2 eq 'cust_srvgrp'){
456 &inc_counter($configsrvgrp,\%customservicegrp,$val2);
457 }
458}
459sub inc_counter
460{
461 my $config=shift;
462 my %hash=%{(shift)};
463 my $val=shift;
464 my $pos;
62fc8511 465
2a81ab0d
AM
466 &General::readhasharray($config, \%hash);
467 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
468 if($hash{$key}[0] eq $val){
469 $pos=$#{$hash{$key}};
470 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
2a81ab0d
AM
471 }
472 }
473 &General::writehasharray($config, \%hash);
474}
475sub dec_counter
476{
477 my $config=shift;
478 my %hash=%{(shift)};
479 my $val=shift;
480 my $pos;
481 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
482 &General::readhasharray($config, \%hash);
483 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
484 if($hash{$key}[0] eq $val){
485 $pos=$#{$hash{$key}};
486 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
2a81ab0d
AM
487 }
488 }
489 &General::writehasharray($config, \%hash);
490}
491sub base
492{
2a81ab0d
AM
493 if ($fwdfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
494 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
495 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
62fc8511 496
2a81ab0d
AM
497 &hint;
498 if ($fwdfwsettings{'POLICY'} ne 'MODE0' && $fwdfwsettings{'POLICY'} ne '') {
499 &addrule;
500 }
62fc8511 501
2a81ab0d
AM
502 #print"<table width='100' border='1'><tr>";
503 #foreach (0 .. 40){
504 #my $i="color".$_;
505 #print"<td bgcolor='$color{$i}'>$_</td>";
506 #}
507 #print"</tr></table>";
36196d0d
AM
508 if ($fwdfwsettings{'POLICY'} eq 'MODE1' || $fwdfwsettings{'POLICY'} eq 'MODE2' ) {
509 &p2pblock;
510 }
2a81ab0d
AM
511 &Header::openbox('100%', 'center', 'Policy');
512print <<END;
513 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
514 <table width='100%'>
515 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 0:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode0'}</td></tr>
516 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 1:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode1'}</td></tr>
517 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 2:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode2'}</td></tr>
518 <tr><td colspan='3'><hr /></td></tr>
519 <tr><td width='10%' align='left'> <select name='POLICY' style="width: 85px"><option value='MODE0' $selected{'POLICY'}{'MODE0'}>$Lang::tr{'mode'} 0</option><option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'mode'} 1</option><option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'mode'} 2</option></select>
36196d0d
AM
520 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
521 <td width='45%' align='left'>
2a81ab0d
AM
522END
523 if ($fwdfwsettings{'POLICY'} ne 'MODE0'&& $fwdfwsettings{'POLICY'} ne '' ) {
524 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />";
525 }
36196d0d 526 print "</table></form>";
2a81ab0d
AM
527 &Header::closebox();
528}
529sub addrule
530{
531 &error;
532 &Header::openbox('100%', 'left', $Lang::tr{'fwdfw addrule'});
62fc8511 533
2a81ab0d
AM
534 print "<form method='post'>";
535 print "<table border='0'>";
536 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
537 if (-f "${General::swroot}/forward/reread"){
538 print "<td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}'></td>";
539 }
540 print"</tr></table></form><hr>";
541
542 &Header::closebox();
543 &viewtablerule;
2a81ab0d
AM
544}
545sub deleterule
546{
547 my %delhash=();
548 &General::readhasharray($fwdfwsettings{'config'}, \%delhash);
2da264ec 549 foreach my $key (sort {$a <=> $b} keys %delhash){
992394d5 550 if ($key == $fwdfwsettings{'key'}){
2a81ab0d
AM
551 #check hosts/net and groups
552 &checkcounter($delhash{$key}[3],$delhash{$key}[4],,);
553 &checkcounter($delhash{$key}[5],$delhash{$key}[6],,);
554 #check services and groups
555 if ($delhash{$key}[11] eq 'ON'){
556 &checkcounter($delhash{$key}[14],$delhash{$key}[15],,);
557 }
558 }
992394d5 559 if ($key >= $fwdfwsettings{'key'}) {
2a81ab0d
AM
560 my $next = $key + 1;
561 if (exists $delhash{$next}) {
e5345541 562 foreach my $i (0 .. $#{$delhash{$next}}) {
2a81ab0d
AM
563 $delhash{$key}[$i] = $delhash{$next}[$i];
564 }
565 }
566 }
567 }
568 # Remove the very last entry.
275a92e8 569 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
2a81ab0d
AM
570 delete $delhash{$last_key};
571
572 &General::writehasharray($fwdfwsettings{'config'}, \%delhash);
573 &rules;
62fc8511 574
2a81ab0d
AM
575 if($fwdfwsettings{'nobase'} ne 'on'){
576 &base;
577 }
578}
579sub disable_rule
580{
581 my $key1=shift;
582 &General::readhasharray("$configfwdfw", \%configfwdfw);
583 foreach my $key (sort keys %configfwdfw){
584 if ($key eq $key1 ){
585 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
586 }
587 }
588 &General::writehasharray("$configfwdfw", \%configfwdfw);
589 &rules;
2a81ab0d
AM
590}
591sub checksource
592{
593 my ($ip,$subnet);
36196d0d 594
2a81ab0d
AM
595 #check ip-address if manual
596 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
597 #check if ip with subnet
598 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?)$/) {
599 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
600 $subnet = &General::iporsubtocidr($subnet);
b5269091 601 $fwdfwsettings{'isip'}='on';
2a81ab0d
AM
602 }
603 #check if only ip
604 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
605 $ip=$fwdfwsettings{'src_addr'};
606 $subnet = '32';
b5269091 607 $fwdfwsettings{'isip'}='on';
2a81ab0d 608 }
36196d0d 609
b5269091
AM
610 if ($fwdfwsettings{'isip'} ne 'on'){
611 if (&General::validmac($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
612 }
613 if ($fwdfwsettings{'isip'} eq 'on'){
614 #check and form valid IP
615 $ip=&General::ip2dec($ip);
616 $ip=&General::dec2ip($ip);
617 #check if net or broadcast
618 my @tmp= split (/\./,$ip);
619 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
620 {
621 $errormessage=$Lang::tr{'fwhost err hostip'}."<br>";
622 }
623 $fwdfwsettings{'src_addr'}="$ip/$subnet";
36196d0d 624
b5269091
AM
625 if(!&General::validipandmask($fwdfwsettings{'src_addr'})){
626 $errormessage.=$Lang::tr{'fwdfw err src_addr'}."<br>";
627 }
628 }
629 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
2a81ab0d
AM
630 $errormessage.=$Lang::tr{'fwdfw err src_addr'}."<br>";
631 }
632 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
633 $errormessage.=$Lang::tr{'fwdfw err nosrcip'};
634 return $errormessage;
635 }
62fc8511 636
2a81ab0d
AM
637 #check empty fields
638 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr{'fwdfw err nosrc'}."<br>";}
639 #check icmp source
640 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
641 $fwdfwsettings{'SRC_PORT'}='';
642 &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
643 foreach my $key (keys %icmptypes){
644 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
645 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
646 }
647 }
62fc8511
AM
648 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
649 $fwdfwsettings{'SRC_PORT'}='';
650 $fwdfwsettings{'ICMP_TYPES'}='';
651 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
652 $fwdfwsettings{'SRC_PORT'}='';
653 $fwdfwsettings{'ICMP_TYPES'}='';
d1f01304
AM
654 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
655 $fwdfwsettings{'SRC_PORT'}='';
656 $fwdfwsettings{'ICMP_TYPES'}='';
2a81ab0d
AM
657 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
658 $fwdfwsettings{'ICMP_TYPES'}='';
659 }else{
660 $fwdfwsettings{'ICMP_TYPES'}='';
661 $fwdfwsettings{'SRC_PORT'}='';
662 $fwdfwsettings{'PROT'}='';
663 }
62fc8511 664
2a81ab0d
AM
665 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP' && $fwdfwsettings{'SRC_PORT'} ne ''){
666 #change dashes with :
667 $fwdfwsettings{'SRC_PORT'}=~ tr/-/:/;
668
669 if ($fwdfwsettings{'SRC_PORT'} eq "*") {
670 $fwdfwsettings{'SRC_PORT'} = "1:65535";
671 }
672 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\D)\:(\d+)$/) {
673 $fwdfwsettings{'SRC_PORT'} = "1:$2";
674 }
675 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\d+)\:(\D)$/) {
676 $fwdfwsettings{'SRC_PORT'} = "$1:65535";
677 }
62fc8511 678
2a81ab0d
AM
679 $errormessage.=&General::validportrange($fwdfwsettings{'SRC_PORT'},'src');
680 }
681 return $errormessage;
682}
683sub checktarget
684{
685 my ($ip,$subnet);
62fc8511 686
2a81ab0d
AM
687 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
688 #check if ip with subnet
689 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?)$/) {
690 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
691 $subnet = &General::iporsubtocidr($subnet);
692 }
693 #check if only ip
694 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
695 $ip=$fwdfwsettings{'tgt_addr'};
696 $subnet='32';
697 }
698 #check and form valid IP
699 $ip=&General::ip2dec($ip);
700 $ip=&General::dec2ip($ip);
36196d0d 701
2a81ab0d
AM
702 #check if net or broadcast
703 my @tmp= split (/\./,$ip);
704 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
705 {
55674e0d 706 $errormessage=$Lang::tr{'fwhost err hostip'}."<br>";
2a81ab0d 707 }
55674e0d 708 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
2a81ab0d
AM
709
710 if(!&General::validipandmask($fwdfwsettings{'tgt_addr'})){
711 $errormessage.=$Lang::tr{'fwdfw err tgt_addr'}."<br>";
712 }
62fc8511 713
2a81ab0d
AM
714 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
715 $errormessage.=$Lang::tr{'fwdfw err notgtip'};
716 return $errormessage;
717 }
62fc8511 718
2a81ab0d
AM
719 #check empty fields
720 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr{'fwdfw err notgt'}."<br>";}
62fc8511 721
2a81ab0d
AM
722 #check tgt services
723 if ($fwdfwsettings{'USESRV'} eq 'ON'){
724 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
725 $fwdfwsettings{'TGT_PROT'}='';
726 $fwdfwsettings{'ICMP_TGT'}='';
727 }
728 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
729 $fwdfwsettings{'TGT_PROT'}='';
730 $fwdfwsettings{'ICMP_TGT'}='';
731 #check target service
732 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
733 $errormessage.=$Lang::tr{'fwdfw err tgt_grp'};
734 }
735 }
736 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
bcbf1b8e 737 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
2a81ab0d
AM
738 if ($fwdfwsettings{'TGT_PORT'} ne ''){
739 #change dashes with :
740 $fwdfwsettings{'TGT_PORT'}=~ tr/-/:/;
741 if ($fwdfwsettings{'TGT_PORT'} eq "*") {
742 $fwdfwsettings{'TGT_PORT'} = "1:65535";
743 }
744 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\D)\:(\d+)$/) {
745 $fwdfwsettings{'TGT_PORT'} = "1:$2";
746 }
747 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\d+)\:(\D)$/) {
748 $fwdfwsettings{'TGT_PORT'} = "$1:65535";
749 }
750 $errormessage .= &General::validportrange($fwdfwsettings{'TGT_PORT'}, 'destination');
751 }
62fc8511 752 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
d1f01304 753 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
bcbf1b8e 754 $fwdfwsettings{'TGT_PORT'} = '';
62fc8511 755 $fwdfwsettings{'ICMP_TGT'} = '';
bcbf1b8e 756 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
d1f01304 757 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
bcbf1b8e 758 $fwdfwsettings{'TGT_PORT'} = '';
d1f01304 759 $fwdfwsettings{'ICMP_TGT'}='';
bcbf1b8e 760 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
d1f01304 761 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
bcbf1b8e 762 $fwdfwsettings{'TGT_PORT'} = '';
62fc8511 763 $fwdfwsettings{'ICMP_TGT'}='';
2a81ab0d 764 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
d1f01304 765 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
bcbf1b8e 766 $fwdfwsettings{'TGT_PORT'} = '';
2a81ab0d
AM
767 &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
768 foreach my $key (keys %icmptypes){
769
770 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
2a81ab0d
AM
771 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
772 }
773 }
774 }
775 }
776 }
62fc8511 777
2a81ab0d
AM
778 #check targetport
779 if ($fwdfwsettings{'USESRV'} ne 'ON'){
780 $fwdfwsettings{'grp3'}='';
781 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
782 $fwdfwsettings{'TGT_PROT'}='';
783 $fwdfwsettings{'ICMP_TGT'}='';
bcbf1b8e 784
2a81ab0d 785 }
2a81ab0d
AM
786 #check timeframe
787 if($fwdfwsettings{'TIME'} eq 'ON'){
788 if($fwdfwsettings{'TIME_MON'} eq '' && $fwdfwsettings{'TIME_TUE'} eq '' && $fwdfwsettings{'TIME_WED'} eq '' && $fwdfwsettings{'TIME_THU'} eq '' && $fwdfwsettings{'TIME_FRI'} eq '' && $fwdfwsettings{'TIME_SAT'} eq '' && $fwdfwsettings{'TIME_SUN'} eq ''){
789 $errormessage=$Lang::tr{'fwdfw err time'};
790 }
791 }
2a81ab0d
AM
792 return $errormessage;
793}
794sub checkrule
795{
796 #check valid remark
797 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark($fwdfwsettings{'ruleremark'})){
798 $errormessage.=$Lang::tr{'fwdfw err remark'}."<br>";
799 }
800 #check if source and target identical
801 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}}){
802 $errormessage.=$Lang::tr{'fwdfw err same'};
803 return $errormessage;
804 }
62fc8511 805
2a81ab0d
AM
806 #get source and targetip address if possible
807 my ($sip,$scidr,$tip,$tcidr);
808 ($sip,$scidr)=&get_ip("src","grp1");
809 ($tip,$tcidr)=&get_ip("tgt","grp2");
62fc8511 810
2a81ab0d
AM
811 #check same iprange in source and target
812 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
2a81ab0d
AM
813 my $networkip1=&General::getnetworkip($sip,$scidr);
814 my $networkip2=&General::getnetworkip($tip,$tcidr);
815 if ($scidr gt $tcidr){
816 if ( &General::IpInSubnet($networkip1,$tip,&General::iporsubtodec($tcidr)) ){
817 $errormessage.=$Lang::tr{'fwdfw err samesub'};
818 }
819 }elsif($scidr eq $tcidr && $scidr eq '32'){
62fc8511
AM
820 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
821 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
2a81ab0d
AM
822 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
823 $hint=$Lang::tr{'fwdfw hint ip1'}."<br>";
55674e0d 824 $hint.=$Lang::tr{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
2a81ab0d 825 }
2a81ab0d
AM
826 }else{
827 if ( &General::IpInSubnet($networkip2,$sip,&General::iporsubtodec($scidr)) ){
828 $errormessage.=$Lang::tr{'fwdfw err samesub'};
829 }
830 }
831 }
62fc8511 832
2a81ab0d
AM
833 #check source and destination protocol if manual
834 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
835 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
836 $errormessage.=$Lang::tr{'fwdfw err prot'};
837 }
838 #check source and destination protocol if source manual and dest servicegrp
839 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
840 &General::readhasharray("$configsrv", \%customservice);
841 foreach my $key (sort keys %customservice){
842 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
843 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
844 $errormessage.=$Lang::tr{'fwdfw err prot'};
845 last;
846 }
847 }
848 }
849 }
850 }
2a81ab0d
AM
851}
852sub get_ip
853{
854 my $val=shift;
855 my $grp =shift;
856 my $a;
857 my $b;
858 &General::readhash("/var/ipfire/ethernet/settings", \%netsettings);
859 if ($fwdfwsettings{$grp} ne $Lang::tr{'fwhost any'}){
860 if ($fwdfwsettings{$grp} eq $val.'_addr'){
861 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
862 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
863 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
864 $a=$netsettings{'GREEN_NETADDRESS'};
865 $b=&General::iporsubtocidr($netsettings{'GREEN_NETMASK'});
866 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
867 $a=$netsettings{'ORANGE_NETADDRESS'};
868 $b=&General::iporsubtocidr($netsettings{'ORANGE_NETMASK'});
869 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
870 $a=$netsettings{'BLUE_NETADDRESS'};
871 $b=&General::iporsubtocidr($netsettings{'BLUE_NETMASK'});
872 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
873 &General::readhash("$configovpn",\%ovpnsettings);
874 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
875 $b=&General::iporsubtocidr($b);
876 }
877 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
878 &General::readhasharray("$confignet", \%customnetwork);
879 foreach my $key (keys %customnetwork){
880 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
881 $a=$customnetwork{$key}[1];
882 $b=&General::iporsubtocidr($customnetwork{$key}[2]);
883 }
884 }
885 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
886 &General::readhasharray("$confighost", \%customhost);
887 foreach my $key (keys %customhost){
888 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
889 if ($customhost{$key}[1] eq 'ip'){
890 ($a,$b)=split (/\//,$customhost{$key}[2]);
891 $b=&General::iporsubtocidr($b);
892 }else{
893 if ($grp eq 'grp2'){
894 $errormessage=$Lang::tr{'fwdfw err tgt_mac'};
895 }
896 }
897 }
898 }
899 }
900 }
2a81ab0d
AM
901 return $a,$b;
902}
903sub newrule
904{
905 &error;
906 &General::setup_default_networks(\%defaultNetworks);
907 #read all configfiles
908 &General::readhasharray("$configccdnet", \%ccdnet);
909 &General::readhasharray("$confignet", \%customnetwork);
910 &General::readhasharray("$configccdhost", \%ccdhost);
911 &General::readhasharray("$confighost", \%customhost);
912 &General::readhasharray("$configccdhost", \%ccdhost);
913 &General::readhasharray("$configgrp", \%customgrp);
914 &General::readhasharray("$configipsec", \%ipsecconf);
915 &General::get_aliases(\%aliases);
2a81ab0d
AM
916 my %checked=();
917 my $helper;
2da264ec 918 my $sum=0;
2a81ab0d
AM
919 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
920 my $config=$fwdfwsettings{'config'};
921 my %hash=();
2a81ab0d
AM
922 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
923 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
924 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
925 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
926 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
927 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
928 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
929 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
930 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
931 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
932 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
933 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
934 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
935 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
936 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
937 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
938 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
939 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
2a81ab0d
AM
940 #check if update and get values
941 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
942 &General::readhasharray("$config", \%hash);
943 foreach my $key (sort keys %hash){
2da264ec 944 $sum++;
2a81ab0d 945 if ($key eq $fwdfwsettings{'key'}){
2da264ec 946 $fwdfwsettings{'oldrulenumber'} = $key;
2a81ab0d
AM
947 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
948 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
949 $fwdfwsettings{'grp1'} = $hash{$key}[3];
950 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
951 $fwdfwsettings{'grp2'} = $hash{$key}[5];
952 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
953 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
954 $fwdfwsettings{'PROT'} = $hash{$key}[8];
955 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
956 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
957 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
958 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
959 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
960 $fwdfwsettings{'grp3'} = $hash{$key}[14];
961 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
962 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
963 $fwdfwsettings{'LOG'} = $hash{$key}[17];
964 $fwdfwsettings{'TIME'} = $hash{$key}[18];
965 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
966 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
967 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
968 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
969 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
970 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
971 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
972 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
973 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
2a81ab0d
AM
974 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
975 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
976 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
977 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
978 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
979 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
980 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
981 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
982 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
983 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
984 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
985 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
986 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
987 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
988 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
989 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
990 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
991 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
992 }
993 }
994 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
995 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
996 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
997 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
998 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
999 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1000 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
02da9f7b 1001 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
2a81ab0d
AM
1002 }else{
1003 $fwdfwsettings{'ACTIVE'}='ON';
1004 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1005 }
62fc8511 1006
2a81ab0d 1007 &Header::openbox('100%', 'left', $Lang::tr{'fwdfw addrule'});
62fc8511 1008
2a81ab0d
AM
1009print <<END;
1010 <form method="post">
1011 <table border='0'>
1012 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1013END
1014 foreach ("ACCEPT","DROP","REJECT")
1015 {
1016 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1017 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1018 }
62fc8511 1019
2a81ab0d
AM
1020 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1021 {
1022 print"<option selected>$_</option>";
1023 }else{
1024 print"<option>$_</option>";
1025 }
1026 }
1027 print"</select></td></tr></table><hr>";
1028
2a81ab0d
AM
1029 &Header::closebox();
1030 &Header::openbox('100%', 'left', $Lang::tr{'fwdfw source'});
62fc8511 1031
2a81ab0d
AM
1032 #------SOURCE-------------------------------------------------------
1033 print<<END;
1034 <table width='100%' border='0'>
1035 <tr><td width='1%'><input type='radio' name='grp1' value='src_addr' checked></td><td colspan='5'>$Lang::tr{'fwdfw sourceip'}<input type='TEXT' name='src_addr' value='$fwdfwsettings{'src_addr'}' ></td></tr>
1036 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1037 <tr><td width='1%'><input type='radio' name='grp1' value='std_net_src' $checked{'grp1'}{'std_net_src'}></td><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost stdnet'}</td><td width='13%'><select name='std_net_src' style='min-width:185px;'>
2a81ab0d
AM
1038END
1039 foreach my $network (sort keys %defaultNetworks)
1040 {
1041 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
62fc8511 1042 next if($defaultNetworks{$network}{'NAME'} eq "RED");
2a81ab0d
AM
1043 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1044 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
1045 print ">$network</option>";
1046 }
1047 print<<END;
1048 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_net_src' $checked{'grp1'}{'ovpn_net_src'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_net_src' style='min-width:185px;'>
1049END
1050 &fillselect(\%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1051 print<<END;
1052 </select></td></tr>
1053 <tr><td><input type='radio' name='grp1' value='cust_net_src' $checked{'grp1'}{'cust_net_src'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='cust_net_src' style='min-width:185px;'>
1054END
1055 &fillselect(\%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1056 print<<END;
1057 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_host_src' $checked{'grp1'}{'ovpn_host_src'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_host_src' style='min-width:185px;'>
1058END
1059 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1060 {
1061 if ($ccdhost{$key}[33] ne ''){
1062
1063 print "<option value='$ccdhost{$key}[1]'";
1064 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1065 print ">$ccdhost{$key}[1]</option>";
1066 }
1067 }
1068 print<<END;
1069 </select></td></tr>
1070 <tr><td valign='top'><input type='radio' name='grp1' value='cust_host_src' $checked{'grp1'}{'cust_host_src'}></td><td>$Lang::tr{'fwhost cust addr'}</td><td><select name='cust_host_src' style='min-width:185px;'>
1071END
1072 &fillselect(\%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1073 print<<END;
1074 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_n2n_src' $checked{'grp1'}{'ovpn_n2n_src'}></td><td >$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='ovpn_n2n_src' style='min-width:185px;'>
1075END
1076 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1077 if($ccdhost{$key}[3] eq 'net'){
1078 print"<option ";
1079 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1080 print ">$ccdhost{$key}[1]</option>";
1081 }
1082 }
1083 print<<END;
1084 </select></td></tr>
62fc8511 1085
2a81ab0d
AM
1086 <tr><td valign='top'><input type='radio' name='grp1' value='cust_grp_src' $checked{'grp1'}{'cust_grp_src'}></td><td >$Lang::tr{'fwhost cust grp'}</td><td><select name='cust_grp_src' style='min-width:185px;'>
1087END
1088 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1089 if($helper ne $customgrp{$key}[0]){
1090 print"<option ";
1091 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1092 print ">$customgrp{$key}[0]</option>";
2a81ab0d
AM
1093 }
1094 $helper=$customgrp{$key}[0];
1095 }
1096 print<<END;
1097 </select></td>
1098 <td valign='top'><input type='radio' name='grp1' value='ipsec_net_src' $checked{'grp1'}{'ipsec_net_src'}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td><select name='ipsec_net_src' style='min-width:185px;'>
1099END
1100 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1101 if ($ipsecconf{$key}[3] eq 'net'){
1102 print "<option ";
1103 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1104 print ">$ipsecconf{$key}[1]</option>";
1105 }
1106 }
1107 #sourceport
1108 print<<END;
1109 </select></td></tr>
1110END
62fc8511 1111
2a81ab0d
AM
1112# <td valign='top'><input type='radio' name='grp1' value='ipsec_host_src' $checked{'grp1'}{'ipsec_host_src'}></td><td >$Lang::tr{'fwhost ipsec host'}</td><td><select name='ipsec_host_src' style='min-width:185px;'>
1113#END
1114# foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1115# if ($ipsecconf{$key}[3] eq 'host'){
1116# print "<option ";
1117# print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1118# print ">$ipsecconf{$key}[1]</option>";
1119# }
1120# }
1121 print<<END;
2a81ab0d 1122 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
2a81ab0d
AM
1123 <table width='100%' border='0'>
1124 <tr><td width='1%'><input type='checkbox' name='USE_SRC_PORT' value='ON' $checked{'USE_SRC_PORT'}{'ON'}></td><td width='51%' colspan='3'>$Lang::tr{'fwdfw use srcport'}</td>
1125 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1126END
d1f01304 1127 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
2a81ab0d
AM
1128 {
1129 if ($_ eq $fwdfwsettings{'PROT'})
1130 {
1131 print"<option selected>$_</option>";
1132 }else{
1133 print"<option>$_</option>";
1134 }
1135 }
1136 print<<END;
1137 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='11' size='9' ></td></tr>
1138 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1139END
1140 &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
1141 print"<option>All ICMP-Types</option>";
1142 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1143 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1144 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1145 }else{
1146 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1147 }
1148 }
1149 print<<END;
1150 </select></td></tr></table><hr>
1151END
1152 &Header::closebox();
1153
1154 #---TARGET------------------------------------------------------
1155 &Header::openbox('100%', 'left', $Lang::tr{'fwdfw target'});
1156 print<<END;
1157 <table width='100%' border='0'>
1158 <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr' checked></td><td colspan='2'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16'><td><input type='radio' name='grp2' value='ipfire' $checked{'grp2'}{'ipfire'}></td><td><b>IPFire ($Lang::tr{'external access'})</b></td><td><select name='ipfire' style='min-width:185px;'>
1159END
1160 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
62fc8511 1161
2a81ab0d
AM
1162 foreach my $alias (sort keys %aliases)
1163 {
1164 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1165 }
62fc8511 1166
2a81ab0d
AM
1167 print<<END;
1168 </td></tr>
1169 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1170 <tr><td width='1%'><input type='radio' name='grp2' value='std_net_tgt' $checked{'grp2'}{'std_net_tgt'}></td><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost stdnet'}</td><td width='13%'><select name='std_net_tgt' style='min-width:185px;'>
2a81ab0d 1171END
2a81ab0d
AM
1172 foreach my $network (sort keys %defaultNetworks)
1173 {
1174 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1175 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1176 print ">$network</option>";
1177 }
1178 print<<END;
1179 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_net_tgt' $checked{'grp2'}{'ovpn_net_tgt'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_net_tgt' style='min-width:185px;'>
1180END
1181 &fillselect(\%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
2a81ab0d
AM
1182 print<<END;
1183 </select></td></tr>
1184 <tr><td><input type='radio' name='grp2' value='cust_net_tgt' $checked{'grp2'}{'cust_net_tgt'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='cust_net_tgt' style='min-width:185px;'>
1185END
1186 &fillselect(\%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1187 print<<END;
1188 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_host_tgt' $checked{'grp2'}{'ovpn_host_tgt'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_host_tgt' style='min-width:185px;'>
1189END
1190 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1191 {
1192 if ($ccdhost{$key}[33] ne ''){
1193 print "<option value='$ccdhost{$key}[1]' ";
1194 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1195 print ">$ccdhost{$key}[1]</option>";
1196 }
1197 }
1198 print<<END;
1199 </select></td></tr>
1200 <tr><td valign='top'><input type='radio' name='grp2' value='cust_host_tgt' $checked{'grp2'}{'cust_host_tgt'}></td><td>$Lang::tr{'fwhost cust addr'}</td><td><select name='cust_host_tgt' style='min-width:185px;'>
1201END
1202 &fillselect(\%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1203 print<<END;
1204 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_n2n_tgt' $checked{'grp2'}{'ovpn_n2n_tgt'}></td><td >$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='ovpn_n2n_tgt' style='min-width:185px;'>
1205END
1206 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1207 if($ccdhost{$key}[3] eq 'net'){
1208 print "<option ";
1209 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1210 print ">$ccdhost{$key}[1]</option>";
1211 }
1212 }
1213 print<<END;
1214 </select></td></tr>
2a81ab0d
AM
1215 <tr><td valign='top'><input type='radio' name='grp2' value='cust_grp_tgt' $checked{'grp2'}{'cust_grp_tgt'}></td><td >$Lang::tr{'fwhost cust grp'}</td><td><select name='cust_grp_tgt' style='min-width:185px;'>
1216END
1217 $helper='';
1218 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1219 if($helper ne $customgrp{$key}[0]){
1220 print"<option ";
1221 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1222 print">$customgrp{$key}[0]</option>";
1223 }
1224 $helper=$customgrp{$key}[0];
1225 }
1226 print<<END;
1227 </select></td>
1228 <td valign='top'><input type='radio' name='grp2' value='ipsec_net_tgt' $checked{'grp2'}{'ipsec_net_tgt'}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td><select name='ipsec_net_tgt' style='min-width:185px;'>
1229END
1230 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1231 if ($ipsecconf{$key}[3] eq 'net'){
1232 print"<option ";
1233 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1234 print">$ipsecconf{$key}[1]</option>";
1235 }
1236 }
1237 print<<END;
1238 </select></td></tr>
1239END
2a81ab0d
AM
1240# <td valign='top'><input type='radio' name='grp2' value='ipsec_host_tgt' $checked{'grp2'}{'ipsec_host_tgt'}></td><td >$Lang::tr{'fwhost ipsec host'}</td><td><select name='ipsec_host_tgt' style='min-width:185px;'>
1241#END
1242# foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1243# if ($ipsecconf{$key}[3] eq 'host'){
1244# print"<option ";
1245# print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1246# print">$ipsecconf{$key}[1]</option>";
1247# }
1248# }
1249 print<<END;
1250 </table>
1251 <b>$Lang::tr{'fwhost attention'}:</b><br>
1252 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
62fc8511 1253
2a81ab0d
AM
1254 <table width='100%' border='0'>
1255 <tr><td width='1%'><input type='checkbox' name='USESRV' value='ON' $checked{'USESRV'}{'ON'} ></td><td width='48%'>$Lang::tr{'fwdfw use srv'}</td><td width='1%'><input type='radio' name='grp3' value='cust_srv' checked></td><td nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td width='1%' colspan='2'><select name='cust_srv'style='min-width:230px;' >
1256END
1257 &General::readhasharray("$configsrv", \%customservice);
62fc8511 1258 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
2a81ab0d
AM
1259 print"<option ";
1260 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1261 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1262 }
1263 print<<END;
1264 </select></td></tr>
1265 <tr><td colspan='2'></td><td><input type='radio' name='grp3' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}></td><td nowrap='nowrap'>$Lang::tr{'fwhost cust srvgrp'}:</td><td colspan='2'><select name='cust_srvgrp'style='min-width:230px;' >
1266END
1267 &General::readhasharray("$configsrvgrp", \%customservicegrp);
1268 my $helper;
62fc8511 1269 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
2a81ab0d
AM
1270 if ($helper ne $customservicegrp{$key}[0]){
1271 print"<option ";
1272 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1273 print">$customservicegrp{$key}[0]</option>";
1274 }
1275 $helper=$customservicegrp{$key}[0];
1276 }
1277 print<<END;
1278 </select></td></tr>
1279 <tr><td colspan='2'></td><td><input type='radio' name='grp3' value='TGT_PORT' $checked{'grp3'}{'TGT_PORT'}></td><td>$Lang::tr{'fwdfw man port'}</td><td><select name='TGT_PROT'>
1280END
d1f01304 1281 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
2a81ab0d
AM
1282 {
1283 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1284 {
1285 print"<option selected>$_</option>";
1286 }else{
1287 print"<option>$_</option>";
1288 }
1289 }
1290 print<<END;
1291 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='11' size='9' ></td></tr>
1292 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1293END
1294 &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
1295 print"<option>All ICMP-Types</option>";
1296 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1297 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1298 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1299 }else{
1300 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1301 }
1302 }
1303 print<<END;
1304 </select></td></tr>
1305 </table><hr><br><br>
62fc8511 1306
2a81ab0d
AM
1307END
1308 #---Activate/logging/remark-------------------------------------
1309 &Header::openbox('100%', 'left', $Lang::tr{'fwdfw additional'});
1310 print<<END;
1311 <table width='100%' border='0'>
2da264ec
AM
1312 <tr><td width='12%'>$Lang::tr{'remark'}:</td><td align='left'><input type='text' name='ruleremark' size='40' maxlength='255' value='$fwdfwsettings{'ruleremark'}'></td></tr>
1313END
1314 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1315 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1316 for (my $count =1; $count <= $sum; $count++){
1317 print"<option value='$count' ";
1318 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1319 print">$count</option>";
1320 }
1321 print"</select></td></tr>";
1322 }
1323
1324 print<<END;
1325 </table><table width='100%'>
2a81ab0d
AM
1326 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1327 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1328 </table><hr><br>
1329END
1330 &Header::closebox();
1331 #---ADD TIMEFRAME-----------------------------------------------
1332 &Header::openbox('100%', 'left', $Lang::tr{'fwdfw timeframe'});
1333 print<<END;
1334 <table width='70%' border='0'>
1335 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1336 <tr><td colspan='7'>&nbsp</td></tr>
1337 <tr>
1338 <td align='left'>$Lang::tr{'time'}:</td>
1339 <td width='30%' align='left'>$Lang::tr{'advproxy monday'} $Lang::tr{'advproxy tuesday'} $Lang::tr{'advproxy wednesday'} $Lang::tr{'advproxy thursday'} $Lang::tr{'advproxy friday'} $Lang::tr{'advproxy saturday'} $Lang::tr{'advproxy sunday'}</td>
2a81ab0d
AM
1340 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1341 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1342 </tr>
1343 <tr>
1344 <td align='right'></td>
1345 <td width='30%' align='left'>
1346 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1347 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1348 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1349 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1350 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1351 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1352 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{$Lang::tr{'fwdfw wd_sun'}} />
1353 </td>
2a81ab0d
AM
1354 <td><select name='TIME_FROM'>
1355END
1356 for (my $i=0;$i<=23;$i++) {
1357 $i = sprintf("%02s",$i);
1358 for (my $j=0;$j<=45;$j+=15) {
1359 $j = sprintf("%02s",$j);
1360 my $time = $i.":".$j;
1361 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1362 }
1363 }
1364 print<<END;
1365 </select></td>
1366 <td><select name='TIME_TO'>
1367END
1368 for (my $i=0;$i<=23;$i++) {
1369 $i = sprintf("%02s",$i);
1370 for (my $j=0;$j<=45;$j+=15) {
1371 $j = sprintf("%02s",$j);
1372 my $time = $i.":".$j;
1373 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1374 }
1375 }
62fc8511 1376 print<<END;
2a81ab0d
AM
1377 </select></td></tr>
1378 </table><hr>
1379END
1380 &Header::closebox();
1381 #---ACTION------------------------------------------------------
1382 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1383 print<<END;
1384 <table border='0' width='100%'>
1385 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1386 <input type='hidden' name='config' value='$config' >
1387 <input type='hidden' name='ACTION' value='saverule' ></form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value'reset'></td></td>
1388 </table></form>
1389END
1390 }else{
1391 print<<END;
1392 <table border='0' width='100%'>
1393 <tr><td align='right'><input type='submit' value='$Lang::tr{'fwdfw change'}' style='min-width:100px;' /><input type='hidden' name='updatefwrule' value='$fwdfwsettings{'updatefwrule'}'><input type='hidden' name='key' value='$fwdfwsettings{'key'}'>
1394 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1395 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1396 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1397 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1398 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1399 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1400 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
2da264ec
AM
1401 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1402 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
2a81ab0d 1403 <input type='hidden' name='ACTION' value='saverule' ></form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value'reset'></td></td>
2a81ab0d
AM
1404 </table></form>
1405END
1406 }
1407 &Header::closebox();
1408}
1409sub saverule
1410{
2a81ab0d
AM
1411 my $hash=shift;
1412 my $config=shift;
1413 &General::readhasharray("$config", $hash);
1414 if (!$errormessage){
2da264ec 1415 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2a81ab0d
AM
1416 my $key = &General::findhasharraykey ($hash);
1417 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1418 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1419 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1420 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1421 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1422 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1423 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1424 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1425 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1426 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1427 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1428 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1429 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1430 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1431 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1432 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1433 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1434 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1435 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1436 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1437 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1438 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1439 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1440 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1441 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1442 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1443 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1444 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1445 &General::writehasharray("$config", $hash);
1446 }else{
e44fa079
AM
1447 foreach my $key (sort {$a <=> $b} keys %$hash){
1448 if($key eq $fwdfwsettings{'key'}){
1449 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1450 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1451 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1452 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1453 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1454 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1455 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1456 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1457 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1458 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1459 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1460 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1461 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1462 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1463 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1464 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1465 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1466 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1467 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1468 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1469 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1470 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1471 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1472 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1473 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1474 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1475 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1476 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1477 last;
1478 }
1479 }
1480 }
1481 &General::writehasharray("$config", $hash);
1482 if($fwdfwsettings{'oldrulenumber'} gt $fwdfwsettings{'rulepos'}){
1483 my %tmp=();
1484 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1485 for (my $z=0;$z<$val;$z++){
1486 foreach my $key (sort {$a <=> $b} keys %$hash){
1487 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1488 my $last = $key -1;
1489 if (exists $$hash{$last}){
1490 #save rule last
1491 foreach my $y (0 .. $#{$$hash{$last}}) {
1492 $tmp{0}[$y] = $$hash{$last}[$y];
1493 }
1494 #copy active rule to last
1495 foreach my $i (0 .. $#{$$hash{$last}}) {
1496 $$hash{$last}[$i] = $$hash{$key}[$i];
1497 }
1498 #copy saved rule to actual position
1499 foreach my $x (0 .. $#{$tmp{0}}) {
1500 $$hash{$key}[$x] = $tmp{0}[$x];
2da264ec
AM
1501 }
1502 }
1503 }
1504 }
e44fa079
AM
1505 $fwdfwsettings{'oldrulenumber'}--;
1506 }
1507 &General::writehasharray("$config", $hash);
1508 &rules;
1509 }elsif($fwdfwsettings{'rulepos'} gt $fwdfwsettings{'oldrulenumber'}){
1510 my %tmp=();
1511 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1512 for (my $z=0;$z<$val;$z++){
1513 foreach my $key (sort {$a <=> $b} keys %$hash){
1514 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1515 my $next = $key + 1;
1516 if (exists $$hash{$next}){
1517 #save rule next
1518 foreach my $y (0 .. $#{$$hash{$next}}) {
1519 $tmp{0}[$y] = $$hash{$next}[$y];
1520 }
1521 #copy active rule to next
1522 foreach my $i (0 .. $#{$$hash{$next}}) {
1523 $$hash{$next}[$i] = $$hash{$key}[$i];
1524 }
1525 #copy saved rule to actual position
1526 foreach my $x (0 .. $#{$tmp{0}}) {
1527 $$hash{$key}[$x] = $tmp{0}[$x];
2da264ec
AM
1528 }
1529 }
1530 }
2a81ab0d 1531 }
e44fa079 1532 $fwdfwsettings{'oldrulenumber'}++;
2a81ab0d
AM
1533 }
1534 &General::writehasharray("$config", $hash);
e44fa079 1535 &rules;
2a81ab0d
AM
1536 }
1537 }
1538}
1539sub error
1540{
1541 if ($errormessage) {
1542 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
1543 print "<class name='base'>$errormessage\n";
1544 print "&nbsp;</class>\n";
1545 &Header::closebox();
1546 print"<hr>";
1547 }
1548}
1549sub hint
1550{
1551 if ($hint) {
1552 &Header::openbox('100%', 'left', $Lang::tr{'fwhost hint'});
1553 print "<class name='base'>$hint\n";
1554 print "&nbsp;</class>\n";
1555 &Header::closebox();
1556 print"<hr>";
1557 }
1558}
1559sub get_name
1560{
1561 my $val=shift;
1562 &General::setup_default_networks(\%defaultNetworks);
1563 foreach my $network (sort keys %defaultNetworks)
1564 {
1565 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
62fc8511 1566 }
2a81ab0d
AM
1567}
1568sub validremark
1569{
1570 # Checks a hostname against RFC1035
1571 my $remark = $_[0];
1572
1573 # Each part should be at least two characters in length
1574 # but no more than 63 characters
d24a34cb 1575 if (length ($remark) < 1 || length ($remark) > 255) {
2a81ab0d
AM
1576 return 0;}
1577 # Only valid characters are a-z, A-Z, 0-9 and -
2da264ec 1578 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:_\/\s]*$/) {
2a81ab0d
AM
1579 return 0;}
1580 # First character can only be a letter or a digit
1581 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1582 return 0;}
1583 # Last character can only be a letter or a digit
62fc8511 1584 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
2a81ab0d
AM
1585 return 0;}
1586 return 1;
1587}
1588sub getsrcport
1589{
1590 my %hash=%{(shift)};
1591 my $key=shift;
1592 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne 'ICMP'){
1593 print" : ($hash{$key}[8]) $hash{$key}[10]";
1594 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1595 print" : ($hash{$key}[8]) <br> $hash{$key}[9]";
1596 }
1597}
1598sub gettgtport
1599{
1600 my %hash=%{(shift)};
1601 my $key=shift;
1602 my $service;
1603 my $prot;
62fc8511 1604
2a81ab0d
AM
1605 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1606 if($hash{$key}[14] eq 'cust_srv'){
1607 &General::readhasharray("$configsrv", \%customservice);
1608 foreach my $i (sort keys %customservice){
1609 #print "HHUHU: $customservice{$i}[0] und $hash{$key}[15]<br>";
1610 if($customservice{$i}[0] eq $hash{$key}[15]){
1611 $prot = $hash{$key}[12];
1612 $service = $customservice{$i}[0];
1613 }
1614 }
1615 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
62fc8511 1616
2a81ab0d
AM
1617 $service=$hash{$key}[15];
1618 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1619 $service=$hash{$key}[15];
1620 $prot=$hash{$key}[12];
1621 }
1622 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1623 print" : ($hash{$key}[12]) <br>$hash{$key}[13]";
1624 }
62fc8511 1625
2a81ab0d
AM
1626 if ($prot ne '' || $service ne ''){
1627 print" :";
1628 if ($prot ne ''){
1629 print"($prot) ";
1630 }
1631 print" $service";
1632 }
1633}
1634sub viewtablerule
1635{
1636 &viewtablenew(\%configfwdfw,$configfwdfw,$Lang::tr{'fwdfw rules'},"Forward" );
1637 &viewtablenew(\%configinputfw,$configinput,"",$Lang::tr{'external access'} );
1638}
1639sub viewtablenew
1640{
1641 my $hash=shift;
1642 my $config=shift;
1643 my $title=shift;
1644 my $title1=shift;
62fc8511 1645
2a81ab0d
AM
1646 if ( ! -z "$config"){
1647 &Header::openbox('100%', 'left',$title);
1648 my $count=0;
1649 my ($gif,$log);
1650 my $ruletype;
1651 my $rulecolor;
1652 my $tooltip;
1653 my @tmpsrc=();
1654 my $coloryellow='';
1655 &General::readhasharray("$config", $hash);
1656 print"<b>$title1</b><br>";
1657 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
d24a34cb 1658 print"<tr><td align='center' width='1%'><b>#</td><td width='1%'></td><td align='center' width='20%'><b>$Lang::tr{'fwdfw source'}</td><td width='1%'><b>Log</td><td align='center' width='20%'><b>$Lang::tr{'fwdfw target'}</td><td align='center' width='70%'><b>$Lang::tr{'remark'}</td><td align='center' colspan='3' width='1%'><b>$Lang::tr{'fwdfw action'}</td></tr>";
62fc8511 1659 foreach my $key (sort {$a <=> $b} keys %$hash){
2a81ab0d
AM
1660 @tmpsrc=();
1661 #check if vpn hosts/nets have been deleted
1662 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1663 push (@tmpsrc,$$hash{$key}[4]);
1664 }
1665 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1666 push (@tmpsrc,$$hash{$key}[6]);
1667 }
2a81ab0d
AM
1668 foreach my $host (@tmpsrc){
1669 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
62fc8511 1670 if(&fwlib::get_ipsec_net_ip($host,11) eq ''){
2a81ab0d
AM
1671 $coloryellow='on';
1672 &disable_rule($key);
1673 $$hash{$key}[2]='';
2a81ab0d
AM
1674 }
1675 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1676 if(&fwlib::get_ovpn_net_ip($host,1) eq ''){
1677 $coloryellow='on';
1678 &disable_rule($key);
1679 $$hash{$key}[2]='';
1680 }
1681 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1682 if(&fwlib::get_ovpn_n2n_ip($host,27) eq ''){
1683 $coloryellow='on';
1684 &disable_rule($key);
1685 $$hash{$key}[2]='';
1686 }
1687 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1688 if(&fwlib::get_ovpn_host_ip($host,33) eq ''){
1689 $coloryellow='on';
1690 &disable_rule($key);
1691 $$hash{$key}[2]='';
1692 }
1693 }
1694 $$hash{$key}[3]='';
1695 $$hash{$key}[5]='';
1696 }
2a81ab0d
AM
1697 $$hash{'ACTIVE'}=$$hash{$key}[2];
1698 $count++;
2a81ab0d
AM
1699 if($coloryellow eq 'on'){
1700 print"<tr bgcolor='$color{'color14'}' >";
1701 $coloryellow='';
1702 }elsif($coloryellow eq ''){
1703 if ($count % 2){
1704 print"<tr bgcolor='$color{'color22'}' >";
1705 }
1706 else{
1707 print"<tr bgcolor='$color{'color20'}' >";
1708 }
1709 }
2a81ab0d
AM
1710 print<<END;
1711 <td align='right'>$key</td>
1712END
1713 if ($$hash{$key}[0] eq 'ACCEPT'){
1714 $ruletype='A';
1715 $tooltip='ACCEPT';
1716 $rulecolor=$color{'color17'};
1717 }elsif($$hash{$key}[0] eq 'DROP'){
1718 $ruletype='D';
1719 $tooltip='DROP';
1720 $rulecolor=$color{'color25'};
1721 }elsif($$hash{$key}[0] eq 'REJECT'){
1722 $ruletype='R';
1723 $tooltip='REJECT';
1724 $rulecolor=$color{'color16'};
1725 }
1726 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1727 print"<td align='center'>";
1728 if ($$hash{$key}[3] eq 'std_net_src'){
1729 print &get_name($$hash{$key}[4]);
1730 }else{
1731 print $$hash{$key}[4];
1732 }
1733 &getsrcport(\%$hash,$key);
1734 if ($$hash{$key}[17] eq 'ON'){
1735 $log="/images/on.gif";
1736 }else{
1737 $log="/images/off.gif";
1738 }
1739 print<<END;
1740 </td>
2a81ab0d 1741 <form method='post'>
d24a34cb 1742 <td width='1%' align='left'><input type='image' img src='$log' alt='$Lang::tr{'click to disable'}' title='$Lang::tr{'fwdfw togglelog'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'/>
2a81ab0d
AM
1743 <input type='hidden' name='key' value='$key' />
1744 <input type='hidden' name='config' value='$config' />
1745 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1746 </td></form>
1747END
1748
1749 print<<END;
d24a34cb 1750 <td align='center' nowrap='nowrap'>
2a81ab0d
AM
1751END
1752 if ($$hash{$key}[5] eq 'std_net_tgt'){
1753 print &get_name($$hash{$key}[6]);
1754 }else{
1755 print $$hash{$key}[6];
1756 }
1757 &gettgtport(\%$hash,$key);
1758 ################################################################################
1759 print"</td><td width='20%'>$$hash{$key}[16]</td>";
1760
1761 if($$hash{$key}[2] eq 'ON'){
1762 $gif="/images/on.gif"
1763
1764 }else{
1765 $gif="/images/off.gif"
2a81ab0d
AM
1766 }
1767 print<<END;
1768 <form method='post'>
1769 <td width='1%'><input type='image' img src='$gif' alt='$Lang::tr{'click to disable'}' title='$Lang::tr{'fwdfw toggle'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
1770 <input type='hidden' name='key' value='$key' />
1771 <input type='hidden' name='config' value='$config' />
1772 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1773 </td></form>
2a81ab0d
AM
1774 <form method='post'>
1775 <td width='1%' ><input type='image' img src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'fwdfw edit'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
1776 <input type='hidden' name='key' value='$key' />
1777 <input type='hidden' name='config' value='$config' />
1778 <input type='hidden' name='ACTION' value='editrule' />
1779 </td></form></td>
2a81ab0d
AM
1780 <form method='post'>
1781 <td width='1%'><input type='image' img src='/images/addblue.gif' alt='$Lang::tr{'fwdfw copy'}' title='$Lang::tr{'fwdfw copy'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
1782 <input type='hidden' name='key' value='$key' />
1783 <input type='hidden' name='config' value='$config' />
1784 <input type='hidden' name='ACTION' value='copyrule' />
1785 </td></form></td>
2a81ab0d
AM
1786 <form method='post'>
1787 <td width='1%' ><input type='image' img src='/images/delete.gif' alt='$Lang::tr{'delete'}' title='$Lang::tr{'fwdfw delete'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
1788 <input type='hidden' name='key' value='$key' />
1789 <input type='hidden' name='config' value='$config' />
1790 <input type='hidden' name='ACTION' value='deleterule' />
1791 </td></form></td>
1792END
1793 if (exists $$hash{$key-1}){
1794 print<<END;
1795 <form method='post'>
1796 <td width='1%'><input type='image' img src='/images/up.gif' alt='$Lang::tr{'fwdfw moveup'}' title='$Lang::tr{'fwdfw moveup'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
1797 <input type='hidden' name='key' value='$key' />
1798 <input type='hidden' name='config' value='$config' />
1799 <input type='hidden' name='ACTION' value='moveup' />
1800 </td></form></td>
1801END
1802 }else{
1803 print"<td></td>";
1804 }
2a81ab0d
AM
1805 if (exists $$hash{$key+1}){
1806 print<<END;
1807 <form method='post'>
1808 <td width='1%' ><input type='image' img src='/images/down.gif' alt='$Lang::tr{'fwdfw movedown'}' title='$Lang::tr{'fwdfw movedown'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
1809 <input type='hidden' name='key' value='$key' />
1810 <input type='hidden' name='config' value='$config' />
1811 <input type='hidden' name='ACTION' value='movedown' />
1812 </td></form></td></tr>
1813END
1814 }else{
1815 print"<td></td></tr>";
1816 }
1817 #if timeframe set, print new line in table
1818 if ($$hash{$key}[18] eq 'ON'){
1819 my @days=();
1820 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr{'fwdfw wd_mon'});}
1821 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr{'fwdfw wd_tue'});}
1822 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr{'fwdfw wd_wed'});}
1823 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr{'fwdfw wd_thu'});}
1824 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr{'fwdfw wd_fri'});}
1825 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr{'fwdfw wd_sat'});}
1826 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr{'fwdfw wd_sun'});}
2a81ab0d 1827 my $weekdays=join(",",@days);
2a81ab0d
AM
1828 if (@days){
1829 print"<tr bgcolor='#FFE4B5'><td colspan='4'>$Lang::tr{'fwdfw time'} ";
1830 print"$weekdays";
1831 print "&nbsp $Lang::tr{'fwdfw from'} $$hash{$key}[26] &nbsp $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
1832 }
1833 }
1834 }
1835 print"</table>";
1836 &Header::closebox();
1837 }
2a81ab0d 1838}
36196d0d
AM
1839sub p2pblock
1840{
1841 my $gif;
1842 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
1843 @p2ps = <FILE>;
1844 close FILE;
1845 &Header::openbox('100%', 'center', 'P2P-Block');
1846 print <<END;
1847 <table width='40%' border='0'>
1848 <tr bgcolor='$color{'color22'}'><td align=center colspan='2' width='30%'><b>$Lang::tr{'protocol'}</b><td width='10%' align=center><b>$Lang::tr{'status'}</b>
1849END
1850 foreach my $p2pentry (sort @p2ps)
1851 {
1852 my @p2pline = split( /\;/, $p2pentry );
1853 if($p2pline[2] eq 'on'){
1854 $gif="/images/on.gif"
1855 }else{
1856 $gif="/images/off.gif"
1857 }
1858 print <<END;
1859 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1860 <tr bgcolor='$color{'color20'}'>
1861 <td width='66%' align='center' colspan='2'>$p2pline[0]:</td><td width='33%' align='center'><input type='hidden' name='P2PROT' value='$p2pline[1]' /><input type='image' img src='$gif' alt='$Lang::tr{'click to disable'}' title='$Lang::tr{'fwdfw toggle'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' ><input type='hidden' name='ACTION' value='togglep2p'></td></tr></form>
1862END
1863 }
1864 print"<tr><td width='10%'><input type='image' img src='/images/on.gif'></td><td>$Lang::tr{'outgoing firewall p2p deny'}</td><td></td></tr>";
1865 print"<tr><td width='10%'><input type='image' img src='/images/off.gif'></td><td>$Lang::tr{'outgoing firewall p2p allow'}</td><td></td></tr></table>";
1866 &Header::closebox();
1867}
2a81ab0d
AM
1868sub fillselect
1869{
1870 my %hash=%{(shift)};
1871 my $val=shift;
1872 my $key;
62fc8511
AM
1873 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1874 if($hash{$key}[0] eq $val){
1875 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1876 }else{
1877 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
2a81ab0d 1878 }
62fc8511 1879 }
2a81ab0d
AM
1880}
1881sub rules
1882{
1883 if (!-f "${General::swroot}/forward/reread"){
1884 system("touch ${General::swroot}/forward/reread");
1885 }
1886}
1887sub reread_rules
1888{
1889 system("/usr/local/bin/forwardfwctrl");
1890 system("rm ${General::swroot}/forward/reread");
1891}
1892&Header::closebigbox();
1893&Header::closepage();