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