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