]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/forwardfw.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
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. #
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. #
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/>. #
20 ###############################################################################
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. #
27 # Now that the ccd extension is ready i am able to develop the main request. #
28 # Any feedback is appreciated. #
31 ###############################################################################
34 no warnings
'uninitialized';
35 # enable only the following on debugging purpose
37 #use CGI::Carp 'fatalsToBrowser';
39 require '/var/ipfire/general-functions.pl';
40 require "${General::swroot}/lang.pl";
41 require "${General::swroot}/header.pl";
42 require "${General::swroot}/forward/bin/firewall-lib.pl";
44 unless (-d
"${General::swroot}/forward") { system("mkdir ${General::swroot}/forward"); }
45 unless (-e
"${General::swroot}/forward/settings") { system("touch ${General::swroot}/forward/settings"); }
46 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
47 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
51 my %defaultNetworks=();
55 my %customnetworks=();
57 my %customservicegrp=();
73 my $confignet = "${General::swroot}/fwhosts/customnetworks";
74 my $confighost = "${General::swroot}/fwhosts/customhosts";
75 my $configgrp = "${General::swroot}/fwhosts/customgroups";
76 my $configsrv = "${General::swroot}/fwhosts/customservices";
77 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
78 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
79 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
80 my $configipsec = "${General::swroot}/vpn/config";
81 my $configipsecrw = "${General::swroot}/vpn/settings";
82 my $configfwdfw = "${General::swroot}/forward/config";
83 my $configinput = "${General::swroot}/forward/input";
84 my $configovpn = "${General::swroot}/ovpn/settings";
85 my $p2pfile = "${General::swroot}/forward/p2protocols";
88 my $ipgrp="${General::swroot}/outgoing/groups";
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);
95 &Header
::showhttpheaders
();
96 &Header
::getcgihash
(\
%fwdfwsettings);
97 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
98 &Header
::openbigbox
('100%', 'center',$errormessage);
101 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'save'})
103 my $MODE = $fwdfwsettings{'POLICY'};
105 $fwdfwsettings{'POLICY'} = "$MODE";
106 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
109 if ($fwdfwsettings{'ACTION'} eq 'saverule')
111 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
112 &General
::readhasharray
("$configinput", \
%configinputfw);
113 $errormessage=&checksource
;
114 if(!$errormessage){&checktarget
;}
115 if(!$errormessage){&checkrule
;}
116 #check if we change an forward rule to an external access
117 if( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
118 $fwdfwsettings{'updatefwrule'}='';
119 $fwdfwsettings{'config'}=$configfwdfw;
120 $fwdfwsettings{'nobase'}='on';
122 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
123 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
125 #check if we change an external access rule to an forward
126 if( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
127 $fwdfwsettings{'updatefwrule'}='';
128 $fwdfwsettings{'config'}=$configinput;
129 $fwdfwsettings{'nobase'}='on';
131 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
132 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
135 if($fwdfwsettings{'grp2'} eq 'ipfire'){
136 $fwdfwsettings{'config'}=$configinput;
137 $fwdfwsettings{'chain'} = 'INPUTFW';
138 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
139 #check if we have an identical rule already
140 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
141 foreach my $key (sort keys %configinputfw){
142 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'}"
143 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]"){
144 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
145 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && &validremark
($fwdfwsettings{'ruleremark'})){
147 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && !&validremark
($fwdfwsettings{'ruleremark'})){
148 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
150 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
151 $fwdfwsettings{'nosave'} = 'on';
156 #check Rulepos on new Rule
157 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
158 $fwdfwsettings{'oldrulenumber'}=$maxkey;
159 foreach my $key (sort keys %configinputfw){
160 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'}"
161 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]"){
162 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
166 #check if we just close a rule
167 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'} ) {
168 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
170 $fwdfwsettings{'nosave2'} = 'on';
173 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
174 if ($fwdfwsettings{'nobase'} ne 'on'){
175 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
177 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
178 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
179 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
180 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
181 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
182 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
184 if($fwdfwsettings{'nosave2'} ne 'on'){
185 &saverule
(\
%configinputfw,$configinput);
187 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
188 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
189 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
190 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
191 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
192 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
193 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
194 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
195 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
196 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
197 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
198 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
199 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
200 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
201 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
202 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
204 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
205 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
206 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
207 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
210 $fwdfwsettings{'config'}=$configfwdfw;
211 $fwdfwsettings{'chain'} = 'FORWARDFW';
212 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
213 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
214 #check if we have an identical rule already
215 foreach my $key (sort keys %configfwdfw){
216 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'}"
217 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]"){
218 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
219 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && &validremark
($fwdfwsettings{'ruleremark'})){
221 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && !&validremark
($fwdfwsettings{'ruleremark'})){
222 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
224 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
225 $fwdfwsettings{'nosave'} = 'on';
230 #check Rulepos on new Rule
231 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
232 $fwdfwsettings{'oldrulenumber'}=$maxkey;
233 foreach my $key (sort keys %configfwdfw){
234 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'}"
235 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]"){
236 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
240 #check if we just close a rule
241 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'} && $fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'} ) {
242 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
243 $fwdfwsettings{'nosave2'} = 'on';
248 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
249 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
250 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
251 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
252 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
253 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
254 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
255 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
257 if ($fwdfwsettings{'nobase'} eq 'on'){
258 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
260 if ($fwdfwsettings{'nosave2'} ne 'on'){
261 &saverule
(\
%configfwdfw,$configfwdfw);
263 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
264 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
265 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
266 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
267 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
268 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
269 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
270 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
271 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
272 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
273 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
274 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
275 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
276 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
277 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
278 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
280 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
281 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
282 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
283 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
288 if($fwdfwsettings{'nosave2'} ne 'on'){
294 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
296 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
297 foreach my $key (sort keys %configfwdfw){
298 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
299 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
300 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
302 &General
::readhasharray
("$configinput", \
%configinputfw);
303 foreach my $key (sort keys %configinputfw){
304 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
305 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
306 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
309 system("rm ${General::swroot}/forward/config");
310 system("rm ${General::swroot}/forward/input");
311 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
312 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
313 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
315 $fwdfwsettings{'POLICY'}='MODE2';
316 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
320 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
324 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
327 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
328 foreach my $key (sort keys %togglehash){
329 if ($key eq $fwdfwsettings{'key'}){
330 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
333 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
337 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
340 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
341 foreach my $key (sort keys %togglehash){
342 if ($key eq $fwdfwsettings{'key'}){
343 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
346 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
350 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
355 if ($fwdfwsettings{'ACTION'} eq 'editrule')
357 $fwdfwsettings{'updatefwrule'}='on';
360 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
364 if ($fwdfwsettings{'ACTION'} eq 'moveup')
369 if ($fwdfwsettings{'ACTION'} eq 'movedown')
374 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
376 $fwdfwsettings{'copyfwrule'}='on';
377 #$fwdfwsettings{'updatefwrule'}='on';
380 if ($fwdfwsettings{'ACTION'} eq 'togglep2p')
382 #$errormessage="Toggle $fwdfwsettings{'P2PROT'}<br>";
383 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
386 open( FILE
, "> $p2pfile" ) or die "Unable to write $p2pfile";
387 foreach my $p2pentry (sort @p2ps)
389 my @p2pline = split( /\;/, $p2pentry );
390 if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) {
391 if($p2pline[2] eq 'on'){
397 print FILE
"$p2pline[0];$p2pline[1];$p2pline[2];\n";
403 if ($fwdfwsettings{'ACTION'} eq '')
412 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
413 foreach my $key (sort keys %uphash){
414 if ($key eq $fwdfwsettings{'key'}) {
416 if (exists $uphash{$last}){
418 foreach my $y (0 .. $#{$uphash{$last}}) {
419 $tmp{0}[$y] = $uphash{$last}[$y];
421 #copy active rule to last
422 foreach my $i (0 .. $#{$uphash{$last}}) {
423 $uphash{$last}[$i] = $uphash{$key}[$i];
425 #copy saved rule to actual position
426 foreach my $x (0 .. $#{$tmp{0}}) {
427 $uphash{$key}[$x] = $tmp{0}[$x];
432 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
439 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
440 foreach my $key (sort keys %downhash){
441 if ($key eq $fwdfwsettings{'key'}) {
443 if (exists $downhash{$next}){
445 foreach my $y (0 .. $#{$downhash{$next}}) {
446 $tmp{0}[$y] = $downhash{$next}[$y];
448 #copy active rule to next
449 foreach my $i (0 .. $#{$downhash{$next}}) {
450 $downhash{$next}[$i] = $downhash{$key}[$i];
452 #copy saved rule to actual position
453 foreach my $x (0 .. $#{$tmp{0}}) {
454 $downhash{$key}[$x] = $tmp{0}[$x];
459 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
464 my ($base1,$val1,$base2,$val2) = @_;
466 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
467 &dec_counter
($confignet,\
%customnetwork,$val1);
468 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
469 &dec_counter
($confighost,\
%customhost,$val1);
470 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
471 &dec_counter
($configgrp,\
%customgrp,$val1);
472 }elsif($base1 eq 'cust_srv'){
473 &dec_counter
($configsrv,\
%customservice,$val1);
474 }elsif($base1 eq 'cust_srvgrp'){
475 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
478 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
479 &inc_counter
($confignet,\
%customnetwork,$val2);
480 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
481 &inc_counter
($confighost,\
%customhost,$val2);
482 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
483 &inc_counter
($configgrp,\
%customgrp,$val2);
484 }elsif($base2 eq 'cust_srv'){
485 &inc_counter
($configsrv,\
%customservice,$val2);
486 }elsif($base2 eq 'cust_srvgrp'){
487 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
497 &General
::readhasharray
($config, \
%hash);
498 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
499 if($hash{$key}[0] eq $val){
500 $pos=$#{$hash{$key}};
501 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
504 &General
::writehasharray
($config, \
%hash);
512 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
513 &General
::readhasharray
($config, \
%hash);
514 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
515 if($hash{$key}[0] eq $val){
516 $pos=$#{$hash{$key}};
517 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
520 &General
::writehasharray
($config, \
%hash);
524 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
525 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
529 &Header
::openbox
('100%', 'center', $Lang::tr
{'fwdfw pol title'});
531 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
532 <table width='100%' border='0'>
533 <tr><td colspan='3'>$Lang::tr{'fwdfw pol text'}</td></tr>
535 <tr><td colspan='3'><hr /></td></tr>
536 <tr><td width='15%' align='left'> <select name='POLICY' style="width: 100px">
537 <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
538 <option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
539 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
540 <td width='45%' align='left'>
542 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />";
543 print "</table></form>";
549 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
551 print "<form method='post'>";
552 print "<table border='0'>";
553 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
554 if (-f
"${General::swroot}/forward/reread"){
555 print "<td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: red; font-weight: bold;'>$Lang::tr{'fwhost reread'}</td>";
557 print"</tr></table></form><hr>";
565 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
566 foreach my $key (sort {$a <=> $b} keys %delhash){
567 if ($key == $fwdfwsettings{'key'}){
568 #check hosts/net and groups
569 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
570 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
571 #check services and groups
572 if ($delhash{$key}[11] eq 'ON'){
573 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
576 if ($key >= $fwdfwsettings{'key'}) {
578 if (exists $delhash{$next}) {
579 foreach my $i (0 .. $#{$delhash{$next}}) {
580 $delhash{$key}[$i] = $delhash{$next}[$i];
585 # Remove the very last entry.
586 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
587 delete $delhash{$last_key};
589 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
592 if($fwdfwsettings{'nobase'} ne 'on'){
599 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
600 foreach my $key (sort keys %configfwdfw){
602 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
605 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
612 #check ip-address if manual
613 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
614 #check if ip with subnet
615 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
616 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
617 $subnet = &General
::iporsubtocidr
($subnet);
618 $fwdfwsettings{'isip'}='on';
621 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
622 $ip=$fwdfwsettings{'src_addr'};
624 $fwdfwsettings{'isip'}='on';
627 if ($fwdfwsettings{'isip'} ne 'on'){
628 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
630 if ($fwdfwsettings{'isip'} eq 'on'){
631 #check and form valid IP
632 $ip=&General
::ip2dec
($ip);
633 $ip=&General
::dec2ip
($ip);
634 #check if net or broadcast
635 my @tmp= split (/\./,$ip);
636 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
638 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
640 $fwdfwsettings{'src_addr'}="$ip/$subnet";
642 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
643 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
646 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
647 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
649 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
650 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
651 return $errormessage;
655 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
657 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
658 $fwdfwsettings{'SRC_PORT'}='';
659 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
660 foreach my $key (keys %icmptypes){
661 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
662 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
665 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
666 $fwdfwsettings{'SRC_PORT'}='';
667 $fwdfwsettings{'ICMP_TYPES'}='';
668 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
669 $fwdfwsettings{'SRC_PORT'}='';
670 $fwdfwsettings{'ICMP_TYPES'}='';
671 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
672 $fwdfwsettings{'SRC_PORT'}='';
673 $fwdfwsettings{'ICMP_TYPES'}='';
674 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
675 $fwdfwsettings{'ICMP_TYPES'}='';
677 $fwdfwsettings{'ICMP_TYPES'}='';
678 $fwdfwsettings{'SRC_PORT'}='';
679 $fwdfwsettings{'PROT'}='';
682 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
683 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
687 if ($_ =~ /^(\d+)\:(\d+)$/) {
689 #change dashes with :
692 push(@values,"1:65535");
695 if ($_ =~ /^(\D)\:(\d+)$/) {
696 push(@values,"1:$2");
699 if ($_ =~ /^(\d+)\:(\D)$/) {
700 push(@values,"$1:65535");
703 $errormessage .= &General
::validportrange
($_, 'destination');
708 if (&General
::validport
($_)){
715 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
716 return $errormessage;
723 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
724 #check if ip with subnet
725 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
726 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
727 $subnet = &General
::iporsubtocidr
($subnet);
730 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
731 $ip=$fwdfwsettings{'tgt_addr'};
734 #check and form valid IP
735 $ip=&General
::ip2dec
($ip);
736 $ip=&General
::dec2ip
($ip);
738 ##check if net or broadcast
739 #my @tmp= split (/\./,$ip);
740 #if ($tmp[3] eq "0" || ($tmp[3] eq "255"))
742 #$errormessage=$Lang::tr{'fwhost err hostip'}."<br>";
744 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
746 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
747 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
750 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
751 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
752 return $errormessage;
756 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
759 if ($fwdfwsettings{'USESRV'} eq 'ON'){
760 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
761 $fwdfwsettings{'TGT_PROT'}='';
762 $fwdfwsettings{'ICMP_TGT'}='';
764 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
765 $fwdfwsettings{'TGT_PROT'}='';
766 $fwdfwsettings{'ICMP_TGT'}='';
767 #check target service
768 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
769 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
772 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
773 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
774 if ($fwdfwsettings{'TGT_PORT'} ne ''){
775 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
779 if ($_ =~ /^(\d+)\:(\d+)$/) {
781 #change dashes with :
784 push(@values,"1:65535");
787 if ($_ =~ /^(\D)\:(\d+)$/) {
788 push(@values,"1:$2");
791 if ($_ =~ /^(\d+)\:(\D)$/) {
792 push(@values,"$1:65535");
795 $errormessage .= &General
::validportrange
($_, 'destination');
800 if (&General
::validport
($_)){
807 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
809 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
810 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
811 $fwdfwsettings{'TGT_PORT'} = '';
812 $fwdfwsettings{'ICMP_TGT'} = '';
813 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
814 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
815 $fwdfwsettings{'TGT_PORT'} = '';
816 $fwdfwsettings{'ICMP_TGT'}='';
817 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
818 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
819 $fwdfwsettings{'TGT_PORT'} = '';
820 $fwdfwsettings{'ICMP_TGT'}='';
821 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
822 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
823 $fwdfwsettings{'TGT_PORT'} = '';
824 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
825 foreach my $key (keys %icmptypes){
827 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
828 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
836 if ($fwdfwsettings{'USESRV'} ne 'ON'){
837 $fwdfwsettings{'grp3'}='';
838 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
839 $fwdfwsettings{'TGT_PROT'}='';
840 $fwdfwsettings{'ICMP_TGT'}='';
843 if($fwdfwsettings{'TIME'} eq 'ON'){
844 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 ''){
845 $errormessage=$Lang::tr
{'fwdfw err time'};
848 return $errormessage;
853 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
854 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
856 #check if source and target identical
857 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
858 $errormessage.=$Lang::tr
{'fwdfw err same'};
859 return $errormessage;
862 #get source and targetip address if possible
863 my ($sip,$scidr,$tip,$tcidr);
864 ($sip,$scidr)=&get_ip
("src","grp1");
865 ($tip,$tcidr)=&get_ip
("tgt","grp2");
867 #check same iprange in source and target
868 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
869 my $networkip1=&General
::getnetworkip
($sip,$scidr);
870 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
871 if ($scidr gt $tcidr){
872 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
873 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
875 }elsif($scidr eq $tcidr && $scidr eq '32'){
876 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
877 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
878 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
879 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
880 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
883 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
884 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
889 #check source and destination protocol if manual
890 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
891 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
892 $errormessage.=$Lang::tr
{'fwdfw err prot'};
894 #check source and destination protocol if source manual and dest servicegrp
895 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
896 &General
::readhasharray
("$configsrv", \
%customservice);
897 foreach my $key (sort keys %customservice){
898 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
899 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
900 $errormessage.=$Lang::tr
{'fwdfw err prot'};
914 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
915 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
916 if ($fwdfwsettings{$grp} eq $val.'_addr'){
917 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
918 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
919 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
920 $a=$netsettings{'GREEN_NETADDRESS'};
921 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
922 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
923 $a=$netsettings{'ORANGE_NETADDRESS'};
924 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
925 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
926 $a=$netsettings{'BLUE_NETADDRESS'};
927 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
928 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
929 &General
::readhash
("$configovpn",\
%ovpnsettings);
930 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
931 $b=&General
::iporsubtocidr
($b);
933 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
934 &General
::readhasharray
("$confignet", \
%customnetwork);
935 foreach my $key (keys %customnetwork){
936 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
937 $a=$customnetwork{$key}[1];
938 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
941 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
942 &General
::readhasharray
("$confighost", \
%customhost);
943 foreach my $key (keys %customhost){
944 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
945 if ($customhost{$key}[1] eq 'ip'){
946 ($a,$b)=split (/\//,$customhost{$key}[2]);
947 $b=&General
::iporsubtocidr
($b);
950 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
962 &General
::setup_default_networks
(\
%defaultNetworks);
963 #read all configfiles
964 &General
::readhasharray
("$configccdnet", \
%ccdnet);
965 &General
::readhasharray
("$confignet", \
%customnetwork);
966 &General
::readhasharray
("$configccdhost", \
%ccdhost);
967 &General
::readhasharray
("$confighost", \
%customhost);
968 &General
::readhasharray
("$configccdhost", \
%ccdhost);
969 &General
::readhasharray
("$configgrp", \
%customgrp);
970 &General
::readhasharray
("$configipsec", \
%ipsecconf);
971 &General
::get_aliases
(\
%aliases);
975 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
976 my $config=$fwdfwsettings{'config'};
978 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
979 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
980 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
981 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
982 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
983 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
984 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
985 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
986 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
987 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
988 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
989 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
990 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
991 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
992 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
993 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
994 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
995 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
996 #check if update and get values
997 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
998 &General
::readhasharray
("$config", \
%hash);
999 foreach my $key (sort keys %hash){
1001 if ($key eq $fwdfwsettings{'key'}){
1002 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1003 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1004 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1005 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1006 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1007 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1008 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1009 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1010 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1011 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1012 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1013 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1014 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1015 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1016 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1017 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1018 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1019 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1020 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1021 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1022 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1023 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1024 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1025 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1026 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1027 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1028 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1029 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1030 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1031 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1032 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1033 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1034 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1035 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1036 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1037 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1038 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1039 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1040 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1041 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1042 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1043 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1044 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1045 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1046 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1047 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1050 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1051 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1052 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1053 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1054 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1055 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1056 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1057 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1059 $fwdfwsettings{'ACTIVE'}='ON';
1060 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1063 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1066 <form method="post">
1068 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1070 foreach ("ACCEPT","DROP","REJECT")
1072 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1074 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1075 print">$_</option>";
1077 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1078 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1081 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1083 print"<option selected>$_</option>";
1085 print"<option>$_</option>";
1089 print"</select></td></tr></table><hr>";
1091 &Header
::closebox
();
1092 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1093 #------SOURCE-------------------------------------------------------
1095 <table width='100%' border='0'>
1096 <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>
1097 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1098 <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;'>
1100 foreach my $network (sort keys %defaultNetworks)
1102 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1103 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1104 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1105 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
1106 print ">$network</option>";
1109 </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;'>
1111 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1114 <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;'>
1116 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1118 </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;'>
1120 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1122 if ($ccdhost{$key}[33] ne ''){
1124 print "<option value='$ccdhost{$key}[1]'";
1125 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1126 print ">$ccdhost{$key}[1]</option>";
1131 <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;'>
1133 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1135 </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;'>
1137 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1138 if($ccdhost{$key}[3] eq 'net'){
1140 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1141 print ">$ccdhost{$key}[1]</option>";
1147 <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;'>
1149 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1150 if($helper ne $customgrp{$key}[0]){
1152 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1153 print ">$customgrp{$key}[0]</option>";
1155 $helper=$customgrp{$key}[0];
1159 <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;'>
1161 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1162 if ($ipsecconf{$key}[3] eq 'net'){
1164 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1165 print ">$ipsecconf{$key}[1]</option>";
1173 # <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;'>
1175 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1176 # if ($ipsecconf{$key}[3] eq 'host'){
1178 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1179 # print ">$ipsecconf{$key}[1]</option>";
1183 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1184 <table width='100%' border='0'>
1185 <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>
1186 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1188 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1190 if ($_ eq $fwdfwsettings{'PROT'})
1192 print"<option selected>$_</option>";
1194 print"<option>$_</option>";
1197 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1199 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1200 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1202 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1203 print"<option>All ICMP-Types</option>";
1204 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1205 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1206 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1208 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1212 </select></td></tr></table><hr>
1214 &Header
::closebox
();
1216 #---TARGET------------------------------------------------------
1217 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1219 <table width='100%' border='0'>
1220 <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;'>
1222 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1224 foreach my $alias (sort keys %aliases)
1226 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1231 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1232 <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;'>
1234 foreach my $network (sort keys %defaultNetworks)
1236 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1237 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1238 print ">$network</option>";
1241 </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;'>
1243 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1246 <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;'>
1248 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1250 </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;'>
1252 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1254 if ($ccdhost{$key}[33] ne ''){
1255 print "<option value='$ccdhost{$key}[1]' ";
1256 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1257 print ">$ccdhost{$key}[1]</option>";
1262 <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;'>
1264 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1266 </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;'>
1268 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1269 if($ccdhost{$key}[3] eq 'net'){
1271 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1272 print ">$ccdhost{$key}[1]</option>";
1277 <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;'>
1280 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1281 if($helper ne $customgrp{$key}[0]){
1283 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1284 print">$customgrp{$key}[0]</option>";
1286 $helper=$customgrp{$key}[0];
1290 <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;'>
1292 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1293 if ($ipsecconf{$key}[3] eq 'net'){
1295 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1296 print">$ipsecconf{$key}[1]</option>";
1302 # <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;'>
1304 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1305 # if ($ipsecconf{$key}[3] eq 'host'){
1307 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1308 # print">$ipsecconf{$key}[1]</option>";
1313 <b>$Lang::tr{'fwhost attention'}:</b><br>
1314 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1316 <table width='100%' border='0'>
1317 <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;' >
1319 &General
::readhasharray
("$configsrv", \
%customservice);
1320 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1322 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1323 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1327 <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;' >
1329 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1331 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1332 if ($helper ne $customservicegrp{$key}[0]){
1334 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1335 print">$customservicegrp{$key}[0]</option>";
1337 $helper=$customservicegrp{$key}[0];
1341 <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'>
1343 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1345 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1347 print"<option selected>$_</option>";
1349 print"<option>$_</option>";
1352 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1354 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1355 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1357 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1358 print"<option>All ICMP-Types</option>";
1359 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1360 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1361 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1363 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1368 </table><hr><br><br>
1371 #---Activate/logging/remark-------------------------------------
1372 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1374 <table width='100%' border='0'>
1375 <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>
1377 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1378 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1379 for (my $count =1; $count <= $sum; $count++){
1380 print"<option value='$count' ";
1381 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1382 print">$count</option>";
1384 print"</select></td></tr>";
1386 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1390 </table><table width='100%'>
1391 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1392 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1395 &Header
::closebox
();
1396 #---ADD TIMEFRAME-----------------------------------------------
1397 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1399 <table width='70%' border='0'>
1400 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1401 <tr><td colspan='7'> </td></tr>
1403 <td align='left'>$Lang::tr{'time'}:</td>
1404 <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>
1405 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1406 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1409 <td align='right'></td>
1410 <td width='30%' align='left'>
1411 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1412 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1413 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1414 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1415 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1416 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1417 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1419 <td><select name='TIME_FROM'>
1421 for (my $i=0;$i<=23;$i++) {
1422 $i = sprintf("%02s",$i);
1423 for (my $j=0;$j<=45;$j+=15) {
1424 $j = sprintf("%02s",$j);
1425 my $time = $i.":".$j;
1426 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1431 <td><select name='TIME_TO'>
1433 for (my $i=0;$i<=23;$i++) {
1434 $i = sprintf("%02s",$i);
1435 for (my $j=0;$j<=45;$j+=15) {
1436 $j = sprintf("%02s",$j);
1437 my $time = $i.":".$j;
1438 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1445 &Header
::closebox
();
1446 #---ACTION------------------------------------------------------
1447 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1449 <table border='0' width='100%'>
1450 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1451 <input type='hidden' name='config' value='$config' >
1452 <input type='hidden' name='ACTION' value='saverule' >
1453 </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>
1458 <table border='0' width='100%'>
1459 <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'}'>
1460 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1461 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1462 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1463 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1464 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1465 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1466 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1467 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1468 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1469 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1470 <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>
1474 &Header
::closebox
();
1480 &General
::readhasharray
("$config", $hash);
1481 if (!$errormessage){
1482 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1483 my $key = &General
::findhasharraykey
($hash);
1484 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1485 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1486 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1487 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1488 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1489 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1490 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1491 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1492 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1493 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1494 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1495 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1496 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1497 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1498 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1499 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1500 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1501 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1502 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1503 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1504 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1505 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1506 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1507 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1508 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1509 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1510 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1511 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1512 &General
::writehasharray
("$config", $hash);
1514 foreach my $key (sort {$a <=> $b} keys %$hash){
1515 if($key eq $fwdfwsettings{'key'}){
1516 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1517 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1518 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1519 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1520 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1521 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1522 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1523 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1524 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1525 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1526 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1527 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1528 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1529 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1530 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1531 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1532 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1533 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1534 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1535 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1536 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1537 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1538 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1539 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1540 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1541 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1542 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1543 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1548 &General
::writehasharray
("$config", $hash);
1549 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
1551 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1552 for (my $z=0;$z<$val;$z++){
1553 foreach my $key (sort {$a <=> $b} keys %$hash){
1554 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1556 if (exists $$hash{$last}){
1558 foreach my $y (0 .. $#{$$hash{$last}}) {
1559 $tmp{0}[$y] = $$hash{$last}[$y];
1561 #copy active rule to last
1562 foreach my $i (0 .. $#{$$hash{$last}}) {
1563 $$hash{$last}[$i] = $$hash{$key}[$i];
1565 #copy saved rule to actual position
1566 foreach my $x (0 .. $#{$tmp{0}}) {
1567 $$hash{$key}[$x] = $tmp{0}[$x];
1572 $fwdfwsettings{'oldrulenumber'}--;
1574 &General
::writehasharray
("$config", $hash);
1576 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
1578 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1579 for (my $z=0;$z<$val;$z++){
1580 foreach my $key (sort {$a <=> $b} keys %$hash){
1581 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1582 my $next = $key + 1;
1583 if (exists $$hash{$next}){
1585 foreach my $y (0 .. $#{$$hash{$next}}) {
1586 $tmp{0}[$y] = $$hash{$next}[$y];
1588 #copy active rule to next
1589 foreach my $i (0 .. $#{$$hash{$next}}) {
1590 $$hash{$next}[$i] = $$hash{$key}[$i];
1592 #copy saved rule to actual position
1593 foreach my $x (0 .. $#{$tmp{0}}) {
1594 $$hash{$key}[$x] = $tmp{0}[$x];
1599 $fwdfwsettings{'oldrulenumber'}++;
1601 &General
::writehasharray
("$config", $hash);
1608 if ($errormessage) {
1609 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1610 print "<class name='base'>$errormessage\n";
1611 print " </class>\n";
1612 &Header
::closebox
();
1619 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1620 print "<class name='base'>$hint\n";
1621 print " </class>\n";
1622 &Header
::closebox
();
1629 &General
::setup_default_networks
(\
%defaultNetworks);
1630 foreach my $network (sort keys %defaultNetworks)
1632 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1637 # Checks a hostname against RFC1035
1640 # Each part should be at least two characters in length
1641 # but no more than 63 characters
1642 if (length ($remark) < 1 || length ($remark) > 255) {
1644 # Only valid characters are a-z, A-Z, 0-9 and -
1645 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:_\/\s
]*$/) {
1647 # First character can only be a letter or a digit
1648 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1650 # Last character can only be a letter or a digit
1651 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
1657 my %hash=%{(shift)};
1659 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1660 $hash{$key}[10]=~ s/\|/,/g;
1661 print": $hash{$key}[10]";
1662 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1663 print": <br>$hash{$key}[9] ";
1668 my %hash=%{(shift)};
1672 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1673 if($hash{$key}[14] eq 'cust_srv'){
1674 &General
::readhasharray
("$configsrv", \
%customservice);
1675 foreach my $i (sort keys %customservice){
1676 if($customservice{$i}[0] eq $hash{$key}[15]){
1677 $service = $customservice{$i}[0];
1680 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1681 $service=$hash{$key}[15];
1682 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1683 $hash{$key}[15]=~ s/\|/,/g;
1684 $service=$hash{$key}[15];
1689 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1690 print":<br>$hash{$key}[13]";
1693 sub get_serviceports
1697 &General
::readhasharray
("$configsrv", \
%customservice);
1698 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1702 if($type eq 'service'){
1703 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1704 if ($customservice{$key}[0] eq $name){
1705 $protocols=$customservice{$key}[2];
1708 }elsif($type eq 'group'){
1709 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1710 if ($customservicegrp{$key}[0] eq $name){
1711 foreach my $key1 (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1712 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1713 if($customservice{$key1}[2] eq 'TCP'){$tcp='TCP';}else{$udp='UDP';}
1719 if($tcp && $udp){$protocols="TCP,UDP";
1720 }elsif($tcp){$protocols.="TCP";
1721 }elsif($udp){$protocols.="UDP";}
1727 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1728 &viewtablenew
(\
%configfwdfw,$configfwdfw,'',"DMZ" );
1729 &viewtablenew
(\
%configfwdfw,$configfwdfw,'',"WLAN" );
1730 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1739 &General
::readhasharray
("$config", $hash);
1740 #check if there are DMZ entries
1741 if ($title1 eq 'DMZ'){
1742 foreach my $key (keys %$hash){
1743 if ($$hash{$key}[4] eq 'ORANGE'){$go='on';last}
1745 }elsif($title1 eq 'WLAN'){
1746 foreach my $key (keys %$hash){
1747 if ($$hash{$key}[4] eq 'BLUE'){$go='on';last}
1749 }elsif($title1 eq 'Forward'){
1750 foreach my $key (keys %$hash){
1751 if (($$hash{$key}[4] ne 'ORANGE' && $$hash{$key}[4] ne 'BLUE')){$go='on';last}
1753 }elsif( ! -z
$config){
1757 &Header
::openbox
('100%', 'left',$title);
1765 print"<b>$title1</b><br>";
1766 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1767 print"<tr><td align='center' width='1%'><b>#</td><td width='1%'></td><td align='center' ><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'><b>$Lang::tr{'protocol'}</b></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>";
1768 foreach my $key (sort {$a <=> $b} keys %$hash){
1769 #check if we have a FORWARDFW OR DMZ RULE
1770 if ($title1 eq 'DMZ' && ($$hash{$key}[4] ne 'ORANGE')){next;}
1771 if ($title1 eq 'WLAN' && ($$hash{$key}[4] ne 'BLUE')){next;}
1772 if ($title1 eq 'Forward' && ($$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE')){next;}
1774 #check if vpn hosts/nets have been deleted
1775 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1776 push (@tmpsrc,$$hash{$key}[4]);
1778 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1779 push (@tmpsrc,$$hash{$key}[6]);
1781 foreach my $host (@tmpsrc){
1782 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1783 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1785 &disable_rule
($key);
1788 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1789 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1791 &disable_rule
($key);
1794 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1795 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1797 &disable_rule
($key);
1800 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1801 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1803 &disable_rule
($key);
1810 $$hash{'ACTIVE'}=$$hash{$key}[2];
1812 if($coloryellow eq 'on'){
1813 print"<tr bgcolor='$color{'color14'}' >";
1815 }elsif($coloryellow eq ''){
1817 print"<tr bgcolor='$color{'color22'}' >";
1820 print"<tr bgcolor='$color{'color20'}' >";
1824 <td align='right'>$key</td>
1826 if ($$hash{$key}[0] eq 'ACCEPT'){
1829 $rulecolor=$color{'color17'};
1830 }elsif($$hash{$key}[0] eq 'DROP'){
1833 $rulecolor=$color{'color25'};
1834 }elsif($$hash{$key}[0] eq 'REJECT'){
1837 $rulecolor=$color{'color16'};
1839 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1840 print"<td align='center' nowrap='nowrap'>";
1841 if ($$hash{$key}[3] eq 'std_net_src'){
1842 print &get_name
($$hash{$key}[4]);
1844 print $$hash{$key}[4];
1846 &getsrcport
(\
%$hash,$key);
1847 if ($$hash{$key}[17] eq 'ON'){
1848 $log="/images/on.gif";
1850 $log="/images/off.gif";
1854 <form method='post'>
1855 <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 ;'/>
1856 <input type='hidden' name='key' value='$key' />
1857 <input type='hidden' name='config' value='$config' />
1858 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1862 <td align='center' nowrap='nowrap'>
1864 if ($$hash{$key}[5] eq 'std_net_tgt'){
1865 print &get_name
($$hash{$key}[6]);
1867 print $$hash{$key}[6];
1869 &gettgtport
(\
%$hash,$key);
1870 ################################################################################
1874 if ($$hash{$key}[12]){ #target prot if manual
1875 $prot=$$hash{$key}[12];
1876 }elsif($$hash{$key}[8]){ #source prot if manual
1877 $prot=$$hash{$key}[8];
1878 }elsif($$hash{$key}[14] eq 'cust_srv'){
1879 $prot=&get_serviceports
("service",$$hash{$key}[15]);
1880 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
1881 $prot=&get_serviceports
("group",$$hash{$key}[15]);
1883 $prot=$Lang::tr
{'all'};
1885 print"<td align='center'>$prot</td>";
1887 print"<td width='20%'>$$hash{$key}[16]</td>";
1889 if($$hash{$key}[2] eq 'ON'){
1890 $gif="/images/on.gif"
1893 $gif="/images/off.gif"
1896 <form method='post'>
1897 <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;' />
1898 <input type='hidden' name='key' value='$key' />
1899 <input type='hidden' name='config' value='$config' />
1900 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1902 <form method='post'>
1903 <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;' />
1904 <input type='hidden' name='key' value='$key' />
1905 <input type='hidden' name='config' value='$config' />
1906 <input type='hidden' name='ACTION' value='editrule' />
1908 <form method='post'>
1909 <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;' />
1910 <input type='hidden' name='key' value='$key' />
1911 <input type='hidden' name='config' value='$config' />
1912 <input type='hidden' name='ACTION' value='copyrule' />
1914 <form method='post'>
1915 <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;' />
1916 <input type='hidden' name='key' value='$key' />
1917 <input type='hidden' name='config' value='$config' />
1918 <input type='hidden' name='ACTION' value='deleterule' />
1921 if (exists $$hash{$key-1}){
1923 <form method='post'>
1924 <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;' />
1925 <input type='hidden' name='key' value='$key' />
1926 <input type='hidden' name='config' value='$config' />
1927 <input type='hidden' name='ACTION' value='moveup' />
1933 if (exists $$hash{$key+1}){
1935 <form method='post'>
1936 <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;' />
1937 <input type='hidden' name='key' value='$key' />
1938 <input type='hidden' name='config' value='$config' />
1939 <input type='hidden' name='ACTION' value='movedown' />
1940 </td></form></td></tr>
1943 print"<td></td></tr>";
1945 #if timeframe set, print new line in table
1946 if ($$hash{$key}[18] eq 'ON'){
1948 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
1949 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
1950 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
1951 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
1952 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
1953 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
1954 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
1955 my $weekdays=join(",",@days);
1957 print"<tr bgcolor='#FFE4B5'><td colspan='6'>$Lang::tr{'fwdfw time'} ";
1959 print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
1964 &Header
::closebox
();
1970 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
1973 &Header
::openbox
('100%', 'center', 'P2P-Block');
1975 <table width='35%' border='0'>
1976 <tr bgcolor='$color{'color22'}'><td align=center colspan='2' ><b>$Lang::tr{'protocol'}</b></td><td align='center'><b>$Lang::tr{'status'}</b></td></tr>
1978 foreach my $p2pentry (sort @p2ps)
1980 my @p2pline = split( /\;/, $p2pentry );
1981 if($p2pline[2] eq 'on'){
1982 $gif="/images/on.gif"
1984 $gif="/images/off.gif"
1987 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1988 <tr bgcolor='$color{'color20'}'>
1989 <td align='center' colspan='2' >$p2pline[0]:</td><td 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>
1992 print"<tr><td><img src='/images/on.gif'></td><td align='left'>$Lang::tr{'outgoing firewall p2p allow'}</td></tr>";
1993 print"<tr><td><img src='/images/off.gif'></td><td align='left'>$Lang::tr{'outgoing firewall p2p deny'}</td></tr></table>";
1994 &Header
::closebox
();
1998 my %hash=%{(shift)};
2001 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
2002 if($hash{$key}[0] eq $val){
2003 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
2005 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
2011 if (!-f
"${General::swroot}/forward/reread"){
2012 system("touch ${General::swroot}/forward/reread");
2017 system("/usr/local/bin/forwardfwctrl");
2018 if ( -f
"${General::swroot}/forward/reread"){
2019 system("rm ${General::swroot}/forward/reread");
2022 &Header
::closebigbox
();
2023 &Header
::closepage
();