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