]>
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 | # # | |
30 | # # | |
31 | ############################################################################### | |
32 | ||
33 | use strict; | |
34 | no warnings 'uninitialized'; | |
35 | # enable only the following on debugging purpose | |
36 | #use warnings; | |
37 | #use CGI::Carp 'fatalsToBrowser'; | |
38 | ||
39 | require '/var/ipfire/general-functions.pl'; | |
40 | require "${General::swroot}/lang.pl"; | |
41 | require "${General::swroot}/header.pl"; | |
42 | require "${General::swroot}/forward/bin/firewall-lib.pl"; | |
43 | ||
44 | unless (-d "${General::swroot}/forward") { system("mkdir ${General::swroot}/forward"); } | |
45 | unless (-e "${General::swroot}/forward/settings") { system("touch ${General::swroot}/forward/settings"); } | |
46 | unless (-e "${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); } | |
47 | unless (-e "${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); } | |
48 | ||
49 | my %fwdfwsettings=(); | |
50 | my %selected=() ; | |
51 | my %defaultNetworks=(); | |
52 | my %netsettings=(); | |
53 | my %customhost=(); | |
54 | my %customgrp=(); | |
55 | my %customnetworks=(); | |
56 | my %customservice=(); | |
57 | my %customservicegrp=(); | |
58 | my %ccdnet=(); | |
59 | my %customnetwork=(); | |
60 | my %ccdhost=(); | |
61 | my %configfwdfw=(); | |
62 | my %configinputfw=(); | |
63 | my %ipsecconf=(); | |
64 | my %color=(); | |
65 | my %mainsettings=(); | |
66 | my %checked=(); | |
67 | my %icmptypes=(); | |
68 | my %ovpnsettings=(); | |
69 | my %ipsecsettings=(); | |
70 | my %aliases=(); | |
71 | my $color; | |
72 | my $confignet = "${General::swroot}/fwhosts/customnetworks"; | |
73 | my $confighost = "${General::swroot}/fwhosts/customhosts"; | |
74 | my $configgrp = "${General::swroot}/fwhosts/customgroups"; | |
75 | my $configsrv = "${General::swroot}/fwhosts/customservices"; | |
76 | my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp"; | |
77 | my $configccdnet = "${General::swroot}/ovpn/ccd.conf"; | |
78 | my $configccdhost = "${General::swroot}/ovpn/ovpnconfig"; | |
79 | my $configipsec = "${General::swroot}/vpn/config"; | |
80 | my $configipsecrw = "${General::swroot}/vpn/settings"; | |
81 | my $configfwdfw = "${General::swroot}/forward/config"; | |
82 | my $configinput = "${General::swroot}/forward/input"; | |
83 | my $configovpn = "${General::swroot}/ovpn/settings"; | |
84 | ||
85 | my $errormessage=''; | |
86 | my $hint=''; | |
87 | my $ipgrp="${General::swroot}/outgoing/groups"; | |
88 | ||
89 | ||
90 | &General::readhash("${General::swroot}/forward/settings", \%fwdfwsettings); | |
91 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
92 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
93 | ||
94 | &Header::showhttpheaders(); | |
95 | &Header::getcgihash(\%fwdfwsettings); | |
96 | &Header::openpage($Lang::tr{'fwdfw menu'}, 1, ''); | |
97 | &Header::openbigbox('100%', 'center',$errormessage); | |
98 | #### ACTION ##### | |
99 | ||
100 | if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'save'}) | |
101 | { | |
102 | my $MODE = $fwdfwsettings{'POLICY'}; | |
103 | %fwdfwsettings = (); | |
104 | $fwdfwsettings{'POLICY'} = "$MODE"; | |
105 | &General::writehash("${General::swroot}/forward/settings", \%fwdfwsettings); | |
106 | &reread_rules; | |
107 | } | |
108 | if ($fwdfwsettings{'ACTION'} eq 'saverule') | |
109 | { | |
110 | &General::readhasharray("$configfwdfw", \%configfwdfw); | |
111 | &General::readhasharray("$configinput", \%configinputfw); | |
112 | $errormessage=&checksource; | |
113 | if(!$errormessage){&checktarget;} | |
114 | if(!$errormessage){&checkrule;} | |
2a81ab0d | 115 | #check if we change an forward rule to an external access |
62fc8511 | 116 | if( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){ |
2a81ab0d AM |
117 | $fwdfwsettings{'updatefwrule'}=''; |
118 | $fwdfwsettings{'config'}=$configfwdfw; | |
119 | $fwdfwsettings{'nobase'}='on'; | |
120 | &deleterule; | |
62fc8511 AM |
121 | &checkcounter(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}}); |
122 | &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}); | |
2a81ab0d | 123 | } |
2a81ab0d | 124 | #check if we change an external access rule to an forward |
62fc8511 | 125 | if( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){ |
2a81ab0d AM |
126 | $fwdfwsettings{'updatefwrule'}=''; |
127 | $fwdfwsettings{'config'}=$configinput; | |
128 | $fwdfwsettings{'nobase'}='on'; | |
129 | &deleterule; | |
62fc8511 AM |
130 | &checkcounter(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}}); |
131 | &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}); | |
2a81ab0d | 132 | } |
2a81ab0d AM |
133 | #INPUT part |
134 | if($fwdfwsettings{'grp2'} eq 'ipfire'){ | |
135 | $fwdfwsettings{'chain'} = 'INPUTFW'; | |
136 | #check if we have an identical rule already | |
2da264ec AM |
137 | if($fwdfwsettings{'oldrulenumer'} eq $fwdfwsettings{'rulepos'}){ |
138 | foreach my $key (sort keys %configinputfw){ | |
139 | 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'}" | |
140 | 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]"){ | |
141 | $errormessage.=$Lang::tr{'fwdfw err ruleexists'}; | |
02da9f7b AM |
142 | if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){ |
143 | $errormessage=''; | |
144 | } | |
145 | if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){ | |
146 | $fwdfwsettings{'nosave'} = 'on'; | |
147 | } | |
2da264ec | 148 | } |
62fc8511 | 149 | } |
2da264ec | 150 | } |
992394d5 AM |
151 | #check if we just close a rule |
152 | 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'} ) { | |
153 | if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){ | |
154 | $errormessage=''; | |
155 | $fwdfwsettings{'nosave2'} = 'on'; | |
156 | } | |
157 | } | |
62fc8511 AM |
158 | &checkcounter($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}}); |
159 | if ($fwdfwsettings{'nobase'} ne 'on'){ | |
160 | &checkcounter($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}}); | |
161 | } | |
162 | if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){ | |
163 | &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}); | |
164 | }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') { | |
165 | &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0); | |
166 | }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){ | |
167 | &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}); | |
168 | } | |
992394d5 AM |
169 | if($fwdfwsettings{'nosave2'} ne 'on'){ |
170 | &saverule(\%configinputfw,$configinput); | |
171 | } | |
2a81ab0d AM |
172 | #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>"; |
173 | #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>"; | |
174 | #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>"; | |
175 | #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>"; | |
176 | #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>"; | |
177 | #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>"; | |
178 | #print " Regel LOG: $fwdfwsettings{'LOG'}<br>"; | |
179 | #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>"; | |
180 | #print " MO: $fwdfwsettings{'TIME_MON'}<br>"; | |
181 | #print " DI: $fwdfwsettings{'TIME_TUE'}<br>"; | |
182 | #print " MI: $fwdfwsettings{'TIME_WED'}<br>"; | |
183 | #print " DO: $fwdfwsettings{'TIME_THU'}<br>"; | |
184 | #print " FR: $fwdfwsettings{'TIME_FRI'}<br>"; | |
185 | #print " SA: $fwdfwsettings{'TIME_SAT'}<br>"; | |
186 | #print " SO: $fwdfwsettings{'TIME_SUN'}<br>"; | |
187 | #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>"; | |
188 | #print "<br>"; | |
189 | #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>"; | |
190 | #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>"; | |
191 | #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>"; | |
192 | #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 |
193 | }else{ |
194 | $fwdfwsettings{'chain'} = 'FORWARDFW'; | |
2da264ec AM |
195 | if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){ |
196 | #check if we have an identical rule already | |
197 | foreach my $key (sort keys %configfwdfw){ | |
198 | 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'}" | |
199 | 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]"){ | |
200 | $errormessage.=$Lang::tr{'fwdfw err ruleexists'}; | |
02da9f7b AM |
201 | if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){ |
202 | $errormessage=''; | |
203 | } | |
204 | if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){ | |
205 | $fwdfwsettings{'nosave'} = 'on'; | |
206 | } | |
2da264ec AM |
207 | } |
208 | } | |
2a81ab0d | 209 | } |
992394d5 AM |
210 | #check if we just close a rule |
211 | 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'} ) { | |
212 | if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){ | |
213 | $fwdfwsettings{'nosave2'} = 'on'; | |
214 | $errormessage=''; | |
215 | } | |
216 | } | |
2a81ab0d AM |
217 | #increase counters |
218 | &checkcounter($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}}); | |
2a81ab0d | 219 | &checkcounter($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}}); |
2a81ab0d AM |
220 | if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){ |
221 | &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}); | |
222 | }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') { | |
223 | &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0); | |
224 | }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){ | |
225 | &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}); | |
226 | } | |
2a81ab0d AM |
227 | if ($fwdfwsettings{'nobase'} eq 'on'){ |
228 | &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}); | |
229 | } | |
992394d5 AM |
230 | if ($fwdfwsettings{'nosave2'} ne 'on'){ |
231 | &saverule(\%configfwdfw,$configfwdfw); | |
232 | } | |
2a81ab0d AM |
233 | #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>"; |
234 | #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>"; | |
235 | #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>"; | |
236 | #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>"; | |
237 | #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>"; | |
238 | #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>"; | |
239 | #print " Regel LOG: $fwdfwsettings{'LOG'}<br>"; | |
240 | #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>"; | |
241 | #print " MO: $fwdfwsettings{'TIME_MON'}<br>"; | |
242 | #print " DI: $fwdfwsettings{'TIME_TUE'}<br>"; | |
243 | #print " MI: $fwdfwsettings{'TIME_WED'}<br>"; | |
244 | #print " DO: $fwdfwsettings{'TIME_THU'}<br>"; | |
245 | #print " FR: $fwdfwsettings{'TIME_FRI'}<br>"; | |
246 | #print " SA: $fwdfwsettings{'TIME_SAT'}<br>"; | |
247 | #print " SO: $fwdfwsettings{'TIME_SUN'}<br>"; | |
248 | #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>"; | |
249 | #print "<br>"; | |
250 | #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>"; | |
251 | #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>"; | |
252 | #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>"; | |
253 | #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 |
254 | } |
255 | if ($errormessage){ | |
256 | &newrule; | |
257 | }else{ | |
992394d5 AM |
258 | if($fwdfwsettings{'nosave2'} ne 'on'){ |
259 | &rules; | |
260 | } | |
2a81ab0d AM |
261 | &base; |
262 | } | |
2a81ab0d AM |
263 | } |
264 | if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'reset'}) | |
265 | { | |
266 | &General::readhasharray("$configfwdfw", \%configfwdfw); | |
267 | foreach my $key (sort keys %configfwdfw){ | |
268 | &checkcounter($configfwdfw{$key}[3],$configfwdfw{$key}[4],,); | |
269 | &checkcounter($configfwdfw{$key}[5],$configfwdfw{$key}[6],,); | |
270 | &checkcounter($configfwdfw{$key}[14],$configfwdfw{$key}[15],,); | |
271 | } | |
272 | &General::readhasharray("$configinput", \%configinputfw); | |
273 | foreach my $key (sort keys %configinputfw){ | |
274 | &checkcounter($configinputfw{$key}[3],$configinputfw{$key}[4],,); | |
275 | &checkcounter($configinputfw{$key}[5],$configinputfw{$key}[6],,); | |
276 | &checkcounter($configinputfw{$key}[14],$configinputfw{$key}[15],,); | |
277 | } | |
278 | $fwdfwsettings{'POLICY'}='MODE0'; | |
279 | system("rm ${General::swroot}/forward/config"); | |
280 | system("rm ${General::swroot}/forward/input"); | |
2a81ab0d AM |
281 | &General::writehash("${General::swroot}/forward/settings", \%fwdfwsettings); |
282 | unless (-e "${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); } | |
283 | unless (-e "${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); } | |
62fc8511 | 284 | %fwdfwsettings = (); |
2a81ab0d AM |
285 | &reread_rules; |
286 | ||
287 | } | |
288 | if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw newrule'}) | |
289 | { | |
290 | &newrule; | |
291 | } | |
292 | if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw toggle'}) | |
293 | { | |
294 | my %togglehash=(); | |
295 | &General::readhasharray($fwdfwsettings{'config'}, \%togglehash); | |
296 | foreach my $key (sort keys %togglehash){ | |
297 | if ($key eq $fwdfwsettings{'key'}){ | |
298 | if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';} | |
299 | } | |
300 | } | |
301 | &General::writehasharray($fwdfwsettings{'config'}, \%togglehash); | |
302 | &rules; | |
303 | &base; | |
304 | } | |
305 | if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw togglelog'}) | |
306 | { | |
307 | my %togglehash=(); | |
308 | &General::readhasharray($fwdfwsettings{'config'}, \%togglehash); | |
309 | foreach my $key (sort keys %togglehash){ | |
310 | if ($key eq $fwdfwsettings{'key'}){ | |
311 | if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';} | |
312 | } | |
313 | } | |
314 | &General::writehasharray($fwdfwsettings{'config'}, \%togglehash); | |
315 | &rules; | |
316 | &base; | |
317 | } | |
318 | if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw reread'}) | |
319 | { | |
320 | &reread_rules; | |
321 | &base; | |
322 | } | |
323 | if ($fwdfwsettings{'ACTION'} eq 'editrule') | |
324 | { | |
325 | $fwdfwsettings{'updatefwrule'}='on'; | |
326 | &newrule; | |
327 | } | |
328 | if ($fwdfwsettings{'ACTION'} eq 'deleterule') | |
329 | { | |
330 | &deleterule; | |
331 | } | |
332 | if ($fwdfwsettings{'ACTION'} eq 'moveup') | |
333 | { | |
334 | &pos_up; | |
335 | &base; | |
336 | } | |
337 | if ($fwdfwsettings{'ACTION'} eq 'movedown') | |
338 | { | |
339 | &pos_down; | |
340 | &base; | |
341 | } | |
342 | if ($fwdfwsettings{'ACTION'} eq 'copyrule') | |
343 | { | |
344 | $fwdfwsettings{'copyfwrule'}='on'; | |
345 | #$fwdfwsettings{'updatefwrule'}='on'; | |
346 | &newrule; | |
347 | } | |
348 | if ($fwdfwsettings{'ACTION'} eq '') | |
349 | { | |
350 | &base; | |
351 | } | |
352 | ### Functions #### | |
353 | sub pos_up | |
354 | { | |
355 | my %uphash=(); | |
356 | my %tmp=(); | |
357 | &General::readhasharray($fwdfwsettings{'config'}, \%uphash); | |
358 | foreach my $key (sort keys %uphash){ | |
359 | if ($key eq $fwdfwsettings{'key'}) { | |
360 | my $last = $key -1; | |
361 | if (exists $uphash{$last}){ | |
362 | #save rule last | |
363 | foreach my $y (0 .. $#{$uphash{$last}}) { | |
364 | $tmp{0}[$y] = $uphash{$last}[$y]; | |
365 | } | |
366 | #copy active rule to last | |
367 | foreach my $i (0 .. $#{$uphash{$last}}) { | |
368 | $uphash{$last}[$i] = $uphash{$key}[$i]; | |
369 | } | |
370 | #copy saved rule to actual position | |
371 | foreach my $x (0 .. $#{$tmp{0}}) { | |
372 | $uphash{$key}[$x] = $tmp{0}[$x]; | |
373 | } | |
374 | } | |
375 | } | |
376 | } | |
377 | &General::writehasharray($fwdfwsettings{'config'}, \%uphash); | |
378 | &rules; | |
379 | } | |
380 | sub pos_down | |
381 | { | |
382 | my %downhash=(); | |
383 | my %tmp=(); | |
384 | &General::readhasharray($fwdfwsettings{'config'}, \%downhash); | |
385 | foreach my $key (sort keys %downhash){ | |
386 | if ($key eq $fwdfwsettings{'key'}) { | |
387 | my $next = $key + 1; | |
388 | if (exists $downhash{$next}){ | |
389 | #save rule next | |
390 | foreach my $y (0 .. $#{$downhash{$next}}) { | |
391 | $tmp{0}[$y] = $downhash{$next}[$y]; | |
392 | } | |
393 | #copy active rule to next | |
394 | foreach my $i (0 .. $#{$downhash{$next}}) { | |
395 | $downhash{$next}[$i] = $downhash{$key}[$i]; | |
396 | } | |
397 | #copy saved rule to actual position | |
398 | foreach my $x (0 .. $#{$tmp{0}}) { | |
399 | $downhash{$key}[$x] = $tmp{0}[$x]; | |
400 | } | |
401 | } | |
402 | } | |
403 | } | |
404 | &General::writehasharray($fwdfwsettings{'config'}, \%downhash); | |
405 | &rules; | |
406 | } | |
407 | sub checkcounter | |
408 | { | |
409 | my ($base1,$val1,$base2,$val2) = @_; | |
410 | ||
411 | if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){ | |
412 | &dec_counter($confignet,\%customnetwork,$val1); | |
413 | }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){ | |
414 | &dec_counter($confighost,\%customhost,$val1); | |
415 | }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){ | |
416 | &dec_counter($configgrp,\%customgrp,$val1); | |
417 | }elsif($base1 eq 'cust_srv'){ | |
418 | &dec_counter($configsrv,\%customservice,$val1); | |
419 | }elsif($base1 eq 'cust_srvgrp'){ | |
420 | &dec_counter($configsrvgrp,\%customservicegrp,$val1); | |
421 | } | |
62fc8511 | 422 | |
2a81ab0d AM |
423 | if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){ |
424 | &inc_counter($confignet,\%customnetwork,$val2); | |
425 | }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){ | |
426 | &inc_counter($confighost,\%customhost,$val2); | |
427 | }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){ | |
428 | &inc_counter($configgrp,\%customgrp,$val2); | |
429 | }elsif($base2 eq 'cust_srv'){ | |
430 | &inc_counter($configsrv,\%customservice,$val2); | |
431 | }elsif($base2 eq 'cust_srvgrp'){ | |
432 | &inc_counter($configsrvgrp,\%customservicegrp,$val2); | |
433 | } | |
434 | } | |
435 | sub inc_counter | |
436 | { | |
437 | my $config=shift; | |
438 | my %hash=%{(shift)}; | |
439 | my $val=shift; | |
440 | my $pos; | |
62fc8511 | 441 | |
2a81ab0d AM |
442 | &General::readhasharray($config, \%hash); |
443 | foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){ | |
444 | if($hash{$key}[0] eq $val){ | |
445 | $pos=$#{$hash{$key}}; | |
446 | $hash{$key}[$pos] = $hash{$key}[$pos]+1; | |
2a81ab0d AM |
447 | } |
448 | } | |
449 | &General::writehasharray($config, \%hash); | |
450 | } | |
451 | sub dec_counter | |
452 | { | |
453 | my $config=shift; | |
454 | my %hash=%{(shift)}; | |
455 | my $val=shift; | |
456 | my $pos; | |
457 | #$errormessage.="ALT:config: $config , verringert wird $val <br>"; | |
458 | &General::readhasharray($config, \%hash); | |
459 | foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){ | |
460 | if($hash{$key}[0] eq $val){ | |
461 | $pos=$#{$hash{$key}}; | |
462 | $hash{$key}[$pos] = $hash{$key}[$pos]-1; | |
2a81ab0d AM |
463 | } |
464 | } | |
465 | &General::writehasharray($config, \%hash); | |
466 | } | |
467 | sub base | |
468 | { | |
2a81ab0d AM |
469 | if ($fwdfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; } |
470 | if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; } | |
471 | if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; } | |
62fc8511 | 472 | |
2a81ab0d AM |
473 | &hint; |
474 | if ($fwdfwsettings{'POLICY'} ne 'MODE0' && $fwdfwsettings{'POLICY'} ne '') { | |
475 | &addrule; | |
476 | } | |
62fc8511 | 477 | |
2a81ab0d AM |
478 | #print"<table width='100' border='1'><tr>"; |
479 | #foreach (0 .. 40){ | |
480 | #my $i="color".$_; | |
481 | #print"<td bgcolor='$color{$i}'>$_</td>"; | |
482 | #} | |
483 | #print"</tr></table>"; | |
484 | &Header::openbox('100%', 'center', 'Policy'); | |
485 | print <<END; | |
486 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
487 | <table width='100%'> | |
488 | <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 0:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode0'}</td></tr> | |
489 | <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 1:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode1'}</td></tr> | |
490 | <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 2:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode2'}</td></tr> | |
491 | <tr><td colspan='3'><hr /></td></tr> | |
492 | <tr><td width='10%' align='left'> <select name='POLICY' style="width: 85px"><option value='MODE0' $selected{'POLICY'}{'MODE0'}>$Lang::tr{'mode'} 0</option><option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'mode'} 1</option><option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'mode'} 2</option></select> | |
493 | <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} /> | |
494 | <td width='45%' align='left'> | |
495 | END | |
496 | if ($fwdfwsettings{'POLICY'} ne 'MODE0'&& $fwdfwsettings{'POLICY'} ne '' ) { | |
497 | print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />"; | |
498 | } | |
499 | print "</table></form>"; | |
500 | &Header::closebox(); | |
501 | } | |
502 | sub addrule | |
503 | { | |
504 | &error; | |
505 | &Header::openbox('100%', 'left', $Lang::tr{'fwdfw addrule'}); | |
62fc8511 | 506 | |
2a81ab0d AM |
507 | print "<form method='post'>"; |
508 | print "<table border='0'>"; | |
509 | print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>"; | |
510 | if (-f "${General::swroot}/forward/reread"){ | |
511 | print "<td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}'></td>"; | |
512 | } | |
513 | print"</tr></table></form><hr>"; | |
514 | ||
515 | &Header::closebox(); | |
516 | &viewtablerule; | |
2a81ab0d AM |
517 | } |
518 | sub deleterule | |
519 | { | |
520 | my %delhash=(); | |
521 | &General::readhasharray($fwdfwsettings{'config'}, \%delhash); | |
2da264ec | 522 | foreach my $key (sort {$a <=> $b} keys %delhash){ |
992394d5 | 523 | if ($key == $fwdfwsettings{'key'}){ |
2a81ab0d AM |
524 | #check hosts/net and groups |
525 | &checkcounter($delhash{$key}[3],$delhash{$key}[4],,); | |
526 | &checkcounter($delhash{$key}[5],$delhash{$key}[6],,); | |
527 | #check services and groups | |
528 | if ($delhash{$key}[11] eq 'ON'){ | |
529 | &checkcounter($delhash{$key}[14],$delhash{$key}[15],,); | |
530 | } | |
531 | } | |
992394d5 | 532 | if ($key >= $fwdfwsettings{'key'}) { |
2a81ab0d AM |
533 | my $next = $key + 1; |
534 | if (exists $delhash{$next}) { | |
e5345541 | 535 | foreach my $i (0 .. $#{$delhash{$next}}) { |
2a81ab0d AM |
536 | $delhash{$key}[$i] = $delhash{$next}[$i]; |
537 | } | |
538 | } | |
539 | } | |
540 | } | |
541 | # Remove the very last entry. | |
275a92e8 | 542 | my $last_key = (sort {$a <=> $b} keys %delhash)[-1]; |
2a81ab0d AM |
543 | delete $delhash{$last_key}; |
544 | ||
545 | &General::writehasharray($fwdfwsettings{'config'}, \%delhash); | |
546 | &rules; | |
62fc8511 | 547 | |
2a81ab0d AM |
548 | if($fwdfwsettings{'nobase'} ne 'on'){ |
549 | &base; | |
550 | } | |
551 | } | |
552 | sub disable_rule | |
553 | { | |
554 | my $key1=shift; | |
555 | &General::readhasharray("$configfwdfw", \%configfwdfw); | |
556 | foreach my $key (sort keys %configfwdfw){ | |
557 | if ($key eq $key1 ){ | |
558 | if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';} | |
559 | } | |
560 | } | |
561 | &General::writehasharray("$configfwdfw", \%configfwdfw); | |
562 | &rules; | |
2a81ab0d AM |
563 | } |
564 | sub checksource | |
565 | { | |
566 | my ($ip,$subnet); | |
567 | ||
568 | #check ip-address if manual | |
569 | if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){ | |
570 | #check if ip with subnet | |
571 | if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?)$/) { | |
572 | ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'}); | |
573 | $subnet = &General::iporsubtocidr($subnet); | |
b5269091 | 574 | $fwdfwsettings{'isip'}='on'; |
2a81ab0d AM |
575 | } |
576 | #check if only ip | |
577 | if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){ | |
578 | $ip=$fwdfwsettings{'src_addr'}; | |
579 | $subnet = '32'; | |
b5269091 | 580 | $fwdfwsettings{'isip'}='on'; |
2a81ab0d | 581 | } |
2a81ab0d | 582 | |
b5269091 AM |
583 | if ($fwdfwsettings{'isip'} ne 'on'){ |
584 | if (&General::validmac($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';} | |
585 | } | |
586 | if ($fwdfwsettings{'isip'} eq 'on'){ | |
587 | #check and form valid IP | |
588 | $ip=&General::ip2dec($ip); | |
589 | $ip=&General::dec2ip($ip); | |
590 | #check if net or broadcast | |
591 | my @tmp= split (/\./,$ip); | |
592 | if (($tmp[3] eq "0") || ($tmp[3] eq "255")) | |
593 | { | |
594 | $errormessage=$Lang::tr{'fwhost err hostip'}."<br>"; | |
595 | } | |
596 | $fwdfwsettings{'src_addr'}="$ip/$subnet"; | |
597 | ||
598 | if(!&General::validipandmask($fwdfwsettings{'src_addr'})){ | |
599 | $errormessage.=$Lang::tr{'fwdfw err src_addr'}."<br>"; | |
600 | } | |
601 | } | |
602 | if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){ | |
2a81ab0d AM |
603 | $errormessage.=$Lang::tr{'fwdfw err src_addr'}."<br>"; |
604 | } | |
605 | }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){ | |
606 | $errormessage.=$Lang::tr{'fwdfw err nosrcip'}; | |
607 | return $errormessage; | |
608 | } | |
62fc8511 | 609 | |
2a81ab0d AM |
610 | #check empty fields |
611 | if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr{'fwdfw err nosrc'}."<br>";} | |
612 | #check icmp source | |
613 | if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){ | |
614 | $fwdfwsettings{'SRC_PORT'}=''; | |
615 | &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes); | |
616 | foreach my $key (keys %icmptypes){ | |
617 | if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){ | |
618 | $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]"; | |
619 | } | |
620 | } | |
62fc8511 AM |
621 | }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){ |
622 | $fwdfwsettings{'SRC_PORT'}=''; | |
623 | $fwdfwsettings{'ICMP_TYPES'}=''; | |
624 | }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){ | |
625 | $fwdfwsettings{'SRC_PORT'}=''; | |
626 | $fwdfwsettings{'ICMP_TYPES'}=''; | |
2a81ab0d AM |
627 | }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){ |
628 | $fwdfwsettings{'ICMP_TYPES'}=''; | |
629 | }else{ | |
630 | $fwdfwsettings{'ICMP_TYPES'}=''; | |
631 | $fwdfwsettings{'SRC_PORT'}=''; | |
632 | $fwdfwsettings{'PROT'}=''; | |
633 | } | |
62fc8511 | 634 | |
2a81ab0d AM |
635 | if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP' && $fwdfwsettings{'SRC_PORT'} ne ''){ |
636 | #change dashes with : | |
637 | $fwdfwsettings{'SRC_PORT'}=~ tr/-/:/; | |
638 | ||
639 | if ($fwdfwsettings{'SRC_PORT'} eq "*") { | |
640 | $fwdfwsettings{'SRC_PORT'} = "1:65535"; | |
641 | } | |
642 | if ($fwdfwsettings{'SRC_PORT'} =~ /^(\D)\:(\d+)$/) { | |
643 | $fwdfwsettings{'SRC_PORT'} = "1:$2"; | |
644 | } | |
645 | if ($fwdfwsettings{'SRC_PORT'} =~ /^(\d+)\:(\D)$/) { | |
646 | $fwdfwsettings{'SRC_PORT'} = "$1:65535"; | |
647 | } | |
62fc8511 | 648 | |
2a81ab0d AM |
649 | $errormessage.=&General::validportrange($fwdfwsettings{'SRC_PORT'},'src'); |
650 | } | |
651 | return $errormessage; | |
652 | } | |
653 | sub checktarget | |
654 | { | |
655 | my ($ip,$subnet); | |
62fc8511 | 656 | |
2a81ab0d AM |
657 | if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){ |
658 | #check if ip with subnet | |
659 | if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?)$/) { | |
660 | ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'}); | |
661 | $subnet = &General::iporsubtocidr($subnet); | |
662 | } | |
663 | #check if only ip | |
664 | if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){ | |
665 | $ip=$fwdfwsettings{'tgt_addr'}; | |
666 | $subnet='32'; | |
667 | } | |
668 | #check and form valid IP | |
669 | $ip=&General::ip2dec($ip); | |
670 | $ip=&General::dec2ip($ip); | |
671 | ||
672 | #check if net or broadcast | |
673 | my @tmp= split (/\./,$ip); | |
674 | if (($tmp[3] eq "0") || ($tmp[3] eq "255")) | |
675 | { | |
55674e0d | 676 | $errormessage=$Lang::tr{'fwhost err hostip'}."<br>"; |
2a81ab0d | 677 | } |
55674e0d | 678 | $fwdfwsettings{'tgt_addr'}="$ip/$subnet"; |
2a81ab0d AM |
679 | |
680 | if(!&General::validipandmask($fwdfwsettings{'tgt_addr'})){ | |
681 | $errormessage.=$Lang::tr{'fwdfw err tgt_addr'}."<br>"; | |
682 | } | |
62fc8511 | 683 | |
2a81ab0d AM |
684 | }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){ |
685 | $errormessage.=$Lang::tr{'fwdfw err notgtip'}; | |
686 | return $errormessage; | |
687 | } | |
62fc8511 | 688 | |
2a81ab0d AM |
689 | #check empty fields |
690 | if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr{'fwdfw err notgt'}."<br>";} | |
62fc8511 | 691 | |
2a81ab0d AM |
692 | #check tgt services |
693 | if ($fwdfwsettings{'USESRV'} eq 'ON'){ | |
694 | if ($fwdfwsettings{'grp3'} eq 'cust_srv'){ | |
695 | $fwdfwsettings{'TGT_PROT'}=''; | |
696 | $fwdfwsettings{'ICMP_TGT'}=''; | |
697 | } | |
698 | if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){ | |
699 | $fwdfwsettings{'TGT_PROT'}=''; | |
700 | $fwdfwsettings{'ICMP_TGT'}=''; | |
701 | #check target service | |
702 | if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){ | |
703 | $errormessage.=$Lang::tr{'fwdfw err tgt_grp'}; | |
704 | } | |
705 | } | |
706 | if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){ | |
62fc8511 | 707 | if ($fwdfwsettings{'TGT_PROT'} ne 'ICMP' && $fwdfwsettings{'TGT_PROT'} ne 'GRE'){ |
2a81ab0d AM |
708 | if ($fwdfwsettings{'TGT_PORT'} ne ''){ |
709 | #change dashes with : | |
710 | $fwdfwsettings{'TGT_PORT'}=~ tr/-/:/; | |
711 | if ($fwdfwsettings{'TGT_PORT'} eq "*") { | |
712 | $fwdfwsettings{'TGT_PORT'} = "1:65535"; | |
713 | } | |
714 | if ($fwdfwsettings{'TGT_PORT'} =~ /^(\D)\:(\d+)$/) { | |
715 | $fwdfwsettings{'TGT_PORT'} = "1:$2"; | |
716 | } | |
717 | if ($fwdfwsettings{'TGT_PORT'} =~ /^(\d+)\:(\D)$/) { | |
718 | $fwdfwsettings{'TGT_PORT'} = "$1:65535"; | |
719 | } | |
720 | $errormessage .= &General::validportrange($fwdfwsettings{'TGT_PORT'}, 'destination'); | |
721 | } | |
62fc8511 AM |
722 | }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){ |
723 | $fwdfwsettings{'TGT_PORT'} = ''; | |
724 | $fwdfwsettings{'ICMP_TGT'} = ''; | |
725 | }elsif($fwdfwsettings{'TGT_PORT'} eq 'ESP'){ | |
726 | $fwdfwsettings{'TGT_PORT'}=''; | |
727 | $fwdfwsettings{'ICMP_TGT'}=''; | |
2a81ab0d | 728 | }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){ |
62fc8511 | 729 | $fwdfwsettings{'TGT_PORT'} = ''; |
2a81ab0d AM |
730 | &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes); |
731 | foreach my $key (keys %icmptypes){ | |
732 | ||
733 | if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){ | |
2a81ab0d AM |
734 | $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0]; |
735 | } | |
736 | } | |
737 | } | |
738 | } | |
739 | } | |
62fc8511 | 740 | |
2a81ab0d AM |
741 | #check targetport |
742 | if ($fwdfwsettings{'USESRV'} ne 'ON'){ | |
743 | $fwdfwsettings{'grp3'}=''; | |
744 | $fwdfwsettings{$fwdfwsettings{'grp3'}}=''; | |
745 | $fwdfwsettings{'TGT_PROT'}=''; | |
746 | $fwdfwsettings{'ICMP_TGT'}=''; | |
747 | } | |
2a81ab0d AM |
748 | #check timeframe |
749 | if($fwdfwsettings{'TIME'} eq 'ON'){ | |
750 | 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 ''){ | |
751 | $errormessage=$Lang::tr{'fwdfw err time'}; | |
752 | } | |
753 | } | |
2a81ab0d AM |
754 | return $errormessage; |
755 | } | |
756 | sub checkrule | |
757 | { | |
758 | #check valid remark | |
759 | if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark($fwdfwsettings{'ruleremark'})){ | |
760 | $errormessage.=$Lang::tr{'fwdfw err remark'}."<br>"; | |
761 | } | |
762 | #check if source and target identical | |
763 | if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}}){ | |
764 | $errormessage.=$Lang::tr{'fwdfw err same'}; | |
765 | return $errormessage; | |
766 | } | |
62fc8511 | 767 | |
2a81ab0d AM |
768 | #get source and targetip address if possible |
769 | my ($sip,$scidr,$tip,$tcidr); | |
770 | ($sip,$scidr)=&get_ip("src","grp1"); | |
771 | ($tip,$tcidr)=&get_ip("tgt","grp2"); | |
62fc8511 | 772 | |
2a81ab0d AM |
773 | #check same iprange in source and target |
774 | if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){ | |
2a81ab0d AM |
775 | my $networkip1=&General::getnetworkip($sip,$scidr); |
776 | my $networkip2=&General::getnetworkip($tip,$tcidr); | |
777 | if ($scidr gt $tcidr){ | |
778 | if ( &General::IpInSubnet($networkip1,$tip,&General::iporsubtodec($tcidr)) ){ | |
779 | $errormessage.=$Lang::tr{'fwdfw err samesub'}; | |
780 | } | |
781 | }elsif($scidr eq $tcidr && $scidr eq '32'){ | |
62fc8511 AM |
782 | my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1); |
783 | my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2); | |
2a81ab0d AM |
784 | if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){ |
785 | $hint=$Lang::tr{'fwdfw hint ip1'}."<br>"; | |
55674e0d | 786 | $hint.=$Lang::tr{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>"; |
2a81ab0d | 787 | } |
2a81ab0d AM |
788 | }else{ |
789 | if ( &General::IpInSubnet($networkip2,$sip,&General::iporsubtodec($scidr)) ){ | |
790 | $errormessage.=$Lang::tr{'fwdfw err samesub'}; | |
791 | } | |
792 | } | |
793 | } | |
62fc8511 | 794 | |
2a81ab0d AM |
795 | #check source and destination protocol if manual |
796 | if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){ | |
797 | if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){ | |
798 | $errormessage.=$Lang::tr{'fwdfw err prot'}; | |
799 | } | |
800 | #check source and destination protocol if source manual and dest servicegrp | |
801 | if ($fwdfwsettings{'grp3'} eq 'cust_srv'){ | |
802 | &General::readhasharray("$configsrv", \%customservice); | |
803 | foreach my $key (sort keys %customservice){ | |
804 | if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){ | |
805 | if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){ | |
806 | $errormessage.=$Lang::tr{'fwdfw err prot'}; | |
807 | last; | |
808 | } | |
809 | } | |
810 | } | |
811 | } | |
812 | } | |
2a81ab0d AM |
813 | } |
814 | sub get_ip | |
815 | { | |
816 | my $val=shift; | |
817 | my $grp =shift; | |
818 | my $a; | |
819 | my $b; | |
820 | &General::readhash("/var/ipfire/ethernet/settings", \%netsettings); | |
821 | if ($fwdfwsettings{$grp} ne $Lang::tr{'fwhost any'}){ | |
822 | if ($fwdfwsettings{$grp} eq $val.'_addr'){ | |
823 | ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}}); | |
824 | }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){ | |
825 | if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){ | |
826 | $a=$netsettings{'GREEN_NETADDRESS'}; | |
827 | $b=&General::iporsubtocidr($netsettings{'GREEN_NETMASK'}); | |
828 | }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){ | |
829 | $a=$netsettings{'ORANGE_NETADDRESS'}; | |
830 | $b=&General::iporsubtocidr($netsettings{'ORANGE_NETMASK'}); | |
831 | }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){ | |
832 | $a=$netsettings{'BLUE_NETADDRESS'}; | |
833 | $b=&General::iporsubtocidr($netsettings{'BLUE_NETMASK'}); | |
834 | }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){ | |
835 | &General::readhash("$configovpn",\%ovpnsettings); | |
836 | ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'}); | |
837 | $b=&General::iporsubtocidr($b); | |
838 | } | |
839 | }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){ | |
840 | &General::readhasharray("$confignet", \%customnetwork); | |
841 | foreach my $key (keys %customnetwork){ | |
842 | if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){ | |
843 | $a=$customnetwork{$key}[1]; | |
844 | $b=&General::iporsubtocidr($customnetwork{$key}[2]); | |
845 | } | |
846 | } | |
847 | }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){ | |
848 | &General::readhasharray("$confighost", \%customhost); | |
849 | foreach my $key (keys %customhost){ | |
850 | if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){ | |
851 | if ($customhost{$key}[1] eq 'ip'){ | |
852 | ($a,$b)=split (/\//,$customhost{$key}[2]); | |
853 | $b=&General::iporsubtocidr($b); | |
854 | }else{ | |
855 | if ($grp eq 'grp2'){ | |
856 | $errormessage=$Lang::tr{'fwdfw err tgt_mac'}; | |
857 | } | |
858 | } | |
859 | } | |
860 | } | |
861 | } | |
862 | } | |
2a81ab0d AM |
863 | return $a,$b; |
864 | } | |
865 | sub newrule | |
866 | { | |
867 | &error; | |
868 | &General::setup_default_networks(\%defaultNetworks); | |
869 | #read all configfiles | |
870 | &General::readhasharray("$configccdnet", \%ccdnet); | |
871 | &General::readhasharray("$confignet", \%customnetwork); | |
872 | &General::readhasharray("$configccdhost", \%ccdhost); | |
873 | &General::readhasharray("$confighost", \%customhost); | |
874 | &General::readhasharray("$configccdhost", \%ccdhost); | |
875 | &General::readhasharray("$configgrp", \%customgrp); | |
876 | &General::readhasharray("$configipsec", \%ipsecconf); | |
877 | &General::get_aliases(\%aliases); | |
2a81ab0d AM |
878 | my %checked=(); |
879 | my $helper; | |
2da264ec | 880 | my $sum=0; |
2a81ab0d AM |
881 | if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;} |
882 | my $config=$fwdfwsettings{'config'}; | |
883 | my %hash=(); | |
2a81ab0d AM |
884 | $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED'; |
885 | $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED'; | |
886 | $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED'; | |
887 | $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED'; | |
888 | $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED'; | |
889 | $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED'; | |
890 | $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED'; | |
891 | $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED'; | |
892 | $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED'; | |
893 | $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED'; | |
894 | $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED'; | |
895 | $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED'; | |
896 | $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED'; | |
897 | $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED'; | |
898 | $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED'; | |
899 | $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected'; | |
900 | $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected'; | |
901 | $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected'; | |
2a81ab0d AM |
902 | #check if update and get values |
903 | if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){ | |
904 | &General::readhasharray("$config", \%hash); | |
905 | foreach my $key (sort keys %hash){ | |
2da264ec | 906 | $sum++; |
2a81ab0d | 907 | if ($key eq $fwdfwsettings{'key'}){ |
2da264ec | 908 | $fwdfwsettings{'oldrulenumber'} = $key; |
2a81ab0d AM |
909 | $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0]; |
910 | $fwdfwsettings{'ACTIVE'} = $hash{$key}[2]; | |
911 | $fwdfwsettings{'grp1'} = $hash{$key}[3]; | |
912 | $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4]; | |
913 | $fwdfwsettings{'grp2'} = $hash{$key}[5]; | |
914 | $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6]; | |
915 | $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7]; | |
916 | $fwdfwsettings{'PROT'} = $hash{$key}[8]; | |
917 | $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9]; | |
918 | $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10]; | |
919 | $fwdfwsettings{'USESRV'} = $hash{$key}[11]; | |
920 | $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12]; | |
921 | $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13]; | |
922 | $fwdfwsettings{'grp3'} = $hash{$key}[14]; | |
923 | $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15]; | |
924 | $fwdfwsettings{'ruleremark'} = $hash{$key}[16]; | |
925 | $fwdfwsettings{'LOG'} = $hash{$key}[17]; | |
926 | $fwdfwsettings{'TIME'} = $hash{$key}[18]; | |
927 | $fwdfwsettings{'TIME_MON'} = $hash{$key}[19]; | |
928 | $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20]; | |
929 | $fwdfwsettings{'TIME_WED'} = $hash{$key}[21]; | |
930 | $fwdfwsettings{'TIME_THU'} = $hash{$key}[22]; | |
931 | $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23]; | |
932 | $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24]; | |
933 | $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25]; | |
934 | $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26]; | |
935 | $fwdfwsettings{'TIME_TO'} = $hash{$key}[27]; | |
2a81ab0d AM |
936 | $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED'; |
937 | $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED'; | |
938 | $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED'; | |
939 | $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED'; | |
940 | $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED'; | |
941 | $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED'; | |
942 | $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED'; | |
943 | $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED'; | |
944 | $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED'; | |
945 | $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED'; | |
946 | $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED'; | |
947 | $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED'; | |
948 | $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED'; | |
949 | $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED'; | |
950 | $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED'; | |
951 | $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected'; | |
952 | $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected'; | |
953 | $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected'; | |
954 | } | |
955 | } | |
956 | $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'}; | |
957 | $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}}; | |
958 | $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'}; | |
959 | $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}}; | |
960 | $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'}; | |
961 | $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}}; | |
962 | $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'}; | |
02da9f7b | 963 | $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'}; |
2a81ab0d AM |
964 | }else{ |
965 | $fwdfwsettings{'ACTIVE'}='ON'; | |
966 | $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED'; | |
967 | } | |
62fc8511 | 968 | |
2a81ab0d | 969 | &Header::openbox('100%', 'left', $Lang::tr{'fwdfw addrule'}); |
62fc8511 | 970 | |
2a81ab0d AM |
971 | print <<END; |
972 | <form method="post"> | |
973 | <table border='0'> | |
974 | <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'> | |
975 | END | |
976 | foreach ("ACCEPT","DROP","REJECT") | |
977 | { | |
978 | if($fwdfwsettings{'POLICY'} eq 'MODE2'){ | |
979 | $fwdfwsettings{'RULE_ACTION'} = 'DROP'; | |
980 | } | |
62fc8511 | 981 | |
2a81ab0d AM |
982 | if ($_ eq $fwdfwsettings{'RULE_ACTION'}) |
983 | { | |
984 | print"<option selected>$_</option>"; | |
985 | }else{ | |
986 | print"<option>$_</option>"; | |
987 | } | |
988 | } | |
989 | print"</select></td></tr></table><hr>"; | |
990 | ||
991 | ||
992 | &Header::closebox(); | |
993 | &Header::openbox('100%', 'left', $Lang::tr{'fwdfw source'}); | |
62fc8511 AM |
994 | |
995 | ||
2a81ab0d AM |
996 | #------SOURCE------------------------------------------------------- |
997 | print<<END; | |
998 | <table width='100%' border='0'> | |
999 | <tr><td width='1%'><input type='radio' name='grp1' value='src_addr' checked></td><td colspan='5'>$Lang::tr{'fwdfw sourceip'}<input type='TEXT' name='src_addr' value='$fwdfwsettings{'src_addr'}' ></td></tr> | |
1000 | <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr> | |
1001 | <tr><td width='1%'><input type='radio' name='grp1' value='std_net_src' $checked{'grp1'}{'std_net_src'}></td><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost stdnet'}</td><td width='13%'><select name='std_net_src' style='min-width:185px;'> | |
2a81ab0d AM |
1002 | END |
1003 | foreach my $network (sort keys %defaultNetworks) | |
1004 | { | |
1005 | next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP"); | |
62fc8511 | 1006 | next if($defaultNetworks{$network}{'NAME'} eq "RED"); |
2a81ab0d AM |
1007 | print "<option value='$defaultNetworks{$network}{'NAME'}'"; |
1008 | print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'}); | |
1009 | print ">$network</option>"; | |
1010 | } | |
1011 | print<<END; | |
1012 | </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_net_src' $checked{'grp1'}{'ovpn_net_src'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_net_src' style='min-width:185px;'> | |
1013 | END | |
1014 | &fillselect(\%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}}); | |
1015 | print<<END; | |
1016 | </select></td></tr> | |
1017 | <tr><td><input type='radio' name='grp1' value='cust_net_src' $checked{'grp1'}{'cust_net_src'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='cust_net_src' style='min-width:185px;'> | |
1018 | END | |
1019 | &fillselect(\%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}}); | |
1020 | print<<END; | |
1021 | </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_host_src' $checked{'grp1'}{'ovpn_host_src'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_host_src' style='min-width:185px;'> | |
1022 | END | |
1023 | foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) | |
1024 | { | |
1025 | if ($ccdhost{$key}[33] ne ''){ | |
1026 | ||
1027 | print "<option value='$ccdhost{$key}[1]'"; | |
1028 | print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]); | |
1029 | print ">$ccdhost{$key}[1]</option>"; | |
1030 | } | |
1031 | } | |
1032 | print<<END; | |
1033 | </select></td></tr> | |
1034 | <tr><td valign='top'><input type='radio' name='grp1' value='cust_host_src' $checked{'grp1'}{'cust_host_src'}></td><td>$Lang::tr{'fwhost cust addr'}</td><td><select name='cust_host_src' style='min-width:185px;'> | |
1035 | END | |
1036 | &fillselect(\%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}}); | |
1037 | print<<END; | |
1038 | </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_n2n_src' $checked{'grp1'}{'ovpn_n2n_src'}></td><td >$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='ovpn_n2n_src' style='min-width:185px;'> | |
1039 | END | |
1040 | foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) { | |
1041 | if($ccdhost{$key}[3] eq 'net'){ | |
1042 | print"<option "; | |
1043 | print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]); | |
1044 | print ">$ccdhost{$key}[1]</option>"; | |
1045 | } | |
1046 | } | |
1047 | print<<END; | |
1048 | </select></td></tr> | |
62fc8511 | 1049 | |
2a81ab0d AM |
1050 | <tr><td valign='top'><input type='radio' name='grp1' value='cust_grp_src' $checked{'grp1'}{'cust_grp_src'}></td><td >$Lang::tr{'fwhost cust grp'}</td><td><select name='cust_grp_src' style='min-width:185px;'> |
1051 | END | |
1052 | foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) { | |
1053 | if($helper ne $customgrp{$key}[0]){ | |
1054 | print"<option "; | |
1055 | print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]); | |
1056 | print ">$customgrp{$key}[0]</option>"; | |
2a81ab0d AM |
1057 | } |
1058 | $helper=$customgrp{$key}[0]; | |
1059 | } | |
1060 | print<<END; | |
1061 | </select></td> | |
1062 | <td valign='top'><input type='radio' name='grp1' value='ipsec_net_src' $checked{'grp1'}{'ipsec_net_src'}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td><select name='ipsec_net_src' style='min-width:185px;'> | |
1063 | END | |
1064 | foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) { | |
1065 | if ($ipsecconf{$key}[3] eq 'net'){ | |
1066 | print "<option "; | |
1067 | print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]); | |
1068 | print ">$ipsecconf{$key}[1]</option>"; | |
1069 | } | |
1070 | } | |
1071 | #sourceport | |
1072 | print<<END; | |
1073 | </select></td></tr> | |
1074 | END | |
62fc8511 | 1075 | |
2a81ab0d AM |
1076 | # <td valign='top'><input type='radio' name='grp1' value='ipsec_host_src' $checked{'grp1'}{'ipsec_host_src'}></td><td >$Lang::tr{'fwhost ipsec host'}</td><td><select name='ipsec_host_src' style='min-width:185px;'> |
1077 | #END | |
1078 | # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) { | |
1079 | # if ($ipsecconf{$key}[3] eq 'host'){ | |
1080 | # print "<option "; | |
1081 | # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]); | |
1082 | # print ">$ipsecconf{$key}[1]</option>"; | |
1083 | # } | |
1084 | # } | |
1085 | print<<END; | |
2a81ab0d | 1086 | <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table> |
2a81ab0d AM |
1087 | <table width='100%' border='0'> |
1088 | <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> | |
1089 | <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'> | |
1090 | END | |
62fc8511 | 1091 | foreach ("TCP","UDP","GRE","ESP","ICMP") |
2a81ab0d AM |
1092 | { |
1093 | if ($_ eq $fwdfwsettings{'PROT'}) | |
1094 | { | |
1095 | print"<option selected>$_</option>"; | |
1096 | }else{ | |
1097 | print"<option>$_</option>"; | |
1098 | } | |
1099 | } | |
1100 | print<<END; | |
1101 | </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='11' size='9' ></td></tr> | |
1102 | <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'> | |
1103 | END | |
1104 | &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes); | |
1105 | print"<option>All ICMP-Types</option>"; | |
1106 | foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){ | |
1107 | if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){ | |
1108 | print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>"; | |
1109 | }else{ | |
1110 | print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>"; | |
1111 | } | |
1112 | } | |
1113 | print<<END; | |
1114 | </select></td></tr></table><hr> | |
1115 | END | |
1116 | &Header::closebox(); | |
1117 | ||
1118 | #---TARGET------------------------------------------------------ | |
1119 | &Header::openbox('100%', 'left', $Lang::tr{'fwdfw target'}); | |
1120 | print<<END; | |
1121 | <table width='100%' border='0'> | |
1122 | <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr' checked></td><td colspan='2'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16'><td><input type='radio' name='grp2' value='ipfire' $checked{'grp2'}{'ipfire'}></td><td><b>IPFire ($Lang::tr{'external access'})</b></td><td><select name='ipfire' style='min-width:185px;'> | |
1123 | END | |
1124 | print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>"; | |
62fc8511 | 1125 | |
2a81ab0d AM |
1126 | foreach my $alias (sort keys %aliases) |
1127 | { | |
1128 | print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>"; | |
1129 | } | |
62fc8511 | 1130 | |
2a81ab0d AM |
1131 | print<<END; |
1132 | </td></tr> | |
1133 | <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr> | |
1134 | <tr><td width='1%'><input type='radio' name='grp2' value='std_net_tgt' $checked{'grp2'}{'std_net_tgt'}></td><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost stdnet'}</td><td width='13%'><select name='std_net_tgt' style='min-width:185px;'> | |
2a81ab0d | 1135 | END |
2a81ab0d AM |
1136 | foreach my $network (sort keys %defaultNetworks) |
1137 | { | |
1138 | print "<option value='$defaultNetworks{$network}{'NAME'}'"; | |
1139 | print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'}); | |
1140 | print ">$network</option>"; | |
1141 | } | |
1142 | print<<END; | |
1143 | </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_net_tgt' $checked{'grp2'}{'ovpn_net_tgt'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_net_tgt' style='min-width:185px;'> | |
1144 | END | |
1145 | &fillselect(\%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}}); | |
2a81ab0d AM |
1146 | print<<END; |
1147 | </select></td></tr> | |
1148 | <tr><td><input type='radio' name='grp2' value='cust_net_tgt' $checked{'grp2'}{'cust_net_tgt'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='cust_net_tgt' style='min-width:185px;'> | |
1149 | END | |
1150 | &fillselect(\%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}}); | |
1151 | print<<END; | |
1152 | </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_host_tgt' $checked{'grp2'}{'ovpn_host_tgt'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_host_tgt' style='min-width:185px;'> | |
1153 | END | |
1154 | foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) | |
1155 | { | |
1156 | if ($ccdhost{$key}[33] ne ''){ | |
1157 | print "<option value='$ccdhost{$key}[1]' "; | |
1158 | print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]); | |
1159 | print ">$ccdhost{$key}[1]</option>"; | |
1160 | } | |
1161 | } | |
1162 | print<<END; | |
1163 | </select></td></tr> | |
1164 | <tr><td valign='top'><input type='radio' name='grp2' value='cust_host_tgt' $checked{'grp2'}{'cust_host_tgt'}></td><td>$Lang::tr{'fwhost cust addr'}</td><td><select name='cust_host_tgt' style='min-width:185px;'> | |
1165 | END | |
1166 | &fillselect(\%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}}); | |
1167 | print<<END; | |
1168 | </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_n2n_tgt' $checked{'grp2'}{'ovpn_n2n_tgt'}></td><td >$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='ovpn_n2n_tgt' style='min-width:185px;'> | |
1169 | END | |
1170 | foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) { | |
1171 | if($ccdhost{$key}[3] eq 'net'){ | |
1172 | print "<option "; | |
1173 | print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]); | |
1174 | print ">$ccdhost{$key}[1]</option>"; | |
1175 | } | |
1176 | } | |
1177 | print<<END; | |
1178 | </select></td></tr> | |
2a81ab0d AM |
1179 | <tr><td valign='top'><input type='radio' name='grp2' value='cust_grp_tgt' $checked{'grp2'}{'cust_grp_tgt'}></td><td >$Lang::tr{'fwhost cust grp'}</td><td><select name='cust_grp_tgt' style='min-width:185px;'> |
1180 | END | |
1181 | $helper=''; | |
1182 | foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) { | |
1183 | if($helper ne $customgrp{$key}[0]){ | |
1184 | print"<option "; | |
1185 | print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]); | |
1186 | print">$customgrp{$key}[0]</option>"; | |
1187 | } | |
1188 | $helper=$customgrp{$key}[0]; | |
1189 | } | |
1190 | print<<END; | |
1191 | </select></td> | |
1192 | <td valign='top'><input type='radio' name='grp2' value='ipsec_net_tgt' $checked{'grp2'}{'ipsec_net_tgt'}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td><select name='ipsec_net_tgt' style='min-width:185px;'> | |
1193 | END | |
1194 | foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) { | |
1195 | if ($ipsecconf{$key}[3] eq 'net'){ | |
1196 | print"<option "; | |
1197 | print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]); | |
1198 | print">$ipsecconf{$key}[1]</option>"; | |
1199 | } | |
1200 | } | |
1201 | print<<END; | |
1202 | </select></td></tr> | |
1203 | END | |
2a81ab0d AM |
1204 | # <td valign='top'><input type='radio' name='grp2' value='ipsec_host_tgt' $checked{'grp2'}{'ipsec_host_tgt'}></td><td >$Lang::tr{'fwhost ipsec host'}</td><td><select name='ipsec_host_tgt' style='min-width:185px;'> |
1205 | #END | |
1206 | # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) { | |
1207 | # if ($ipsecconf{$key}[3] eq 'host'){ | |
1208 | # print"<option "; | |
1209 | # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]); | |
1210 | # print">$ipsecconf{$key}[1]</option>"; | |
1211 | # } | |
1212 | # } | |
1213 | print<<END; | |
1214 | </table> | |
1215 | <b>$Lang::tr{'fwhost attention'}:</b><br> | |
1216 | $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br> | |
62fc8511 | 1217 | |
2a81ab0d AM |
1218 | <table width='100%' border='0'> |
1219 | <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;' > | |
1220 | END | |
1221 | &General::readhasharray("$configsrv", \%customservice); | |
62fc8511 | 1222 | foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){ |
2a81ab0d AM |
1223 | print"<option "; |
1224 | print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]); | |
1225 | print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>"; | |
1226 | } | |
1227 | print<<END; | |
1228 | </select></td></tr> | |
1229 | <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;' > | |
1230 | END | |
1231 | &General::readhasharray("$configsrvgrp", \%customservicegrp); | |
1232 | my $helper; | |
62fc8511 | 1233 | foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){ |
2a81ab0d AM |
1234 | if ($helper ne $customservicegrp{$key}[0]){ |
1235 | print"<option "; | |
1236 | print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]); | |
1237 | print">$customservicegrp{$key}[0]</option>"; | |
1238 | } | |
1239 | $helper=$customservicegrp{$key}[0]; | |
1240 | } | |
1241 | print<<END; | |
1242 | </select></td></tr> | |
1243 | <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'> | |
1244 | END | |
62fc8511 | 1245 | foreach ("TCP","UDP","GRE","ESP","ICMP") |
2a81ab0d AM |
1246 | { |
1247 | if ($_ eq $fwdfwsettings{'TGT_PROT'}) | |
1248 | { | |
1249 | print"<option selected>$_</option>"; | |
1250 | }else{ | |
1251 | print"<option>$_</option>"; | |
1252 | } | |
1253 | } | |
1254 | print<<END; | |
1255 | </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='11' size='9' ></td></tr> | |
1256 | <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'> | |
1257 | END | |
1258 | &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes); | |
1259 | print"<option>All ICMP-Types</option>"; | |
1260 | foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){ | |
1261 | if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){ | |
1262 | print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>"; | |
1263 | }else{ | |
1264 | print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>"; | |
1265 | } | |
1266 | } | |
1267 | print<<END; | |
1268 | </select></td></tr> | |
1269 | </table><hr><br><br> | |
62fc8511 | 1270 | |
2a81ab0d AM |
1271 | END |
1272 | #---Activate/logging/remark------------------------------------- | |
1273 | &Header::openbox('100%', 'left', $Lang::tr{'fwdfw additional'}); | |
1274 | print<<END; | |
1275 | <table width='100%' border='0'> | |
2da264ec AM |
1276 | <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> |
1277 | END | |
1278 | if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){ | |
1279 | print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >"; | |
1280 | for (my $count =1; $count <= $sum; $count++){ | |
1281 | print"<option value='$count' "; | |
1282 | print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count); | |
1283 | print">$count</option>"; | |
1284 | } | |
1285 | print"</select></td></tr>"; | |
1286 | } | |
1287 | ||
1288 | print<<END; | |
1289 | </table><table width='100%'> | |
2a81ab0d AM |
1290 | <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr> |
1291 | <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr> | |
1292 | </table><hr><br> | |
1293 | END | |
1294 | &Header::closebox(); | |
1295 | #---ADD TIMEFRAME----------------------------------------------- | |
1296 | &Header::openbox('100%', 'left', $Lang::tr{'fwdfw timeframe'}); | |
1297 | print<<END; | |
1298 | <table width='70%' border='0'> | |
1299 | <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr> | |
1300 | <tr><td colspan='7'> </td></tr> | |
1301 | <tr> | |
1302 | <td align='left'>$Lang::tr{'time'}:</td> | |
1303 | <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 |
1304 | <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td> |
1305 | <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td> | |
1306 | </tr> | |
1307 | <tr> | |
1308 | <td align='right'></td> | |
1309 | <td width='30%' align='left'> | |
1310 | <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} /> | |
1311 | <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} /> | |
1312 | <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} /> | |
1313 | <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} /> | |
1314 | <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} /> | |
1315 | <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} /> | |
1316 | <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{$Lang::tr{'fwdfw wd_sun'}} /> | |
1317 | </td> | |
2a81ab0d AM |
1318 | <td><select name='TIME_FROM'> |
1319 | END | |
1320 | for (my $i=0;$i<=23;$i++) { | |
1321 | $i = sprintf("%02s",$i); | |
1322 | for (my $j=0;$j<=45;$j+=15) { | |
1323 | $j = sprintf("%02s",$j); | |
1324 | my $time = $i.":".$j; | |
1325 | print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n"; | |
1326 | } | |
1327 | } | |
1328 | print<<END; | |
1329 | </select></td> | |
1330 | <td><select name='TIME_TO'> | |
1331 | END | |
1332 | for (my $i=0;$i<=23;$i++) { | |
1333 | $i = sprintf("%02s",$i); | |
1334 | for (my $j=0;$j<=45;$j+=15) { | |
1335 | $j = sprintf("%02s",$j); | |
1336 | my $time = $i.":".$j; | |
1337 | print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n"; | |
1338 | } | |
1339 | } | |
62fc8511 | 1340 | print<<END; |
2a81ab0d AM |
1341 | </select></td></tr> |
1342 | </table><hr> | |
1343 | END | |
1344 | &Header::closebox(); | |
1345 | #---ACTION------------------------------------------------------ | |
1346 | if($fwdfwsettings{'updatefwrule'} ne 'on'){ | |
1347 | print<<END; | |
1348 | <table border='0' width='100%'> | |
1349 | <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' /> | |
1350 | <input type='hidden' name='config' value='$config' > | |
1351 | <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> | |
1352 | </table></form> | |
1353 | END | |
1354 | }else{ | |
1355 | print<<END; | |
1356 | <table border='0' width='100%'> | |
1357 | <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'}'> | |
1358 | <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' /> | |
1359 | <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' /> | |
1360 | <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' /> | |
1361 | <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' /> | |
1362 | <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' /> | |
1363 | <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' /> | |
1364 | <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' /> | |
2da264ec AM |
1365 | <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' /> |
1366 | <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' /> | |
2a81ab0d | 1367 | <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> |
2a81ab0d AM |
1368 | </table></form> |
1369 | END | |
1370 | } | |
1371 | &Header::closebox(); | |
1372 | } | |
1373 | sub saverule | |
1374 | { | |
2a81ab0d AM |
1375 | my $hash=shift; |
1376 | my $config=shift; | |
1377 | &General::readhasharray("$config", $hash); | |
1378 | if (!$errormessage){ | |
2da264ec | 1379 | if ($fwdfwsettings{'updatefwrule'} ne 'on'){ |
2a81ab0d AM |
1380 | my $key = &General::findhasharraykey ($hash); |
1381 | $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'}; | |
1382 | $$hash{$key}[1] = $fwdfwsettings{'chain'}; | |
1383 | $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'}; | |
1384 | $$hash{$key}[3] = $fwdfwsettings{'grp1'}; | |
1385 | $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}}; | |
1386 | $$hash{$key}[5] = $fwdfwsettings{'grp2'}; | |
1387 | $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}}; | |
1388 | $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'}; | |
1389 | $$hash{$key}[8] = $fwdfwsettings{'PROT'}; | |
1390 | $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'}; | |
1391 | $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'}; | |
1392 | $$hash{$key}[11] = $fwdfwsettings{'USESRV'}; | |
1393 | $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'}; | |
1394 | $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'}; | |
1395 | $$hash{$key}[14] = $fwdfwsettings{'grp3'}; | |
1396 | $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}}; | |
1397 | $$hash{$key}[16] = $fwdfwsettings{'ruleremark'}; | |
1398 | $$hash{$key}[17] = $fwdfwsettings{'LOG'}; | |
1399 | $$hash{$key}[18] = $fwdfwsettings{'TIME'}; | |
1400 | $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'}; | |
1401 | $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'}; | |
1402 | $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'}; | |
1403 | $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'}; | |
1404 | $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'}; | |
1405 | $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'}; | |
1406 | $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'}; | |
1407 | $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'}; | |
1408 | $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'}; | |
1409 | &General::writehasharray("$config", $hash); | |
1410 | }else{ | |
2da264ec AM |
1411 | #ruleposition check |
1412 | if($fwdfwsettings{'oldrulenumber'} gt $fwdfwsettings{'rulepos'}){ | |
1413 | my %tmp=(); | |
1414 | my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'}; | |
68ae5e59 | 1415 | for (my $z=0;$z<$val;$z++){ |
2da264ec AM |
1416 | foreach my $key (sort {$a <=> $b} keys %$hash){ |
1417 | if ($key eq $fwdfwsettings{'oldrulenumber'}) { | |
1418 | my $last = $key -1; | |
1419 | if (exists $$hash{$last}){ | |
1420 | #save rule last | |
1421 | foreach my $y (0 .. $#{$$hash{$last}}) { | |
1422 | $tmp{0}[$y] = $$hash{$last}[$y]; | |
1423 | } | |
1424 | #copy active rule to last | |
1425 | foreach my $i (0 .. $#{$$hash{$last}}) { | |
1426 | $$hash{$last}[$i] = $$hash{$key}[$i]; | |
1427 | } | |
1428 | #copy saved rule to actual position | |
1429 | foreach my $x (0 .. $#{$tmp{0}}) { | |
1430 | $$hash{$key}[$x] = $tmp{0}[$x]; | |
1431 | } | |
1432 | } | |
1433 | } | |
1434 | } | |
68ae5e59 | 1435 | $fwdfwsettings{'oldrulenumber'}--; |
2da264ec AM |
1436 | } |
1437 | &General::writehasharray("$config", $hash); | |
1438 | &rules; | |
1439 | }elsif($fwdfwsettings{'rulepos'} gt $fwdfwsettings{'oldrulenumber'}){ | |
1440 | my %tmp=(); | |
1441 | my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'}; | |
68ae5e59 AM |
1442 | for (my $z=0;$z<$val;$z++){ |
1443 | foreach my $key (sort {$a <=> $b} keys %$hash){ | |
2da264ec AM |
1444 | if ($key eq $fwdfwsettings{'oldrulenumber'}) { |
1445 | my $next = $key + 1; | |
1446 | if (exists $$hash{$next}){ | |
1447 | #save rule next | |
1448 | foreach my $y (0 .. $#{$$hash{$next}}) { | |
1449 | $tmp{0}[$y] = $$hash{$next}[$y]; | |
1450 | } | |
1451 | #copy active rule to next | |
1452 | foreach my $i (0 .. $#{$$hash{$next}}) { | |
1453 | $$hash{$next}[$i] = $$hash{$key}[$i]; | |
1454 | } | |
1455 | #copy saved rule to actual position | |
1456 | foreach my $x (0 .. $#{$tmp{0}}) { | |
1457 | $$hash{$key}[$x] = $tmp{0}[$x]; | |
1458 | } | |
1459 | } | |
1460 | } | |
1461 | } | |
68ae5e59 | 1462 | $fwdfwsettings{'oldrulenumber'}++; |
2da264ec AM |
1463 | } |
1464 | &General::writehasharray("$config", $hash); | |
1465 | &rules; | |
1466 | }else{ | |
1467 | foreach my $key (sort {$a <=> $b} keys %$hash){ | |
1468 | if($key eq $fwdfwsettings{'key'}){ | |
1469 | $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'}; | |
1470 | $$hash{$key}[1] = $fwdfwsettings{'chain'}; | |
1471 | $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'}; | |
1472 | $$hash{$key}[3] = $fwdfwsettings{'grp1'}; | |
1473 | $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}}; | |
1474 | $$hash{$key}[5] = $fwdfwsettings{'grp2'}; | |
1475 | $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}}; | |
1476 | $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'}; | |
1477 | $$hash{$key}[8] = $fwdfwsettings{'PROT'}; | |
1478 | $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'}; | |
1479 | $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'}; | |
1480 | $$hash{$key}[11] = $fwdfwsettings{'USESRV'}; | |
1481 | $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'}; | |
1482 | $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'}; | |
1483 | $$hash{$key}[14] = $fwdfwsettings{'grp3'}; | |
1484 | $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}}; | |
1485 | $$hash{$key}[16] = $fwdfwsettings{'ruleremark'}; | |
1486 | $$hash{$key}[17] = $fwdfwsettings{'LOG'}; | |
1487 | $$hash{$key}[18] = $fwdfwsettings{'TIME'}; | |
1488 | $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'}; | |
1489 | $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'}; | |
1490 | $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'}; | |
1491 | $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'}; | |
1492 | $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'}; | |
1493 | $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'}; | |
1494 | $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'}; | |
1495 | $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'}; | |
1496 | $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'}; | |
1497 | last; | |
1498 | } | |
2a81ab0d AM |
1499 | } |
1500 | } | |
1501 | &General::writehasharray("$config", $hash); | |
1502 | } | |
1503 | } | |
1504 | } | |
1505 | sub error | |
1506 | { | |
1507 | if ($errormessage) { | |
1508 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); | |
1509 | print "<class name='base'>$errormessage\n"; | |
1510 | print " </class>\n"; | |
1511 | &Header::closebox(); | |
1512 | print"<hr>"; | |
1513 | } | |
1514 | } | |
1515 | sub hint | |
1516 | { | |
1517 | if ($hint) { | |
1518 | &Header::openbox('100%', 'left', $Lang::tr{'fwhost hint'}); | |
1519 | print "<class name='base'>$hint\n"; | |
1520 | print " </class>\n"; | |
1521 | &Header::closebox(); | |
1522 | print"<hr>"; | |
1523 | } | |
1524 | } | |
1525 | sub get_name | |
1526 | { | |
1527 | my $val=shift; | |
1528 | &General::setup_default_networks(\%defaultNetworks); | |
1529 | foreach my $network (sort keys %defaultNetworks) | |
1530 | { | |
1531 | return "$network" if ($val eq $defaultNetworks{$network}{'NAME'}); | |
62fc8511 | 1532 | } |
2a81ab0d AM |
1533 | } |
1534 | sub validremark | |
1535 | { | |
1536 | # Checks a hostname against RFC1035 | |
1537 | my $remark = $_[0]; | |
1538 | ||
1539 | # Each part should be at least two characters in length | |
1540 | # but no more than 63 characters | |
d24a34cb | 1541 | if (length ($remark) < 1 || length ($remark) > 255) { |
2a81ab0d AM |
1542 | return 0;} |
1543 | # Only valid characters are a-z, A-Z, 0-9 and - | |
2da264ec | 1544 | if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:_\/\s]*$/) { |
2a81ab0d AM |
1545 | return 0;} |
1546 | # First character can only be a letter or a digit | |
1547 | if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) { | |
1548 | return 0;} | |
1549 | # Last character can only be a letter or a digit | |
62fc8511 | 1550 | if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) { |
2a81ab0d AM |
1551 | return 0;} |
1552 | return 1; | |
1553 | } | |
1554 | sub getsrcport | |
1555 | { | |
1556 | my %hash=%{(shift)}; | |
1557 | my $key=shift; | |
1558 | if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne 'ICMP'){ | |
1559 | print" : ($hash{$key}[8]) $hash{$key}[10]"; | |
1560 | }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){ | |
1561 | print" : ($hash{$key}[8]) <br> $hash{$key}[9]"; | |
1562 | } | |
1563 | } | |
1564 | sub gettgtport | |
1565 | { | |
1566 | my %hash=%{(shift)}; | |
1567 | my $key=shift; | |
1568 | my $service; | |
1569 | my $prot; | |
62fc8511 | 1570 | |
2a81ab0d AM |
1571 | if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){ |
1572 | if($hash{$key}[14] eq 'cust_srv'){ | |
1573 | &General::readhasharray("$configsrv", \%customservice); | |
1574 | foreach my $i (sort keys %customservice){ | |
1575 | #print "HHUHU: $customservice{$i}[0] und $hash{$key}[15]<br>"; | |
1576 | if($customservice{$i}[0] eq $hash{$key}[15]){ | |
1577 | $prot = $hash{$key}[12]; | |
1578 | $service = $customservice{$i}[0]; | |
1579 | } | |
1580 | } | |
1581 | }elsif($hash{$key}[14] eq 'cust_srvgrp'){ | |
62fc8511 | 1582 | |
2a81ab0d AM |
1583 | $service=$hash{$key}[15]; |
1584 | }elsif($hash{$key}[14] eq 'TGT_PORT'){ | |
1585 | $service=$hash{$key}[15]; | |
1586 | $prot=$hash{$key}[12]; | |
1587 | } | |
1588 | }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){ | |
1589 | print" : ($hash{$key}[12]) <br>$hash{$key}[13]"; | |
1590 | } | |
62fc8511 | 1591 | |
2a81ab0d AM |
1592 | if ($prot ne '' || $service ne ''){ |
1593 | print" :"; | |
1594 | if ($prot ne ''){ | |
1595 | print"($prot) "; | |
1596 | } | |
1597 | print" $service"; | |
1598 | } | |
1599 | } | |
1600 | sub viewtablerule | |
1601 | { | |
1602 | &viewtablenew(\%configfwdfw,$configfwdfw,$Lang::tr{'fwdfw rules'},"Forward" ); | |
1603 | &viewtablenew(\%configinputfw,$configinput,"",$Lang::tr{'external access'} ); | |
1604 | } | |
1605 | sub viewtablenew | |
1606 | { | |
1607 | my $hash=shift; | |
1608 | my $config=shift; | |
1609 | my $title=shift; | |
1610 | my $title1=shift; | |
62fc8511 | 1611 | |
2a81ab0d AM |
1612 | if ( ! -z "$config"){ |
1613 | &Header::openbox('100%', 'left',$title); | |
1614 | my $count=0; | |
1615 | my ($gif,$log); | |
1616 | my $ruletype; | |
1617 | my $rulecolor; | |
1618 | my $tooltip; | |
1619 | my @tmpsrc=(); | |
1620 | my $coloryellow=''; | |
1621 | &General::readhasharray("$config", $hash); | |
1622 | print"<b>$title1</b><br>"; | |
1623 | print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>"; | |
d24a34cb | 1624 | print"<tr><td align='center' width='1%'><b>#</td><td width='1%'></td><td align='center' width='20%'><b>$Lang::tr{'fwdfw source'}</td><td width='1%'><b>Log</td><td align='center' width='20%'><b>$Lang::tr{'fwdfw target'}</td><td align='center' width='70%'><b>$Lang::tr{'remark'}</td><td align='center' colspan='3' width='1%'><b>$Lang::tr{'fwdfw action'}</td></tr>"; |
62fc8511 | 1625 | foreach my $key (sort {$a <=> $b} keys %$hash){ |
2a81ab0d AM |
1626 | @tmpsrc=(); |
1627 | #check if vpn hosts/nets have been deleted | |
1628 | if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){ | |
1629 | push (@tmpsrc,$$hash{$key}[4]); | |
1630 | } | |
1631 | if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){ | |
1632 | push (@tmpsrc,$$hash{$key}[6]); | |
1633 | } | |
2a81ab0d AM |
1634 | foreach my $host (@tmpsrc){ |
1635 | if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){ | |
62fc8511 | 1636 | if(&fwlib::get_ipsec_net_ip($host,11) eq ''){ |
2a81ab0d AM |
1637 | $coloryellow='on'; |
1638 | &disable_rule($key); | |
1639 | $$hash{$key}[2]=''; | |
2a81ab0d AM |
1640 | } |
1641 | }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){ | |
1642 | if(&fwlib::get_ovpn_net_ip($host,1) eq ''){ | |
1643 | $coloryellow='on'; | |
1644 | &disable_rule($key); | |
1645 | $$hash{$key}[2]=''; | |
1646 | } | |
1647 | }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){ | |
1648 | if(&fwlib::get_ovpn_n2n_ip($host,27) eq ''){ | |
1649 | $coloryellow='on'; | |
1650 | &disable_rule($key); | |
1651 | $$hash{$key}[2]=''; | |
1652 | } | |
1653 | }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){ | |
1654 | if(&fwlib::get_ovpn_host_ip($host,33) eq ''){ | |
1655 | $coloryellow='on'; | |
1656 | &disable_rule($key); | |
1657 | $$hash{$key}[2]=''; | |
1658 | } | |
1659 | } | |
1660 | $$hash{$key}[3]=''; | |
1661 | $$hash{$key}[5]=''; | |
1662 | } | |
2a81ab0d AM |
1663 | $$hash{'ACTIVE'}=$$hash{$key}[2]; |
1664 | $count++; | |
2a81ab0d AM |
1665 | if($coloryellow eq 'on'){ |
1666 | print"<tr bgcolor='$color{'color14'}' >"; | |
1667 | $coloryellow=''; | |
1668 | }elsif($coloryellow eq ''){ | |
1669 | if ($count % 2){ | |
1670 | print"<tr bgcolor='$color{'color22'}' >"; | |
1671 | } | |
1672 | else{ | |
1673 | print"<tr bgcolor='$color{'color20'}' >"; | |
1674 | } | |
1675 | } | |
2a81ab0d AM |
1676 | print<<END; |
1677 | <td align='right'>$key</td> | |
1678 | END | |
1679 | if ($$hash{$key}[0] eq 'ACCEPT'){ | |
1680 | $ruletype='A'; | |
1681 | $tooltip='ACCEPT'; | |
1682 | $rulecolor=$color{'color17'}; | |
1683 | }elsif($$hash{$key}[0] eq 'DROP'){ | |
1684 | $ruletype='D'; | |
1685 | $tooltip='DROP'; | |
1686 | $rulecolor=$color{'color25'}; | |
1687 | }elsif($$hash{$key}[0] eq 'REJECT'){ | |
1688 | $ruletype='R'; | |
1689 | $tooltip='REJECT'; | |
1690 | $rulecolor=$color{'color16'}; | |
1691 | } | |
1692 | print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>"; | |
1693 | print"<td align='center'>"; | |
1694 | if ($$hash{$key}[3] eq 'std_net_src'){ | |
1695 | print &get_name($$hash{$key}[4]); | |
1696 | }else{ | |
1697 | print $$hash{$key}[4]; | |
1698 | } | |
1699 | &getsrcport(\%$hash,$key); | |
1700 | if ($$hash{$key}[17] eq 'ON'){ | |
1701 | $log="/images/on.gif"; | |
1702 | }else{ | |
1703 | $log="/images/off.gif"; | |
1704 | } | |
1705 | print<<END; | |
1706 | </td> | |
2a81ab0d | 1707 | <form method='post'> |
d24a34cb | 1708 | <td width='1%' align='left'><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 |
1709 | <input type='hidden' name='key' value='$key' /> |
1710 | <input type='hidden' name='config' value='$config' /> | |
1711 | <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' /> | |
1712 | </td></form> | |
1713 | END | |
1714 | ||
1715 | print<<END; | |
d24a34cb | 1716 | <td align='center' nowrap='nowrap'> |
2a81ab0d AM |
1717 | END |
1718 | if ($$hash{$key}[5] eq 'std_net_tgt'){ | |
1719 | print &get_name($$hash{$key}[6]); | |
1720 | }else{ | |
1721 | print $$hash{$key}[6]; | |
1722 | } | |
1723 | &gettgtport(\%$hash,$key); | |
1724 | ################################################################################ | |
1725 | print"</td><td width='20%'>$$hash{$key}[16]</td>"; | |
1726 | ||
1727 | if($$hash{$key}[2] eq 'ON'){ | |
1728 | $gif="/images/on.gif" | |
1729 | ||
1730 | }else{ | |
1731 | $gif="/images/off.gif" | |
2a81ab0d AM |
1732 | } |
1733 | print<<END; | |
1734 | <form method='post'> | |
1735 | <td width='1%'><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;' /> | |
1736 | <input type='hidden' name='key' value='$key' /> | |
1737 | <input type='hidden' name='config' value='$config' /> | |
1738 | <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' /> | |
1739 | </td></form> | |
2a81ab0d AM |
1740 | <form method='post'> |
1741 | <td width='1%' ><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;' /> | |
1742 | <input type='hidden' name='key' value='$key' /> | |
1743 | <input type='hidden' name='config' value='$config' /> | |
1744 | <input type='hidden' name='ACTION' value='editrule' /> | |
1745 | </td></form></td> | |
2a81ab0d AM |
1746 | <form method='post'> |
1747 | <td width='1%'><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;' /> | |
1748 | <input type='hidden' name='key' value='$key' /> | |
1749 | <input type='hidden' name='config' value='$config' /> | |
1750 | <input type='hidden' name='ACTION' value='copyrule' /> | |
1751 | </td></form></td> | |
2a81ab0d AM |
1752 | <form method='post'> |
1753 | <td width='1%' ><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;' /> | |
1754 | <input type='hidden' name='key' value='$key' /> | |
1755 | <input type='hidden' name='config' value='$config' /> | |
1756 | <input type='hidden' name='ACTION' value='deleterule' /> | |
1757 | </td></form></td> | |
1758 | END | |
1759 | if (exists $$hash{$key-1}){ | |
1760 | print<<END; | |
1761 | <form method='post'> | |
1762 | <td width='1%'><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;' /> | |
1763 | <input type='hidden' name='key' value='$key' /> | |
1764 | <input type='hidden' name='config' value='$config' /> | |
1765 | <input type='hidden' name='ACTION' value='moveup' /> | |
1766 | </td></form></td> | |
1767 | END | |
1768 | }else{ | |
1769 | print"<td></td>"; | |
1770 | } | |
2a81ab0d AM |
1771 | if (exists $$hash{$key+1}){ |
1772 | print<<END; | |
1773 | <form method='post'> | |
1774 | <td width='1%' ><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;' /> | |
1775 | <input type='hidden' name='key' value='$key' /> | |
1776 | <input type='hidden' name='config' value='$config' /> | |
1777 | <input type='hidden' name='ACTION' value='movedown' /> | |
1778 | </td></form></td></tr> | |
1779 | END | |
1780 | }else{ | |
1781 | print"<td></td></tr>"; | |
1782 | } | |
1783 | #if timeframe set, print new line in table | |
1784 | if ($$hash{$key}[18] eq 'ON'){ | |
1785 | my @days=(); | |
1786 | if($$hash{$key}[19] ne ''){push (@days,$Lang::tr{'fwdfw wd_mon'});} | |
1787 | if($$hash{$key}[20] ne ''){push (@days,$Lang::tr{'fwdfw wd_tue'});} | |
1788 | if($$hash{$key}[21] ne ''){push (@days,$Lang::tr{'fwdfw wd_wed'});} | |
1789 | if($$hash{$key}[22] ne ''){push (@days,$Lang::tr{'fwdfw wd_thu'});} | |
1790 | if($$hash{$key}[23] ne ''){push (@days,$Lang::tr{'fwdfw wd_fri'});} | |
1791 | if($$hash{$key}[24] ne ''){push (@days,$Lang::tr{'fwdfw wd_sat'});} | |
1792 | if($$hash{$key}[25] ne ''){push (@days,$Lang::tr{'fwdfw wd_sun'});} | |
2a81ab0d | 1793 | my $weekdays=join(",",@days); |
2a81ab0d AM |
1794 | if (@days){ |
1795 | print"<tr bgcolor='#FFE4B5'><td colspan='4'>$Lang::tr{'fwdfw time'} "; | |
1796 | print"$weekdays"; | |
1797 | print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>"; | |
1798 | } | |
1799 | } | |
1800 | } | |
1801 | print"</table>"; | |
1802 | &Header::closebox(); | |
1803 | } | |
2a81ab0d AM |
1804 | } |
1805 | sub fillselect | |
1806 | { | |
1807 | my %hash=%{(shift)}; | |
1808 | my $val=shift; | |
1809 | my $key; | |
62fc8511 AM |
1810 | foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){ |
1811 | if($hash{$key}[0] eq $val){ | |
1812 | print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>"; | |
1813 | }else{ | |
1814 | print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>"; | |
2a81ab0d | 1815 | } |
62fc8511 | 1816 | } |
2a81ab0d AM |
1817 | } |
1818 | sub rules | |
1819 | { | |
1820 | if (!-f "${General::swroot}/forward/reread"){ | |
1821 | system("touch ${General::swroot}/forward/reread"); | |
1822 | } | |
1823 | } | |
1824 | sub reread_rules | |
1825 | { | |
1826 | system("/usr/local/bin/forwardfwctrl"); | |
1827 | system("rm ${General::swroot}/forward/reread"); | |
1828 | } | |
1829 | &Header::closebigbox(); | |
1830 | &Header::closepage(); |