]>
Commit | Line | Data |
---|---|---|
2a81ab0d AM |
1 | #!/usr/bin/perl |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5bee9a9d | 5 | # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> # |
2a81ab0d AM |
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 | ############################################################################### | |
2a81ab0d AM |
21 | |
22 | use strict; | |
eff2dbf8 | 23 | use Sort::Naturally; |
323923d9 MT |
24 | use utf8; |
25 | use feature 'unicode_strings'; | |
26 | ||
2a81ab0d | 27 | no warnings 'uninitialized'; |
323923d9 | 28 | |
2a81ab0d AM |
29 | # enable only the following on debugging purpose |
30 | #use warnings; | |
31 | #use CGI::Carp 'fatalsToBrowser'; | |
32 | ||
33 | require '/var/ipfire/general-functions.pl'; | |
f770b728 | 34 | require '/var/ipfire/network-functions.pl'; |
2a81ab0d AM |
35 | require "${General::swroot}/lang.pl"; |
36 | require "${General::swroot}/header.pl"; | |
c0a97a0f | 37 | require "${General::swroot}/geoip-functions.pl"; |
fe307136 | 38 | require "/usr/lib/firewall/firewall-lib.pl"; |
2a81ab0d | 39 | |
6d8eb5de AM |
40 | unless (-d "${General::swroot}/firewall") { system("mkdir ${General::swroot}/firewall"); } |
41 | unless (-e "${General::swroot}/firewall/settings") { system("touch ${General::swroot}/firewall/settings"); } | |
42 | unless (-e "${General::swroot}/firewall/config") { system("touch ${General::swroot}/firewall/config"); } | |
43 | unless (-e "${General::swroot}/firewall/input") { system("touch ${General::swroot}/firewall/input"); } | |
44 | unless (-e "${General::swroot}/firewall/outgoing") { system("touch ${General::swroot}/firewall/outgoing"); } | |
2a81ab0d AM |
45 | |
46 | my %fwdfwsettings=(); | |
47 | my %selected=() ; | |
48 | my %defaultNetworks=(); | |
49 | my %netsettings=(); | |
50 | my %customhost=(); | |
51 | my %customgrp=(); | |
c0a97a0f | 52 | my %customgeoipgrp=(); |
2a81ab0d AM |
53 | my %customnetworks=(); |
54 | my %customservice=(); | |
55 | my %customservicegrp=(); | |
56 | my %ccdnet=(); | |
57 | my %customnetwork=(); | |
58 | my %ccdhost=(); | |
59 | my %configfwdfw=(); | |
60 | my %configinputfw=(); | |
c7043621 | 61 | my %configoutgoingfw=(); |
2a81ab0d AM |
62 | my %ipsecconf=(); |
63 | my %color=(); | |
64 | my %mainsettings=(); | |
65 | my %checked=(); | |
66 | my %icmptypes=(); | |
67 | my %ovpnsettings=(); | |
68 | my %ipsecsettings=(); | |
69 | my %aliases=(); | |
15add1c8 | 70 | my %optionsfw=(); |
2669161d | 71 | my %ifaces=(); |
84a05311 | 72 | my %rulehash=(); |
c7043621 | 73 | |
11760a70 | 74 | my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE","IPv6","IPIP"); |
a1e89f48 | 75 | |
2a81ab0d AM |
76 | my $color; |
77 | my $confignet = "${General::swroot}/fwhosts/customnetworks"; | |
78 | my $confighost = "${General::swroot}/fwhosts/customhosts"; | |
79 | my $configgrp = "${General::swroot}/fwhosts/customgroups"; | |
c0a97a0f | 80 | my $configgeoipgrp = "${General::swroot}/fwhosts/customgeoipgrp"; |
2a81ab0d AM |
81 | my $configsrv = "${General::swroot}/fwhosts/customservices"; |
82 | my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp"; | |
83 | my $configccdnet = "${General::swroot}/ovpn/ccd.conf"; | |
84 | my $configccdhost = "${General::swroot}/ovpn/ovpnconfig"; | |
85 | my $configipsec = "${General::swroot}/vpn/config"; | |
86 | my $configipsecrw = "${General::swroot}/vpn/settings"; | |
6d8eb5de AM |
87 | my $configfwdfw = "${General::swroot}/firewall/config"; |
88 | my $configinput = "${General::swroot}/firewall/input"; | |
89 | my $configoutgoing = "${General::swroot}/firewall/outgoing"; | |
2a81ab0d | 90 | my $configovpn = "${General::swroot}/ovpn/settings"; |
15add1c8 | 91 | my $fwoptions = "${General::swroot}/optionsfw/settings"; |
2669161d | 92 | my $ifacesettings = "${General::swroot}/ethernet/settings"; |
2a81ab0d AM |
93 | my $errormessage=''; |
94 | my $hint=''; | |
95 | my $ipgrp="${General::swroot}/outgoing/groups"; | |
15add1c8 | 96 | my $tdcolor=''; |
515863e2 | 97 | my $checkorange=''; |
b3f4a4ef | 98 | my @protocols; |
6d8eb5de | 99 | &General::readhash("${General::swroot}/firewall/settings", \%fwdfwsettings); |
2a81ab0d AM |
100 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); |
101 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
15add1c8 | 102 | &General::readhash($fwoptions, \%optionsfw); |
2669161d | 103 | &General::readhash($ifacesettings, \%ifaces); |
931e1fed AM |
104 | &General::readhash("$configovpn", \%ovpnsettings); |
105 | &General::readhash("$configipsecrw", \%ipsecsettings); | |
106 | &General::readhasharray("$configipsec", \%ipsecconf); | |
2a81ab0d AM |
107 | &Header::showhttpheaders(); |
108 | &Header::getcgihash(\%fwdfwsettings); | |
cc81c430 | 109 | &Header::openpage($Lang::tr{'firewall rules'}, 1, ''); |
2a81ab0d | 110 | &Header::openbigbox('100%', 'center',$errormessage); |
b88c8829 AM |
111 | #### JAVA SCRIPT #### |
112 | print<<END; | |
113 | <script> | |
a1e89f48 MT |
114 | var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"]; |
115 | ||
116 | var update_protocol = function() { | |
117 | var protocol = \$("#protocol").val(); | |
118 | ||
119 | if (protocol === undefined) | |
120 | return; | |
121 | ||
122 | // Check if a template is/should be used. | |
123 | if (protocol === "template") { | |
124 | \$("#PROTOCOL_TEMPLATE").show(); | |
125 | } else { | |
126 | \$("#PROTOCOL_TEMPLATE").hide(); | |
a5cb9aca | 127 | } |
a1e89f48 MT |
128 | |
129 | // Check if we are dealing with a protocol, that knows ports. | |
130 | if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) { | |
131 | \$("#PROTOCOL_PORTS").show(); | |
132 | } else { | |
133 | \$("#PROTOCOL_PORTS").hide(); | |
a5cb9aca | 134 | } |
a1e89f48 MT |
135 | |
136 | // Handle ICMP. | |
137 | if (protocol === "ICMP") { | |
138 | \$("#PROTOCOL_ICMP_TYPES").show(); | |
139 | } else { | |
140 | \$("#PROTOCOL_ICMP_TYPES").hide(); | |
a5cb9aca | 141 | } |
a1e89f48 MT |
142 | }; |
143 | ||
144 | \$(document).ready(function() { | |
145 | \$("#protocol").change(update_protocol); | |
146 | update_protocol(); | |
147 | ||
bfaa6956 SS |
148 | // Show/Hide elements when NAT checkbox is checked. |
149 | if (\$("#USE_NAT").attr("checked")) { | |
150 | \$("#actions").hide(); | |
151 | } else { | |
6bcb5ffe | 152 | \$(".NAT").hide(); |
ec6fd189 AM |
153 | } |
154 | ||
155 | // Show NAT area when "use nat" checkbox is clicked | |
93e0855b | 156 | \$("#USE_NAT").change(function() { |
6bcb5ffe | 157 | \$(".NAT").toggle(); |
bfaa6956 | 158 | \$("#actions").toggle(); |
a5cb9aca | 159 | }); |
a1e89f48 | 160 | |
c98b743c SS |
161 | // Hide SNAT items when DNAT is selected and vice versa. |
162 | if (\$('input[name=nat]:checked').val() == 'dnat') { | |
163 | \$('.snat').hide(); | |
164 | } else { | |
165 | \$('.dnat').hide(); | |
166 | } | |
167 | ||
168 | // Show/Hide elements when SNAT/DNAT get changed. | |
169 | \$('input[name=nat]').change(function() { | |
170 | \$('.snat').toggle(); | |
171 | \$('.dnat').toggle(); | |
172 | }); | |
173 | ||
f18c3831 MT |
174 | // Time constraints |
175 | if(!\$("#USE_TIME_CONSTRAINTS").attr("checked")) { | |
176 | \$("#TIME_CONSTRAINTS").hide(); | |
177 | } | |
178 | \$("#USE_TIME_CONSTRAINTS").change(function() { | |
179 | \$("#TIME_CONSTRAINTS").toggle(); | |
180 | }); | |
181 | ||
79ad6f7e AM |
182 | // Limit concurrent connections per ip |
183 | if(!\$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").attr("checked")) { | |
184 | \$("#LIMIT_CON").hide(); | |
185 | } | |
186 | \$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").change(function() { | |
187 | \$("#LIMIT_CON").toggle(); | |
188 | }); | |
189 | ||
d8deec0b AM |
190 | // Rate-limit new connections |
191 | if(!\$("#USE_RATELIMIT").attr("checked")) { | |
192 | \$("#RATELIMIT").hide(); | |
193 | } | |
194 | \$("#USE_RATELIMIT").change(function() { | |
195 | \$("#RATELIMIT").toggle(); | |
196 | }); | |
197 | ||
b88c8829 AM |
198 | // Automatically select radio buttons when corresponding |
199 | // dropdown menu changes. | |
200 | \$("select").change(function() { | |
201 | var id = \$(this).attr("name"); | |
b88c8829 AM |
202 | \$('#' + id).prop("checked", true); |
203 | }); | |
204 | }); | |
b88c8829 AM |
205 | </script> |
206 | END | |
207 | ||
2a81ab0d AM |
208 | #### ACTION ##### |
209 | ||
2a81ab0d AM |
210 | if ($fwdfwsettings{'ACTION'} eq 'saverule') |
211 | { | |
212 | &General::readhasharray("$configfwdfw", \%configfwdfw); | |
213 | &General::readhasharray("$configinput", \%configinputfw); | |
5d7faa45 | 214 | &General::readhasharray("$configoutgoing", \%configoutgoingfw); |
84a05311 | 215 | my $maxkey; |
79bb8c75 AM |
216 | #Set Variables according to the JQuery code in protocol section |
217 | if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') | |
218 | { | |
219 | if ($fwdfwsettings{'SRC_PORT'} ne '') | |
220 | { | |
221 | $fwdfwsettings{'USE_SRC_PORT'} = 'ON'; | |
222 | } | |
223 | if ($fwdfwsettings{'TGT_PORT'} ne '') | |
224 | { | |
225 | $fwdfwsettings{'USESRV'} = 'ON'; | |
226 | $fwdfwsettings{'grp3'} = 'TGT_PORT'; | |
227 | } | |
228 | } | |
229 | if ($fwdfwsettings{'PROT'} eq 'template') | |
230 | { | |
231 | $fwdfwsettings{'USESRV'} = 'ON'; | |
232 | } | |
2a81ab0d AM |
233 | $errormessage=&checksource; |
234 | if(!$errormessage){&checktarget;} | |
235 | if(!$errormessage){&checkrule;} | |
abb3cfcc | 236 | |
515863e2 AM |
237 | #check if manual ip (source) is orange network |
238 | if ($fwdfwsettings{'grp1'} eq 'src_addr'){ | |
239 | my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}}); | |
240 | if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){ | |
241 | $checkorange='on'; | |
242 | } | |
243 | } | |
244 | #check useless rules | |
245 | if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){ | |
246 | $errormessage.=$Lang::tr{'fwdfw useless rule'}."<br>"; | |
247 | } | |
c7043621 | 248 | #check if we try to break rules |
d4cb89d2 | 249 | if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){ |
cb4439f3 | 250 | $errormessage=$Lang::tr{'fwdfw err same'}; |
c7043621 | 251 | } |
84a05311 AM |
252 | # INPUT part |
253 | if ($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){ | |
5de39dea | 254 | $fwdfwsettings{'config'}=$configinput; |
2a81ab0d | 255 | $fwdfwsettings{'chain'} = 'INPUTFW'; |
84a05311 AM |
256 | $maxkey=&General::findhasharraykey(\%configinputfw); |
257 | %rulehash=%configinputfw; | |
258 | }elsif ($fwdfwsettings{'grp1'} eq 'ipfire_src' ){ | |
a0fb1099 | 259 | # OUTGOING PART |
c7043621 AM |
260 | $fwdfwsettings{'config'}=$configoutgoing; |
261 | $fwdfwsettings{'chain'} = 'OUTGOINGFW'; | |
84a05311 AM |
262 | $maxkey=&General::findhasharraykey(\%configoutgoingfw); |
263 | %rulehash=%configoutgoingfw; | |
264 | }else { | |
265 | # FORWARD PART | |
5de39dea | 266 | $fwdfwsettings{'config'}=$configfwdfw; |
2a81ab0d | 267 | $fwdfwsettings{'chain'} = 'FORWARDFW'; |
84a05311 AM |
268 | $maxkey=&General::findhasharraykey(\%configfwdfw); |
269 | %rulehash=%configfwdfw; | |
270 | } | |
271 | #check if we have an identical rule already | |
272 | if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){ | |
273 | foreach my $key (sort keys %rulehash){ | |
5ca4ae11 AM |
274 | 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{'ruleremark'},$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'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'},$fwdfwsettings{'RATE_LIMIT'},$fwdfwsettings{'ratecon'},$fwdfwsettings{'RATETIME'}" |
275 | eq "$rulehash{$key}[0],$rulehash{$key}[2],$rulehash{$key}[3],$rulehash{$key}[4],$rulehash{$key}[5],$rulehash{$key}[6],$rulehash{$key}[7],$rulehash{$key}[8],$rulehash{$key}[9],$rulehash{$key}[10],$rulehash{$key}[11],$rulehash{$key}[12],$rulehash{$key}[13],$rulehash{$key}[14],$rulehash{$key}[15],$rulehash{$key}[16],$rulehash{$key}[17],$rulehash{$key}[18],$rulehash{$key}[19],$rulehash{$key}[20],$rulehash{$key}[21],$rulehash{$key}[22],$rulehash{$key}[23],$rulehash{$key}[24],$rulehash{$key}[25],$rulehash{$key}[26],$rulehash{$key}[27],$rulehash{$key}[28],$rulehash{$key}[29],$rulehash{$key}[30],$rulehash{$key}[31],$rulehash{$key}[32],$rulehash{$key}[33],$rulehash{$key}[34],$rulehash{$key}[35],$rulehash{$key}[36]"){ | |
84a05311 AM |
276 | $errormessage.=$Lang::tr{'fwdfw err ruleexists'}; |
277 | if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark($fwdfwsettings{'ruleremark'})){ | |
278 | $errormessage=$Lang::tr{'fwdfw err remark'}."<br>"; | |
279 | } | |
280 | if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark($fwdfwsettings{'ruleremark'})){ | |
281 | $errormessage=''; | |
282 | } | |
283 | if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){ | |
284 | $fwdfwsettings{'nosave'} = 'on'; | |
285 | } | |
2da264ec | 286 | } |
46a6d6c7 | 287 | } |
84a05311 AM |
288 | } |
289 | #check Rulepos on new Rule | |
290 | if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){ | |
291 | $fwdfwsettings{'oldrulenumber'}=$maxkey; | |
292 | foreach my $key (sort keys %rulehash){ | |
293 | if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'},$fwdfwsettings{'RATE_LIMIT'},$fwdfwsettings{'ratecon'},$fwdfwsettings{'RATETIME'}" | |
294 | eq "$rulehash{$key}[0],$rulehash{$key}[2],$rulehash{$key}[3],$rulehash{$key}[4],$rulehash{$key}[5],$rulehash{$key}[6],$rulehash{$key}[7],$rulehash{$key}[8],$rulehash{$key}[9],$rulehash{$key}[10],$rulehash{$key}[11],$rulehash{$key}[12],$rulehash{$key}[13],$rulehash{$key}[14],$rulehash{$key}[15],$rulehash{$key}[18],$rulehash{$key}[19],$rulehash{$key}[20],$rulehash{$key}[21],$rulehash{$key}[22],$rulehash{$key}[23],$rulehash{$key}[24],$rulehash{$key}[25],$rulehash{$key}[26],$rulehash{$key}[27],$rulehash{$key}[28],$rulehash{$key}[29],$rulehash{$key}[30],$rulehash{$key}[31],$rulehash{$key}[32],$rulehash{$key}[33],$rulehash{$key}[34],$rulehash{$key}[35],$rulehash{$key}[36]"){ | |
295 | $errormessage.=$Lang::tr{'fwdfw err ruleexists'}; | |
70d38e50 AM |
296 | } |
297 | } | |
84a05311 AM |
298 | } |
299 | #check if we just close a rule | |
300 | if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'}){ | |
301 | if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){ | |
302 | $fwdfwsettings{'nosave2'} = 'on'; | |
303 | $errormessage=''; | |
992394d5 | 304 | } |
84a05311 AM |
305 | } |
306 | #check max concurrent connections per ip address | |
307 | if ($fwdfwsettings{'LIMIT_CON_CON'} eq 'ON'){ | |
308 | if (!($fwdfwsettings{'concon'} =~ /^(\d+)$/)) { | |
309 | $errormessage.=$Lang::tr{'fwdfw err concon'}; | |
79ad6f7e | 310 | } |
84a05311 AM |
311 | }else{ |
312 | $fwdfwsettings{'concon'}=''; | |
313 | } | |
314 | #check ratelimit value | |
315 | if ($fwdfwsettings{'RATE_LIMIT'} eq 'ON'){ | |
316 | if (!($fwdfwsettings{'ratecon'} =~ /^(\d+)$/)) { | |
317 | $errormessage.=$Lang::tr{'fwdfw err ratecon'}; | |
d8deec0b | 318 | } |
84a05311 AM |
319 | }else{ |
320 | $fwdfwsettings{'ratecon'}=''; | |
321 | } | |
322 | #increase counters | |
323 | if (!$errormessage){ | |
324 | if ($fwdfwsettings{'nosave2'} ne 'on'){ | |
325 | &saverule(\%rulehash,$fwdfwsettings{'config'}); | |
2a81ab0d | 326 | } |
2a81ab0d AM |
327 | } |
328 | if ($errormessage){ | |
329 | &newrule; | |
330 | }else{ | |
992394d5 | 331 | if($fwdfwsettings{'nosave2'} ne 'on'){ |
0e430797 | 332 | &General::firewall_config_changed(); |
992394d5 | 333 | } |
2a81ab0d AM |
334 | &base; |
335 | } | |
2a81ab0d | 336 | } |
2a81ab0d AM |
337 | if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw newrule'}) |
338 | { | |
339 | &newrule; | |
340 | } | |
341 | if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw toggle'}) | |
342 | { | |
343 | my %togglehash=(); | |
344 | &General::readhasharray($fwdfwsettings{'config'}, \%togglehash); | |
345 | foreach my $key (sort keys %togglehash){ | |
346 | if ($key eq $fwdfwsettings{'key'}){ | |
347 | if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';} | |
348 | } | |
349 | } | |
350 | &General::writehasharray($fwdfwsettings{'config'}, \%togglehash); | |
0e430797 | 351 | &General::firewall_config_changed(); |
2a81ab0d AM |
352 | &base; |
353 | } | |
354 | if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw togglelog'}) | |
355 | { | |
356 | my %togglehash=(); | |
357 | &General::readhasharray($fwdfwsettings{'config'}, \%togglehash); | |
358 | foreach my $key (sort keys %togglehash){ | |
359 | if ($key eq $fwdfwsettings{'key'}){ | |
360 | if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';} | |
361 | } | |
362 | } | |
363 | &General::writehasharray($fwdfwsettings{'config'}, \%togglehash); | |
0e430797 | 364 | &General::firewall_config_changed(); |
2a81ab0d AM |
365 | &base; |
366 | } | |
367 | if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw reread'}) | |
368 | { | |
0e430797 | 369 | &General::firewall_reload(); |
2a81ab0d AM |
370 | &base; |
371 | } | |
372 | if ($fwdfwsettings{'ACTION'} eq 'editrule') | |
373 | { | |
374 | $fwdfwsettings{'updatefwrule'}='on'; | |
375 | &newrule; | |
376 | } | |
377 | if ($fwdfwsettings{'ACTION'} eq 'deleterule') | |
378 | { | |
379 | &deleterule; | |
380 | } | |
381 | if ($fwdfwsettings{'ACTION'} eq 'moveup') | |
382 | { | |
383 | &pos_up; | |
384 | &base; | |
385 | } | |
386 | if ($fwdfwsettings{'ACTION'} eq 'movedown') | |
387 | { | |
388 | &pos_down; | |
389 | &base; | |
390 | } | |
391 | if ($fwdfwsettings{'ACTION'} eq 'copyrule') | |
392 | { | |
393 | $fwdfwsettings{'copyfwrule'}='on'; | |
2a81ab0d AM |
394 | &newrule; |
395 | } | |
653a71b9 | 396 | if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset') |
2a81ab0d AM |
397 | { |
398 | &base; | |
399 | } | |
400 | ### Functions #### | |
8013bd0a | 401 | sub addrule |
2a81ab0d | 402 | { |
8013bd0a | 403 | &error; |
85d6e8a9 | 404 | |
c03d4a5e | 405 | &Header::openbox('100%', 'left', ""); |
85d6e8a9 MT |
406 | print <<END; |
407 | <form method="POST" action=""> | |
408 | <table border='0' width="100%"> | |
409 | <tr> | |
c03d4a5e | 410 | <td align='center'> |
85d6e8a9 | 411 | <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'> |
85d6e8a9 MT |
412 | END |
413 | ||
0e430797 | 414 | if (&General::firewall_needs_reload()) { |
85d6e8a9 MT |
415 | print <<END; |
416 | <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-weight: bold; color: green;'> | |
417 | END | |
418 | } | |
419 | ||
420 | print <<END; | |
421 | </td> | |
422 | </tr> | |
423 | </table> | |
424 | </form> | |
425 | ||
c03d4a5e | 426 | <br> |
85d6e8a9 | 427 | END |
c03d4a5e | 428 | |
8013bd0a AM |
429 | &Header::closebox(); |
430 | &viewtablerule; | |
2a81ab0d AM |
431 | } |
432 | sub base | |
433 | { | |
2a81ab0d | 434 | &hint; |
7bd9d462 | 435 | &addrule; |
2a81ab0d | 436 | } |
8013bd0a | 437 | sub changerule |
2a81ab0d | 438 | { |
8013bd0a AM |
439 | my $oldchain=shift; |
440 | $fwdfwsettings{'updatefwrule'}=''; | |
441 | $fwdfwsettings{'config'}=$oldchain; | |
442 | $fwdfwsettings{'nobase'}='on'; | |
443 | &deleterule; | |
2a81ab0d AM |
444 | } |
445 | sub checksource | |
446 | { | |
447 | my ($ip,$subnet); | |
2a81ab0d AM |
448 | #check ip-address if manual |
449 | if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){ | |
450 | #check if ip with subnet | |
451 | if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?)$/) { | |
452 | ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'}); | |
453 | $subnet = &General::iporsubtocidr($subnet); | |
b5269091 | 454 | $fwdfwsettings{'isip'}='on'; |
2a81ab0d AM |
455 | } |
456 | #check if only ip | |
457 | if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){ | |
458 | $ip=$fwdfwsettings{'src_addr'}; | |
459 | $subnet = '32'; | |
b5269091 | 460 | $fwdfwsettings{'isip'}='on'; |
2a81ab0d | 461 | } |
36196d0d | 462 | |
b5269091 | 463 | if ($fwdfwsettings{'isip'} ne 'on'){ |
ab4fe66f AM |
464 | if (&General::validmac($fwdfwsettings{'src_addr'})){ |
465 | $fwdfwsettings{'ismac'}='on'; | |
466 | } | |
b5269091 AM |
467 | } |
468 | if ($fwdfwsettings{'isip'} eq 'on'){ | |
f770b728 AM |
469 | #remove leading zero |
470 | $ip = &Network::ip_remove_zero($ip); | |
471 | ||
931e1fed AM |
472 | ##check if ip is valid |
473 | if (! &General::validip($ip)){ | |
474 | $errormessage.=$Lang::tr{'fwdfw err src_addr'}."<br>"; | |
475 | return $errormessage; | |
476 | } | |
b5269091 AM |
477 | #check and form valid IP |
478 | $ip=&General::ip2dec($ip); | |
479 | $ip=&General::dec2ip($ip); | |
480 | #check if net or broadcast | |
d9b691e1 | 481 | $fwdfwsettings{'src_addr'}="$ip/$subnet"; |
b5269091 AM |
482 | if(!&General::validipandmask($fwdfwsettings{'src_addr'})){ |
483 | $errormessage.=$Lang::tr{'fwdfw err src_addr'}."<br>"; | |
931e1fed | 484 | return $errormessage; |
b5269091 AM |
485 | } |
486 | } | |
487 | if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){ | |
2a81ab0d | 488 | $errormessage.=$Lang::tr{'fwdfw err src_addr'}."<br>"; |
931e1fed | 489 | return $errormessage; |
2a81ab0d AM |
490 | } |
491 | }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){ | |
2610f393 | 492 | $fwdfwsettings{'grp1'}='std_net_src'; |
9556a0fb | 493 | $fwdfwsettings{$fwdfwsettings{'grp1'}} = 'ALL'; |
2a81ab0d | 494 | } |
62fc8511 | 495 | |
2a81ab0d AM |
496 | #check empty fields |
497 | if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr{'fwdfw err nosrc'}."<br>";} | |
8f0b047b AM |
498 | if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){ |
499 | my @parts=split(",",$fwdfwsettings{'SRC_PORT'}); | |
500 | my @values=(); | |
501 | foreach (@parts){ | |
502 | chomp($_); | |
829697d0 | 503 | if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) { |
8f0b047b AM |
504 | my $check; |
505 | #change dashes with : | |
506 | $_=~ tr/-/:/; | |
507 | if ($_ eq "*") { | |
508 | push(@values,"1:65535"); | |
509 | $check='on'; | |
510 | } | |
829697d0 | 511 | if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) { |
8f0b047b AM |
512 | push(@values,"1:$2"); |
513 | $check='on'; | |
514 | } | |
829697d0 | 515 | if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) { |
8f0b047b AM |
516 | push(@values,"$1:65535"); |
517 | $check='on' | |
518 | } | |
519 | $errormessage .= &General::validportrange($_, 'destination'); | |
520 | if(!$check){ | |
521 | push (@values,$_); | |
522 | } | |
523 | }else{ | |
524 | if (&General::validport($_)){ | |
525 | push (@values,$_); | |
526 | }else{ | |
527 | ||
528 | } | |
529 | } | |
2a81ab0d | 530 | } |
8f0b047b | 531 | $fwdfwsettings{'SRC_PORT'}=join("|",@values); |
2a81ab0d | 532 | } |
931e1fed | 533 | return $errormessage; |
2a81ab0d AM |
534 | } |
535 | sub checktarget | |
536 | { | |
537 | my ($ip,$subnet); | |
a6edca5a | 538 | &General::readhasharray("$configsrv", \%customservice); |
bc912c6e | 539 | #check DNAT settings (has to be single Host and single Port or portrange) |
a6edca5a AM |
540 | if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){ |
541 | if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){ | |
bc912c6e | 542 | #check if Port is a single Port or portrange |
a6edca5a | 543 | if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){ |
a4c7bf6b | 544 | if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){ |
a6edca5a | 545 | $errormessage=$Lang::tr{'fwdfw target'}.": ".$Lang::tr{'fwdfw dnat porterr'}."<br>"; |
931e1fed | 546 | return $errormessage; |
a6edca5a | 547 | } |
a4c7bf6b | 548 | if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport($fwdfwsettings{'TGT_PORT'})){ |
a6edca5a | 549 | $errormessage=$Lang::tr{'fwdfw target'}.": ".$Lang::tr{'fwdfw dnat porterr'}."<br>"; |
931e1fed | 550 | return $errormessage; |
a6edca5a AM |
551 | } |
552 | } | |
553 | }else{ | |
896eb2d6 AM |
554 | if ($fwdfwsettings{'grp2'} ne 'ipfire'){ |
555 | $errormessage=$Lang::tr{'fwdfw dnat error'}."<br>"; | |
556 | return $errormessage; | |
557 | } | |
a6edca5a AM |
558 | } |
559 | } | |
2a81ab0d AM |
560 | if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){ |
561 | #check if ip with subnet | |
562 | if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?)$/) { | |
563 | ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'}); | |
564 | $subnet = &General::iporsubtocidr($subnet); | |
565 | } | |
f770b728 | 566 | |
2a81ab0d AM |
567 | #check if only ip |
568 | if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){ | |
569 | $ip=$fwdfwsettings{'tgt_addr'}; | |
570 | $subnet='32'; | |
571 | } | |
f770b728 AM |
572 | #remove leading zero |
573 | $ip = &Network::ip_remove_zero($ip); | |
574 | ||
931e1fed AM |
575 | #check if ip is valid |
576 | if (! &General::validip($ip)){ | |
577 | $errormessage.=$Lang::tr{'fwdfw err tgt_addr'}."<br>"; | |
578 | return $errormessage; | |
579 | } | |
2a81ab0d AM |
580 | #check and form valid IP |
581 | $ip=&General::ip2dec($ip); | |
582 | $ip=&General::dec2ip($ip); | |
d9b691e1 | 583 | $fwdfwsettings{'tgt_addr'}="$ip/$subnet"; |
2a81ab0d AM |
584 | if(!&General::validipandmask($fwdfwsettings{'tgt_addr'})){ |
585 | $errormessage.=$Lang::tr{'fwdfw err tgt_addr'}."<br>"; | |
931e1fed | 586 | return $errormessage; |
2a81ab0d | 587 | } |
2a81ab0d | 588 | }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){ |
2610f393 | 589 | $fwdfwsettings{'grp2'}='std_net_tgt'; |
9556a0fb | 590 | $fwdfwsettings{$fwdfwsettings{'grp2'}} = 'ALL'; |
2a81ab0d | 591 | } |
d334d7cb AM |
592 | #check for mac in targetgroup |
593 | if ($fwdfwsettings{'grp2'} eq 'cust_grp_tgt'){ | |
594 | &General::readhasharray("$configgrp", \%customgrp); | |
595 | &General::readhasharray("$confighost", \%customhost); | |
596 | foreach my $grpkey (sort keys %customgrp){ | |
597 | foreach my $hostkey (sort keys %customhost){ | |
8b7417c5 | 598 | if ($customgrp{$grpkey}[2] eq $customhost{$hostkey}[0] && $customgrp{$grpkey}[2] eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $customhost{$hostkey}[1] eq 'mac'){ |
d334d7cb AM |
599 | $hint=$Lang::tr{'fwdfw hint mac'}; |
600 | return $hint; | |
601 | } | |
602 | } | |
603 | } | |
604 | } | |
2a81ab0d AM |
605 | #check empty fields |
606 | if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr{'fwdfw err notgt'}."<br>";} | |
2a81ab0d AM |
607 | #check tgt services |
608 | if ($fwdfwsettings{'USESRV'} eq 'ON'){ | |
609 | if ($fwdfwsettings{'grp3'} eq 'cust_srv'){ | |
610 | $fwdfwsettings{'TGT_PROT'}=''; | |
611 | $fwdfwsettings{'ICMP_TGT'}=''; | |
a4c7bf6b | 612 | $fwdfwsettings{'TGT_PORT'}=''; |
2a81ab0d AM |
613 | } |
614 | if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){ | |
615 | $fwdfwsettings{'TGT_PROT'}=''; | |
616 | $fwdfwsettings{'ICMP_TGT'}=''; | |
a4c7bf6b | 617 | $fwdfwsettings{'TGT_PORT'}=''; |
2a81ab0d AM |
618 | #check target service |
619 | if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){ | |
620 | $errormessage.=$Lang::tr{'fwdfw err tgt_grp'}; | |
621 | } | |
622 | } | |
623 | if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){ | |
a4c7bf6b | 624 | if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){ |
2a81ab0d | 625 | if ($fwdfwsettings{'TGT_PORT'} ne ''){ |
08e1c65d | 626 | if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') { |
829697d0 | 627 | $errormessage=$Lang::tr{'fwdfw dnat porterr'}."<br>"; |
931e1fed | 628 | return $errormessage; |
829697d0 | 629 | } |
8f0b047b AM |
630 | my @parts=split(",",$fwdfwsettings{'TGT_PORT'}); |
631 | my @values=(); | |
632 | foreach (@parts){ | |
633 | chomp($_); | |
829697d0 | 634 | if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) { |
8f0b047b AM |
635 | my $check; |
636 | #change dashes with : | |
637 | $_=~ tr/-/:/; | |
638 | if ($_ eq "*") { | |
639 | push(@values,"1:65535"); | |
640 | $check='on'; | |
641 | } | |
829697d0 | 642 | if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) { |
8f0b047b AM |
643 | push(@values,"1:$2"); |
644 | $check='on'; | |
645 | } | |
829697d0 | 646 | if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) { |
8f0b047b AM |
647 | push(@values,"$1:65535"); |
648 | $check='on' | |
649 | } | |
650 | $errormessage .= &General::validportrange($_, 'destination'); | |
651 | if(!$check){ | |
652 | push (@values,$_); | |
653 | } | |
654 | }else{ | |
655 | if (&General::validport($_)){ | |
656 | push (@values,$_); | |
657 | }else{ | |
d0f8bbc1 AM |
658 | $errormessage=$Lang::tr{'fwdfw err tgt_port'}; |
659 | return $errormessage; | |
8f0b047b AM |
660 | } |
661 | } | |
2a81ab0d | 662 | } |
8f0b047b | 663 | $fwdfwsettings{'TGT_PORT'}=join("|",@values); |
2a81ab0d | 664 | } |
a4c7bf6b | 665 | }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){ |
d1f01304 | 666 | $fwdfwsettings{$fwdfwsettings{'grp3'}} = ''; |
bcbf1b8e | 667 | $fwdfwsettings{'TGT_PORT'} = ''; |
62fc8511 | 668 | $fwdfwsettings{'ICMP_TGT'} = ''; |
a4c7bf6b | 669 | }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){ |
d1f01304 | 670 | $fwdfwsettings{$fwdfwsettings{'grp3'}} = ''; |
bcbf1b8e | 671 | $fwdfwsettings{'TGT_PORT'} = ''; |
d1f01304 | 672 | $fwdfwsettings{'ICMP_TGT'}=''; |
a4c7bf6b | 673 | }elsif ($fwdfwsettings{'PROT'} eq 'AH'){ |
d1f01304 | 674 | $fwdfwsettings{$fwdfwsettings{'grp3'}} = ''; |
bcbf1b8e | 675 | $fwdfwsettings{'TGT_PORT'} = ''; |
62fc8511 | 676 | $fwdfwsettings{'ICMP_TGT'}=''; |
a4c7bf6b | 677 | }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){ |
d1f01304 | 678 | $fwdfwsettings{$fwdfwsettings{'grp3'}} = ''; |
bcbf1b8e | 679 | $fwdfwsettings{'TGT_PORT'} = ''; |
2a81ab0d AM |
680 | } |
681 | } | |
682 | } | |
2a81ab0d AM |
683 | #check targetport |
684 | if ($fwdfwsettings{'USESRV'} ne 'ON'){ | |
685 | $fwdfwsettings{'grp3'}=''; | |
686 | $fwdfwsettings{$fwdfwsettings{'grp3'}}=''; | |
2a81ab0d AM |
687 | $fwdfwsettings{'ICMP_TGT'}=''; |
688 | } | |
2a81ab0d AM |
689 | #check timeframe |
690 | if($fwdfwsettings{'TIME'} eq 'ON'){ | |
691 | 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 ''){ | |
692 | $errormessage=$Lang::tr{'fwdfw err time'}; | |
931e1fed | 693 | return $errormessage; |
2a81ab0d AM |
694 | } |
695 | } | |
2a81ab0d AM |
696 | return $errormessage; |
697 | } | |
a6edca5a AM |
698 | sub check_natport |
699 | { | |
700 | my $val=shift; | |
829697d0 AM |
701 | if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){ |
702 | if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) { | |
703 | $fwdfwsettings{'dnatport'} =~ tr/-/:/; | |
704 | if ($fwdfwsettings{'dnatport'} eq "*") { | |
705 | $fwdfwsettings{'dnatport'}="1:65535"; | |
706 | } | |
707 | if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) { | |
708 | $fwdfwsettings{'dnatport'} = "1:$2"; | |
709 | } | |
710 | if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) { | |
711 | $fwdfwsettings{'dnatport'} ="$1:65535"; | |
712 | } | |
713 | } | |
714 | return 1; | |
715 | } | |
716 | if ($val =~ "," || $val>65536 || $val<0){ | |
a6edca5a AM |
717 | return 0; |
718 | } | |
719 | return 1; | |
720 | } | |
2a81ab0d AM |
721 | sub checkrule |
722 | { | |
a6edca5a AM |
723 | #check valid port for NAT |
724 | if($fwdfwsettings{'USE_NAT'} eq 'ON'){ | |
f5f71c79 | 725 | #RULE_ACTION must be ACCEPT if we use NAT |
8e713726 AM |
726 | $fwdfwsettings{'RULE_ACTION'} = 'ACCEPT'; |
727 | ||
f5f71c79 AM |
728 | #if no dnat or snat selected errormessage |
729 | if ($fwdfwsettings{'nat'} eq ''){ | |
730 | $errormessage=$Lang::tr{'fwdfw dnat nochoice'}; | |
731 | return; | |
732 | } | |
733 | ||
734 | #if using snat, the external port has to be empty | |
735 | if ($fwdfwsettings{'nat'} eq 'snat' && $fwdfwsettings{'dnatport'} ne ''){ | |
736 | $errormessage=$Lang::tr{'fwdfw dnat extport'}; | |
737 | return; | |
738 | } | |
3c037075 | 739 | #if no dest port is given in nat area, take target host port |
a6edca5a | 740 | if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};} |
0051027b | 741 | if($fwdfwsettings{'TGT_PORT'} eq '' && $fwdfwsettings{'dnatport'} ne '' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')){ |
3c037075 | 742 | $errormessage=$Lang::tr{'fwdfw dnat porterr2'}; |
f5f71c79 | 743 | return; |
3c037075 | 744 | } |
bc912c6e | 745 | #check if port given in nat area is a single valid port or portrange |
98cee89f | 746 | if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport($fwdfwsettings{'dnatport'})){ |
a6edca5a | 747 | $errormessage=$Lang::tr{'fwdfw target'}.": ".$Lang::tr{'fwdfw dnat porterr'}."<br>"; |
98cee89f | 748 | }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){ |
a6edca5a | 749 | my $custsrvport; |
f5f71c79 | 750 | #get service Protocol and Port |
a6edca5a AM |
751 | foreach my $key (sort keys %customservice){ |
752 | if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){ | |
753 | if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){ | |
754 | $errormessage=$Lang::tr{'fwdfw target'}.": ".$Lang::tr{'fwdfw dnat porterr'}."<br>"; | |
755 | } | |
756 | $custsrvport= $customservice{$key}[1]; | |
757 | } | |
758 | } | |
759 | if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;} | |
760 | } | |
98cee89f AM |
761 | #check if DNAT port is multiple |
762 | if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){ | |
763 | my @parts=split(",",$fwdfwsettings{'dnatport'}); | |
764 | my @values=(); | |
765 | foreach (@parts){ | |
766 | chomp($_); | |
767 | if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) { | |
768 | my $check; | |
769 | #change dashes with : | |
770 | $_=~ tr/-/:/; | |
771 | if ($_ eq "*") { | |
772 | push(@values,"1:65535"); | |
773 | $check='on'; | |
774 | } | |
775 | if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) { | |
776 | push(@values,"1:$2"); | |
777 | $check='on'; | |
778 | } | |
779 | if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) { | |
780 | push(@values,"$1:65535"); | |
781 | $check='on' | |
782 | } | |
783 | $errormessage .= &General::validportrange($_, 'destination'); | |
784 | if(!$check){ | |
785 | push (@values,$_); | |
786 | } | |
787 | }else{ | |
788 | if (&General::validport($_)){ | |
789 | push (@values,$_); | |
790 | }else{ | |
791 | ||
792 | } | |
793 | } | |
794 | } | |
795 | $fwdfwsettings{'dnatport'}=join("|",@values); | |
796 | } | |
ce2dbe92 AM |
797 | #check if a rule with prot tcp or udp and ports is edited and now prot is "all", then delete all ports |
798 | if($fwdfwsettings{'PROT'} eq ''){ | |
799 | $fwdfwsettings{'dnatport'}=''; | |
800 | } | |
a6edca5a | 801 | } |
2a81ab0d AM |
802 | #check valid remark |
803 | if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark($fwdfwsettings{'ruleremark'})){ | |
804 | $errormessage.=$Lang::tr{'fwdfw err remark'}."<br>"; | |
805 | } | |
806 | #check if source and target identical | |
59c2888b | 807 | if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL' && $fwdfwsettings{'grp2'} ne 'ipfire'){ |
cb4439f3 | 808 | $errormessage=$Lang::tr{'fwdfw err same'}; |
2a81ab0d AM |
809 | return $errormessage; |
810 | } | |
2a81ab0d AM |
811 | #get source and targetip address if possible |
812 | my ($sip,$scidr,$tip,$tcidr); | |
813 | ($sip,$scidr)=&get_ip("src","grp1"); | |
814 | ($tip,$tcidr)=&get_ip("tgt","grp2"); | |
2a81ab0d AM |
815 | #check same iprange in source and target |
816 | if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){ | |
2a81ab0d AM |
817 | my $networkip1=&General::getnetworkip($sip,$scidr); |
818 | my $networkip2=&General::getnetworkip($tip,$tcidr); | |
819 | if ($scidr gt $tcidr){ | |
210ee67b | 820 | if ( &General::IpInSubnet($networkip1,$tip,&General::iporsubtodec($tcidr))){ |
2a81ab0d AM |
821 | $errormessage.=$Lang::tr{'fwdfw err samesub'}; |
822 | } | |
8013bd0a AM |
823 | }elsif($scidr eq $tcidr && $scidr eq '32'){ |
824 | my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1); | |
825 | my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2); | |
826 | if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){ | |
827 | $hint=$Lang::tr{'fwdfw hint ip1'}."<br>"; | |
828 | $hint.=$Lang::tr{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>"; | |
829 | } | |
830 | }else{ | |
831 | if ( &General::IpInSubnet($networkip2,$sip,&General::iporsubtodec($scidr)) ){ | |
832 | $errormessage.=$Lang::tr{'fwdfw err samesub'}; | |
833 | } | |
834 | } | |
835 | } | |
35ca8e02 | 836 | #when icmp selected, no source and targetport allowed |
79bb8c75 | 837 | if (($fwdfwsettings{'PROT'} ne '' && $fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP' && $fwdfwsettings{'PROT'} ne 'template') && ($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON')){ |
e6e9a811 AM |
838 | $errormessage.=$Lang::tr{'fwdfw err prot_port'}; |
839 | return; | |
840 | } | |
841 | #change protocol if prot not equal dest single service | |
a4c7bf6b AM |
842 | if ($fwdfwsettings{'grp3'} eq 'cust_srv'){ |
843 | foreach my $key (sort keys %customservice){ | |
844 | if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){ | |
845 | if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){ | |
846 | $fwdfwsettings{'PROT'} = $customservice{$key}[2]; | |
847 | last; | |
8013bd0a AM |
848 | } |
849 | } | |
850 | } | |
851 | } | |
a4c7bf6b AM |
852 | #check source and destination protocol if source manual and dest servicegroup |
853 | if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){ | |
854 | $fwdfwsettings{'PROT'} = ''; | |
72586f0f | 855 | } |
a4c7bf6b | 856 | #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013 |
fadcfb73 | 857 | $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated) |
a4c7bf6b AM |
858 | #Check ICMP Types |
859 | if ($fwdfwsettings{'PROT'} eq 'ICMP'){ | |
860 | $fwdfwsettings{'USE_SRC_PORT'}=''; | |
861 | $fwdfwsettings{'SRC_PORT'}=''; | |
e6e9a811 | 862 | #$fwdfwsettings{'USESRV'}=''; |
a4c7bf6b AM |
863 | $fwdfwsettings{'TGT_PORT'}=''; |
864 | &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes); | |
865 | foreach my $key (keys %icmptypes){ | |
866 | if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){ | |
867 | $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]"; | |
868 | } | |
869 | } | |
870 | }elsif($fwdfwsettings{'PROT'} eq 'GRE'){ | |
871 | $fwdfwsettings{'USE_SRC_PORT'}=''; | |
872 | $fwdfwsettings{'SRC_PORT'}=''; | |
873 | $fwdfwsettings{'ICMP_TYPES'}=''; | |
874 | $fwdfwsettings{'USESRV'}=''; | |
875 | $fwdfwsettings{'TGT_PORT'}=''; | |
876 | }elsif($fwdfwsettings{'PROT'} eq 'ESP'){ | |
877 | $fwdfwsettings{'USE_SRC_PORT'}=''; | |
878 | $fwdfwsettings{'SRC_PORT'}=''; | |
879 | $fwdfwsettings{'ICMP_TYPES'}=''; | |
880 | $fwdfwsettings{'USESRV'}=''; | |
881 | $fwdfwsettings{'TGT_PORT'}=''; | |
882 | }elsif($fwdfwsettings{'PROT'} eq 'AH'){ | |
883 | $fwdfwsettings{'USE_SRC_PORT'}=''; | |
884 | $fwdfwsettings{'SRC_PORT'}=''; | |
885 | $fwdfwsettings{'ICMP_TYPES'}=''; | |
886 | $fwdfwsettings{'USESRV'}=''; | |
887 | $fwdfwsettings{'TGT_PORT'}=''; | |
79bb8c75 AM |
888 | }elsif($fwdfwsettings{'PROT'} eq 'IGMP'){ |
889 | $fwdfwsettings{'USE_SRC_PORT'}=''; | |
890 | $fwdfwsettings{'SRC_PORT'}=''; | |
891 | $fwdfwsettings{'ICMP_TYPES'}=''; | |
892 | $fwdfwsettings{'USESRV'}=''; | |
893 | $fwdfwsettings{'TGT_PORT'}=''; | |
11760a70 AM |
894 | }elsif($fwdfwsettings{'PROT'} eq 'IPv6'){ |
895 | $fwdfwsettings{'USE_SRC_PORT'}=''; | |
896 | $fwdfwsettings{'SRC_PORT'}=''; | |
897 | $fwdfwsettings{'ICMP_TYPES'}=''; | |
898 | $fwdfwsettings{'USESRV'}=''; | |
899 | $fwdfwsettings{'TGT_PORT'}=''; | |
900 | }elsif($fwdfwsettings{'PROT'} eq 'IPIP'){ | |
901 | $fwdfwsettings{'USE_SRC_PORT'}=''; | |
902 | $fwdfwsettings{'SRC_PORT'}=''; | |
903 | $fwdfwsettings{'ICMP_TYPES'}=''; | |
904 | $fwdfwsettings{'USESRV'}=''; | |
905 | $fwdfwsettings{'TGT_PORT'}=''; | |
35ca8e02 | 906 | }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP'){ |
a4c7bf6b | 907 | $fwdfwsettings{'ICMP_TYPES'}=''; |
35ca8e02 AM |
908 | $fwdfwsettings{'SRC_PORT'}=''; |
909 | $fwdfwsettings{'TGT_PORT'}=''; | |
a4c7bf6b AM |
910 | }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){ |
911 | $fwdfwsettings{'ICMP_TYPES'}=''; | |
912 | } | |
8013bd0a | 913 | } |
931e1fed AM |
914 | sub checkvpn |
915 | { | |
916 | my $ip=shift; | |
917 | #Test if manual IP is part of static OpenVPN networks | |
918 | &General::readhasharray("$configccdnet", \%ccdnet); | |
919 | foreach my $key (sort keys %ccdnet){ | |
920 | my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]); | |
921 | my $sub=&General::iporsubtodec($vpnsubnet); | |
922 | if (&General::IpInSubnet($ip,$vpnip,$sub)){ | |
923 | return 0; | |
924 | } | |
925 | } | |
926 | # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor | |
927 | # because if one creates a custom host with the ip, we need to check the color there! | |
928 | # It does not make sense to check this here | |
929 | ||
930 | # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here | |
931 | # Is also checked in getcolor | |
932 | ||
933 | # Test if manual ip is part of an IPsec Network is also checked in getcolor | |
934 | return 1; | |
935 | } | |
936 | sub checkvpncolor | |
937 | { | |
938 | ||
8013bd0a AM |
939 | } |
940 | sub deleterule | |
941 | { | |
942 | my %delhash=(); | |
943 | &General::readhasharray($fwdfwsettings{'config'}, \%delhash); | |
944 | foreach my $key (sort {$a <=> $b} keys %delhash){ | |
8013bd0a AM |
945 | if ($key >= $fwdfwsettings{'key'}) { |
946 | my $next = $key + 1; | |
947 | if (exists $delhash{$next}) { | |
948 | foreach my $i (0 .. $#{$delhash{$next}}) { | |
949 | $delhash{$key}[$i] = $delhash{$next}[$i]; | |
950 | } | |
951 | } | |
952 | } | |
953 | } | |
954 | # Remove the very last entry. | |
955 | my $last_key = (sort {$a <=> $b} keys %delhash)[-1]; | |
956 | delete $delhash{$last_key}; | |
957 | ||
958 | &General::writehasharray($fwdfwsettings{'config'}, \%delhash); | |
0e430797 | 959 | &General::firewall_config_changed(); |
8013bd0a AM |
960 | |
961 | if($fwdfwsettings{'nobase'} ne 'on'){ | |
962 | &base; | |
963 | } | |
964 | } | |
fd169d0a AM |
965 | sub del_double |
966 | { | |
967 | my %all=(); | |
968 | @all{@_}=1; | |
969 | return (keys %all); | |
970 | } | |
8013bd0a AM |
971 | sub disable_rule |
972 | { | |
973 | my $key1=shift; | |
974 | &General::readhasharray("$configfwdfw", \%configfwdfw); | |
975 | foreach my $key (sort keys %configfwdfw){ | |
976 | if ($key eq $key1 ){ | |
977 | if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';} | |
978 | } | |
979 | } | |
980 | &General::writehasharray("$configfwdfw", \%configfwdfw); | |
0e430797 | 981 | &General::firewall_config_changed(); |
8013bd0a | 982 | } |
8013bd0a AM |
983 | sub error |
984 | { | |
985 | if ($errormessage) { | |
986 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); | |
987 | print "<class name='base'>$errormessage\n"; | |
988 | print " </class>\n"; | |
989 | &Header::closebox(); | |
8013bd0a AM |
990 | } |
991 | } | |
992 | sub fillselect | |
993 | { | |
994 | my %hash=%{(shift)}; | |
995 | my $val=shift; | |
996 | my $key; | |
eff2dbf8 | 997 | foreach my $key (sort { ncmp($hash{$a}[0],$hash{$b}[0]) } keys %hash){ |
8013bd0a AM |
998 | if($hash{$key}[0] eq $val){ |
999 | print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>"; | |
1000 | }else{ | |
1001 | print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>"; | |
1002 | } | |
1003 | } | |
1004 | } | |
1005 | sub gen_dd_block | |
1006 | { | |
1007 | my $srctgt = shift; | |
1008 | my $grp=shift; | |
1009 | my $helper=''; | |
1010 | my $show=''; | |
1011 | $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED'; | |
1012 | $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED'; | |
1013 | $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED'; | |
1014 | $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED'; | |
1015 | $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED'; | |
1016 | $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED'; | |
1017 | $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED'; | |
1018 | $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED'; | |
1019 | $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED'; | |
1020 | $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED'; | |
1021 | $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED'; | |
1022 | $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED'; | |
1023 | $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED'; | |
1024 | $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED'; | |
1025 | $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED'; | |
1026 | $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected'; | |
1027 | $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected'; | |
a0fb1099 | 1028 | $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected'; |
8013bd0a AM |
1029 | $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected'; |
1030 | print<<END; | |
1031 | <table width='100%' border='0'> | |
1032 | <tr><td width='50%' valign='top'> | |
f5f71c79 | 1033 | <table width='95%' border='0'> |
b88c8829 | 1034 | <tr><td width='1%'><input type='radio' name='$grp' id='std_net_$srctgt' 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 |
1035 | END |
1036 | foreach my $network (sort keys %defaultNetworks) | |
1037 | { | |
a0fb1099 | 1038 | next if($defaultNetworks{$network}{'NAME'} eq "IPFire"); |
8013bd0a AM |
1039 | print "<option value='$defaultNetworks{$network}{'NAME'}'"; |
1040 | print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'}); | |
3b2ad4a1 | 1041 | my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS"; |
1a8fde0e AM |
1042 | my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK"; |
1043 | my $defsub1=&General::subtocidr($ifaces{$defsub}); | |
7326051e | 1044 | $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED'); |
a0fb1099 | 1045 | if ($ifaces{$defnet}){ |
1a8fde0e | 1046 | print ">$network ($ifaces{$defnet}/$defsub1)</option>"; |
a0fb1099 AM |
1047 | }else{ |
1048 | print ">$network</option>"; | |
1049 | } | |
8013bd0a AM |
1050 | } |
1051 | print"</select></td></tr>"; | |
1052 | #custom networks | |
d9987841 | 1053 | if (! -z $confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ |
b88c8829 | 1054 | print"<tr><td><input type='radio' name='$grp' id='cust_net_$srctgt' 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 |
1055 | &fillselect(\%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}}); |
1056 | print"</select></td>"; | |
1057 | } | |
1058 | #custom hosts | |
d9987841 | 1059 | if (! -z $confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ |
b88c8829 | 1060 | print"<tr><td><input type='radio' name='$grp' id='cust_host_$srctgt' 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 |
1061 | &fillselect(\%customhost,$fwdfwsettings{$fwdfwsettings{$grp}}); |
1062 | print"</select></td>"; | |
1063 | } | |
1064 | #custom groups | |
d9987841 | 1065 | if (! -z $configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ |
b88c8829 | 1066 | print"<tr><td valign='top'><input type='radio' name='$grp' id='cust_grp_$srctgt' 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;'>"; |
eff2dbf8 | 1067 | foreach my $key (sort { ncmp($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) { |
aeefcc9c | 1068 | if($helper ne $customgrp{$key}[0] && $customgrp{$key}[2] ne 'none'){ |
8013bd0a AM |
1069 | print"<option "; |
1070 | print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]); | |
1071 | print ">$customgrp{$key}[0]</option>"; | |
1072 | } | |
1073 | $helper=$customgrp{$key}[0]; | |
1074 | } | |
1075 | print"</select></td>"; | |
1076 | } | |
c0a97a0f SS |
1077 | # geoip locations / groups. |
1078 | my @geoip_locations = &fwlib::get_geoip_locations(); | |
1079 | ||
1080 | print "<tr>\n"; | |
1081 | print "<td valign='top'><input type='radio' name='$grp' id='cust_geoip_$srctgt' value='cust_geoip_$srctgt' $checked{$grp}{'cust_geoip_'.$srctgt}></td>\n"; | |
1082 | print "<td>$Lang::tr{'geoip'}</td>\n"; | |
1083 | print "<td align='right'><select name='cust_geoip_$srctgt' style='width:200px;'>\n"; | |
1084 | ||
1085 | # Add GeoIP groups to dropdown. | |
1086 | if (!-z $configgeoipgrp) { | |
1087 | print "<optgroup label='$Lang::tr{'fwhost cust geoipgroup'}'>\n"; | |
1088 | foreach my $key (sort { ncmp($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) } keys %customgeoipgrp) { | |
1089 | my $selected; | |
1090 | ||
1091 | # Generate stored value for select detection. | |
1092 | my $stored = join(':', "group",$customgeoipgrp{$key}[0]); | |
1093 | ||
1094 | # Only show a group once and group with elements. | |
1095 | if($helper ne $customgeoipgrp{$key}[0] && $customgeoipgrp{$key}[2] ne 'none') { | |
1096 | # Mark current entry as selected. | |
1097 | if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $stored) { | |
1098 | $selected = "selected='selected'"; | |
1099 | } | |
1100 | print"<option $selected value='group:$customgeoipgrp{$key}[0]'>$customgeoipgrp{$key}[0]</option>\n"; | |
1101 | } | |
1102 | $helper=$customgeoipgrp{$key}[0]; | |
1103 | } | |
1104 | print "</optgroup>\n"; | |
1105 | } | |
1106 | ||
1107 | # Add locations. | |
1108 | print "<optgroup label='$Lang::tr{'fwhost cust geoiplocation'}'>\n"; | |
1109 | foreach my $location (@geoip_locations) { | |
1110 | # Get country name. | |
1111 | my $country_name = &GeoIP::get_full_country_name($location); | |
1112 | ||
1113 | # Mark current entry as selected. | |
1114 | my $selected; | |
1115 | if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $location) { | |
1116 | $selected = "selected='selected'"; | |
1117 | } | |
1118 | print "<option $selected value='$location'>$location - $country_name</option>\n"; | |
1119 | } | |
1120 | print "</optgroup>\n"; | |
1121 | ||
1122 | # Close GeoIP dropdown. | |
1123 | print "</select></td>\n"; | |
1124 | ||
8013bd0a | 1125 | #End left table. start right table (vpn) |
f5f71c79 | 1126 | print"</tr></table></td><td valign='top'><table width='95%' border='0' align='right'><tr>"; |
8013bd0a | 1127 | # CCD networks |
d9987841 | 1128 | if( ! -z $configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ |
b88c8829 | 1129 | print"<td width='1%'><input type='radio' name='$grp' id='ovpn_net_$srctgt' 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 |
1130 | &fillselect(\%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}}); |
1131 | print"</select></td></tr>"; | |
1132 | } | |
1133 | #OVPN CCD Hosts | |
eff2dbf8 | 1134 | foreach my $key (sort { ncmp($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){ |
d9987841 | 1135 | if ($ccdhost{$key}[33] ne '' ){ |
b88c8829 | 1136 | print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_host_$srctgt' 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 |
1137 | $show='1'; |
1138 | print "<option value='$ccdhost{$key}[1]'"; | |
1139 | print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]); | |
1140 | print ">$ccdhost{$key}[1]</option>"; | |
1141 | } | |
1142 | } | |
d9987841 | 1143 | if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){ |
b88c8829 | 1144 | print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_host_$srctgt' 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 | 1145 | } |
8013bd0a AM |
1146 | if ($show eq '1'){$show='';print"</select></td></tr>";} |
1147 | #OVPN N2N | |
eff2dbf8 | 1148 | foreach my $key (sort { ncmp($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){ |
8013bd0a | 1149 | if ($ccdhost{$key}[3] eq 'net'){ |
b88c8829 | 1150 | print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_n2n_$srctgt' 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 | 1151 | $show='1'; |
8013bd0a AM |
1152 | print "<option value='$ccdhost{$key}[1]'"; |
1153 | print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]); | |
1154 | print ">$ccdhost{$key}[1]</option>"; | |
1155 | } | |
1156 | } | |
d9987841 | 1157 | if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){ |
b88c8829 | 1158 | print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_n2n_$srctgt' 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 | 1159 | } |
8013bd0a AM |
1160 | if ($show eq '1'){$show='';print"</select></td></tr>";} |
1161 | #IPsec netze | |
eff2dbf8 | 1162 | foreach my $key (sort { ncmp($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) { |
5558ca2a | 1163 | if ($ipsecconf{$key}[3] eq 'net' || ($optionsfw{'SHOWDROPDOWN'} eq 'on' && $ipsecconf{$key}[3] ne 'host')){ |
93a017cb | 1164 | print"<tr><td valign='top'><input type='radio' name='$grp' id='ipsec_net_$srctgt' 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 | 1165 | $show='1'; |
93a017cb AM |
1166 | |
1167 | #Check if we have more than one REMOTE subnet in config | |
1168 | my @arr1 = split /\|/, $ipsecconf{$key}[11]; | |
1169 | my $cnt1 += @arr1; | |
1170 | ||
8013bd0a | 1171 | print "<option "; |
93a017cb AM |
1172 | print "value=$ipsecconf{$key}[1]"; |
1173 | print " selected " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq "$ipsecconf{$key}[1]"); | |
1174 | print ">$ipsecconf{$key}[1] "; | |
1175 | print "($Lang::tr{'fwdfw all subnets'})" if $cnt1 > 1; #If this Conenction has more than one subnet, print one option for all subnets | |
1176 | print "</option>"; | |
1177 | ||
1178 | if ($cnt1 > 1){ | |
1179 | foreach my $val (@arr1){ | |
1180 | #normalize subnet to cidr notation | |
1181 | my ($val1,$val2) = split /\//, $val; | |
1182 | my $val3 = &General::iporsubtocidr($val2); | |
1183 | print "<option "; | |
1184 | print "value='$ipsecconf{$key}[1]|$val1/$val3'"; | |
1185 | print "selected " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq "$ipsecconf{$key}[1]|$val1/$val3"); | |
1186 | print ">$ipsecconf{$key}[1] ($val1/$val3)</option>"; | |
1187 | } | |
1188 | } | |
8013bd0a AM |
1189 | } |
1190 | } | |
d9987841 | 1191 | if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){ |
b88c8829 | 1192 | print"<tr><td valign='top'><input type='radio' name='$grp' id='ipsec_net_$srctgt' 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 | 1193 | } |
8013bd0a AM |
1194 | if ($show eq '1'){$show='';print"</select></td></tr>";} |
1195 | ||
b88c8829 | 1196 | print"</table>"; |
8013bd0a AM |
1197 | print"</td></tr></table><br>"; |
1198 | } | |
1199 | sub get_ip | |
1200 | { | |
1201 | my $val=shift; | |
1202 | my $grp =shift; | |
1203 | my $a; | |
1204 | my $b; | |
1205 | &General::readhash("/var/ipfire/ethernet/settings", \%netsettings); | |
1206 | if ($fwdfwsettings{$grp} ne $Lang::tr{'fwhost any'}){ | |
1207 | if ($fwdfwsettings{$grp} eq $val.'_addr'){ | |
1208 | ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}}); | |
1209 | }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){ | |
1210 | if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){ | |
1211 | $a=$netsettings{'GREEN_NETADDRESS'}; | |
1212 | $b=&General::iporsubtocidr($netsettings{'GREEN_NETMASK'}); | |
1213 | }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){ | |
1214 | $a=$netsettings{'ORANGE_NETADDRESS'}; | |
1215 | $b=&General::iporsubtocidr($netsettings{'ORANGE_NETMASK'}); | |
1216 | }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){ | |
1217 | $a=$netsettings{'BLUE_NETADDRESS'}; | |
1218 | $b=&General::iporsubtocidr($netsettings{'BLUE_NETMASK'}); | |
1219 | }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){ | |
1220 | &General::readhash("$configovpn",\%ovpnsettings); | |
1221 | ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'}); | |
1222 | $b=&General::iporsubtocidr($b); | |
1223 | } | |
1224 | }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){ | |
1225 | &General::readhasharray("$confignet", \%customnetwork); | |
1226 | foreach my $key (keys %customnetwork){ | |
1227 | if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){ | |
1228 | $a=$customnetwork{$key}[1]; | |
1229 | $b=&General::iporsubtocidr($customnetwork{$key}[2]); | |
1230 | } | |
1231 | } | |
1232 | }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){ | |
1233 | &General::readhasharray("$confighost", \%customhost); | |
1234 | foreach my $key (keys %customhost){ | |
1235 | if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){ | |
1236 | if ($customhost{$key}[1] eq 'ip'){ | |
1237 | ($a,$b)=split (/\//,$customhost{$key}[2]); | |
1238 | $b=&General::iporsubtocidr($b); | |
1239 | }else{ | |
1240 | if ($grp eq 'grp2'){ | |
1241 | $errormessage=$Lang::tr{'fwdfw err tgt_mac'}; | |
1242 | } | |
1243 | } | |
1244 | } | |
1245 | } | |
1246 | } | |
1247 | } | |
1248 | return $a,$b; | |
1249 | } | |
1250 | sub get_name | |
1251 | { | |
1252 | my $val=shift; | |
1253 | &General::setup_default_networks(\%defaultNetworks); | |
1254 | foreach my $network (sort keys %defaultNetworks) | |
1255 | { | |
1256 | return "$network" if ($val eq $defaultNetworks{$network}{'NAME'}); | |
1257 | } | |
1258 | } | |
1259 | sub getsrcport | |
1260 | { | |
1261 | my %hash=%{(shift)}; | |
1262 | my $key=shift; | |
a4c7bf6b | 1263 | if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){ |
8013bd0a AM |
1264 | $hash{$key}[10]=~ s/\|/,/g; |
1265 | print": $hash{$key}[10]"; | |
1266 | }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){ | |
1267 | print": <br>$hash{$key}[9] "; | |
1268 | } | |
1269 | } | |
1270 | sub gettgtport | |
1271 | { | |
1272 | my %hash=%{(shift)}; | |
1273 | my $key=shift; | |
1274 | my $service; | |
1275 | my $prot; | |
1276 | if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){ | |
1277 | if($hash{$key}[14] eq 'cust_srv'){ | |
1278 | &General::readhasharray("$configsrv", \%customservice); | |
1279 | foreach my $i (sort keys %customservice){ | |
1280 | if($customservice{$i}[0] eq $hash{$key}[15]){ | |
1281 | $service = $customservice{$i}[0]; | |
1282 | } | |
1283 | } | |
1284 | }elsif($hash{$key}[14] eq 'cust_srvgrp'){ | |
1285 | $service=$hash{$key}[15]; | |
1286 | }elsif($hash{$key}[14] eq 'TGT_PORT'){ | |
1287 | $hash{$key}[15]=~ s/\|/,/g; | |
1288 | $service=$hash{$key}[15]; | |
1289 | } | |
1290 | if($service){ | |
1291 | print": $service"; | |
1292 | } | |
8013bd0a AM |
1293 | } |
1294 | } | |
1295 | sub get_serviceports | |
1296 | { | |
1297 | my $type=shift; | |
1298 | my $name=shift; | |
1299 | &General::readhasharray("$configsrv", \%customservice); | |
1300 | &General::readhasharray("$configsrvgrp", \%customservicegrp); | |
b3f4a4ef | 1301 | @protocols=(); |
712500d0 | 1302 | my @specprot=("IPIP","IPV6","IGMP","GRE","AH","ESP"); |
8013bd0a | 1303 | if($type eq 'service'){ |
eff2dbf8 | 1304 | foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){ |
8013bd0a | 1305 | if ($customservice{$key}[0] eq $name){ |
0626fac1 | 1306 | push (@protocols,$customservice{$key}[2]); |
8013bd0a AM |
1307 | } |
1308 | } | |
1309 | }elsif($type eq 'group'){ | |
eff2dbf8 | 1310 | foreach my $key (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){ |
8013bd0a | 1311 | if ($customservicegrp{$key}[0] eq $name){ |
712500d0 AM |
1312 | if ($customservicegrp{$key}[2] ~~ @specprot){ |
1313 | push (@protocols," ".$customservicegrp{$key}[2]); | |
1314 | }else{ | |
1315 | foreach my $key1 (sort { ncmp($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){ | |
1316 | if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){ | |
1317 | if (!grep(/$customservice{$key1}[2]/, @protocols)){ | |
0626fac1 | 1318 | push (@protocols,$customservice{$key1}[2]);} |
b3f4a4ef | 1319 | } |
8013bd0a AM |
1320 | } |
1321 | } | |
1322 | } | |
1323 | } | |
1324 | } | |
28e003e4 MT |
1325 | |
1326 | # Sort protocols alphabetically. | |
1327 | @protocols = sort(@protocols); | |
1328 | ||
b3f4a4ef | 1329 | return @protocols; |
8013bd0a AM |
1330 | } |
1331 | sub getcolor | |
1332 | { | |
1333 | my $nettype=shift; | |
1334 | my $val=shift; | |
1335 | my $hash=shift; | |
1336 | if($optionsfw{'SHOWCOLORS'} eq 'on'){ | |
b062a11b MT |
1337 | # Don't colourise MAC addresses |
1338 | if (&General::validmac($val)) { | |
1339 | $tdcolor = ""; | |
1340 | return; | |
1341 | } | |
1342 | ||
b119578f AM |
1343 | #custom Hosts |
1344 | if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){ | |
1345 | foreach my $key (sort keys %$hash){ | |
1346 | if ($$hash{$key}[0] eq $val){ | |
1347 | $val=$$hash{$key}[2]; | |
1348 | } | |
1349 | } | |
1350 | } | |
e3c58927 AM |
1351 | #standard networks |
1352 | if ($val eq 'GREEN'){ | |
43215686 | 1353 | $tdcolor="style='background-color: $Header::colourgreen;color:white;'"; |
e3c58927 AM |
1354 | return; |
1355 | }elsif ($val eq 'ORANGE'){ | |
43215686 | 1356 | $tdcolor="style='background-color: $Header::colourorange;color:white;'"; |
e3c58927 AM |
1357 | return; |
1358 | }elsif ($val eq 'BLUE'){ | |
43215686 | 1359 | $tdcolor="style='background-color: $Header::colourblue;color:white;'"; |
e3c58927 | 1360 | return; |
05d4f131 | 1361 | }elsif ($val eq 'RED' ||$val eq 'RED1' ){ |
43215686 | 1362 | $tdcolor="style='background-color: $Header::colourred;color:white;'"; |
e3c58927 AM |
1363 | return; |
1364 | }elsif ($val eq 'IPFire' ){ | |
43215686 | 1365 | $tdcolor="style='background-color: $Header::colourred;color:white;'"; |
e3c58927 | 1366 | return; |
d8afe3e2 AM |
1367 | }elsif ($val eq 'OpenVPN-Dyn' ){ |
1368 | $tdcolor="style='background-color: $Header::colourovpn;color:white;'"; | |
1369 | return; | |
1370 | }elsif ($val eq 'IPsec RW' ){ | |
1371 | $tdcolor="style='background-color: $Header::colourvpn;color:white;'"; | |
1372 | return; | |
e3c58927 AM |
1373 | }elsif($val =~ /^(.*?)\/(.*?)$/){ |
1374 | my ($sip,$scidr) = split ("/",$val); | |
1be052f9 | 1375 | if ( &Header::orange_used() && &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){ |
43215686 | 1376 | $tdcolor="style='background-color: $Header::colourorange;color:white;'"; |
e3c58927 AM |
1377 | return; |
1378 | } | |
1379 | if ( &General::IpInSubnet($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){ | |
43215686 | 1380 | $tdcolor="style='background-color: $Header::colourgreen;color:white;'"; |
e3c58927 AM |
1381 | return; |
1382 | } | |
1be052f9 | 1383 | if ( &Header::blue_used() && &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){ |
43215686 | 1384 | $tdcolor="style='background-color: $Header::colourblue;color:white;'"; |
e3c58927 AM |
1385 | return; |
1386 | } | |
1387 | }elsif ($val eq 'Default IP'){ | |
43215686 | 1388 | $tdcolor="style='background-color: $Header::colourred;color:white;'"; |
e3c58927 AM |
1389 | return; |
1390 | } | |
b119578f AM |
1391 | #Check if a manual IP or custom host is part of a VPN |
1392 | if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){ | |
931e1fed AM |
1393 | #Check if IP is part of OpenVPN dynamic subnet |
1394 | my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'}); | |
1395 | my ($c,$d) = split("/",$val); | |
1396 | if (&General::IpInSubnet($c,$a,$b)){ | |
43215686 | 1397 | $tdcolor="style='background-color: $Header::colourovpn;color:white;'"; |
931e1fed AM |
1398 | return; |
1399 | } | |
d9b691e1 AM |
1400 | #Check if IP is part of OpenVPN static subnet |
1401 | foreach my $key (sort keys %ccdnet){ | |
1402 | my ($a,$b) = split("/",$ccdnet{$key}[1]); | |
1403 | $b =&General::iporsubtodec($b); | |
1404 | if (&General::IpInSubnet($c,$a,$b)){ | |
43215686 | 1405 | $tdcolor="style='background-color: $Header::colourovpn;color:white;'"; |
d9b691e1 AM |
1406 | return; |
1407 | } | |
1408 | } | |
1409 | #Check if IP is part of OpenVPN N2N subnet | |
1410 | foreach my $key (sort keys %ccdhost){ | |
1411 | if ($ccdhost{$key}[3] eq 'net'){ | |
1412 | my ($a,$b) = split("/",$ccdhost{$key}[11]); | |
1413 | if (&General::IpInSubnet($c,$a,$b)){ | |
43215686 | 1414 | $tdcolor="style='background-color: $Header::colourovpn;color:white;'"; |
d9b691e1 AM |
1415 | return; |
1416 | } | |
1417 | } | |
1418 | } | |
931e1fed AM |
1419 | #Check if IP is part of IPsec RW network |
1420 | if ($ipsecsettings{'RW_NET'} ne ''){ | |
1421 | my ($a,$b) = split("/",$ipsecsettings{'RW_NET'}); | |
1422 | $b=&General::iporsubtodec($b); | |
1423 | if (&General::IpInSubnet($c,$a,$b)){ | |
43215686 | 1424 | $tdcolor="style='background-color: $Header::colourvpn;color:white;'"; |
931e1fed AM |
1425 | return; |
1426 | } | |
1427 | } | |
1428 | #Check if IP is part of a IPsec N2N network | |
1429 | foreach my $key (sort keys %ipsecconf){ | |
476b122f AM |
1430 | if ($ipsecconf{$key}[11]){ |
1431 | my ($a,$b) = split("/",$ipsecconf{$key}[11]); | |
1432 | $b=&General::iporsubtodec($b); | |
1433 | if (&General::IpInSubnet($c,$a,$b)){ | |
1434 | $tdcolor="style='background-color: $Header::colourvpn;color:white;'"; | |
1435 | return; | |
1436 | } | |
931e1fed AM |
1437 | } |
1438 | } | |
1439 | } | |
8013bd0a AM |
1440 | #VPN networks |
1441 | 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'){ | |
43215686 | 1442 | $tdcolor="style='background-color: $Header::colourovpn;color:white;'"; |
8013bd0a AM |
1443 | return; |
1444 | } | |
1445 | if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){ | |
43215686 | 1446 | $tdcolor="style='background-color: $Header::colourvpn;color:white;'"; |
8013bd0a AM |
1447 | return; |
1448 | } | |
8013bd0a AM |
1449 | #ALIASE |
1450 | foreach my $alias (sort keys %aliases) | |
1451 | { | |
1452 | if ($val eq $alias){ | |
43215686 | 1453 | $tdcolor="style='background-color:$Header::colourred;color:white;'"; |
8013bd0a AM |
1454 | return; |
1455 | } | |
1456 | } | |
2a81ab0d | 1457 | } |
e3c58927 AM |
1458 | $tdcolor=''; |
1459 | return; | |
8013bd0a AM |
1460 | } |
1461 | sub hint | |
1462 | { | |
1463 | if ($hint) { | |
1464 | &Header::openbox('100%', 'left', $Lang::tr{'fwhost hint'}); | |
1465 | print "<class name='base'>$hint\n"; | |
1466 | print " </class>\n"; | |
1467 | &Header::closebox(); | |
2a81ab0d | 1468 | } |
2a81ab0d AM |
1469 | } |
1470 | sub newrule | |
1471 | { | |
1472 | &error; | |
1473 | &General::setup_default_networks(\%defaultNetworks); | |
515863e2 | 1474 | &General::readhash("/var/ipfire/ethernet/settings", \%netsettings); |
2a81ab0d AM |
1475 | #read all configfiles |
1476 | &General::readhasharray("$configccdnet", \%ccdnet); | |
1477 | &General::readhasharray("$confignet", \%customnetwork); | |
1478 | &General::readhasharray("$configccdhost", \%ccdhost); | |
1479 | &General::readhasharray("$confighost", \%customhost); | |
1480 | &General::readhasharray("$configccdhost", \%ccdhost); | |
1481 | &General::readhasharray("$configgrp", \%customgrp); | |
c0a97a0f | 1482 | &General::readhasharray("$configgeoipgrp", \%customgeoipgrp); |
2a81ab0d AM |
1483 | &General::readhasharray("$configipsec", \%ipsecconf); |
1484 | &General::get_aliases(\%aliases); | |
2a81ab0d AM |
1485 | my %checked=(); |
1486 | my $helper; | |
2da264ec | 1487 | my $sum=0; |
2a81ab0d AM |
1488 | if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;} |
1489 | my $config=$fwdfwsettings{'config'}; | |
1490 | my %hash=(); | |
43d8be09 | 1491 | #Get Red IP-ADDRESS |
1492 | open (CONN1,"/var/ipfire/red/local-ipaddress"); | |
1493 | my $redip = <CONN1>; | |
1494 | close(CONN1); | |
f0dc00d8 | 1495 | if (! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE2'){ |
9566c8f5 | 1496 | $fwdfwsettings{'RULE_ACTION'}='DROP'; |
f0dc00d8 | 1497 | }elsif(! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE1'){ |
9566c8f5 AM |
1498 | $fwdfwsettings{'RULE_ACTION'}='ACCEPT'; |
1499 | } | |
2a81ab0d AM |
1500 | $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED'; |
1501 | $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED'; | |
1502 | $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED'; | |
1503 | $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED'; | |
1504 | $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED'; | |
1505 | $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED'; | |
1506 | $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED'; | |
1507 | $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED'; | |
1508 | $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED'; | |
1509 | $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED'; | |
1510 | $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED'; | |
1511 | $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED'; | |
1512 | $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED'; | |
1513 | $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED'; | |
1514 | $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED'; | |
a6edca5a | 1515 | $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED'; |
2a81ab0d AM |
1516 | $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected'; |
1517 | $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected'; | |
1518 | $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected'; | |
43d8be09 | 1519 | $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected'; |
2a81ab0d AM |
1520 | #check if update and get values |
1521 | if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){ | |
1522 | &General::readhasharray("$config", \%hash); | |
1523 | foreach my $key (sort keys %hash){ | |
2da264ec | 1524 | $sum++; |
2a81ab0d | 1525 | if ($key eq $fwdfwsettings{'key'}){ |
70d38e50 | 1526 | $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'}; |
2a81ab0d | 1527 | $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0]; |
2669161d | 1528 | $fwdfwsettings{'chain'} = $hash{$key}[1]; |
2a81ab0d AM |
1529 | $fwdfwsettings{'ACTIVE'} = $hash{$key}[2]; |
1530 | $fwdfwsettings{'grp1'} = $hash{$key}[3]; | |
1531 | $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4]; | |
1532 | $fwdfwsettings{'grp2'} = $hash{$key}[5]; | |
1533 | $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6]; | |
1534 | $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7]; | |
1535 | $fwdfwsettings{'PROT'} = $hash{$key}[8]; | |
1536 | $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9]; | |
1537 | $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10]; | |
1538 | $fwdfwsettings{'USESRV'} = $hash{$key}[11]; | |
1539 | $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12]; | |
1540 | $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13]; | |
1541 | $fwdfwsettings{'grp3'} = $hash{$key}[14]; | |
1542 | $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15]; | |
1543 | $fwdfwsettings{'ruleremark'} = $hash{$key}[16]; | |
1544 | $fwdfwsettings{'LOG'} = $hash{$key}[17]; | |
1545 | $fwdfwsettings{'TIME'} = $hash{$key}[18]; | |
1546 | $fwdfwsettings{'TIME_MON'} = $hash{$key}[19]; | |
1547 | $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20]; | |
1548 | $fwdfwsettings{'TIME_WED'} = $hash{$key}[21]; | |
1549 | $fwdfwsettings{'TIME_THU'} = $hash{$key}[22]; | |
1550 | $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23]; | |
1551 | $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24]; | |
1552 | $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25]; | |
1553 | $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26]; | |
1554 | $fwdfwsettings{'TIME_TO'} = $hash{$key}[27]; | |
2669161d | 1555 | $fwdfwsettings{'USE_NAT'} = $hash{$key}[28]; |
a6edca5a | 1556 | $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order |
2669161d | 1557 | $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29]; |
a6edca5a | 1558 | $fwdfwsettings{'dnatport'} = $hash{$key}[30]; |
79ad6f7e AM |
1559 | $fwdfwsettings{'LIMIT_CON_CON'} = $hash{$key}[32]; |
1560 | $fwdfwsettings{'concon'} = $hash{$key}[33]; | |
d8deec0b AM |
1561 | $fwdfwsettings{'RATE_LIMIT'} = $hash{$key}[34]; |
1562 | $fwdfwsettings{'ratecon'} = $hash{$key}[35]; | |
1563 | $fwdfwsettings{'RATETIME'} = $hash{$key}[36]; | |
2a81ab0d AM |
1564 | $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED'; |
1565 | $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED'; | |
1566 | $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED'; | |
1567 | $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED'; | |
1568 | $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED'; | |
1569 | $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED'; | |
1570 | $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED'; | |
1571 | $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED'; | |
1572 | $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED'; | |
1573 | $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED'; | |
1574 | $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED'; | |
1575 | $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED'; | |
1576 | $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED'; | |
1577 | $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED'; | |
1578 | $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED'; | |
2669161d | 1579 | $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED'; |
f5f71c79 | 1580 | $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED'; |
79ad6f7e | 1581 | $checked{'LIMIT_CON_CON'}{$fwdfwsettings{'LIMIT_CON_CON'}} = 'CHECKED'; |
d8deec0b | 1582 | $checked{'RATE_LIMIT'}{$fwdfwsettings{'RATE_LIMIT'}} = 'CHECKED'; |
2a81ab0d AM |
1583 | $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected'; |
1584 | $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected'; | |
1585 | $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected'; | |
b044bb05 | 1586 | $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected'; |
95cda259 | 1587 | $selected{'dnat'}{$fwdfwsettings{'dnat'}} ='selected'; |
2ed8330e | 1588 | $selected{'snat'}{$fwdfwsettings{'snat'}} ='selected'; |
d8deec0b | 1589 | $selected{'RATETIME'}{$fwdfwsettings{'RATETIME'}} ='selected'; |
2a81ab0d AM |
1590 | } |
1591 | } | |
1592 | $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'}; | |
1593 | $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}}; | |
1594 | $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'}; | |
1595 | $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}}; | |
1596 | $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'}; | |
1597 | $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}}; | |
1598 | $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'}; | |
02da9f7b | 1599 | $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'}; |
2669161d | 1600 | $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'}; |
8442c937 | 1601 | $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'}; |
79ad6f7e | 1602 | $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'}; |
d8deec0b | 1603 | $fwdfwsettings{'olduseratelimit'}=$fwdfwsettings{'RATE_LIMIT'}; |
57518765 | 1604 | $fwdfwsettings{'olduseratelimitamount'}=$fwdfwsettings{'ratecon'}; |
d8deec0b AM |
1605 | $fwdfwsettings{'oldratelimittime'}=$fwdfwsettings{'RATETIME'}; |
1606 | ||
515863e2 AM |
1607 | #check if manual ip (source) is orange network |
1608 | if ($fwdfwsettings{'grp1'} eq 'src_addr'){ | |
1609 | my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}}); | |
1610 | if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){ | |
1611 | $fwdfwsettings{'oldorange'} ='on'; | |
1612 | } | |
1613 | } | |
2a81ab0d AM |
1614 | }else{ |
1615 | $fwdfwsettings{'ACTIVE'}='ON'; | |
f5f71c79 | 1616 | $fwdfwsettings{'nat'} = 'dnat'; |
2a81ab0d | 1617 | $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED'; |
f5f71c79 | 1618 | $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED'; |
515863e2 AM |
1619 | $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'}; |
1620 | $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}}; | |
1621 | $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'}; | |
1622 | $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}}; | |
1623 | $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'}; | |
1624 | $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}}; | |
1625 | $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'}; | |
1626 | $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'}; | |
2669161d | 1627 | $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'}; |
79ad6f7e | 1628 | $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'}; |
515863e2 AM |
1629 | #check if manual ip (source) is orange network |
1630 | if ($fwdfwsettings{'grp1'} eq 'src_addr'){ | |
1631 | my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}}); | |
1632 | if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){ | |
1633 | $fwdfwsettings{'oldorange'} ='on'; | |
1634 | } | |
1635 | } | |
2a81ab0d | 1636 | } |
f4d5310d AM |
1637 | # Split manual source and target address and delete the subnet |
1638 | my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}}); | |
1639 | if ($scidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp1'}}=$sip;} | |
1640 | my ($dip,$dcidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp2'}}); | |
90c2ce0c | 1641 | if ($dcidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp2'}}=$dip;} |
2a81ab0d | 1642 | &Header::openbox('100%', 'left', $Lang::tr{'fwdfw source'}); |
2a81ab0d | 1643 | #------SOURCE------------------------------------------------------- |
ec6fd189 | 1644 | print "<form method='post'>"; |
2a81ab0d AM |
1645 | print<<END; |
1646 | <table width='100%' border='0'> | |
ab4fe66f | 1647 | <tr><td width='1%'><input type='radio' name='grp1' value='src_addr' checked></td><td width='60%'>$Lang::tr{'fwdfw sourceip'}<input type='TEXT' name='src_addr' value='$fwdfwsettings{'src_addr'}' size='16' maxlength='18' ></td><td width='1%'><input type='radio' name='grp1' id='ipfire_src' value='ipfire_src' $checked{'grp1'}{'ipfire_src'}></td><td><b>Firewall</b></td> |
a0fb1099 AM |
1648 | END |
1649 | print"<td align='right'><select name='ipfire_src' style='width:200px;'>"; | |
b044bb05 AM |
1650 | print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>"; |
1651 | print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'}; | |
595a90f0 AM |
1652 | print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header::orange_used()); |
1653 | print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header::blue_used()); | |
b044bb05 | 1654 | print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip); |
a0fb1099 AM |
1655 | if (! -z "${General::swroot}/ethernet/aliases"){ |
1656 | foreach my $alias (sort keys %aliases) | |
1657 | { | |
f1dd1972 | 1658 | print "<option value='$alias' $selected{'ipfire_src'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>"; |
a0fb1099 AM |
1659 | } |
1660 | } | |
1661 | print<<END; | |
b88c8829 | 1662 | </select></td></tr> |
62f34bba AM |
1663 | <tr><td><br></td></tr> |
1664 | </table> | |
2a81ab0d | 1665 | END |
a4c7bf6b | 1666 | &gen_dd_block('src','grp1'); |
2a81ab0d | 1667 | &Header::closebox(); |
bee56a2d | 1668 | |
fadcfb73 AM |
1669 | #---SNAT / DNAT ------------------------------------------------ |
1670 | &Header::openbox('100%', 'left', 'NAT'); | |
1671 | print<<END; | |
93e0855b | 1672 | <label> |
0eadfdad | 1673 | <input type='checkbox' name='USE_NAT' id='USE_NAT' value="ON" $checked{'USE_NAT'}{'ON'}> |
93e0855b MT |
1674 | $Lang::tr{'fwdfw use nat'} |
1675 | </label> | |
6bcb5ffe | 1676 | <div class="NAT"> |
c98b743c | 1677 | <table class='fw-nat' width='100%' border='0'> |
93e0855b | 1678 | <tr> |
bee56a2d MT |
1679 | <td width='5%'></td> |
1680 | <td width='40%'> | |
1681 | <label> | |
4234ca5d | 1682 | <input type='radio' name='nat' value='dnat' $checked{'nat'}{'dnat'}> |
bee56a2d MT |
1683 | $Lang::tr{'fwdfw dnat'} |
1684 | </label> | |
1685 | </td> | |
1686 | END | |
1687 | ||
1aa5439c | 1688 | print <<END; |
c98b743c | 1689 | <td width='25%' align='right'><span class='dnat'>$Lang::tr{'dnat address'}:</span></td> |
bee56a2d | 1690 | <td width='30%'> |
c98b743c | 1691 | <select name='dnat' class='dnat' style='width: 100%;'> |
1aa5439c | 1692 | <option value='AUTO' $selected{'dnat'}{'AUTO'}>- $Lang::tr{'automatic'} -</option> |
95cda259 | 1693 | <option value='Default IP' $selected{'dnat'}{'Default IP'}>$Lang::tr{'red1'} ($redip)</option> |
bee56a2d | 1694 | END |
1aa5439c | 1695 | if (%aliases) { |
bee56a2d | 1696 | foreach my $alias (sort keys %aliases) { |
11ab2c7d | 1697 | print "<option value='$alias' $selected{'dnat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>"; |
bee56a2d | 1698 | } |
fadcfb73 | 1699 | } |
1aa5439c AM |
1700 | #DNAT Dropdown |
1701 | foreach my $network (sort keys %defaultNetworks) | |
1702 | { | |
1703 | if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){ | |
1704 | print "<option value='$defaultNetworks{$network}{'NAME'}'"; | |
cc77ac23 | 1705 | print " selected='selected'" if ($fwdfwsettings{'dnat'} eq $defaultNetworks{$network}{'NAME'}); |
1aa5439c AM |
1706 | print ">$network ($defaultNetworks{$network}{'NET'})</option>"; |
1707 | } | |
1708 | } | |
1709 | print "</select>"; | |
bee56a2d MT |
1710 | print "</tr>"; |
1711 | ||
fadcfb73 | 1712 | #SNAT |
bee56a2d MT |
1713 | print <<END; |
1714 | <tr> | |
1715 | <td width='5%'></td> | |
1716 | <td width='40%'> | |
1717 | <label> | |
4234ca5d | 1718 | <input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}> |
bee56a2d MT |
1719 | $Lang::tr{'fwdfw snat'} |
1720 | </label> | |
1721 | </td> | |
c98b743c | 1722 | <td width='25%' align='right'><span class='snat'>$Lang::tr{'snat new source ip address'}:</span></td> |
bee56a2d | 1723 | <td width='30%'> |
c98b743c | 1724 | <select name='snat' class='snat' style='width: 100%;'> |
bee56a2d MT |
1725 | END |
1726 | ||
1727 | foreach my $alias (sort keys %aliases) { | |
11ab2c7d | 1728 | print "<option value='$alias' $selected{'snat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>"; |
bee56a2d | 1729 | } |
1aa5439c | 1730 | # SNAT Dropdown |
bee56a2d | 1731 | foreach my $network (sort keys %defaultNetworks) { |
1aa5439c AM |
1732 | if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){ |
1733 | print "<option value='$defaultNetworks{$network}{'NAME'}'"; | |
cc77ac23 | 1734 | print " selected='selected'" if ($fwdfwsettings{'snat'} eq $defaultNetworks{$network}{'NAME'}); |
1aa5439c AM |
1735 | print ">$network ($defaultNetworks{$network}{'NET'})</option>"; |
1736 | } | |
fadcfb73 | 1737 | } |
bee56a2d MT |
1738 | print <<END; |
1739 | </select> | |
1740 | </td> | |
1741 | </tr> | |
1742 | </table> | |
1743 | </div> | |
1744 | END | |
fadcfb73 | 1745 | &Header::closebox(); |
bee56a2d | 1746 | |
2a81ab0d AM |
1747 | #---TARGET------------------------------------------------------ |
1748 | &Header::openbox('100%', 'left', $Lang::tr{'fwdfw target'}); | |
1749 | print<<END; | |
1750 | <table width='100%' border='0'> | |
ab4fe66f | 1751 | <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr' checked></td><td width='60%' nowrap='nowrap'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16' maxlength='18'><td width='1%'><input type='radio' name='grp2' id='ipfire' value='ipfire' $checked{'grp2'}{'ipfire'}></td><td><b>Firewall</b></td> |
2a81ab0d | 1752 | END |
05d4f131 | 1753 | print"<td align='right'><select name='ipfire' style='width:200px;'>"; |
a0fb1099 AM |
1754 | print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>"; |
1755 | print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'}; | |
595a90f0 AM |
1756 | print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header::orange_used()); |
1757 | print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header::blue_used()); | |
fc83b09d | 1758 | print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip); |
05d4f131 | 1759 | if (! -z "${General::swroot}/ethernet/aliases"){ |
bedb72f3 AM |
1760 | foreach my $alias (sort keys %aliases) |
1761 | { | |
f1dd1972 | 1762 | print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>"; |
bedb72f3 | 1763 | } |
2a81ab0d | 1764 | } |
2a81ab0d | 1765 | print<<END; |
b88c8829 | 1766 | </select></td></tr> |
62f34bba | 1767 | <tr><td><br></td></tr></table> |
2a81ab0d | 1768 | END |
8013bd0a | 1769 | &gen_dd_block('tgt','grp2'); |
a4c7bf6b AM |
1770 | &Header::closebox; |
1771 | #---PROTOCOL------------------------------------------------------ | |
901aa8b9 MT |
1772 | $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g; |
1773 | $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g; | |
1774 | $fwdfwsettings{'dnatport'} =~ tr/|/,/; | |
1775 | ||
1776 | # The dnatport may be empty, if it matches TGT_PORT | |
1777 | if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) { | |
1778 | $fwdfwsettings{'dnatport'} = ""; | |
1779 | } | |
1780 | ||
a4c7bf6b | 1781 | &Header::openbox('100%', 'left', $Lang::tr{'fwhost prot'}); |
79bb8c75 AM |
1782 | #Fix Protocol for JQuery |
1783 | if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){ | |
1784 | $fwdfwsettings{'PROT'} = 'template'; | |
1785 | } | |
a4c7bf6b | 1786 | print<<END; |
901aa8b9 | 1787 | <table width='100%' border='0'> |
a1e89f48 | 1788 | <tr> |
901aa8b9 MT |
1789 | <td width="25%"> |
1790 | <select name='PROT' id='protocol' style="width: 95px;"> | |
a4c7bf6b | 1791 | END |
a1e89f48 MT |
1792 | print "<option value=\"\""; |
1793 | if ($fwdfwsettings{'PROT'} eq '') { | |
1794 | print " selected=\"selected\""; | |
a4c7bf6b | 1795 | } |
a1e89f48 MT |
1796 | print ">$Lang::tr{'all'}</option>"; |
1797 | ||
1798 | print "<option value=\"template\""; | |
79bb8c75 | 1799 | print " selected=\"selected\"" if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'); |
a1e89f48 MT |
1800 | print ">- $Lang::tr{'template'} -</option>"; |
1801 | ||
1802 | foreach (@PROTOCOLS) { | |
1803 | print"<option value=\"$_\""; | |
1804 | if ($_ eq $fwdfwsettings{'PROT'}) { | |
1805 | print " selected=\"selected\""; | |
a4c7bf6b | 1806 | } |
9c89c64d AM |
1807 | if($_ eq "IPv6"){ |
1808 | print ">$Lang::tr{'fwdfw prot41'}</option>"; | |
1809 | }else{ | |
1810 | print ">$_</option>"; | |
1811 | } | |
a4c7bf6b | 1812 | } |
901aa8b9 | 1813 | |
a4c7bf6b | 1814 | print<<END; |
a1e89f48 MT |
1815 | </select> |
1816 | </td> | |
901aa8b9 MT |
1817 | <td width="75%"> |
1818 | <table width='100%' border='0' id="PROTOCOL_ICMP_TYPES"> | |
1819 | <tr> | |
1820 | <td width='20%'>$Lang::tr{'fwhost icmptype'}</td> | |
1821 | <td colspan='2'> | |
1822 | <select name='ICMP_TYPES' style='min-width:230px;'> | |
a4c7bf6b AM |
1823 | END |
1824 | &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes); | |
86a921ee | 1825 | print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>"; |
a4c7bf6b AM |
1826 | foreach my $key (sort { ncmp($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){ |
1827 | if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){ | |
1828 | print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>"; | |
1829 | }else{ | |
1830 | print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>"; | |
1831 | } | |
1832 | } | |
a1e89f48 MT |
1833 | |
1834 | print <<END; | |
901aa8b9 MT |
1835 | </select> |
1836 | </td> | |
1837 | </tr> | |
1838 | </table> | |
a1e89f48 | 1839 | |
901aa8b9 MT |
1840 | <table width="100%" border="0" id="PROTOCOL_PORTS"> |
1841 | <tr> | |
1842 | <!-- #SOURCEPORT --> | |
1843 | <td> | |
1844 | $Lang::tr{'fwdfw use srcport'} | |
1845 | </td> | |
1846 | <td> | |
1847 | <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'> | |
1848 | </td> | |
1849 | <td width='10%'> | |
1850 | </td> | |
6bcb5ffe | 1851 | |
901aa8b9 MT |
1852 | <!-- #TARGETPORT --> |
1853 | <td> | |
1854 | $Lang::tr{'fwdfw use srv'} | |
1855 | </td> | |
a1e89f48 | 1856 | |
901aa8b9 MT |
1857 | <td> |
1858 | <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'> | |
1859 | </td> | |
1860 | </tr> | |
1861 | <tr class="NAT"> | |
1862 | <td colspan='3'></td> | |
1863 | <td>$Lang::tr{'fwdfw external port nat'}:</td> | |
1864 | <td> | |
1865 | <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'> | |
1866 | </td> | |
1867 | </tr> | |
1868 | </table> | |
a1e89f48 | 1869 | |
901aa8b9 MT |
1870 | <table width="100%" border="0" id="PROTOCOL_TEMPLATE"> |
1871 | <tr> | |
1872 | <td> | |
1873 | <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked> | |
1874 | $Lang::tr{'fwhost cust service'} | |
1875 | </td> | |
1876 | <td> | |
1877 | <select name='cust_srv' style='min-width: 230px;'> | |
2a81ab0d | 1878 | END |
901aa8b9 | 1879 | |
2a81ab0d | 1880 | &General::readhasharray("$configsrv", \%customservice); |
eff2dbf8 | 1881 | foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){ |
2a81ab0d AM |
1882 | print"<option "; |
1883 | print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]); | |
1884 | print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>"; | |
a1e89f48 MT |
1885 | } |
1886 | ||
901aa8b9 MT |
1887 | print <<END; |
1888 | </select> | |
1889 | </td> | |
1890 | </tr> | |
1891 | <tr> | |
1892 | <td> | |
1893 | <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}> | |
1894 | $Lang::tr{'fwhost cust srvgrp'} | |
1895 | </td> | |
1896 | <td> | |
1897 | <select name='cust_srvgrp' style='min-width:230px;'> | |
2a81ab0d | 1898 | END |
a1e89f48 | 1899 | |
2a81ab0d AM |
1900 | &General::readhasharray("$configsrvgrp", \%customservicegrp); |
1901 | my $helper; | |
eff2dbf8 | 1902 | foreach my $key (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){ |
aeefcc9c | 1903 | if ($helper ne $customservicegrp{$key}[0] && $customservicegrp{$key}[2] ne 'none'){ |
2a81ab0d AM |
1904 | print"<option "; |
1905 | print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]); | |
1906 | print">$customservicegrp{$key}[0]</option>"; | |
1907 | } | |
1908 | $helper=$customservicegrp{$key}[0]; | |
901aa8b9 MT |
1909 | } |
1910 | ||
2a81ab0d | 1911 | print<<END; |
901aa8b9 MT |
1912 | </select> |
1913 | </td> | |
1914 | </tr> | |
1915 | </table> | |
a1e89f48 MT |
1916 | </td> |
1917 | </tr> | |
1918 | </table> | |
2a81ab0d | 1919 | END |
a1e89f48 | 1920 | |
fadcfb73 | 1921 | &Header::closebox; |
f0dc00d8 | 1922 | $checked{"RULE_ACTION"}{$fwdfwsettings{'RULE_ACTION'}} = 'CHECKED'; |
0c7d0c08 | 1923 | print <<END; |
0c7d0c08 | 1924 | <center> |
8e713726 | 1925 | <table width="80%" class='tbl' id='actions'> |
0c7d0c08 MT |
1926 | <tr> |
1927 | <td width="33%" align="center" bgcolor="$color{'color17'}"> | |
1928 | <br> | |
1929 | </td> | |
1930 | <td width="33%" align="center" bgcolor="$color{'color25'}"> | |
1931 | <br> | |
1932 | </td> | |
1933 | <td width="33%" align="center" bgcolor="$color{'color16'}"> | |
1934 | <br> | |
1935 | </td> | |
1936 | </tr> | |
1937 | <tr> | |
1938 | <td width="33%" align="center"> | |
1939 | <label> | |
1940 | <input type="radio" name="RULE_ACTION" value="ACCEPT" $checked{"RULE_ACTION"}{"ACCEPT"}> | |
1941 | <strong>$Lang::tr{'fwdfw ACCEPT'}</strong> | |
1942 | </label> | |
1943 | </td> | |
1944 | <td width="33%" align="center"> | |
1945 | <label> | |
1946 | <input type="radio" name="RULE_ACTION" value="DROP" $checked{"RULE_ACTION"}{"DROP"}> | |
1947 | <strong>$Lang::tr{'fwdfw DROP'}</strong> | |
1948 | </label> | |
1949 | </td> | |
1950 | <td width="33%" align="center"> | |
1951 | <label> | |
1952 | <input type="radio" name="RULE_ACTION" value="REJECT" $checked{"RULE_ACTION"}{"REJECT"}> | |
1953 | <strong>$Lang::tr{'fwdfw REJECT'}</strong> | |
1954 | </label> | |
1955 | </td> | |
1956 | </tr> | |
1957 | </table> | |
1958 | </center> | |
1959 | ||
1960 | <br> | |
1961 | END | |
2a81ab0d AM |
1962 | #---Activate/logging/remark------------------------------------- |
1963 | &Header::openbox('100%', 'left', $Lang::tr{'fwdfw additional'}); | |
1964 | print<<END; | |
43d8be09 | 1965 | <table width='100%' border='0'> |
2da264ec | 1966 | END |
b88c8829 | 1967 | print"<tr><td width='12%'>$Lang::tr{'remark'}:</td><td width='88%' align='left'><input type='text' name='ruleremark' maxlength='255' value='$fwdfwsettings{'ruleremark'}' style='width:99%;'></td></tr>"; |
2da264ec AM |
1968 | if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){ |
1969 | print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >"; | |
1970 | for (my $count =1; $count <= $sum; $count++){ | |
1971 | print"<option value='$count' "; | |
1972 | print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count); | |
1973 | print">$count</option>"; | |
1974 | } | |
1975 | print"</select></td></tr>"; | |
70d38e50 AM |
1976 | }else{ |
1977 | print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>"; | |
2da264ec AM |
1978 | } |
1979 | ||
1980 | print<<END; | |
d8d7dd3b MT |
1981 | </table> |
1982 | <table width='100%'> | |
1983 | <tr> | |
1984 | END | |
1985 | ||
1986 | if ($fwdfwsettings{'updatefwrule'} eq 'on') { | |
1987 | print <<END; | |
1988 | <td> | |
0eadfdad | 1989 | <input type='checkbox' name='ACTIVE' value="ON" $checked{'ACTIVE'}{'ON'}> |
d8d7dd3b MT |
1990 | </td> |
1991 | <td>$Lang::tr{'fwdfw rule activate'}</td> | |
1992 | END | |
1993 | } else { | |
1994 | print <<END; | |
1995 | <td colspan="2"> | |
1996 | <input type="hidden" name="ACTIVE" value="ON"> | |
1997 | </td> | |
1998 | END | |
1999 | } | |
2000 | ||
2001 | print <<END; | |
2002 | </tr> | |
2003 | <tr> | |
2004 | <td> | |
2005 | <input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'}> | |
2006 | </td> | |
2007 | <td>$Lang::tr{'fwdfw log rule'}</td> | |
2008 | </tr> | |
f18c3831 MT |
2009 | <tr> |
2010 | <td width='1%'> | |
2011 | <input type='checkbox' name='TIME' id="USE_TIME_CONSTRAINTS" value='ON' $checked{'TIME'}{'ON'}> | |
2012 | </td> | |
2013 | <td>$Lang::tr{'fwdfw timeframe'}</td> | |
2014 | </tr> | |
2015 | <tr id="TIME_CONSTRAINTS"> | |
2016 | <td colspan="2"> | |
2017 | <table width="66%" border="0"> | |
2018 | <tr> | |
2019 | <td width="8em"> </td> | |
2020 | <td align="center">$Lang::tr{'advproxy monday'}</td> | |
2021 | <td align="center">$Lang::tr{'advproxy tuesday'}</td> | |
2022 | <td align="center">$Lang::tr{'advproxy wednesday'}</td> | |
2023 | <td align="center">$Lang::tr{'advproxy thursday'}</td> | |
2024 | <td align="center">$Lang::tr{'advproxy friday'}</td> | |
2025 | <td align="center">$Lang::tr{'advproxy saturday'}</td> | |
2026 | <td align="center">$Lang::tr{'advproxy sunday'}</td> | |
2027 | <td> </td> | |
2028 | </tr> | |
2029 | <tr> | |
2030 | <td width="8em"> </td> | |
2031 | <td align="center"><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td> | |
2032 | <td align="center"><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td> | |
2033 | <td align="center"><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td> | |
2034 | <td align="center"><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td> | |
2035 | <td align="center"><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td> | |
2036 | <td align="center"><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td> | |
2037 | <td align="center"><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td> | |
2038 | <td> | |
2039 | <select name='TIME_FROM'> | |
2a81ab0d AM |
2040 | END |
2041 | for (my $i=0;$i<=23;$i++) { | |
2042 | $i = sprintf("%02s",$i); | |
2043 | for (my $j=0;$j<=45;$j+=15) { | |
2044 | $j = sprintf("%02s",$j); | |
2045 | my $time = $i.":".$j; | |
f18c3831 | 2046 | print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n"; |
2a81ab0d AM |
2047 | } |
2048 | } | |
2049 | print<<END; | |
f18c3831 MT |
2050 | </select> ‐ |
2051 | <select name='TIME_TO'> | |
2a81ab0d AM |
2052 | END |
2053 | for (my $i=0;$i<=23;$i++) { | |
2054 | $i = sprintf("%02s",$i); | |
2055 | for (my $j=0;$j<=45;$j+=15) { | |
2056 | $j = sprintf("%02s",$j); | |
2057 | my $time = $i.":".$j; | |
f18c3831 | 2058 | print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n"; |
2a81ab0d AM |
2059 | } |
2060 | } | |
8013bd0a | 2061 | print<<END; |
f18c3831 MT |
2062 | </select> |
2063 | </td> | |
2064 | </tr> | |
2065 | </table> | |
2066 | </td> | |
2067 | </tr> | |
79ad6f7e AM |
2068 | <tr> |
2069 | <td width='1%'> | |
2070 | <input type='checkbox' name='LIMIT_CON_CON' id="USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP" value='ON' $checked{'LIMIT_CON_CON'}{'ON'}> | |
2071 | </td> | |
2072 | <td>$Lang::tr{'fwdfw limitconcon'}</td> | |
2073 | </tr> | |
2074 | <tr id="LIMIT_CON"> | |
2075 | <td colspan='2'> | |
2076 | <table width='66%' border='0'> | |
2077 | <tr> | |
2078 | <td width="20em"> </td> | |
2079 | <td>$Lang::tr{'fwdfw maxconcon'}: <input type='text' name='concon' size='2' value="$fwdfwsettings{'concon'}"></td> | |
2080 | </tr> | |
2081 | </table> | |
2082 | </td> | |
2083 | </tr> | |
d8deec0b AM |
2084 | <tr> |
2085 | <td width='1%'> | |
2086 | <input type='checkbox' name='RATE_LIMIT' id="USE_RATELIMIT" value='ON' $checked{'RATE_LIMIT'}{'ON'}> | |
2087 | </td> | |
2088 | <td>$Lang::tr{'fwdfw ratelimit'}</td> | |
2089 | </tr> | |
2090 | <tr id="RATELIMIT"> | |
2091 | <td colspan='2'> | |
2092 | <table width='66%' border='0'> | |
2093 | <tr> | |
2094 | <td width="20em"> </td> | |
2095 | <td>$Lang::tr{'fwdfw numcon'}: <input type='text' name='ratecon' size='2' value="$fwdfwsettings{'ratecon'}"> / | |
2096 | <select name='RATETIME' style='width:100px;'> | |
2097 | <option value='second' $selected{'RATETIME'}{'second'}>$Lang::tr{'age second'}</option> | |
2098 | <option value='minute' $selected{'RATETIME'}{'minute'}>$Lang::tr{'minute'}</option> | |
2099 | <option value='hour' $selected{'RATETIME'}{'hour'}>$Lang::tr{'hour'}</option> | |
2100 | </select> | |
2101 | </td> | |
2102 | </tr> | |
2103 | </table> | |
2104 | </td> | |
2105 | </tr> | |
f18c3831 | 2106 | </table> |
62f34bba | 2107 | <br> |
8013bd0a | 2108 | END |
f18c3831 | 2109 | |
8013bd0a AM |
2110 | #---ACTION------------------------------------------------------ |
2111 | if($fwdfwsettings{'updatefwrule'} ne 'on'){ | |
2112 | print<<END; | |
2113 | <table border='0' width='100%'> | |
2114 | <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' /> | |
2115 | <input type='hidden' name='config' value='$config' > | |
b88c8829 AM |
2116 | <input type='hidden' name='ACTION' value='saverule' ></form> |
2117 | <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'></form></td></tr> | |
2118 | </table> | |
2119 | <br> | |
8013bd0a AM |
2120 | END |
2121 | }else{ | |
2122 | print<<END; | |
2123 | <table border='0' width='100%'> | |
2124 | <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'}'> | |
2125 | <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' /> | |
2126 | <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' /> | |
2127 | <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' /> | |
2128 | <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' /> | |
2129 | <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' /> | |
2130 | <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' /> | |
2131 | <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' /> | |
2132 | <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' /> | |
2133 | <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' /> | |
2134 | <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' /> | |
2135 | <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' /> | |
2669161d AM |
2136 | <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' /> |
2137 | <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' /> | |
79ad6f7e | 2138 | <input type='hidden' name='oldconcon' value='$fwdfwsettings{'oldconcon'}' /> |
8013bd0a AM |
2139 | <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> |
2140 | </table></form> | |
2141 | END | |
2142 | } | |
2143 | &Header::closebox(); | |
2144 | } | |
2145 | sub pos_up | |
2146 | { | |
2147 | my %uphash=(); | |
2148 | my %tmp=(); | |
2149 | &General::readhasharray($fwdfwsettings{'config'}, \%uphash); | |
2150 | foreach my $key (sort keys %uphash){ | |
2151 | if ($key eq $fwdfwsettings{'key'}) { | |
2152 | my $last = $key -1; | |
2153 | if (exists $uphash{$last}){ | |
2154 | #save rule last | |
2155 | foreach my $y (0 .. $#{$uphash{$last}}) { | |
2156 | $tmp{0}[$y] = $uphash{$last}[$y]; | |
2157 | } | |
2158 | #copy active rule to last | |
2159 | foreach my $i (0 .. $#{$uphash{$last}}) { | |
2160 | $uphash{$last}[$i] = $uphash{$key}[$i]; | |
2161 | } | |
2162 | #copy saved rule to actual position | |
2163 | foreach my $x (0 .. $#{$tmp{0}}) { | |
2164 | $uphash{$key}[$x] = $tmp{0}[$x]; | |
2165 | } | |
2166 | } | |
2167 | } | |
2168 | } | |
2169 | &General::writehasharray($fwdfwsettings{'config'}, \%uphash); | |
0e430797 | 2170 | &General::firewall_config_changed(); |
8013bd0a AM |
2171 | } |
2172 | sub pos_down | |
2173 | { | |
2174 | my %downhash=(); | |
2175 | my %tmp=(); | |
2176 | &General::readhasharray($fwdfwsettings{'config'}, \%downhash); | |
2177 | foreach my $key (sort keys %downhash){ | |
2178 | if ($key eq $fwdfwsettings{'key'}) { | |
2179 | my $next = $key + 1; | |
2180 | if (exists $downhash{$next}){ | |
2181 | #save rule next | |
2182 | foreach my $y (0 .. $#{$downhash{$next}}) { | |
2183 | $tmp{0}[$y] = $downhash{$next}[$y]; | |
2184 | } | |
2185 | #copy active rule to next | |
2186 | foreach my $i (0 .. $#{$downhash{$next}}) { | |
2187 | $downhash{$next}[$i] = $downhash{$key}[$i]; | |
2188 | } | |
2189 | #copy saved rule to actual position | |
2190 | foreach my $x (0 .. $#{$tmp{0}}) { | |
2191 | $downhash{$key}[$x] = $tmp{0}[$x]; | |
2192 | } | |
2193 | } | |
2194 | } | |
2195 | } | |
2196 | &General::writehasharray($fwdfwsettings{'config'}, \%downhash); | |
0e430797 | 2197 | &General::firewall_config_changed(); |
2a81ab0d AM |
2198 | } |
2199 | sub saverule | |
2200 | { | |
2a81ab0d AM |
2201 | my $hash=shift; |
2202 | my $config=shift; | |
2203 | &General::readhasharray("$config", $hash); | |
2204 | if (!$errormessage){ | |
2669161d | 2205 | ################################################################ |
2669161d | 2206 | #check if we change an INPUT rule to a OUTGOING |
c12392c0 | 2207 | if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){ |
2669161d | 2208 | &changerule($configinput); |
c12392c0 | 2209 | #print"1"; |
d7127db8 | 2210 | } |
8442c937 | 2211 | #check if we change an INPUT rule to a FORWARD |
2669161d AM |
2212 | elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){ |
2213 | &changerule($configinput); | |
c12392c0 | 2214 | #print"2"; |
d7127db8 | 2215 | } |
2669161d AM |
2216 | ################################################################ |
2217 | #check if we change an OUTGOING rule to an INPUT | |
2218 | elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){ | |
2219 | &changerule($configoutgoing); | |
c12392c0 | 2220 | #print"3"; |
d7127db8 | 2221 | } |
8442c937 | 2222 | #check if we change an OUTGOING rule to a FORWARD |
2669161d | 2223 | elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){ |
d7127db8 | 2224 | &changerule($configoutgoing); |
c12392c0 | 2225 | #print"4"; |
2669161d AM |
2226 | } |
2227 | ################################################################ | |
2228 | #check if we change a FORWARD rule to an INPUT | |
2229 | elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){ | |
2230 | &changerule($configfwdfw); | |
c12392c0 | 2231 | #print"5"; |
2669161d AM |
2232 | } |
2233 | #check if we change a FORWARD rule to an OUTGOING | |
2234 | elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){ | |
2235 | &changerule($configfwdfw); | |
c12392c0 | 2236 | #print"6"; |
2669161d | 2237 | } |
65c9b3a5 | 2238 | $fwdfwsettings{'ruleremark'}=~ s/,/;/g; |
323923d9 | 2239 | utf8::decode($fwdfwsettings{'ruleremark'}); |
abb3cfcc | 2240 | $fwdfwsettings{'ruleremark'}=&Header::escape($fwdfwsettings{'ruleremark'}); |
2da264ec | 2241 | if ($fwdfwsettings{'updatefwrule'} ne 'on'){ |
2a81ab0d AM |
2242 | my $key = &General::findhasharraykey ($hash); |
2243 | $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'}; | |
2244 | $$hash{$key}[1] = $fwdfwsettings{'chain'}; | |
2245 | $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'}; | |
2246 | $$hash{$key}[3] = $fwdfwsettings{'grp1'}; | |
2247 | $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}}; | |
2248 | $$hash{$key}[5] = $fwdfwsettings{'grp2'}; | |
2249 | $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}}; | |
2250 | $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'}; | |
2251 | $$hash{$key}[8] = $fwdfwsettings{'PROT'}; | |
2252 | $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'}; | |
2253 | $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'}; | |
2254 | $$hash{$key}[11] = $fwdfwsettings{'USESRV'}; | |
2255 | $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'}; | |
2256 | $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'}; | |
2257 | $$hash{$key}[14] = $fwdfwsettings{'grp3'}; | |
2258 | $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}}; | |
2259 | $$hash{$key}[16] = $fwdfwsettings{'ruleremark'}; | |
2260 | $$hash{$key}[17] = $fwdfwsettings{'LOG'}; | |
2261 | $$hash{$key}[18] = $fwdfwsettings{'TIME'}; | |
2262 | $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'}; | |
2263 | $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'}; | |
2264 | $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'}; | |
2265 | $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'}; | |
2266 | $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'}; | |
2267 | $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'}; | |
2268 | $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'}; | |
2269 | $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'}; | |
2270 | $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'}; | |
c12392c0 AM |
2271 | $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'}; |
2272 | $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}}; | |
2273 | $$hash{$key}[30] = $fwdfwsettings{'dnatport'}; | |
2274 | $$hash{$key}[31] = $fwdfwsettings{'nat'}; | |
79ad6f7e AM |
2275 | $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'}; |
2276 | $$hash{$key}[33] = $fwdfwsettings{'concon'}; | |
d8deec0b AM |
2277 | $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'}; |
2278 | $$hash{$key}[35] = $fwdfwsettings{'ratecon'}; | |
2279 | $$hash{$key}[36] = $fwdfwsettings{'RATETIME'}; | |
2a81ab0d AM |
2280 | &General::writehasharray("$config", $hash); |
2281 | }else{ | |
e44fa079 AM |
2282 | foreach my $key (sort {$a <=> $b} keys %$hash){ |
2283 | if($key eq $fwdfwsettings{'key'}){ | |
2284 | $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'}; | |
2285 | $$hash{$key}[1] = $fwdfwsettings{'chain'}; | |
2286 | $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'}; | |
2287 | $$hash{$key}[3] = $fwdfwsettings{'grp1'}; | |
2288 | $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}}; | |
2289 | $$hash{$key}[5] = $fwdfwsettings{'grp2'}; | |
2290 | $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}}; | |
2291 | $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'}; | |
2292 | $$hash{$key}[8] = $fwdfwsettings{'PROT'}; | |
2293 | $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'}; | |
2294 | $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'}; | |
2295 | $$hash{$key}[11] = $fwdfwsettings{'USESRV'}; | |
2296 | $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'}; | |
2297 | $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'}; | |
2298 | $$hash{$key}[14] = $fwdfwsettings{'grp3'}; | |
2299 | $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}}; | |
2300 | $$hash{$key}[16] = $fwdfwsettings{'ruleremark'}; | |
2301 | $$hash{$key}[17] = $fwdfwsettings{'LOG'}; | |
2302 | $$hash{$key}[18] = $fwdfwsettings{'TIME'}; | |
2303 | $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'}; | |
2304 | $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'}; | |
2305 | $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'}; | |
2306 | $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'}; | |
2307 | $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'}; | |
2308 | $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'}; | |
2309 | $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'}; | |
2310 | $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'}; | |
2311 | $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'}; | |
c12392c0 AM |
2312 | $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'}; |
2313 | $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}}; | |
2314 | $$hash{$key}[30] = $fwdfwsettings{'dnatport'}; | |
2315 | $$hash{$key}[31] = $fwdfwsettings{'nat'}; | |
79ad6f7e AM |
2316 | $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'}; |
2317 | $$hash{$key}[33] = $fwdfwsettings{'concon'}; | |
d8deec0b AM |
2318 | $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'}; |
2319 | $$hash{$key}[35] = $fwdfwsettings{'ratecon'}; | |
2320 | $$hash{$key}[36] = $fwdfwsettings{'RATETIME'}; | |
e44fa079 AM |
2321 | last; |
2322 | } | |
2323 | } | |
2324 | } | |
2325 | &General::writehasharray("$config", $hash); | |
0918e516 | 2326 | if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){ |
e44fa079 AM |
2327 | my %tmp=(); |
2328 | my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'}; | |
2329 | for (my $z=0;$z<$val;$z++){ | |
2330 | foreach my $key (sort {$a <=> $b} keys %$hash){ | |
2331 | if ($key eq $fwdfwsettings{'oldrulenumber'}) { | |
2332 | my $last = $key -1; | |
2333 | if (exists $$hash{$last}){ | |
2334 | #save rule last | |
2335 | foreach my $y (0 .. $#{$$hash{$last}}) { | |
2336 | $tmp{0}[$y] = $$hash{$last}[$y]; | |
2337 | } | |
2338 | #copy active rule to last | |
2339 | foreach my $i (0 .. $#{$$hash{$last}}) { | |
2340 | $$hash{$last}[$i] = $$hash{$key}[$i]; | |
2341 | } | |
2342 | #copy saved rule to actual position | |
2343 | foreach my $x (0 .. $#{$tmp{0}}) { | |
2344 | $$hash{$key}[$x] = $tmp{0}[$x]; | |
2da264ec AM |
2345 | } |
2346 | } | |
2347 | } | |
2348 | } | |
e44fa079 AM |
2349 | $fwdfwsettings{'oldrulenumber'}--; |
2350 | } | |
2351 | &General::writehasharray("$config", $hash); | |
0e430797 | 2352 | &General::firewall_config_changed(); |
0918e516 | 2353 | }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){ |
e44fa079 AM |
2354 | my %tmp=(); |
2355 | my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'}; | |
2356 | for (my $z=0;$z<$val;$z++){ | |
2357 | foreach my $key (sort {$a <=> $b} keys %$hash){ | |
2358 | if ($key eq $fwdfwsettings{'oldrulenumber'}) { | |
2359 | my $next = $key + 1; | |
2360 | if (exists $$hash{$next}){ | |
2361 | #save rule next | |
2362 | foreach my $y (0 .. $#{$$hash{$next}}) { | |
2363 | $tmp{0}[$y] = $$hash{$next}[$y]; | |
2364 | } | |
2365 | #copy active rule to next | |
2366 | foreach my $i (0 .. $#{$$hash{$next}}) { | |
2367 | $$hash{$next}[$i] = $$hash{$key}[$i]; | |
2368 | } | |
2369 | #copy saved rule to actual position | |
2370 | foreach my $x (0 .. $#{$tmp{0}}) { | |
2371 | $$hash{$key}[$x] = $tmp{0}[$x]; | |
2da264ec AM |
2372 | } |
2373 | } | |
2374 | } | |
2a81ab0d | 2375 | } |
e44fa079 | 2376 | $fwdfwsettings{'oldrulenumber'}++; |
2a81ab0d AM |
2377 | } |
2378 | &General::writehasharray("$config", $hash); | |
0e430797 | 2379 | &General::firewall_config_changed(); |
2a81ab0d AM |
2380 | } |
2381 | } | |
2382 | } | |
2a81ab0d AM |
2383 | sub validremark |
2384 | { | |
2385 | # Checks a hostname against RFC1035 | |
abb3cfcc | 2386 | my $remark = $_[0]; |
323923d9 MT |
2387 | |
2388 | # Try to decode $remark into UTF-8. If this doesn't work, | |
2389 | # we assume that the string it not sane. | |
2390 | if (!utf8::decode($remark)) { | |
2391 | return 0; | |
2392 | } | |
2393 | ||
2394 | # Check if the string only contains of printable characters. | |
abb3cfcc AM |
2395 | if ($remark =~ /^[[:print:]]*$/) { |
2396 | return 1; | |
2397 | } | |
2398 | return 0; | |
2a81ab0d | 2399 | } |
3a162dc1 AM |
2400 | sub viewtablerule |
2401 | { | |
15add1c8 | 2402 | &General::readhash("/var/ipfire/ethernet/settings", \%netsettings); |
c03d4a5e MT |
2403 | |
2404 | &viewtablenew(\%configfwdfw, $configfwdfw, $Lang::tr{'firewall rules'}); | |
2dd3aa93 MT |
2405 | &viewtablenew(\%configinputfw, $configinput, $Lang::tr{'incoming firewall access'}); |
2406 | &viewtablenew(\%configoutgoingfw, $configoutgoing, $Lang::tr{'outgoing firewall access'}); | |
2a81ab0d AM |
2407 | } |
2408 | sub viewtablenew | |
2409 | { | |
2410 | my $hash=shift; | |
2411 | my $config=shift; | |
2412 | my $title=shift; | |
7bd9d462 | 2413 | my $go=''; |
c03d4a5e MT |
2414 | |
2415 | my $show_box = (! -z $config) || ($optionsfw{'SHOWTABLES'} eq 'on'); | |
2416 | return if (!$show_box); | |
2417 | ||
15add1c8 | 2418 | &General::get_aliases(\%aliases); |
af768a7e | 2419 | &General::readhasharray("$confighost", \%customhost); |
7bd9d462 | 2420 | &General::readhasharray("$config", $hash); |
d9b691e1 AM |
2421 | &General::readhasharray("$configccdnet", \%ccdnet); |
2422 | &General::readhasharray("$configccdhost", \%ccdhost); | |
aeefcc9c AM |
2423 | &General::readhasharray("$configgrp", \%customgrp); |
2424 | &General::readhasharray("$configsrvgrp", \%customservicegrp); | |
c03d4a5e MT |
2425 | |
2426 | &Header::openbox('100%', 'left', $title); | |
8d28e3d0 | 2427 | print "<table width='100%' cellspacing='0' class='tbl'>"; |
c03d4a5e MT |
2428 | |
2429 | if (! -z $config) { | |
2a81ab0d AM |
2430 | my $count=0; |
2431 | my ($gif,$log); | |
2432 | my $ruletype; | |
2433 | my $rulecolor; | |
2434 | my $tooltip; | |
2435 | my @tmpsrc=(); | |
a15f7d0d | 2436 | my @tmptgt=(); |
2a81ab0d | 2437 | my $coloryellow=''; |
989d0fd7 | 2438 | |
c03d4a5e | 2439 | print <<END; |
989d0fd7 MT |
2440 | <tr> |
2441 | <th align='right' width='3%'> | |
2442 | # | |
2443 | </th> | |
2444 | <th width='2%'></th> | |
2445 | <th align='center'> | |
2446 | <b>$Lang::tr{'protocol'}</b> | |
2447 | </th> | |
2448 | <th align='center' width='30%'> | |
2449 | <b>$Lang::tr{'fwdfw source'}</b> | |
2450 | </th> | |
2451 | <th align='center'> | |
daf400fa | 2452 | <b>$Lang::tr{'fwdfw log'}</b> |
989d0fd7 MT |
2453 | </th> |
2454 | <th align='center' width='30%'> | |
2455 | <b>$Lang::tr{'fwdfw target'}</b> | |
2456 | </th> | |
2457 | <th align='center' colspan='6' width='18%'> | |
2458 | <b>$Lang::tr{'fwdfw action'}</b> | |
2459 | </th> | |
2460 | </tr> | |
2461 | END | |
2462 | ||
62fc8511 | 2463 | foreach my $key (sort {$a <=> $b} keys %$hash){ |
12a43202 | 2464 | $tdcolor=''; |
2a81ab0d | 2465 | @tmpsrc=(); |
a15f7d0d | 2466 | @tmptgt=(); |
2a81ab0d AM |
2467 | #check if vpn hosts/nets have been deleted |
2468 | if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){ | |
2469 | push (@tmpsrc,$$hash{$key}[4]); | |
2470 | } | |
2471 | if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){ | |
a15f7d0d | 2472 | push (@tmptgt,$$hash{$key}[6]); |
2a81ab0d | 2473 | } |
2a81ab0d | 2474 | foreach my $host (@tmpsrc){ |
a15f7d0d | 2475 | if($$hash{$key}[3] eq 'ipsec_net_src'){ |
62fc8511 | 2476 | if(&fwlib::get_ipsec_net_ip($host,11) eq ''){ |
2a81ab0d | 2477 | $coloryellow='on'; |
2a81ab0d | 2478 | } |
a15f7d0d | 2479 | }elsif($$hash{$key}[3] eq 'ovpn_net_src'){ |
2a81ab0d AM |
2480 | if(&fwlib::get_ovpn_net_ip($host,1) eq ''){ |
2481 | $coloryellow='on'; | |
2a81ab0d | 2482 | } |
a15f7d0d | 2483 | }elsif($$hash{$key}[3] eq 'ovpn_n2n_src'){ |
2a81ab0d AM |
2484 | if(&fwlib::get_ovpn_n2n_ip($host,27) eq ''){ |
2485 | $coloryellow='on'; | |
2a81ab0d | 2486 | } |
a15f7d0d AM |
2487 | }elsif($$hash{$key}[3] eq 'ovpn_host_src'){ |
2488 | if(&fwlib::get_ovpn_host_ip($host,33) eq ''){ | |
2489 | $coloryellow='on'; | |
a15f7d0d AM |
2490 | } |
2491 | } | |
2492 | } | |
2493 | foreach my $host (@tmptgt){ | |
2494 | if($$hash{$key}[5] eq 'ipsec_net_tgt'){ | |
2495 | if(&fwlib::get_ipsec_net_ip($host,11) eq ''){ | |
2496 | $coloryellow='on'; | |
a15f7d0d AM |
2497 | } |
2498 | }elsif($$hash{$key}[5] eq 'ovpn_net_tgt'){ | |
2499 | if(&fwlib::get_ovpn_net_ip($host,1) eq ''){ | |
2500 | $coloryellow='on'; | |
a15f7d0d AM |
2501 | } |
2502 | }elsif($$hash{$key}[5] eq 'ovpn_n2n_tgt'){ | |
2503 | if(&fwlib::get_ovpn_n2n_ip($host,27) eq ''){ | |
2504 | $coloryellow='on'; | |
a15f7d0d AM |
2505 | } |
2506 | }elsif($$hash{$key}[5] eq 'ovpn_host_tgt'){ | |
2a81ab0d AM |
2507 | if(&fwlib::get_ovpn_host_ip($host,33) eq ''){ |
2508 | $coloryellow='on'; | |
2a81ab0d AM |
2509 | } |
2510 | } | |
2a81ab0d | 2511 | } |
aeefcc9c AM |
2512 | #check if networkgroups or servicegroups are empty |
2513 | foreach my $netgroup (sort keys %customgrp){ | |
2514 | if(($$hash{$key}[4] eq $customgrp{$netgroup}[0] || $$hash{$key}[6] eq $customgrp{$netgroup}[0]) && $customgrp{$netgroup}[2] eq 'none'){ | |
2515 | $coloryellow='on'; | |
aeefcc9c AM |
2516 | } |
2517 | } | |
2518 | foreach my $srvgroup (sort keys %customservicegrp){ | |
2519 | if($$hash{$key}[15] eq $customservicegrp{$srvgroup}[0] && $customservicegrp{$srvgroup}[2] eq 'none'){ | |
2520 | $coloryellow='on'; | |
aeefcc9c AM |
2521 | } |
2522 | } | |
2a81ab0d AM |
2523 | $$hash{'ACTIVE'}=$$hash{$key}[2]; |
2524 | $count++; | |
2a81ab0d | 2525 | if($coloryellow eq 'on'){ |
a15f7d0d | 2526 | $color="$color{'color14'}"; |
2a81ab0d AM |
2527 | $coloryellow=''; |
2528 | }elsif($coloryellow eq ''){ | |
2529 | if ($count % 2){ | |
15add1c8 | 2530 | $color="$color{'color22'}"; |
2a81ab0d AM |
2531 | } |
2532 | else{ | |
15add1c8 | 2533 | $color="$color{'color20'}"; |
2a81ab0d AM |
2534 | } |
2535 | } | |
2a81ab0d | 2536 | print<<END; |
989d0fd7 MT |
2537 | <tr bgcolor='$color'> |
2538 | <td align='right' width='3%'> | |
2539 | <b>$key </b> | |
2540 | </td> | |
2a81ab0d | 2541 | END |
989d0fd7 | 2542 | |
a0fb1099 | 2543 | #RULETYPE (A,R,D) |
2a81ab0d AM |
2544 | if ($$hash{$key}[0] eq 'ACCEPT'){ |
2545 | $ruletype='A'; | |
2546 | $tooltip='ACCEPT'; | |
2547 | $rulecolor=$color{'color17'}; | |
2548 | }elsif($$hash{$key}[0] eq 'DROP'){ | |
2549 | $ruletype='D'; | |
2550 | $tooltip='DROP'; | |
2551 | $rulecolor=$color{'color25'}; | |
2552 | }elsif($$hash{$key}[0] eq 'REJECT'){ | |
2553 | $ruletype='R'; | |
2554 | $tooltip='REJECT'; | |
2555 | $rulecolor=$color{'color16'}; | |
2556 | } | |
989d0fd7 MT |
2557 | |
2558 | print <<END; | |
2559 | <td bgcolor='$rulecolor' align='center' width='2%'> | |
2560 | <span title='$tooltip'> </span> | |
2561 | </td> | |
2562 | END | |
2563 | ||
a0fb1099 AM |
2564 | #Get Protocol |
2565 | my $prot; | |
fadcfb73 | 2566 | if ($$hash{$key}[8]){ |
9c89c64d | 2567 | if ($$hash{$key}[8] eq "IPv6"){ |
39e360b2 | 2568 | push (@protocols,$Lang::tr{'fwdfw prot41 short'}) |
9c89c64d AM |
2569 | }else{ |
2570 | push (@protocols,$$hash{$key}[8]); | |
2571 | } | |
a0fb1099 AM |
2572 | }elsif($$hash{$key}[14] eq 'cust_srv'){ |
2573 | &get_serviceports("service",$$hash{$key}[15]); | |
2574 | }elsif($$hash{$key}[14] eq 'cust_srvgrp'){ | |
2575 | &get_serviceports("group",$$hash{$key}[15]); | |
2576 | }else{ | |
2577 | push (@protocols,$Lang::tr{'all'}); | |
2578 | } | |
989d0fd7 | 2579 | |
0626fac1 | 2580 | my $protz=join(", ",@protocols); |
90f8339a | 2581 | if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){ |
a4c7bf6b AM |
2582 | &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes); |
2583 | foreach my $keyicmp (sort { ncmp($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){ | |
2584 | if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){ | |
2585 | print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>"; | |
2586 | last; | |
2587 | } | |
2588 | } | |
0626fac1 AM |
2589 | }elsif($#protocols gt '3'){ |
2590 | print"<td align='center'><span title='$protz'>$Lang::tr{'fwdfw many'}</span></td>"; | |
a4c7bf6b AM |
2591 | }else{ |
2592 | print"<td align='center'>$protz</td>"; | |
2593 | } | |
a0fb1099 AM |
2594 | @protocols=(); |
2595 | #SOURCE | |
d4cb89d2 | 2596 | my $ipfireiface; |
af768a7e | 2597 | &getcolor($$hash{$key}[3],$$hash{$key}[4],\%customhost); |
93a017cb AM |
2598 | # Check SRC Host and replace "|" with space |
2599 | if ($$hash{$key}[4] =~ /\|/){ | |
2600 | $$hash{$key}[4] =~ s/\|/ (/g; | |
2601 | $$hash{$key}[4] = $$hash{$key}[4].")"; | |
2602 | } | |
85860aff | 2603 | print"<td align='center' width='30%' $tdcolor>"; |
d4cb89d2 | 2604 | if ($$hash{$key}[3] eq 'ipfire_src'){ |
daf400fa | 2605 | $ipfireiface=$Lang::tr{'fwdfw iface'}; |
d4cb89d2 | 2606 | } |
2a81ab0d AM |
2607 | if ($$hash{$key}[3] eq 'std_net_src'){ |
2608 | print &get_name($$hash{$key}[4]); | |
4f3bd0ca AM |
2609 | }elsif ($$hash{$key}[3] eq 'src_addr'){ |
2610 | my ($split1,$split2) = split("/",$$hash{$key}[4]); | |
2611 | if ($split2 eq '32'){ | |
2612 | print $split1; | |
2613 | }else{ | |
2614 | print $$hash{$key}[4]; | |
2615 | } | |
c0a97a0f SS |
2616 | }elsif ($$hash{$key}[3] eq 'cust_geoip_src') { |
2617 | my ($split1,$split2) = split(":", $$hash{$key}[4]); | |
2618 | if ($split2) { | |
2619 | print "$split2\n"; | |
2620 | }else{ | |
2621 | print "$Lang::tr{'geoip'}: $$hash{$key}[4]\n"; | |
2622 | } | |
43d8be09 | 2623 | }elsif ($$hash{$key}[4] eq 'RED1'){ |
d4cb89d2 | 2624 | print "$ipfireiface $Lang::tr{'fwdfw red'}"; |
2be048ce AM |
2625 | }elsif ($$hash{$key}[4] eq 'ALL'){ |
2626 | print "$ipfireiface $Lang::tr{'all'}"; | |
2a81ab0d | 2627 | }else{ |
2be048ce AM |
2628 | if ($$hash{$key}[4] eq 'GREEN' || $$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE' || $$hash{$key}[4] eq 'RED'){ |
2629 | print "$ipfireiface $Lang::tr{lc($$hash{$key}[4])}"; | |
2630 | }else{ | |
2631 | print "$ipfireiface $$hash{$key}[4]"; | |
2632 | } | |
2a81ab0d | 2633 | } |
15add1c8 | 2634 | $tdcolor=''; |
a0fb1099 | 2635 | #SOURCEPORT |
2a81ab0d | 2636 | &getsrcport(\%$hash,$key); |
2669161d | 2637 | #Is this a SNAT rule? |
ac9e77e3 | 2638 | if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){ |
f1934a05 AM |
2639 | my $net=&get_name($$hash{$key}[29]); |
2640 | if ( ! $net){ $net=$$hash{$key}[29];} | |
2641 | print"<br>->$net"; | |
2669161d AM |
2642 | if ($$hash{$key}[30] ne ''){ |
2643 | print": $$hash{$key}[30]"; | |
2644 | } | |
2645 | } | |
2a81ab0d AM |
2646 | if ($$hash{$key}[17] eq 'ON'){ |
2647 | $log="/images/on.gif"; | |
2648 | }else{ | |
2649 | $log="/images/off.gif"; | |
2650 | } | |
a0fb1099 | 2651 | #LOGGING |
2a81ab0d | 2652 | print<<END; |
989d0fd7 MT |
2653 | </td> |
2654 | <td align='center'> | |
2655 | <form method='POST' action=''> | |
2656 | <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 ;'/> | |
2657 | <input type='hidden' name='key' value='$key' /> | |
2658 | <input type='hidden' name='config' value='$config' /> | |
2659 | <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' /> | |
2660 | </form> | |
2661 | </td> | |
2a81ab0d | 2662 | END |
a0fb1099 | 2663 | #TARGET |
af768a7e | 2664 | &getcolor($$hash{$key}[5],$$hash{$key}[6],\%customhost); |
2a81ab0d | 2665 | print<<END; |
989d0fd7 | 2666 | <td align='center' $tdcolor> |
2a81ab0d | 2667 | END |
93a017cb AM |
2668 | # Check TGT Host and replace "|" with space |
2669 | if ($$hash{$key}[6] =~ /\|/){ | |
2670 | $$hash{$key}[6] =~ s/\|/ (/g; | |
2671 | $$hash{$key}[6] = $$hash{$key}[6].")"; | |
2672 | } | |
2669161d | 2673 | #Is this a DNAT rule? |
fd169d0a | 2674 | my $natstring; |
ac9e77e3 | 2675 | if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){ |
95cda259 | 2676 | if ($$hash{$key}[29] eq 'Default IP'){$$hash{$key}[29]=$Lang::tr{'red1'};} |
fd169d0a AM |
2677 | if ($$hash{$key}[29] eq 'AUTO'){ |
2678 | my @src_addresses=&fwlib::get_addresses(\%$hash,$key,'src'); | |
2679 | my @nat_ifaces; | |
2680 | foreach my $val (@src_addresses){ | |
896eb2d6 | 2681 | push (@nat_ifaces,&fwlib::get_nat_address($$hash{$key}[29],$val)); |
fd169d0a AM |
2682 | } |
2683 | @nat_ifaces=&del_double(@nat_ifaces); | |
107060da | 2684 | $natstring = ""; |
fd169d0a | 2685 | }else{ |
107060da | 2686 | $natstring = "($$hash{$key}[29])"; |
fd169d0a | 2687 | } |
107060da | 2688 | print "$Lang::tr{'firewall'} $natstring"; |
a6edca5a | 2689 | if($$hash{$key}[30] ne ''){ |
98cee89f | 2690 | $$hash{$key}[30]=~ tr/|/,/; |
a6edca5a | 2691 | print": $$hash{$key}[30]"; |
2669161d | 2692 | } |
989d0fd7 | 2693 | print"<br>->"; |
2669161d | 2694 | } |
0c733ab7 | 2695 | if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire'){ |
cb4439f3 | 2696 | if ($$hash{$key}[6] eq 'RED1'){ |
0c733ab7 | 2697 | print "$Lang::tr{'red1'}"; |
d8afe3e2 | 2698 | }elsif ($$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE'|| $$hash{$key}[6] eq 'ALL' || $$hash{$key}[6] eq 'RED') |
cb4439f3 | 2699 | { |
0c733ab7 | 2700 | print &get_name($$hash{$key}[6]); |
05d4f131 | 2701 | }else{ |
b044bb05 | 2702 | print $$hash{$key}[6]; |
05d4f131 | 2703 | } |
c0a97a0f SS |
2704 | }elsif ($$hash{$key}[5] eq 'cust_geoip_tgt') { |
2705 | my ($split1,$split2) = split(":", $$hash{$key}[6]); | |
2706 | if ($split2) { | |
2707 | print "$split2\n"; | |
2708 | }else{ | |
2709 | print "$Lang::tr{'geoip'}: $$hash{$key}[6]\n"; | |
2710 | } | |
4f3bd0ca AM |
2711 | }elsif ($$hash{$key}[5] eq 'tgt_addr'){ |
2712 | my ($split1,$split2) = split("/",$$hash{$key}[6]); | |
2713 | if ($split2 eq '32'){ | |
2714 | print $split1; | |
2715 | }else{ | |
2716 | print $$hash{$key}[6]; | |
2717 | } | |
2a81ab0d | 2718 | }else{ |
cb4439f3 | 2719 | print "$$hash{$key}[6]"; |
2a81ab0d | 2720 | } |
12a43202 | 2721 | $tdcolor=''; |
a0fb1099 | 2722 | #TARGETPORT |
2a81ab0d | 2723 | &gettgtport(\%$hash,$key); |
93a5f4a5 | 2724 | print"</td>"; |
a0fb1099 | 2725 | #RULE ACTIVE |
2a81ab0d AM |
2726 | if($$hash{$key}[2] eq 'ON'){ |
2727 | $gif="/images/on.gif" | |
2a81ab0d AM |
2728 | }else{ |
2729 | $gif="/images/off.gif" | |
2a81ab0d AM |
2730 | } |
2731 | print<<END; | |
989d0fd7 MT |
2732 | <td width='3%' align='center'> |
2733 | <form method='POST' action=''> | |
2734 | <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;' /> | |
2735 | <input type='hidden' name='key' value='$key' /> | |
2736 | <input type='hidden' name='config' value='$config' /> | |
2737 | <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' /> | |
2738 | </form> | |
2739 | </td> | |
2740 | <td width='3%' align='center'> | |
2741 | <form method='POST' action=''> | |
2742 | <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;' /> | |
2743 | <input type='hidden' name='key' value='$key' /> | |
2744 | <input type='hidden' name='config' value='$config' /> | |
2745 | <input type='hidden' name='ACTION' value='editrule' /> | |
2746 | </form> | |
2747 | </td> | |
2748 | <td width='3%' align='center'> | |
2749 | <form method='POST' action=''> | |
2750 | <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;' /> | |
2751 | <input type='hidden' name='key' value='$key' /> | |
2752 | <input type='hidden' name='config' value='$config' /> | |
2753 | <input type='hidden' name='ACTION' value='copyrule' /> | |
2754 | </form> | |
2755 | </td> | |
2756 | <td width='3%' align='center'> | |
2757 | <form method='POST' action=''> | |
2758 | <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;' /> | |
2759 | <input type='hidden' name='key' value='$key' /> | |
2760 | <input type='hidden' name='config' value='$config' /> | |
2761 | <input type='hidden' name='ACTION' value='deleterule' /> | |
2762 | </form> | |
2763 | </td> | |
2a81ab0d AM |
2764 | END |
2765 | if (exists $$hash{$key-1}){ | |
2766 | print<<END; | |
989d0fd7 MT |
2767 | <td width='3%' align='center'> |
2768 | <form method='POST' action=''> | |
2769 | <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;' /> | |
2770 | <input type='hidden' name='key' value='$key' /> | |
2771 | <input type='hidden' name='config' value='$config' /> | |
2772 | <input type='hidden' name='ACTION' value='moveup' /> | |
2773 | </form> | |
2774 | </td> | |
2a81ab0d AM |
2775 | END |
2776 | }else{ | |
989d0fd7 | 2777 | print"<td width='3%'></td>"; |
2a81ab0d | 2778 | } |
989d0fd7 | 2779 | |
2a81ab0d AM |
2780 | if (exists $$hash{$key+1}){ |
2781 | print<<END; | |
989d0fd7 MT |
2782 | <td width='3%' align='center'> |
2783 | <form method='POST' action=''> | |
2784 | <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;' /> | |
2785 | <input type='hidden' name='key' value='$key' /> | |
2786 | <input type='hidden' name='config' value='$config' /> | |
2787 | <input type='hidden' name='ACTION' value='movedown' /> | |
2788 | </form> | |
2789 | </td> | |
2790 | </tr> | |
2a81ab0d AM |
2791 | END |
2792 | }else{ | |
989d0fd7 | 2793 | print"<td width='3%'></td></tr>"; |
2a81ab0d | 2794 | } |
15add1c8 | 2795 | #REMARK |
3b2ad4a1 | 2796 | if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){ |
989d0fd7 MT |
2797 | print <<END; |
2798 | <tr bgcolor='$color'> | |
2799 | <td> </td> | |
2800 | <td bgcolor='$rulecolor'></td> | |
2801 | <td colspan='10'> | |
2802 | <em>$$hash{$key}[16]</em> | |
2803 | </td> | |
2804 | </tr> | |
2805 | END | |
3b2ad4a1 | 2806 | } |
989d0fd7 | 2807 | |
3b2ad4a1 | 2808 | if ($$hash{$key}[18] eq 'ON'){ |
533a2da3 AM |
2809 | #TIMEFRAME |
2810 | if ($$hash{$key}[18] eq 'ON'){ | |
2811 | my @days=(); | |
2812 | if($$hash{$key}[19] ne ''){push (@days,$Lang::tr{'fwdfw wd_mon'});} | |
2813 | if($$hash{$key}[20] ne ''){push (@days,$Lang::tr{'fwdfw wd_tue'});} | |
2814 | if($$hash{$key}[21] ne ''){push (@days,$Lang::tr{'fwdfw wd_wed'});} | |
2815 | if($$hash{$key}[22] ne ''){push (@days,$Lang::tr{'fwdfw wd_thu'});} | |
2816 | if($$hash{$key}[23] ne ''){push (@days,$Lang::tr{'fwdfw wd_fri'});} | |
2817 | if($$hash{$key}[24] ne ''){push (@days,$Lang::tr{'fwdfw wd_sat'});} | |
2818 | if($$hash{$key}[25] ne ''){push (@days,$Lang::tr{'fwdfw wd_sun'});} | |
2819 | my $weekdays=join(",",@days); | |
2820 | if (@days){ | |
3b2ad4a1 | 2821 | print"<tr bgcolor='$color'>"; |
989d0fd7 | 2822 | print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27]</td></tr>"; |
533a2da3 | 2823 | } |
3b2ad4a1 | 2824 | } |
96502a5a | 2825 | } |
533a2da3 | 2826 | print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>"; |
2a81ab0d | 2827 | } |
c03d4a5e MT |
2828 | } elsif ($optionsfw{'SHOWTABLES'} eq 'on') { |
2829 | print <<END; | |
2830 | <tr> | |
2831 | <td colspan='7' height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td> | |
2832 | </tr> | |
2833 | END | |
2834 | } | |
2835 | ||
2836 | #SHOW FINAL RULE | |
2837 | my $policy = 'fwdfw ' . $fwdfwsettings{'POLICY'}; | |
2838 | my $colour = "bgcolor='green'"; | |
2839 | if ($fwdfwsettings{'POLICY'} eq 'MODE1') { | |
2840 | $colour = "bgcolor='darkred'"; | |
2841 | } | |
2842 | ||
2843 | my $message; | |
2844 | if (($config eq '/var/ipfire/firewall/config') && ($fwdfwsettings{'POLICY'} ne 'MODE1')) { | |
2845 | print <<END; | |
2846 | <tr> | |
2847 | <td colspan='13'> </td> | |
2848 | </tr> | |
2849 | <tr> | |
ec56a539 | 2850 | <td colspan='13' style="padding-left:0px;padding-right:0px"> |
c03d4a5e MT |
2851 | <table width="100%" border='1' rules="cols" cellspacing='0'> |
2852 | END | |
2853 | ||
2854 | # GREEN | |
2855 | print <<END; | |
2856 | <tr> | |
2857 | <td align='center'> | |
2858 | <font color="$Header::colourgreen">$Lang::tr{'green'}</font> | |
2859 | </td> | |
2860 | <td align='center'> | |
2861 | <font color="$Header::colourred">$Lang::tr{'red'}</font> | |
2862 | ($Lang::tr{'fwdfw pol allow'}) | |
2863 | </td> | |
2864 | END | |
2865 | ||
2866 | if (&Header::orange_used()) { | |
2867 | print <<END; | |
2868 | <td align='center'> | |
2869 | <font color="$Header::colourorange">$Lang::tr{'orange'}</font> | |
2870 | ($Lang::tr{'fwdfw pol allow'}) | |
2871 | </td> | |
2872 | END | |
2af92cf5 | 2873 | } |
c03d4a5e MT |
2874 | |
2875 | if (&Header::blue_used()) { | |
2876 | print <<END; | |
2877 | <td align='center'> | |
2878 | <font color="$Header::colourblue">$Lang::tr{'blue'}</font> | |
2879 | ($Lang::tr{'fwdfw pol allow'}) | |
2880 | </td> | |
2881 | END | |
515863e2 | 2882 | } |
a6485463 | 2883 | |
cb051c57 | 2884 | print"</tr>"; |
c03d4a5e MT |
2885 | |
2886 | # ORANGE | |
2887 | if (&Header::orange_used()) { | |
2888 | print <<END; | |
2889 | <tr> | |
2890 | <td align='center' width='20%'> | |
2891 | <font color="$Header::colourorange">$Lang::tr{'orange'}</font> | |
2892 | </td> | |
2893 | <td align='center'> | |
2894 | <font color="$Header::colourred">$Lang::tr{'red'}</font> | |
2895 | ($Lang::tr{'fwdfw pol allow'}) | |
2896 | </td> | |
2897 | <td align='center'> | |
2898 | <font color="$Header::colourgreen">$Lang::tr{'green'}</font> | |
2899 | ($Lang::tr{'fwdfw pol block'}) | |
2900 | </td> | |
2901 | END | |
2902 | ||
2903 | if (&Header::blue_used()) { | |
2904 | print <<END; | |
2905 | <td align='center'> | |
2906 | <font color="$Header::colourblue">$Lang::tr{'blue'}</font> | |
2907 | ($Lang::tr{'fwdfw pol block'}) | |
2908 | </td> | |
2909 | END | |
2910 | } | |
2911 | ||
cb051c57 AM |
2912 | print"</tr>"; |
2913 | } | |
c03d4a5e MT |
2914 | |
2915 | if (&Header::blue_used()) { | |
2916 | print <<END; | |
2917 | <tr> | |
2918 | <td align='center'> | |
12b901f8 | 2919 | <font color="$Header::colourblue">$Lang::tr{'blue'}</font> |
c03d4a5e MT |
2920 | </td> |
2921 | <td align='center'> | |
2922 | <font color="$Header::colourred">$Lang::tr{'red'}</font> | |
2923 | ($Lang::tr{'fwdfw pol allow'}) | |
2924 | </td> | |
2925 | END | |
2926 | ||
2927 | if (&Header::orange_used()) { | |
2928 | print <<END; | |
2929 | <td align='center'> | |
2930 | <font color="$Header::colourorange">$Lang::tr{'orange'}</font> | |
2931 | ($Lang::tr{'fwdfw pol block'}) | |
2932 | </td> | |
3e5e8a4a MT |
2933 | END |
2934 | } | |
2935 | ||
2936 | print <<END; | |
c03d4a5e MT |
2937 | <td align='center'> |
2938 | <font color="$Header::colourgreen">$Lang::tr{'green'}</font> | |
2939 | ($Lang::tr{'fwdfw pol block'}) | |
2940 | </td> | |
3e5e8a4a | 2941 | </tr> |
c03d4a5e | 2942 | END |
cb051c57 | 2943 | } |
c03d4a5e MT |
2944 | |
2945 | print <<END; | |
2946 | </table> | |
2947 | </td> | |
2948 | </tr> | |
2949 | END | |
2950 | ||
2951 | $message = $Lang::tr{'fwdfw pol allow'}; | |
2952 | ||
35ca8e02 | 2953 | } elsif ($config eq '/var/ipfire/firewall/outgoing' && ($fwdfwsettings{'POLICY1'} ne 'MODE1')) { |
c03d4a5e | 2954 | $message = $Lang::tr{'fwdfw pol allow'}; |
35ca8e02 | 2955 | $colour = "bgcolor='green'"; |
c03d4a5e MT |
2956 | } else { |
2957 | $message = $Lang::tr{'fwdfw pol block'}; | |
2958 | $colour = "bgcolor='darkred'"; | |
2959 | } | |
2960 | ||
2961 | if ($message) { | |
2962 | print <<END; | |
2963 | <tr> | |
2964 | <td $colour align='center' colspan='13'> | |
2965 | <font color='#FFFFFF'>$Lang::tr{'policy'}: $message</font> | |
2966 | </td> | |
2967 | </tr> | |
2968 | END | |
cb051c57 | 2969 | } |
c03d4a5e MT |
2970 | |
2971 | print "</table>"; | |
2972 | print "<br>"; | |
2973 | ||
2974 | &Header::closebox(); | |
a6485463 | 2975 | } |
c03d4a5e MT |
2976 | |
2977 | &Header::closebigbox(); | |
2978 | &Header::closepage(); |