]>
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 ###############################################################################
35 no warnings
'uninitialized';
36 # enable only the following on debugging purpose
38 #use CGI::Carp 'fatalsToBrowser';
40 require '/var/ipfire/general-functions.pl';
41 require "${General::swroot}/lang.pl";
42 require "${General::swroot}/header.pl";
43 require "${General::swroot}/forward/bin/firewall-lib.pl";
45 unless (-d
"${General::swroot}/forward") { system("mkdir ${General::swroot}/forward"); }
46 unless (-e
"${General::swroot}/forward/settings") { system("touch ${General::swroot}/forward/settings"); }
47 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
48 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
49 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
50 unless (-e
"${General::swroot}/forward/nat") { system("touch ${General::swroot}/forward/nat"); }
54 my %defaultNetworks=();
58 my %customnetworks=();
60 my %customservicegrp=();
66 my %configoutgoingfw=();
78 my $VERSION='0.9.9.8';
80 my $confignet = "${General::swroot}/fwhosts/customnetworks";
81 my $confighost = "${General::swroot}/fwhosts/customhosts";
82 my $configgrp = "${General::swroot}/fwhosts/customgroups";
83 my $configsrv = "${General::swroot}/fwhosts/customservices";
84 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
85 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
86 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
87 my $configipsec = "${General::swroot}/vpn/config";
88 my $configipsecrw = "${General::swroot}/vpn/settings";
89 my $configfwdfw = "${General::swroot}/forward/config";
90 my $configinput = "${General::swroot}/forward/input";
91 my $configoutgoing = "${General::swroot}/forward/outgoing";
92 my $configovpn = "${General::swroot}/ovpn/settings";
93 my $fwoptions = "${General::swroot}/optionsfw/settings";
94 my $ifacesettings = "${General::swroot}/ethernet/settings";
97 my $ipgrp="${General::swroot}/outgoing/groups";
101 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
102 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
103 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
104 &General
::readhash
($fwoptions, \
%optionsfw);
105 &General
::readhash
($ifacesettings, \
%ifaces);
106 &General
::readhash
("$configovpn", \
%ovpnsettings);
107 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
108 &General
::readhasharray
("$configipsec", \
%ipsecconf);
109 &Header
::showhttpheaders
();
110 &Header
::getcgihash
(\
%fwdfwsettings);
111 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
112 &Header
::openbigbox
('100%', 'center',$errormessage);
115 if ($fwdfwsettings{'ACTION'} eq 'saverule')
117 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
118 &General
::readhasharray
("$configinput", \
%configinputfw);
119 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
120 $errormessage=&checksource
;
121 if(!$errormessage){&checktarget
;}
122 if(!$errormessage){&checkrule
;}
124 #check if manual ip (source) is orange network
125 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
126 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
127 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
132 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
133 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
135 #check if we try to break rules
136 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire'){
137 $errormessage.=$Lang::tr
{'fwdfw err same'};
140 if($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
141 $fwdfwsettings{'config'}=$configinput;
142 $fwdfwsettings{'chain'} = 'INPUTFW';
143 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
144 #check if we have an identical rule already
145 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
146 foreach my $key (sort keys %configinputfw){
147 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'}"
148 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]"){
149 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
150 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
152 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
153 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
155 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
156 $fwdfwsettings{'nosave'} = 'on';
161 #check Rulepos on new Rule
162 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
163 $fwdfwsettings{'oldrulenumber'}=$maxkey;
164 foreach my $key (sort keys %configinputfw){
165 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'}"
166 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]"){
167 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
171 #check if we just close a rule
172 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'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'}) {
173 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
175 $fwdfwsettings{'nosave2'} = 'on';
178 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
179 if ($fwdfwsettings{'nobase'} ne 'on'){
180 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
182 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
183 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
184 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
185 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
186 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
187 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
189 if($fwdfwsettings{'nosave2'} ne 'on'){
190 &saverule
(\
%configinputfw,$configinput);
192 }elsif($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' ){
194 $fwdfwsettings{'config'}=$configoutgoing;
195 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
196 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
197 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
198 foreach my $key (sort keys %configoutgoingfw){
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 "$configoutgoingfw{$key}[0],$configoutgoingfw{$key}[2],$configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],$configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],$configoutgoingfw{$key}[7],$configoutgoingfw{$key}[8],$configoutgoingfw{$key}[9],$configoutgoingfw{$key}[10],$configoutgoingfw{$key}[11],$configoutgoingfw{$key}[12],$configoutgoingfw{$key}[13],$configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],$configoutgoingfw{$key}[17],$configoutgoingfw{$key}[18],$configoutgoingfw{$key}[19],$configoutgoingfw{$key}[20],$configoutgoingfw{$key}[21],$configoutgoingfw{$key}[22],$configoutgoingfw{$key}[23],$configoutgoingfw{$key}[24],$configoutgoingfw{$key}[25],$configoutgoingfw{$key}[26],$configoutgoingfw{$key}[27]"){
201 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
202 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
204 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
205 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
207 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
208 $fwdfwsettings{'nosave'} = 'on';
213 #check Rulepos on new Rule
214 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
215 print"CHECK OUTGOING DOPPELTE REGEL<br>";
216 $fwdfwsettings{'oldrulenumber'}=$maxkey;
217 foreach my $key (sort keys %configoutgoingfw){
218 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'}"
219 eq "$configoutgoingfw{$key}[0],$configoutgoingfw{$key}[2],$configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],$configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],$configoutgoingfw{$key}[7],$configoutgoingfw{$key}[8],$configoutgoingfw{$key}[9],$configoutgoingfw{$key}[10],$configoutgoingfw{$key}[11],$configoutgoingfw{$key}[12],$configoutgoingfw{$key}[13],$configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],$configoutgoingfw{$key}[17],$configoutgoingfw{$key}[18],$configoutgoingfw{$key}[19],$configoutgoingfw{$key}[20],$configoutgoingfw{$key}[21],$configoutgoingfw{$key}[22],$configoutgoingfw{$key}[23],$configoutgoingfw{$key}[24],$configoutgoingfw{$key}[25],$configoutgoingfw{$key}[26],$configoutgoingfw{$key}[27]"){
220 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
224 #check if we just close a rule
225 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'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'}) {
226 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
227 $fwdfwsettings{'nosave2'} = 'on';
232 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
233 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
234 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
235 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
236 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
237 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
238 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
239 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
241 if ($fwdfwsettings{'nobase'} eq 'on'){
242 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
244 if ($fwdfwsettings{'nosave2'} ne 'on'){
245 &saverule
(\
%configoutgoingfw,$configoutgoing);
249 $fwdfwsettings{'config'}=$configfwdfw;
250 $fwdfwsettings{'chain'} = 'FORWARDFW';
251 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
252 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
253 #check if we have an identical rule already
254 foreach my $key (sort keys %configfwdfw){
255 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{'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'}"
256 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}[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]"){
257 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
258 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
260 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
261 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
263 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
264 $fwdfwsettings{'nosave'} = 'on';
269 #check Rulepos on new Rule
270 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
271 $fwdfwsettings{'oldrulenumber'}=$maxkey;
272 foreach my $key (sort keys %configfwdfw){
273 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{'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'}"
274 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}[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]"){
275 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
279 #check if we just close a rule
280 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'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'}) {
281 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
282 $fwdfwsettings{'nosave2'} = 'on';
287 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
288 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
289 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
290 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
291 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
292 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
293 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
294 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
296 if ($fwdfwsettings{'nobase'} eq 'on'){
297 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
299 if ($fwdfwsettings{'nosave2'} ne 'on'){
300 &saverule
(\
%configfwdfw,$configfwdfw);
306 if($fwdfwsettings{'nosave2'} ne 'on'){
312 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
316 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
319 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
320 foreach my $key (sort keys %togglehash){
321 if ($key eq $fwdfwsettings{'key'}){
322 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
325 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
329 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
332 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
333 foreach my $key (sort keys %togglehash){
334 if ($key eq $fwdfwsettings{'key'}){
335 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
338 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
342 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
347 if ($fwdfwsettings{'ACTION'} eq 'editrule')
349 $fwdfwsettings{'updatefwrule'}='on';
352 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
356 if ($fwdfwsettings{'ACTION'} eq 'moveup')
361 if ($fwdfwsettings{'ACTION'} eq 'movedown')
366 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
368 $fwdfwsettings{'copyfwrule'}='on';
371 if ($fwdfwsettings{'ACTION'} eq '')
379 if (-f
"${General::swroot}/forward/reread"){
380 print "<table border='1' rules='groups' bgcolor='lightgreen' width='100%'><form method='post'><td><div style='font-size:11pt; font-weight: bold;vertical-align: middle; '><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: green; font-weight: bold; font-size: 14pt;'>    $Lang::tr{'fwhost reread'}</div</td></tr></table></form><hr><br>";
382 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw menu'});
383 print "<form method='post'>";
384 print "<table border='0'>";
385 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
386 print"</tr></table></form><hr>";
395 print "<br><br><div align='right'><font size='1' color='grey'>Version: $VERSION</font></div>";
400 $fwdfwsettings{'updatefwrule'}='';
401 $fwdfwsettings{'config'}=$oldchain;
402 $fwdfwsettings{'nobase'}='on';
404 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
405 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
410 #check ip-address if manual
411 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
412 #check if ip with subnet
413 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
414 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
415 $subnet = &General
::iporsubtocidr
($subnet);
416 $fwdfwsettings{'isip'}='on';
419 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
420 $ip=$fwdfwsettings{'src_addr'};
422 $fwdfwsettings{'isip'}='on';
425 if ($fwdfwsettings{'isip'} ne 'on'){
426 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
428 if ($fwdfwsettings{'isip'} eq 'on'){
429 ##check if ip is valid
430 if (! &General
::validip
($ip)){
431 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
432 return $errormessage;
434 #check and form valid IP
435 $ip=&General
::ip2dec
($ip);
436 $ip=&General
::dec2ip
($ip);
437 #check if net or broadcast
438 my @tmp= split (/\./,$ip);
439 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
441 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
442 return $errormessage;
444 $fwdfwsettings{'src_addr'}="$ip/$subnet";
445 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
446 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
447 return $errormessage;
450 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
451 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
452 return $errormessage;
454 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
455 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
456 return $errormessage;
460 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
462 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
463 $fwdfwsettings{'SRC_PORT'}='';
464 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
465 foreach my $key (keys %icmptypes){
466 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
467 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
470 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
471 $fwdfwsettings{'SRC_PORT'}='';
472 $fwdfwsettings{'ICMP_TYPES'}='';
473 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
474 $fwdfwsettings{'SRC_PORT'}='';
475 $fwdfwsettings{'ICMP_TYPES'}='';
476 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
477 $fwdfwsettings{'SRC_PORT'}='';
478 $fwdfwsettings{'ICMP_TYPES'}='';
479 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
480 $fwdfwsettings{'ICMP_TYPES'}='';
482 $fwdfwsettings{'ICMP_TYPES'}='';
483 $fwdfwsettings{'SRC_PORT'}='';
484 $fwdfwsettings{'PROT'}='';
487 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
488 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
492 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
494 #change dashes with :
497 push(@values,"1:65535");
500 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
501 push(@values,"1:$2");
504 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
505 push(@values,"$1:65535");
508 $errormessage .= &General
::validportrange
($_, 'destination');
513 if (&General
::validport
($_)){
520 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
522 return $errormessage;
527 &General
::readhasharray
("$configsrv", \
%customservice);
528 #check DNAT settings (has to be single Host and single Port or portrange)
529 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
530 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
531 if ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'dnatport'} eq ''){
532 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
533 return $errormessage;
535 #check if manual ip is a single Host (if set)
536 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
537 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
538 my @tmp1= split ("/",$tmp[3]);
539 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
541 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
542 return $errormessage;
545 #check if Port is a single Port or portrange
546 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
547 if(($fwdfwsettings{'TGT_PROT'} ne 'TCP'|| $fwdfwsettings{'TGT_PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
548 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
549 return $errormessage;
551 if (($fwdfwsettings{'TGT_PROT'} eq 'TCP'|| $fwdfwsettings{'TGT_PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
552 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
553 return $errormessage;
557 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
558 return $errormessage;
561 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
562 #check if ip with subnet
563 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
564 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
565 $subnet = &General
::iporsubtocidr
($subnet);
568 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
569 $ip=$fwdfwsettings{'tgt_addr'};
572 #check if ip is valid
573 if (! &General
::validip
($ip)){
574 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
575 return $errormessage;
577 #check and form valid IP
578 $ip=&General
::ip2dec
($ip);
579 $ip=&General
::dec2ip
($ip);
580 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
581 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
582 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
583 return $errormessage;
585 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
586 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
587 return $errormessage;
590 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
592 if ($fwdfwsettings{'USESRV'} eq 'ON'){
593 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
594 $fwdfwsettings{'TGT_PROT'}='';
595 $fwdfwsettings{'ICMP_TGT'}='';
597 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
598 $fwdfwsettings{'TGT_PROT'}='';
599 $fwdfwsettings{'ICMP_TGT'}='';
600 #check target service
601 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
602 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
605 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
606 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
607 if ($fwdfwsettings{'TGT_PORT'} ne ''){
608 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
609 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
610 return $errormessage;
612 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
616 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
618 #change dashes with :
621 push(@values,"1:65535");
624 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
625 push(@values,"1:$2");
628 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
629 push(@values,"$1:65535");
632 $errormessage .= &General
::validportrange
($_, 'destination');
637 if (&General
::validport
($_)){
644 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
646 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
647 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
648 $fwdfwsettings{'TGT_PORT'} = '';
649 $fwdfwsettings{'ICMP_TGT'} = '';
650 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
651 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
652 $fwdfwsettings{'TGT_PORT'} = '';
653 $fwdfwsettings{'ICMP_TGT'}='';
654 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
655 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
656 $fwdfwsettings{'TGT_PORT'} = '';
657 $fwdfwsettings{'ICMP_TGT'}='';
658 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
659 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
660 $fwdfwsettings{'TGT_PORT'} = '';
661 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
662 foreach my $key (keys %icmptypes){
664 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
665 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
672 if ($fwdfwsettings{'USESRV'} ne 'ON'){
673 $fwdfwsettings{'grp3'}='';
674 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
675 $fwdfwsettings{'ICMP_TGT'}='';
678 if($fwdfwsettings{'TIME'} eq 'ON'){
679 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 ''){
680 $errormessage=$Lang::tr
{'fwdfw err time'};
681 return $errormessage;
684 return $errormessage;
689 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
690 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
691 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
692 if ($fwdfwsettings{'dnatport'} eq "*") {
693 $fwdfwsettings{'dnatport'}="1:65535";
695 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
696 $fwdfwsettings{'dnatport'} = "1:$2";
698 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
699 $fwdfwsettings{'dnatport'} ="$1:65535";
704 if ($val =~ "," || $val>65536 || $val<0){
711 #check valid port for NAT
712 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
713 #if no port is given in nat area, take target host port
714 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
715 #check if port given in nat area is a single valid port or portrange
716 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
717 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
718 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
720 #get servcie Protocol and Port
721 foreach my $key (sort keys %customservice){
722 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
723 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
724 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
726 $custsrvport= $customservice{$key}[1];
729 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
731 #check if DNAT port is multiple
732 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
733 my @parts=split(",",$fwdfwsettings{'dnatport'});
737 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
739 #change dashes with :
742 push(@values,"1:65535");
745 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
746 push(@values,"1:$2");
749 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
750 push(@values,"$1:65535");
753 $errormessage .= &General
::validportrange
($_, 'destination');
758 if (&General
::validport
($_)){
765 $fwdfwsettings{'dnatport'}=join("|",@values);
769 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
770 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
772 #check if source and target identical
773 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
774 $errormessage.=$Lang::tr
{'fwdfw err same'};
775 return $errormessage;
777 #get source and targetip address if possible
778 my ($sip,$scidr,$tip,$tcidr);
779 ($sip,$scidr)=&get_ip
("src","grp1");
780 ($tip,$tcidr)=&get_ip
("tgt","grp2");
781 #check same iprange in source and target
782 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
783 my $networkip1=&General
::getnetworkip
($sip,$scidr);
784 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
785 if ($scidr gt $tcidr){
786 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
787 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
789 }elsif($scidr eq $tcidr && $scidr eq '32'){
790 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
791 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
792 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
793 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
794 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
797 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
798 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
802 #check source and destination protocol if manual
803 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
804 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
805 $errormessage.=$Lang::tr
{'fwdfw err prot'};
807 #check source and destination protocol if source manual and dest servicegrp
808 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
809 foreach my $key (sort keys %customservice){
810 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
811 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
812 $errormessage.=$Lang::tr
{'fwdfw err prot'};
822 my ($base1,$val1,$base2,$val2) = @_;
824 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
825 &dec_counter
($confignet,\
%customnetwork,$val1);
826 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
827 &dec_counter
($confighost,\
%customhost,$val1);
828 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
829 &dec_counter
($configgrp,\
%customgrp,$val1);
830 }elsif($base1 eq 'cust_srv'){
831 &dec_counter
($configsrv,\
%customservice,$val1);
832 }elsif($base1 eq 'cust_srvgrp'){
833 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
836 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
837 &inc_counter
($confignet,\
%customnetwork,$val2);
838 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
839 &inc_counter
($confighost,\
%customhost,$val2);
840 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
841 &inc_counter
($configgrp,\
%customgrp,$val2);
842 }elsif($base2 eq 'cust_srv'){
843 &inc_counter
($configsrv,\
%customservice,$val2);
844 }elsif($base2 eq 'cust_srvgrp'){
845 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
851 #Test if manual IP is part of static OpenVPN networks
852 &General
::readhasharray
("$configccdnet", \
%ccdnet);
853 foreach my $key (sort keys %ccdnet){
854 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
855 my $sub=&General
::iporsubtodec
($vpnsubnet);
856 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
860 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
861 # because if one creates a custom host with the ip, we need to check the color there!
862 # It does not make sense to check this here
864 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
865 # Is also checked in getcolor
867 # Test if manual ip is part of an IPsec Network is also checked in getcolor
877 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
878 foreach my $key (sort {$a <=> $b} keys %delhash){
879 if ($key == $fwdfwsettings{'key'}){
880 #check hosts/net and groups
881 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
882 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
883 #check services and groups
884 if ($delhash{$key}[11] eq 'ON'){
885 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
888 if ($key >= $fwdfwsettings{'key'}) {
890 if (exists $delhash{$next}) {
891 foreach my $i (0 .. $#{$delhash{$next}}) {
892 $delhash{$key}[$i] = $delhash{$next}[$i];
897 # Remove the very last entry.
898 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
899 delete $delhash{$last_key};
901 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
904 if($fwdfwsettings{'nobase'} ne 'on'){
911 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
912 foreach my $key (sort keys %configfwdfw){
914 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
917 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
926 &General
::readhasharray
($config, \
%hash);
927 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
928 if($hash{$key}[0] eq $val){
929 $pos=$#{$hash{$key}};
930 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
933 &General
::writehasharray
($config, \
%hash);
938 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
939 print "<class name='base'>$errormessage\n";
940 print " </class>\n";
950 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
951 if($hash{$key}[0] eq $val){
952 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
954 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
964 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
965 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
966 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
967 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
968 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
969 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
970 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
971 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
972 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
973 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
974 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
975 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
976 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
977 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
978 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
979 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
980 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
981 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
983 <table width='100%' border='0'>
984 <tr><td width='50%' valign='top'>
985 <table width='100%' border='0'>
986 <tr><td width='1%'><input type='radio' name='$grp' value='std_net_$srctgt' $checked{$grp}{'std_net_'.$srctgt}></td><td>$Lang::tr{'fwhost stdnet'}</td><td align='right'><select name='std_net_$srctgt' style='width:200px;'>
988 foreach my $network (sort keys %defaultNetworks)
990 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
991 next if($defaultNetworks{$network}{'NAME'} eq "IPFire" && $srctgt eq 'tgt');
992 print "<option value='$defaultNetworks{$network}{'NAME'}'";
993 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
994 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
995 $ifaces{$defnet} = '0.0.0.0' if ($defaultNetworks{$network}{'NAME'} eq 'ALL');
996 $defnet = "RED_ADDRESS" if ($defaultNetworks{$network}{'NAME'} eq 'IPFire');
997 print ">$network $ifaces{$defnet} </option>";
999 print"</select></td></tr>";
1001 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1002 print"<tr><td><input type='radio' name='$grp' value='cust_net_$srctgt' $checked{$grp}{'cust_net_'.$srctgt}></td><td>$Lang::tr{'fwhost cust net'}</td><td align='right'><select name='cust_net_$srctgt' style='width:200px;'>";
1003 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1004 print"</select></td>";
1007 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1008 print"<tr><td><input type='radio' name='$grp' value='cust_host_$srctgt' $checked{$grp}{'cust_host_'.$srctgt}></td><td>$Lang::tr{'fwhost cust addr'}</td><td align='right'><select name='cust_host_$srctgt' style='width:200px;'>";
1009 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1010 print"</select></td>";
1013 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1014 print"<tr><td valign='top'><input type='radio' name='$grp' value='cust_grp_$srctgt' $checked{$grp}{'cust_grp_'.$srctgt}></td><td >$Lang::tr{'fwhost cust grp'}</td><td align='right'><select name='cust_grp_$srctgt' style='width:200px;'>";
1015 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1016 if($helper ne $customgrp{$key}[0]){
1018 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1019 print ">$customgrp{$key}[0]</option>";
1021 $helper=$customgrp{$key}[0];
1023 print"</select></td>";
1025 #End left table. start right table (vpn)
1026 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1028 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1029 print"<td width='1%'><input type='radio' name='$grp' value='ovpn_net_$srctgt' $checked{$grp}{'ovpn_net_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_net_$srctgt' style='width:200px;'>";
1030 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1031 print"</select></td></tr>";
1034 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1035 if ($ccdhost{$key}[33] ne '' ){
1036 print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_host_$srctgt' $checked{$grp}{'ovpn_host_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_host_$srctgt' style='width:200px;'>" if ($show eq '');
1038 print "<option value='$ccdhost{$key}[1]'";
1039 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1040 print ">$ccdhost{$key}[1]</option>";
1043 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1044 print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_host_$srctgt' $checked{$grp}{'ovpn_host_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_host_$srctgt' style='width:200px;'></select></td></tr>" ;
1046 if ($show eq '1'){$show='';print"</select></td></tr>";}
1048 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1049 if ($ccdhost{$key}[3] eq 'net'){
1050 print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_n2n_$srctgt' $checked{$grp}{'ovpn_n2n_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ovpn_n2n'}:</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_n2n_$srctgt' style='width:200px;'>" if ($show eq '');
1052 print "<option value='$ccdhost{$key}[1]'";
1053 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1054 print ">$ccdhost{$key}[1]</option>";
1057 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1058 print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_n2n_$srctgt' $checked{$grp}{'ovpn_n2n_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ovpn_n2n'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_n2n_$srctgt' style='width:200px;'></select></td></tr>" ;
1060 if ($show eq '1'){$show='';print"</select></td></tr>";}
1062 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1063 if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1064 print"<tr><td valign='top'><input type='radio' name='$grp' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td align='right'><select name='ipsec_net_$srctgt' style='width:200px;'>" if ($show eq '');
1067 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1068 print ">$ipsecconf{$key}[1]</option>";
1071 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1072 print"<tr><td valign='top'><input type='radio' name='$grp' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td align='right'><select name='ipsec_net_$srctgt' style='width:200px;'><select></td></tr>";
1074 if ($show eq '1'){$show='';print"</select></td></tr>";}
1076 print"</tr></table>";
1077 print"</td></tr></table><br>";
1085 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1086 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1087 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1088 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1089 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1090 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1091 $a=$netsettings{'GREEN_NETADDRESS'};
1092 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1093 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1094 $a=$netsettings{'ORANGE_NETADDRESS'};
1095 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1096 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1097 $a=$netsettings{'BLUE_NETADDRESS'};
1098 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1099 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1100 &General
::readhash
("$configovpn",\
%ovpnsettings);
1101 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1102 $b=&General
::iporsubtocidr
($b);
1104 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1105 &General
::readhasharray
("$confignet", \
%customnetwork);
1106 foreach my $key (keys %customnetwork){
1107 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1108 $a=$customnetwork{$key}[1];
1109 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1112 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1113 &General
::readhasharray
("$confighost", \
%customhost);
1114 foreach my $key (keys %customhost){
1115 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1116 if ($customhost{$key}[1] eq 'ip'){
1117 ($a,$b)=split (/\//,$customhost{$key}[2]);
1118 $b=&General
::iporsubtocidr
($b);
1120 if ($grp eq 'grp2'){
1121 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1133 &General
::setup_default_networks
(\
%defaultNetworks);
1134 foreach my $network (sort keys %defaultNetworks)
1136 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1141 my %hash=%{(shift)};
1143 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1144 $hash{$key}[10]=~ s/\|/,/g;
1145 print": $hash{$key}[10]";
1146 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1147 print": <br>$hash{$key}[9] ";
1152 my %hash=%{(shift)};
1156 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1157 if($hash{$key}[14] eq 'cust_srv'){
1158 &General
::readhasharray
("$configsrv", \
%customservice);
1159 foreach my $i (sort keys %customservice){
1160 if($customservice{$i}[0] eq $hash{$key}[15]){
1161 $service = $customservice{$i}[0];
1164 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1165 $service=$hash{$key}[15];
1166 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1167 $hash{$key}[15]=~ s/\|/,/g;
1168 $service=$hash{$key}[15];
1173 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1174 print":<br>$hash{$key}[13]";
1177 sub get_serviceports
1181 &General
::readhasharray
("$configsrv", \
%customservice);
1182 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1187 if($type eq 'service'){
1188 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1189 if ($customservice{$key}[0] eq $name){
1190 push (@protocols,$customservice{$key}[2]);
1193 }elsif($type eq 'group'){
1194 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1195 if ($customservicegrp{$key}[0] eq $name){
1196 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1197 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1198 if($customservice{$key1}[2] eq 'TCP'){
1200 }elsif($customservice{$key1}[2] eq 'ICMP'){
1202 }elsif($customservice{$key1}[2] eq 'UDP'){
1210 if($tcp && $udp && $icmp){
1211 push (@protocols,"All");
1215 push (@protocols,"TCP");
1218 push (@protocols,"UDP");
1221 push (@protocols,"ICMP");
1230 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1232 if ($val eq 'GREEN'){
1233 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1235 }elsif ($val eq 'ORANGE'){
1236 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1238 }elsif ($val eq 'BLUE'){
1239 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1241 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1242 $tdcolor="style='border: 1px solid $Header::colourred;'";
1244 }elsif ($val eq 'IPFire' ){
1245 $tdcolor="style='border: 1px solid $Header::colourred;'";
1247 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1248 my ($sip,$scidr) = split ("/",$val);
1249 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1250 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1253 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1254 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1257 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1258 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1261 }elsif ($val eq 'Default IP'){
1262 $tdcolor="style='border: 1px solid $Header::colourred;'";
1265 #Check if a manual IP is part of a VPN
1266 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr'){
1267 #Check if IP is part of OpenVPN dynamic subnet
1268 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1269 my ($c,$d) = split("/",$val);
1270 if (&General
::IpInSubnet
($c,$a,$b)){
1271 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1274 #Check if IP is part of OpenVPN static subnet
1275 foreach my $key (sort keys %ccdnet){
1276 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1277 $b =&General
::iporsubtodec
($b);
1278 if (&General
::IpInSubnet
($c,$a,$b)){
1279 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1283 #Check if IP is part of OpenVPN N2N subnet
1284 foreach my $key (sort keys %ccdhost){
1285 if ($ccdhost{$key}[3] eq 'net'){
1286 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1287 if (&General
::IpInSubnet
($c,$a,$b)){
1288 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1293 #Check if IP is part of IPsec RW network
1294 if ($ipsecsettings{'RW_NET'} ne ''){
1295 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1296 $b=&General
::iporsubtodec
($b);
1297 if (&General
::IpInSubnet
($c,$a,$b)){
1298 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1302 #Check if IP is part of a IPsec N2N network
1303 foreach my $key (sort keys %ipsecconf){
1304 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1305 if (&General
::IpInSubnet
($c,$a,$b)){
1306 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1312 if ($nettype eq 'ovpn_n2n_src' || $nettype eq 'ovpn_n2n_tgt' || $nettype eq 'ovpn_net_src' || $nettype eq 'ovpn_net_tgt'|| $nettype eq 'ovpn_host_src' || $nettype eq 'ovpn_host_tgt'){
1313 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1316 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1317 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1321 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1322 foreach my $key (sort keys %$hash){
1323 if ($$hash{$key}[0] eq $val){
1324 $val=$$hash{$key}[2];
1329 foreach my $alias (sort keys %aliases)
1331 if ($val eq $alias){
1332 $tdcolor="style='border: 1px solid $Header::colourred;'";
1343 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1344 print "<class name='base'>$hint\n";
1345 print " </class>\n";
1346 &Header
::closebox
();
1353 my %hash=%{(shift)};
1357 &General
::readhasharray
($config, \
%hash);
1358 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1359 if($hash{$key}[0] eq $val){
1360 $pos=$#{$hash{$key}};
1361 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1364 &General
::writehasharray
($config, \
%hash);
1369 &General
::setup_default_networks
(\
%defaultNetworks);
1370 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1371 #read all configfiles
1372 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1373 &General
::readhasharray
("$confignet", \
%customnetwork);
1374 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1375 &General
::readhasharray
("$confighost", \
%customhost);
1376 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1377 &General
::readhasharray
("$configgrp", \
%customgrp);
1378 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1379 &General
::get_aliases
(\
%aliases);
1383 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1384 my $config=$fwdfwsettings{'config'};
1386 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1387 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1388 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1389 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1390 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1391 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1392 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1393 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1394 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1395 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1396 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1397 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1398 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1399 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1400 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1401 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1402 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1403 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1404 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1405 #check if update and get values
1406 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1407 &General
::readhasharray
("$config", \
%hash);
1408 foreach my $key (sort keys %hash){
1410 if ($key eq $fwdfwsettings{'key'}){
1411 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1412 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1413 $fwdfwsettings{'chain'} = $hash{$key}[1];
1414 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1415 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1416 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1417 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1418 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1419 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1420 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1421 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1422 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1423 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1424 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1425 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1426 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1427 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1428 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1429 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1430 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1431 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1432 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1433 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1434 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1435 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1436 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1437 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1438 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1439 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1440 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1441 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1442 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1443 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1444 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1445 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1446 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1447 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1448 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1449 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1450 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1451 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1452 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1453 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1454 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1455 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1456 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1457 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1458 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1459 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1460 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1461 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1462 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1463 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1464 $selected{'dnat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1465 $selected{'snat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1468 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1469 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1470 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1471 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1472 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1473 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1474 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1475 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1476 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1477 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1478 #check if manual ip (source) is orange network
1479 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1480 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1481 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1482 $fwdfwsettings{'oldorange'} ='on';
1486 $fwdfwsettings{'ACTIVE'}='ON';
1487 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1488 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1489 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1490 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1491 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1492 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1493 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1494 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1495 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1496 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1497 #check if manual ip (source) is orange network
1498 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1499 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1500 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1501 $fwdfwsettings{'oldorange'} ='on';
1505 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1506 print "<form method='post'>";
1507 &Header
::closebox
();
1508 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1509 #------SOURCE-------------------------------------------------------
1511 <table width='100%' border='0'>
1512 <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'}' size='16' maxlength='17'></td></tr>
1513 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1516 &gen_dd_block
('src','grp1');
1518 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1519 <table width='100%' border='0'>
1520 <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>
1521 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1523 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1525 if ($_ eq $fwdfwsettings{'PROT'})
1527 print"<option selected>$_</option>";
1529 print"<option>$_</option>";
1532 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1534 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1535 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES' style='width:230px;'>
1537 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1538 print"<option>All ICMP-Types</option>";
1539 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) } keys %icmptypes){
1540 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1541 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1543 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1547 </select></td></tr></table><br><hr>
1549 &Header
::closebox
();
1551 #---TARGET------------------------------------------------------
1552 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1554 <table width='100%' border='0'>
1555 <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr' checked></td><td width='57%' nowrap='nowrap'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16' maxlength='17'><td width='1%'><input type='radio' name='grp2' value='ipfire' $checked{'grp2'}{'ipfire'}></td><td><b>Firewall</b></td>
1557 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1558 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'} 0.0.0.0</option>";
1559 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} $ifaces{'GREEN_ADDRESS'}</option>" if $ifaces{'GREEN_ADDRESS'};
1560 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} $ifaces{'ORANGE_ADDRESS'}</option>" if $ifaces{'ORANGE_ADDRESS'};
1561 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} $ifaces{'BLUE_ADDRESS'}</option>" if $ifaces{'BLUE_ADDRESS'};
1562 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} $ifaces{'RED_ADDRESS'}</option>" if $ifaces{'RED_ADDRESS'};
1564 if (! -z
"${General::swroot}/ethernet/aliases"){
1565 foreach my $alias (sort keys %aliases)
1567 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1572 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1574 &gen_dd_block
('tgt','grp2');
1576 <b>$Lang::tr{'fwhost attention'}:</b><br>
1577 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1578 <table width='100%' border='0'>
1579 <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;' >
1581 &General
::readhasharray
("$configsrv", \
%customservice);
1582 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1584 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1585 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1589 <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;' >
1591 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1593 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1594 if ($helper ne $customservicegrp{$key}[0]){
1596 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1597 print">$customservicegrp{$key}[0]</option>";
1599 $helper=$customservicegrp{$key}[0];
1603 <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'>
1605 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1607 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1609 print"<option selected>$_</option>";
1611 print"<option>$_</option>";
1614 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1616 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1617 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT' style='min-width:230px;'>
1619 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1620 print"<option>All ICMP-Types</option>";
1621 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1622 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1623 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1625 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1634 #---SNAT / DNAT ------------------------------------------------
1635 &Header
::openbox
('100%', 'left', 'NAT');
1637 <table width='100%' border='0'>
1638 <tr><td width='1%'><input type='checkbox' name='USE_NAT' value='ON' $checked{'USE_NAT'}{'ON'}></td><td width='15%'>$Lang::tr{'fwdfw use nat'}</td><td colspan='5'></td></tr>
1639 <tr><td colspan='2'></td><td width='1%'><input type='radio' name='nat' value='dnat' checked ></td><td width='50%'>$Lang::tr{'fwdfw dnat'}</td>
1641 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='dnat' style='width:140px;'>";
1642 print "<option value='ALL' $selected{'dnat'}{$Lang::tr{'all'}}>$Lang::tr{'all'}</option>";
1643 print "<option value='Default IP' $selected{'dnat'}{'Default IP'}>Default IP</option>";
1644 foreach my $alias (sort keys %aliases)
1646 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
1649 $fwdfwsettings{'dnatport'}=~ tr/|/,/;
1650 print"<tr><td colspan='4'></td><td>Port: </td><td align='right'><input type='text' name='dnatport' style='width:130px;' value=$fwdfwsettings{'dnatport'}> </td></tr>";
1651 print"<tr><td colspan='8'><br></td></tr>";
1653 print"<tr><td colspan='2'></td><td width='1%'><input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}></td><td width='20%'>$Lang::tr{'fwdfw snat'}</td>";
1654 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='snat' style='width:140px;'>";
1655 print "<option value='Default IP' $selected{'snat'}{'Default IP'}>Default IP</option>";
1656 foreach my $alias (sort keys %aliases)
1658 print "<option value='$alias' $selected{'snat'}{$alias}>$alias</option>";
1660 foreach my $network (sort keys %defaultNetworks)
1662 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1663 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1664 next if($defaultNetworks{$network}{'NAME'} eq "ALL");
1665 next if($defaultNetworks{$network}{'NAME'} =~ /OpenVPN/i);
1666 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1667 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'nat'}} eq $defaultNetworks{$network}{'NAME'});
1668 print ">$network</option>";
1672 &Header
::closebox
();
1673 #---Activate/logging/remark-------------------------------------
1674 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1676 <table width='100%' border='0'>
1677 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1679 foreach ("ACCEPT","DROP","REJECT")
1681 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1682 print"<option value='$_'";
1683 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1684 print">$Lang::tr{'fwdfw '.$_}</option>";
1686 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1687 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1689 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1691 print"<option value='$_' selected>$Lang::tr{'fwdfw '.$_}</option>";
1693 print"<option value='$_'>$Lang::tr{'fwdfw '.$_}</option>";
1697 print"</select></td></tr>";
1698 print"<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>";
1699 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1700 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1701 for (my $count =1; $count <= $sum; $count++){
1702 print"<option value='$count' ";
1703 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1704 print">$count</option>";
1706 print"</select></td></tr>";
1708 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1712 </table><table width='100%'>
1713 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1714 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1717 &Header
::closebox
();
1718 #---ADD TIMEFRAME-----------------------------------------------
1719 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1721 <table width='70%' border='0'>
1722 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1723 <tr><td colspan='7'> </td></tr>
1725 <td align='left'>$Lang::tr{'time'}:</td>
1726 <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>
1727 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1728 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1731 <td align='right'></td>
1732 <td width='30%' align='left'>
1733 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1734 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1735 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1736 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1737 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1738 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1739 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1741 <td><select name='TIME_FROM'>
1743 for (my $i=0;$i<=23;$i++) {
1744 $i = sprintf("%02s",$i);
1745 for (my $j=0;$j<=45;$j+=15) {
1746 $j = sprintf("%02s",$j);
1747 my $time = $i.":".$j;
1748 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1753 <td><select name='TIME_TO'>
1755 for (my $i=0;$i<=23;$i++) {
1756 $i = sprintf("%02s",$i);
1757 for (my $j=0;$j<=45;$j+=15) {
1758 $j = sprintf("%02s",$j);
1759 my $time = $i.":".$j;
1760 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1767 #---ACTION------------------------------------------------------
1768 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1770 <table border='0' width='100%'>
1771 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1772 <input type='hidden' name='config' value='$config' >
1773 <input type='hidden' name='ACTION' value='saverule' >
1774 </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>
1779 <table border='0' width='100%'>
1780 <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'}'>
1781 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1782 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1783 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1784 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1785 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1786 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1787 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1788 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1789 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1790 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1791 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1792 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
1793 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
1794 <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>
1798 &Header
::closebox
();
1804 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
1805 foreach my $key (sort keys %uphash){
1806 if ($key eq $fwdfwsettings{'key'}) {
1808 if (exists $uphash{$last}){
1810 foreach my $y (0 .. $#{$uphash{$last}}) {
1811 $tmp{0}[$y] = $uphash{$last}[$y];
1813 #copy active rule to last
1814 foreach my $i (0 .. $#{$uphash{$last}}) {
1815 $uphash{$last}[$i] = $uphash{$key}[$i];
1817 #copy saved rule to actual position
1818 foreach my $x (0 .. $#{$tmp{0}}) {
1819 $uphash{$key}[$x] = $tmp{0}[$x];
1824 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
1831 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
1832 foreach my $key (sort keys %downhash){
1833 if ($key eq $fwdfwsettings{'key'}) {
1834 my $next = $key + 1;
1835 if (exists $downhash{$next}){
1837 foreach my $y (0 .. $#{$downhash{$next}}) {
1838 $tmp{0}[$y] = $downhash{$next}[$y];
1840 #copy active rule to next
1841 foreach my $i (0 .. $#{$downhash{$next}}) {
1842 $downhash{$next}[$i] = $downhash{$key}[$i];
1844 #copy saved rule to actual position
1845 foreach my $x (0 .. $#{$tmp{0}}) {
1846 $downhash{$key}[$x] = $tmp{0}[$x];
1851 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
1856 if (!-f
"${General::swroot}/forward/reread"){
1857 system("touch ${General::swroot}/forward/reread");
1858 system("touch ${General::swroot}/fwhosts/reread");
1863 system("/usr/local/bin/forwardfwctrl");
1864 if ( -f
"${General::swroot}/forward/reread"){
1865 system("rm ${General::swroot}/forward/reread");
1866 system("rm ${General::swroot}/fwhosts/reread");
1873 &General
::readhasharray
("$config", $hash);
1874 if (!$errormessage){
1875 ################################################################
1876 #check if we change an INPUT rule to a OUTGOING
1877 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
1878 &changerule
($configinput);
1881 #check if we change an INPUT rule to a FORWARD
1882 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
1883 &changerule
($configinput);
1886 ################################################################
1887 #check if we change an OUTGOING rule to an INPUT
1888 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
1889 &changerule
($configoutgoing);
1892 #check if we change an OUTGOING rule to a FORWARD
1893 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
1894 &changerule
($configoutgoing);
1897 ################################################################
1898 #check if we change a FORWARD rule to an INPUT
1899 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
1900 &changerule
($configfwdfw);
1903 #check if we change a FORWARD rule to an OUTGOING
1904 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
1905 &changerule
($configfwdfw);
1908 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1909 my $key = &General
::findhasharraykey
($hash);
1910 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1911 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1912 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1913 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1914 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1915 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1916 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1917 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1918 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1919 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1920 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1921 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1922 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1923 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1924 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1925 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1926 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1927 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1928 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1929 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1930 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1931 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1932 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1933 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1934 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1935 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1936 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1937 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1938 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
1939 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
1940 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
1941 $$hash{$key}[31] = $fwdfwsettings{'nat'};
1942 &General
::writehasharray
("$config", $hash);
1944 foreach my $key (sort {$a <=> $b} keys %$hash){
1945 if($key eq $fwdfwsettings{'key'}){
1946 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1947 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1948 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1949 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1950 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1951 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1952 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1953 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1954 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1955 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1956 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1957 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1958 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1959 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1960 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1961 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1962 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1963 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1964 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1965 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1966 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1967 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1968 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1969 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1970 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1971 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1972 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1973 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1974 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
1975 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
1976 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
1977 $$hash{$key}[31] = $fwdfwsettings{'nat'};
1982 &General
::writehasharray
("$config", $hash);
1983 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
1985 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1986 for (my $z=0;$z<$val;$z++){
1987 foreach my $key (sort {$a <=> $b} keys %$hash){
1988 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1990 if (exists $$hash{$last}){
1992 foreach my $y (0 .. $#{$$hash{$last}}) {
1993 $tmp{0}[$y] = $$hash{$last}[$y];
1995 #copy active rule to last
1996 foreach my $i (0 .. $#{$$hash{$last}}) {
1997 $$hash{$last}[$i] = $$hash{$key}[$i];
1999 #copy saved rule to actual position
2000 foreach my $x (0 .. $#{$tmp{0}}) {
2001 $$hash{$key}[$x] = $tmp{0}[$x];
2006 $fwdfwsettings{'oldrulenumber'}--;
2008 &General
::writehasharray
("$config", $hash);
2010 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2012 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2013 for (my $z=0;$z<$val;$z++){
2014 foreach my $key (sort {$a <=> $b} keys %$hash){
2015 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2016 my $next = $key + 1;
2017 if (exists $$hash{$next}){
2019 foreach my $y (0 .. $#{$$hash{$next}}) {
2020 $tmp{0}[$y] = $$hash{$next}[$y];
2022 #copy active rule to next
2023 foreach my $i (0 .. $#{$$hash{$next}}) {
2024 $$hash{$next}[$i] = $$hash{$key}[$i];
2026 #copy saved rule to actual position
2027 foreach my $x (0 .. $#{$tmp{0}}) {
2028 $$hash{$key}[$x] = $tmp{0}[$x];
2033 $fwdfwsettings{'oldrulenumber'}++;
2035 &General
::writehasharray
("$config", $hash);
2042 # Checks a hostname against RFC1035
2045 # Each part should be at least two characters in length
2046 # but no more than 63 characters
2047 if (length ($remark) < 1 || length ($remark) > 255) {
2049 # Only valid characters are a-z, A-Z, 0-9 and -
2050 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2052 # First character can only be a letter or a digit
2053 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2055 # Last character can only be a letter or a digit
2056 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2062 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2063 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
2064 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'fwdfw xt access'} );
2065 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
2074 &General
::get_aliases
(\
%aliases);
2075 &General
::readhasharray
("$confighost", \
%customhost);
2076 &General
::readhasharray
("$config", $hash);
2077 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2078 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2080 &Header
::openbox
('100%', 'left',$title);
2088 print"<b>$title1</b><br>";
2089 print"<table width='100%' cellspacing='0' cellpadding='0' border='0'>";
2090 print"<tr><td align='center'><b>#</td><td ></td><td align='center'><b>$Lang::tr{'fwdfw source'}</td><td width='1%'><b>Log</td><td align='center'><b>$Lang::tr{'fwdfw target'}</td><td align='center' width='25'></td><td align='center' colspan='6' width='1%'><b>$Lang::tr{'fwdfw action'}</td></tr>";#<td align='center'><b>$Lang::tr{'fwdfw time'}</td><b>$Lang::tr{'protocol'}</b>
2091 foreach my $key (sort {$a <=> $b} keys %$hash){
2094 #check if vpn hosts/nets have been deleted
2095 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2096 push (@tmpsrc,$$hash{$key}[4]);
2098 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2099 push (@tmpsrc,$$hash{$key}[6]);
2101 foreach my $host (@tmpsrc){
2102 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2103 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2105 &disable_rule
($key);
2108 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2109 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2111 &disable_rule
($key);
2114 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2115 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2117 &disable_rule
($key);
2120 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2121 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2123 &disable_rule
($key);
2128 $$hash{'ACTIVE'}=$$hash{$key}[2];
2130 if($coloryellow eq 'on'){
2131 print"<tr bgcolor='$color{'color14'}' >";
2133 }elsif($coloryellow eq ''){
2135 $color="$color{'color22'}";
2138 $color="$color{'color20'}";
2141 print"<tr bgcolor='$color' >";
2143 <td align='right' width='18'><b>$key  </b></td>
2145 if ($$hash{$key}[0] eq 'ACCEPT'){
2148 $rulecolor=$color{'color17'};
2149 }elsif($$hash{$key}[0] eq 'DROP'){
2152 $rulecolor=$color{'color25'};
2153 }elsif($$hash{$key}[0] eq 'REJECT'){
2156 $rulecolor=$color{'color16'};
2158 print"<td bgcolor='$rulecolor' align='center' width='10'><span title='$tooltip'><b>$ruletype</b></span></td>";
2159 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2160 print"<td align='center' width='160' $tdcolor>";
2161 if ($$hash{$key}[3] eq 'std_net_src'){
2162 print &get_name
($$hash{$key}[4]);
2163 }elsif ($$hash{$key}[3] eq 'src_addr'){
2164 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2165 if ($split2 eq '32'){
2168 print $$hash{$key}[4];
2171 print $$hash{$key}[4];
2174 &getsrcport
(\
%$hash,$key);
2175 #Is this a SNAT rule?
2176 if ($$hash{$key}[31] eq 'snat'){
2177 print"<br>-> $$hash{$key}[29]";
2178 if ($$hash{$key}[30] ne ''){
2179 print": $$hash{$key}[30]";
2182 if ($$hash{$key}[17] eq 'ON'){
2183 $log="/images/on.gif";
2185 $log="/images/off.gif";
2189 <form method='post'>
2190 <td align='left' width='25'><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 ;'/>
2191 <input type='hidden' name='key' value='$key' />
2192 <input type='hidden' name='config' value='$config' />
2193 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2196 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2198 <td align='center' width='160' $tdcolor>
2200 #Is this a DNAT rule?
2201 if ($$hash{$key}[31] eq 'dnat'){
2202 print "IPFire ($$hash{$key}[29])";
2203 if($$hash{$key}[30] ne ''){
2204 $$hash{$key}[30]=~ tr/|/,/;
2205 print": $$hash{$key}[30]";
2209 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire' && $$hash{$key}[6] eq 'RED' || $$hash{$key}[6] eq 'RED1' || $$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE' ){
2210 if ($$hash{$key}[6] eq 'RED1')
2212 print $Lang::tr
{'red1'};
2214 print &get_name
($$hash{$key}[6]);
2216 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2217 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2218 if ($split2 eq '32'){
2221 print $$hash{$key}[6];
2224 print $$hash{$key}[6];
2227 &gettgtport
(\
%$hash,$key);
2231 if ($$hash{$key}[8] && $$hash{$key}[7] eq 'ON'){#source prot if manual
2232 push (@protocols,$$hash{$key}[8]);
2233 }elsif ($$hash{$key}[12]){ #target prot if manual
2234 push (@protocols,$$hash{$key}[12]);
2235 }elsif($$hash{$key}[14] eq 'cust_srv'){
2236 &get_serviceports
("service",$$hash{$key}[15]);
2237 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2238 &get_serviceports
("group",$$hash{$key}[15]);
2240 push (@protocols,$Lang::tr
{'all'});
2242 my $protz=join(",",@protocols);
2243 print"<td align='center'>$protz</td>";
2246 if($$hash{$key}[2] eq 'ON'){
2247 $gif="/images/on.gif"
2250 $gif="/images/off.gif"
2253 <form method='post'>
2254 <td width='25'><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;' />
2255 <input type='hidden' name='key' value='$key' />
2256 <input type='hidden' name='config' value='$config' />
2257 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2259 <form method='post'>
2260 <td width='25' ><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;' />
2261 <input type='hidden' name='key' value='$key' />
2262 <input type='hidden' name='config' value='$config' />
2263 <input type='hidden' name='ACTION' value='editrule' />
2265 <form method='post'>
2266 <td width='25'><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;' />
2267 <input type='hidden' name='key' value='$key' />
2268 <input type='hidden' name='config' value='$config' />
2269 <input type='hidden' name='ACTION' value='copyrule' />
2271 <form method='post'>
2272 <td width='25' ><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;' />
2273 <input type='hidden' name='key' value='$key' />
2274 <input type='hidden' name='config' value='$config' />
2275 <input type='hidden' name='ACTION' value='deleterule' />
2278 if (exists $$hash{$key-1}){
2280 <form method='post'>
2281 <td width='25'><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;' />
2282 <input type='hidden' name='key' value='$key' />
2283 <input type='hidden' name='config' value='$config' />
2284 <input type='hidden' name='ACTION' value='moveup' />
2288 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2290 if (exists $$hash{$key+1}){
2292 <form method='post'>
2293 <td width='25' ><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;' />
2294 <input type='hidden' name='key' value='$key' />
2295 <input type='hidden' name='config' value='$config' />
2296 <input type='hidden' name='ACTION' value='movedown' />
2297 </td></form></td></tr>
2300 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2303 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2304 print"<tr bgcolor='$color'>";
2305 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='10'>  $$hash{$key}[16]</td></tr>";
2307 if ($$hash{$key}[18] eq 'ON'){
2309 if ($$hash{$key}[18] eq 'ON'){
2311 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2312 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2313 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2314 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2315 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2316 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2317 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2318 my $weekdays=join(",",@days);
2320 print"<tr bgcolor='$color'>";
2321 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'>$weekdays   $$hash{$key}[26] - $$hash{$key}[27] </td></tr>";
2325 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2328 &Header
::closebox
();
2332 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2333 print "<b>$title1</b><br>";
2334 print"<table width='100%' border='0' rules='none'><tr><td height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td></tr></table><br><br>";
2338 &Header
::closebigbox
();
2339 &Header
::closepage
();