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