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