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