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