]>
Commit | Line | Data |
---|---|---|
ac1cfefa | 1 | #!/usr/bin/perl |
70df8302 MT |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
c010871a | 5 | # Copyright (C) 2007-2014 IPFire Team <info@ipfire.org> # |
70df8302 MT |
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 | ############################################################################### | |
ac1cfefa MT |
21 | |
22 | use strict; | |
54fd0535 | 23 | use Net::Telnet; |
9d386698 | 24 | use Sort::Naturally; |
ac1cfefa MT |
25 | |
26 | # enable only the following on debugging purpose | |
cb5e9c6c CS |
27 | #use warnings; |
28 | #use CGI::Carp 'fatalsToBrowser'; | |
ac1cfefa | 29 | |
e383179b | 30 | require '/var/ipfire/general-functions.pl'; |
ac1cfefa MT |
31 | require "${General::swroot}/lang.pl"; |
32 | require "${General::swroot}/header.pl"; | |
2b38ab5c | 33 | require "/opt/pakfire/lib/functions.pl"; |
ac1cfefa MT |
34 | |
35 | my %cgiparams=(); | |
36 | my %pppsettings=(); | |
37 | my %modemsettings=(); | |
38 | my %netsettings=(); | |
39 | my %ddnssettings=(); | |
9d386698 AM |
40 | my %proxysettings=(); |
41 | my %vpnsettings=(); | |
42 | my %vpnconfig=(); | |
43 | my %ovpnconfig=(); | |
ac1cfefa | 44 | my $warnmessage = ''; |
c85ec3b4 | 45 | my $refresh = ""; |
e383179b | 46 | my $ipaddr=''; |
9d386698 AM |
47 | my $showbox=0; |
48 | my $showipsec=0; | |
49 | my $showovpn=0; | |
50 | ||
51 | if ( ! -e "/var/ipfire/main/gpl_accepted" ) { | |
52 | print "Status: 302 Moved Temporarily\n"; | |
53 | print "Location: gpl.cgi\n\n"; | |
54 | exit (0); | |
55 | } | |
337305ef | 56 | |
ac1cfefa MT |
57 | &Header::showhttpheaders(); |
58 | ||
59 | $cgiparams{'ACTION'} = ''; | |
60 | &Header::getcgihash(\%cgiparams); | |
61 | $pppsettings{'VALID'} = ''; | |
62 | $pppsettings{'PROFILENAME'} = 'None'; | |
63 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
64 | &General::readhash("${General::swroot}/modem/settings", \%modemsettings); | |
65 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
66 | &General::readhash("${General::swroot}/ddns/settings", \%ddnssettings); | |
9d386698 AM |
67 | &General::readhash("${General::swroot}/proxy/advanced/settings", \%proxysettings); |
68 | &General::readhash("${General::swroot}/vpn/settings", \%vpnsettings); | |
ac1cfefa | 69 | |
f2fdd0c1 CS |
70 | my %color = (); |
71 | my %mainsettings = (); | |
72 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
73 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
74 | ||
ac1cfefa | 75 | my $connstate = &Header::connectionstatus(); |
56b7a3e2 | 76 | |
9d386698 AM |
77 | if ( -e "/var/ipfire/main/gpl-accepted" ) { |
78 | if ($connstate =~ /$Lang::tr{'connecting'}/ || /$Lang::tr{'connection closed'}/ ){ | |
79 | $refresh = "<meta http-equiv='refresh' content='5;'>"; | |
80 | }elsif ($connstate =~ /$Lang::tr{'dod waiting'}/ || -e "${General::swroot}/main/refreshindex") { | |
81 | $refresh = "<meta http-equiv='refresh' content='30;'>"; | |
82 | } | |
f341a168 | 83 | } |
ac1cfefa | 84 | |
957363eb CS |
85 | if ($cgiparams{'ACTION'} eq $Lang::tr{'dial profile'}) |
86 | { | |
87 | my $profile = $cgiparams{'PROFILE'}; | |
88 | my %tempcgiparams = (); | |
89 | $tempcgiparams{'PROFILE'} = ''; | |
90 | &General::readhash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}", | |
91 | \%tempcgiparams); | |
92 | ||
93 | # make a link from the selected profile to the "default" one. | |
94 | unlink("${General::swroot}/ppp/settings"); | |
95 | link("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}", | |
96 | "${General::swroot}/ppp/settings"); | |
9d386698 AM |
97 | open (TMP, ">${General::swroot}/ppp/updatesettings"); |
98 | close TMP; | |
957363eb CS |
99 | # read in the new params "early" so we can write secrets. |
100 | %cgiparams = (); | |
101 | &General::readhash("${General::swroot}/ppp/settings", \%cgiparams); | |
102 | $cgiparams{'PROFILE'} = $profile; | |
103 | $cgiparams{'BACKUPPROFILE'} = $profile; | |
104 | &General::writehash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}", | |
105 | \%cgiparams); | |
106 | ||
107 | # write secrets file. | |
108 | open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file."; | |
109 | flock(FILE, 2); | |
110 | my $username = $cgiparams{'USERNAME'}; | |
111 | my $password = $cgiparams{'PASSWORD'}; | |
112 | print FILE "'$username' * '$password'\n"; | |
113 | chmod 0600, "${General::swroot}/ppp/secrets"; | |
114 | close FILE; | |
115 | ||
116 | &General::log("$Lang::tr{'profile made current'} $tempcgiparams{'PROFILENAME'}"); | |
117 | $cgiparams{'ACTION'} = "$Lang::tr{'dial'}"; | |
118 | } | |
119 | ||
120 | if ($cgiparams{'ACTION'} eq $Lang::tr{'dial'}) { | |
a56b5be4 | 121 | system('/usr/local/bin/redctrl start > /dev/null') == 0 |
9d386698 AM |
122 | or &General::log("Dial failed: $?"); sleep 1; |
123 | }elsif ($cgiparams{'ACTION'} eq $Lang::tr{'hangup'}) { | |
a56b5be4 | 124 | system('/usr/local/bin/redctrl stop > /dev/null') == 0 |
9d386698 AM |
125 | or &General::log("Hangup failed: $?"); sleep 1; |
126 | } | |
957363eb | 127 | |
e383179b MT |
128 | my $c; |
129 | my $maxprofiles = 5; | |
130 | my @profilenames = (); | |
131 | ||
132 | for ($c = 1; $c <= $maxprofiles; $c++) | |
133 | { | |
134 | my %temppppsettings = (); | |
135 | $temppppsettings{'PROFILENAME'} = ''; | |
136 | &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings); | |
137 | $profilenames[$c] = $temppppsettings{'PROFILENAME'}; | |
138 | } | |
139 | my %selected; | |
140 | for ($c = 1; $c <= $maxprofiles; $c++) { | |
141 | $selected{'PROFILE'}{$c} = ''; | |
142 | } | |
143 | $selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'"; | |
144 | my $dialButtonDisabled = "disabled='disabled'"; | |
145 | ||
ac1cfefa MT |
146 | &Header::openpage($Lang::tr{'main page'}, 1, $refresh); |
147 | &Header::openbigbox('', 'center'); | |
9d386698 AM |
148 | if (open(IPADDR,"${General::swroot}/red/local-ipaddress")) { |
149 | $ipaddr = <IPADDR>; | |
150 | close IPADDR; | |
151 | chomp ($ipaddr); | |
152 | } | |
ac1cfefa | 153 | |
043cfbc0 | 154 | &Header::openbox('100%', 'center', ''); |
a08a5f33 | 155 | if ( ( $pppsettings{'VALID'} eq 'yes' && $modemsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ )) { |
986e08d9 MT |
156 | if (open(IPADDR,"${General::swroot}/ddns/ipcache")) { |
157 | $ipaddr = <IPADDR>; | |
158 | close IPADDR; | |
159 | chomp ($ipaddr); | |
160 | } | |
4e7c3114 EK |
161 | if (open(IPADDR,"${General::swroot}/red/local-ipaddress")) { |
162 | $ipaddr = <IPADDR>; | |
163 | close IPADDR; | |
164 | chomp ($ipaddr); | |
165 | } | |
ac1cfefa MT |
166 | } elsif ($modemsettings{'VALID'} eq 'no') { |
167 | print "$Lang::tr{'modem settings have errors'}\n </b></font>\n"; | |
168 | } else { | |
169 | print "$Lang::tr{'profile has errors'}\n </b></font>\n"; | |
170 | } | |
171 | ||
a56b5be4 | 172 | print <<END; |
e383179b | 173 | <!-- Table of networks --> |
c010871a AH |
174 | <table class='tbl' style='width:80%;'> |
175 | <tr> | |
176 | <th style='background-color:$color{'color20'};'>$Lang::tr{'network'}</th> | |
177 | <th style='background-color:$color{'color20'};'>$Lang::tr{'ip address'}</th> | |
178 | <th style='background-color:$color{'color20'};'>$Lang::tr{'status'}</th> | |
179 | </tr> | |
180 | <tr> | |
181 | <td style='width:25%; text-align:center; background-color:$Header::colourred;'><a href='/cgi-bin/pppsetup.cgi' style='color:white;'><b>$Lang::tr{'internet'}</b></a><br/></td> | |
182 | <td style='width:30%; text-align:center;'>$ipaddr </td> | |
183 | <td style='width:45%; text-align:center;'>$connstate </td> | |
184 | </tr> | |
f3bbb213 | 185 | END |
043cfbc0 AM |
186 | my $HOSTNAME = (gethostbyaddr(pack("C4", split(/\./, $ipaddr)), 2))[0]; |
187 | if ( "$HOSTNAME" ne "" ) { | |
188 | print <<END; | |
c010871a | 189 | <tr><td><b>$Lang::tr{'hostname'}:</b><td style='text-align:center;'>$HOSTNAME</td><td></td> |
043cfbc0 AM |
190 | END |
191 | } | |
192 | ||
9d386698 AM |
193 | if ( -e "${General::swroot}/red/remote-ipaddress" ) { |
194 | open (TMP, "<${General::swroot}/red/remote-ipaddress"); | |
195 | my $GATEWAY = <TMP>; | |
043cfbc0 | 196 | chomp($GATEWAY); |
9d386698 | 197 | close TMP; |
043cfbc0 | 198 | print <<END; |
c010871a | 199 | <tr><td><b>$Lang::tr{'gateway'}:</b><td style='text-align:center;'>$GATEWAY</td><td></td></tr> |
043cfbc0 AM |
200 | END |
201 | } | |
317638e7 | 202 | |
c335b0cd MT |
203 | if (&General::RedIsWireless()) { |
204 | my $iface = $netsettings{"RED_DEV"} || "red0"; | |
205 | ||
206 | my $essid = &Network::wifi_get_essid($iface); | |
207 | my $frequency = &Network::wifi_get_frequency($iface); | |
208 | my $access_point = &Network::wifi_get_access_point($iface); | |
209 | my $bit_rate = &Network::wifi_get_bit_rate($iface); | |
210 | my $link_quality = &Network::wifi_get_link_quality($iface); | |
211 | my $signal_level = &Network::wifi_get_signal_level($iface); | |
212 | ||
213 | print <<END; | |
214 | <tr> | |
215 | <td> | |
216 | <strong>$Lang::tr{'wireless network'}:</strong> | |
217 | </td> | |
218 | <td style="text-align: center"> | |
219 | $essid | |
220 | </td> | |
221 | <td style="text-align: center"> | |
222 | $access_point @ $frequency | |
223 | </td> | |
224 | </tr> | |
225 | <tr> | |
226 | <td> | |
227 | <strong> | |
228 | $Lang::tr{'uplink bit rate'}: | |
229 | </strong> | |
230 | </td> | |
231 | <td style="text-align: center"> | |
232 | $bit_rate | |
233 | </td> | |
234 | <td style="text-align: center"> | |
235 | $link_quality% @ $signal_level | |
236 | </td> | |
237 | </tr> | |
238 | END | |
239 | } | |
240 | ||
241 | print <<END; | |
242 | </table> | |
043cfbc0 | 243 | END |
043cfbc0 AM |
244 | |
245 | #Dial profiles | |
c85ec3b4 | 246 | if ( $netsettings{'RED_TYPE'} ne "STATIC" && $netsettings{'RED_TYPE'} ne "DHCP" ){ |
c010871a AH |
247 | if ( ( $pppsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) { |
248 | print <<END; | |
249 | <br/> | |
250 | <table style='width:80%;'> | |
043cfbc0 | 251 | <tr><td> |
957363eb | 252 | <form method='post' action='$ENV{'SCRIPT_NAME'}'>$Lang::tr{'profile'}: |
e383179b MT |
253 | <select name='PROFILE'> |
254 | END | |
c010871a AH |
255 | for ($c = 1; $c <= $maxprofiles; $c++) |
256 | { | |
257 | if ($profilenames[$c] ne '') { | |
258 | $dialButtonDisabled = ""; | |
259 | print "<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>"; | |
260 | } | |
e383179b | 261 | } |
c010871a | 262 | $dialButtonDisabled = "disabled='disabled'" if (-e '/var/run/ppp-ipfire.pid' || -e "${General::swroot}/red/active"); |
e383179b | 263 | print <<END; |
c010871a AH |
264 | </select> |
265 | <input type='submit' name='ACTION' value='$Lang::tr{'dial profile'}' $dialButtonDisabled /> | |
266 | </form> | |
267 | </td> | |
268 | <td style='text-align:center;'> | |
269 | <table style='width:100%;'> | |
270 | <tr> | |
271 | <td style='width=50%; text-align:right;'> | |
272 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
273 | <input type='submit' name='ACTION' value='$Lang::tr{'dial'}'> | |
274 | </form> | |
275 | </td> | |
276 | <td style='width=50%; text-align:left;'> | |
277 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
278 | <input type='submit' name='ACTION' value='$Lang::tr{'hangup'}'> | |
279 | </form> | |
280 | </td> | |
281 | </tr> | |
282 | </table> | |
283 | </td> | |
284 | </tr> | |
285 | </table> | |
e383179b MT |
286 | END |
287 | } else { | |
c010871a | 288 | print "<br/><span style='color:red;'>$Lang::tr{'profile has errors'}</span><br/>"; |
e383179b | 289 | } |
c85ec3b4 | 290 | } |
c010871a AH |
291 | |
292 | ||
293 | print <<END; | |
294 | <br/> | |
295 | <table class='tbl' style='width:80%;'> | |
296 | <tr> | |
297 | <th>$Lang::tr{'network'}</th> | |
298 | <th>$Lang::tr{'ip address'}</th> | |
299 | <th>$Lang::tr{'status'}</th> | |
300 | </tr> | |
301 | END | |
302 | ||
303 | if ( $netsettings{'GREEN_DEV'} ) { | |
043cfbc0 | 304 | my $sub=&General::iporsubtocidr($netsettings{'GREEN_NETMASK'}); |
786f2c8a | 305 | print <<END; |
043cfbc0 | 306 | <tr> |
c010871a AH |
307 | <td style='width:25%; text-align:center; background-color:$Header::colourgreen;'> |
308 | <a href='/cgi-bin/dhcp.cgi' style='color:white'><b>$Lang::tr{'lan'}</b></a> | |
309 | </td> | |
310 | <td style='width:30%; text-align:center;'>$netsettings{'GREEN_ADDRESS'}/$sub</td> | |
311 | <td style='width:45%; text-align:center;'> | |
e383179b | 312 | END |
9d386698 AM |
313 | if ( $proxysettings{'ENABLE'} eq 'on' ) { |
314 | print $Lang::tr{'advproxy on'}; | |
315 | if ( $proxysettings{'TRANSPARENT'} eq 'on' ) { print " (transparent)"; } | |
ef482d53 | 316 | } else { print $Lang::tr{'advproxy off'}; } |
c010871a AH |
317 | print '</td>'; |
318 | print '</tr>'; | |
072cd997 | 319 | } |
db1078ff | 320 | if (&Header::blue_used()) { |
043cfbc0 AM |
321 | my $sub=&General::iporsubtocidr($netsettings{'BLUE_NETMASK'}); |
322 | print <<END; | |
c010871a AH |
323 | <tr> |
324 | <td style='width:25%; text-align:center; background-color:$Header::colourblue;'> | |
325 | <a href='/cgi-bin/wireless.cgi' style='color:white'><b>$Lang::tr{'wireless'}</b></a> | |
326 | </td> | |
327 | <td style='width:30%; text-align:center;'>$netsettings{'BLUE_ADDRESS'}/$sub | |
328 | <td style='width:45%; text-align:center;'> | |
e383179b | 329 | END |
9d386698 AM |
330 | if ( $proxysettings{'ENABLE_BLUE'} eq 'on' ) { |
331 | print $Lang::tr{'advproxy on'}; | |
332 | if ( $proxysettings{'TRANSPARENT_BLUE'} eq 'on' ) { print " (transparent)"; } | |
ef482d53 | 333 | } else { print $Lang::tr{'advproxy off'}; } |
c010871a AH |
334 | print '</td>'; |
335 | print '</tr>'; | |
072cd997 | 336 | } |
db1078ff | 337 | if (&Header::orange_used()) { |
043cfbc0 AM |
338 | my $sub=&General::iporsubtocidr($netsettings{'ORANGE_NETMASK'}); |
339 | print <<END; | |
c010871a AH |
340 | <tr> |
341 | <td style='width:25%; text-align:center; background-color:$Header::colourorange;'> | |
342 | <a href='/cgi-bin/firewall.cgi' style='color:white'><b>$Lang::tr{'dmz'}</b></a> | |
343 | </td> | |
344 | <td style='width:30%; text-align:center;'>$netsettings{'ORANGE_ADDRESS'}/$sub</td> | |
345 | <td style='width:45%; text-align:center; color:$Header::colourgreen;'>Online</td> | |
346 | </tr> | |
043cfbc0 AM |
347 | END |
348 | } | |
349 | #check if IPSEC is running | |
9d386698 | 350 | if ( $vpnsettings{'ENABLED'} eq 'on' || $vpnsettings{'ENABLED_BLUE'} eq 'on' ) { |
043cfbc0 | 351 | print<<END; |
c010871a AH |
352 | <tr> |
353 | <td style='width:25%; text-align:center; background-color:$Header::colourvpn;'> | |
354 | <a href='/cgi-bin/vpnmain.cgi' style='color:white'><b>$Lang::tr{'ipsec'}</b></a> | |
355 | </td> | |
517683ee | 356 | <td style='width:30%; text-align:center;'></td> |
c010871a AH |
357 | <td style='width:45%; text-align:center; color:$Header::colourgreen;'>Online</td> |
358 | </tr> | |
043cfbc0 AM |
359 | END |
360 | } | |
361 | ||
362 | #check if OpenVPN is running | |
363 | my %confighash=(); | |
364 | &General::readhash("${General::swroot}/ovpn/settings", \%confighash); | |
365 | ||
366 | if (($confighash{'ENABLED'} eq "on") || | |
367 | ($confighash{'ENABLED_BLUE'} eq "on") || | |
368 | ($confighash{'ENABLED_ORANGE'} eq "on")) { | |
369 | my ($ovpnip,$sub) = split("/",$confighash{'DOVPN_SUBNET'}); | |
370 | $sub=&General::iporsubtocidr($sub); | |
371 | $ovpnip="$ovpnip/$sub"; | |
043cfbc0 AM |
372 | print <<END; |
373 | <tr> | |
5ef260ae | 374 | <td style='width:25%; text-align:center; background-color:$Header::colourovpn;'> |
c010871a | 375 | <a href='/cgi-bin/ovpnmain.cgi' style='color:white'><b>OpenVPN</b></a> |
043cfbc0 | 376 | </td> |
c010871a AH |
377 | <td style='width:30%; text-align:center;'>$ovpnip</td> |
378 | <td style='width:45%; text-align:center; color:$Header::colourgreen;'>Online</td> | |
379 | </tr> | |
e383179b | 380 | END |
072cd997 | 381 | } |
c010871a | 382 | print"</table>"; |
043cfbc0 AM |
383 | &Header::closebox(); |
384 | ||
9d386698 AM |
385 | #Check if there are any vpns configured (ipsec and openvpn) |
386 | &General::readhasharray("${General::swroot}/vpn/config", \%vpnconfig); | |
387 | foreach my $key (sort { ncmp($vpnconfig{$a}[1],$vpnconfig{$b}[1]) } keys %vpnconfig) { | |
5ef260ae | 388 | if ($vpnconfig{$key}[0] eq 'on' && $vpnconfig{$key}[3] ne 'host'){ |
9d386698 AM |
389 | $showipsec=1; |
390 | $showbox=1; | |
391 | last; | |
392 | } | |
393 | } | |
394 | &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%ovpnconfig); | |
395 | foreach my $dkey (sort { ncmp($ovpnconfig{$a}[1],$ovpnconfig{$b}[1])} keys %ovpnconfig) { | |
396 | if (($ovpnconfig{$dkey}[3] eq 'net') && (-e "/var/run/$ovpnconfig{$dkey}[1]n2n.pid")){ | |
397 | $showbox=1; | |
398 | $showovpn=1; | |
399 | last; | |
400 | } | |
401 | } | |
043cfbc0 | 402 | |
9d386698 AM |
403 | if ($showbox){ |
404 | # Start of Box wich contains all vpn connections | |
405 | &Header::openbox('100%', 'center', $Lang::tr{'vpn'}); | |
c010871a AH |
406 | |
407 | #show ipsec connectiontable | |
9d386698 AM |
408 | if ( $showipsec ) { |
409 | my $ipsecip = $vpnsettings{'VPN_IP'}; | |
db073a10 | 410 | my @status = `/usr/local/bin/ipsecctrl I`; |
e455cafe | 411 | my %confighash = (); |
9d386698 AM |
412 | my $id = 0; |
413 | my $gif; | |
414 | my $col=""; | |
415 | my $count=0; | |
072cd997 | 416 | print <<END; |
c010871a | 417 | <table class='tbl' style='width:80%;'> |
043cfbc0 | 418 | <tr> |
c010871a AH |
419 | <th style='width:40%;'>$Lang::tr{'ipsec network'}</th> |
420 | <th style='width:30%;'>$Lang::tr{'ip address'}</th> | |
421 | <th style='width:30%;'>$Lang::tr{'status'}</th> | |
043cfbc0 | 422 | </tr> |
e383179b | 423 | END |
9d386698 | 424 | foreach my $key (sort { uc($vpnconfig{$a}[1]) cmp uc($vpnconfig{$b}[1]) } keys %vpnconfig) { |
5ef260ae | 425 | if ($vpnconfig{$key}[0] eq 'on' && $vpnconfig{$key}[3] ne 'host') { |
9d386698 | 426 | $count++; |
cb18f193 MT |
427 | |
428 | my @n = (); | |
429 | ||
430 | my @networks = split(/\|/, $vpnconfig{$key}[11]); | |
431 | foreach my $network (@networks) { | |
432 | my ($vpnip, $vpnsub) = split("/", $network); | |
433 | $vpnsub = &Network::convert_netmask2prefix($vpnsub) || $vpnsub; | |
434 | push(@n, "$vpnip/$vpnsub"); | |
435 | } | |
436 | ||
9d386698 | 437 | if ($count % 2){ |
c010871a | 438 | $col = $color{'color22'}; |
9d386698 | 439 | }else{ |
c010871a | 440 | $col = $color{'color20'}; |
9d386698 | 441 | } |
c010871a | 442 | print "<tr>"; |
5ef260ae | 443 | print "<td style='text-align:left; color:white; background-color:$Header::colourvpn;'>$vpnconfig{$key}[1]</td>"; |
cb18f193 | 444 | print "<td style='text-align:center; background-color:$col'>" . join("<br>", @n) . "</td>"; |
c010871a AH |
445 | |
446 | my $activecolor = $Header::colourred; | |
447 | my $activestatus = $Lang::tr{'capsclosed'}; | |
aec1925b MT |
448 | if ($vpnconfig{$key}[33] eq "add") { |
449 | $activecolor = ${Header::colourorange}; | |
450 | $activestatus = $Lang::tr{'vpn wait'}; | |
451 | } | |
9d386698 | 452 | if ($vpnconfig{$key}[0] eq 'off') { |
c010871a AH |
453 | $activecolor = $Header::colourblue; |
454 | $activestatus = $Lang::tr{'capsclosed'}; | |
9d386698 AM |
455 | } else { |
456 | foreach my $line (@status) { | |
457 | if (($line =~ /\"$vpnconfig{$key}[1]\".*IPsec SA established/) || ($line =~/$vpnconfig{$key}[1]\{.*INSTALLED/ )){ | |
c010871a AH |
458 | $activecolor = $Header::colourgreen; |
459 | $activestatus = $Lang::tr{'capsopen'}; | |
1fab4edf MT |
460 | } elsif ($line =~ /$vpnconfig{$key}[1]\[.*CONNECTING/) { |
461 | $activecolor = $Header::colourorange; | |
462 | $activestatus = $Lang::tr{'vpn connecting'}; | |
8057ab15 MT |
463 | } elsif ($line =~ /$vpnconfig{$key}[1]\{.*ROUTED/) { |
464 | $activecolor = $Header::colourorange; | |
465 | $activestatus = $Lang::tr{'vpn on-demand'}; | |
9d386698 AM |
466 | } |
467 | } | |
e455cafe | 468 | } |
c010871a AH |
469 | print "<td style='text-align:center; color:white; background-color:$activecolor;'><b>$activestatus</b></td>"; |
470 | print "</tr>"; | |
e455cafe | 471 | } |
e455cafe | 472 | } |
c010871a | 473 | print "</table>"; |
072cd997 | 474 | } |
4715ddb3 | 475 | |
c010871a | 476 | # Check if there is any OpenVPN connection configured. |
9d386698 AM |
477 | if ( $showovpn ){ |
478 | print <<END; | |
c010871a AH |
479 | <br/> |
480 | <table class='tbl' style='width:80%;'> | |
9d386698 | 481 | <tr> |
c010871a AH |
482 | <th style='width:40%;'>$Lang::tr{'openvpn network'}</th> |
483 | <th style='width:30%;'>$Lang::tr{'ip address'}</th> | |
484 | <th style='width:30%;'>$Lang::tr{'status'}</th> | |
4715ddb3 | 485 | END |
4715ddb3 | 486 | |
9d386698 AM |
487 | # Check if the OpenVPN server for Road Warrior Connections is running and display status information. |
488 | my $active; | |
489 | my $count=0; | |
490 | # Print the OpenVPN N2N connection status. | |
491 | if ( -d "${General::swroot}/ovpn/n2nconf") { | |
492 | my $col=""; | |
493 | foreach my $dkey (sort { ncmp ($ovpnconfig{$a}[1],$ovpnconfig{$b}[1])} keys %ovpnconfig) { | |
494 | if (($ovpnconfig{$dkey}[3] eq 'net') && (-e "/var/run/$ovpnconfig{$dkey}[1]n2n.pid")){ | |
495 | $count++; | |
496 | my $tport = $ovpnconfig{$dkey}[22]; | |
497 | next if ($tport eq ''); | |
498 | my $tnet = new Net::Telnet ( Timeout=>5, Errmode=>'return', Port=>$tport); | |
499 | $tnet->open('127.0.0.1'); | |
500 | my @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/'); | |
501 | my @tustate = split(/\,/, $output[1]); | |
502 | my $display; | |
503 | my $display_colour = $Header::colourred; | |
504 | if ( $tustate[1] eq 'CONNECTED' || ($tustate[1] eq 'WAIT')) { | |
505 | $display_colour = $Header::colourgreen; | |
506 | $display = $Lang::tr{'capsopen'}; | |
507 | } else { | |
508 | $display = $tustate[1]; | |
509 | } | |
510 | if ($count %2){ | |
c010871a | 511 | $col = $color{'color22'}; |
9d386698 | 512 | }else{ |
c010871a | 513 | $col = $color{'color20'}; |
9d386698 AM |
514 | } |
515 | $active='off'; | |
516 | #make cidr from ip | |
517 | my ($vpnip,$vpnsub) = split("/",$ovpnconfig{$dkey}[11]); | |
518 | my $vpnsub=&General::iporsubtocidr($vpnsub); | |
519 | my $vpnip="$vpnip/$vpnsub"; | |
520 | print <<END; | |
521 | <tr> | |
c010871a AH |
522 | <td style='text-align:left; color:white; background-color:$Header::colourovpn;'>$ovpnconfig{$dkey}[1]</td> |
523 | <td style='text-align:center; background-color:$col'>$vpnip</td> | |
524 | <td style='text-align:center; color:white; background-color:$display_colour' ><b>$display</b></td> | |
9d386698 | 525 | </tr> |
54fd0535 | 526 | END |
9d386698 | 527 | } |
4715ddb3 | 528 | } |
acb305f5 | 529 | } |
9d386698 | 530 | if ($active ne 'off'){ |
c010871a | 531 | print "<tr><td colspan='3' style='text-align:center;'>$Lang::tr{'ovpn no connections'}</td></tr>"; |
9d386698 AM |
532 | } |
533 | print"</table>"; | |
acb305f5 | 534 | } |
043cfbc0 | 535 | &Header::closebox(); |
9d386698 AM |
536 | } |
537 | ||
183b23b5 MT |
538 | my $dnssec_status = &General::dnssec_status(); |
539 | if ($dnssec_status eq "off") { | |
540 | $warnmessage .= "<li>$Lang::tr{'dnssec disabled warning'}</li>"; | |
541 | } | |
542 | ||
579a39d0 MT |
543 | # Fireinfo |
544 | if ( ! -e "/var/ipfire/main/send_profile") { | |
545 | $warnmessage .= "<li><a style='color: white;' href='fireinfo.cgi'>$Lang::tr{'fireinfo please enable'}</a></li>"; | |
546 | } | |
547 | ||
ac1cfefa MT |
548 | # Memory usage warning |
549 | my @free = `/usr/bin/free`; | |
550 | $free[1] =~ m/(\d+)/; | |
551 | my $mem = $1; | |
552 | $free[2] =~ m/(\d+)/; | |
553 | my $used = $1; | |
554 | my $pct = int 100 * ($mem - $used) / $mem; | |
555 | if ($used / $mem > 90) { | |
c010871a | 556 | $warnmessage .= "<li>$Lang::tr{'high memory usage'}: $pct% !</li>"; |
ac1cfefa MT |
557 | } |
558 | ||
559 | # Diskspace usage warning | |
560 | my @temp=(); | |
561 | my $temp2=(); | |
8955b5a7 | 562 | my @df = `/bin/df -B M -P -x rootfs`; |
ac1cfefa MT |
563 | foreach my $line (@df) { |
564 | next if $line =~ m/^Filesystem/; | |
565 | if ($line =~ m/root/ ) { | |
566 | $line =~ m/^.* (\d+)M.*$/; | |
567 | @temp = split(/ +/,$line); | |
568 | if ($1<5) { | |
569 | # available:plain value in MB, and not %used as 10% is too much to waste on small disk | |
570 | # and root size should not vary during time | |
c010871a | 571 | $warnmessage .= "<li>$Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$1M</b> !</li>"; |
ac1cfefa MT |
572 | } |
573 | ||
574 | } else { | |
575 | # $line =~ m/^.* (\d+)m.*$/; | |
576 | $line =~ m/^.* (\d+)\%.*$/; | |
577 | if ($1>90) { | |
578 | @temp = split(/ /,$line); | |
579 | $temp2=int(100-$1); | |
c010871a | 580 | $warnmessage .= "<li>$Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$temp2%</b> !</li>"; |
ac1cfefa MT |
581 | } |
582 | } | |
583 | } | |
584 | ||
c1712013 | 585 | # S.M.A.R.T. health warning |
73c7eff8 | 586 | my @files = `/bin/ls /var/run/smartctl_out_hddtemp-* 2>/dev/null`; |
c1712013 AF |
587 | foreach my $file (@files) { |
588 | chomp ($file); | |
589 | my $disk=`echo $file | cut -d"-" -f2`; | |
590 | chomp ($disk); | |
591 | if (`/bin/grep "SAVE ALL DATA" $file`) { | |
c010871a | 592 | $warnmessage .= "<li>$Lang::tr{'smartwarn1'} /dev/$disk $Lang::tr{'smartwarn2'} !</li>"; |
c1712013 AF |
593 | } |
594 | } | |
595 | ||
b81b96d2 AF |
596 | # Reiser4 warning |
597 | my @files = `mount | grep " reiser4 (" 2>/dev/null`; | |
598 | foreach my $disk (@files) { | |
599 | chomp ($disk); | |
c010871a | 600 | $warnmessage .= "<li>$disk - $Lang::tr{'deprecated fs warn'}</li>"; |
b81b96d2 AF |
601 | } |
602 | ||
ac1cfefa | 603 | if ($warnmessage) { |
9d386698 | 604 | &Header::openbox('100%','center', ); |
c010871a | 605 | print "<table class='tbl' style='width:80%;'>"; |
9d386698 | 606 | print "<tr><th>$Lang::tr{'fwhost hint'}</th></tr>"; |
c010871a AH |
607 | print "<tr><td style='color:white; background-color:$Header::colourred;'>$warnmessage</td></tr>"; |
608 | print "</table>"; | |
9d386698 | 609 | &Header::closebox(); |
ac1cfefa | 610 | } |
9d386698 | 611 | |
2b38ab5c | 612 | &Pakfire::dblist("upgrade", "notice"); |
f341a168 | 613 | if ( -e "/var/run/need_reboot" ) { |
c010871a AH |
614 | print "<div style='text-align:center; color:red;'>"; |
615 | print "<br/><br/>$Lang::tr{'needreboot'}!"; | |
616 | print "</div>"; | |
337305ef | 617 | } |
7fa7c7dd | 618 | |
ac1cfefa | 619 | &Header::closebigbox(); |
ac1cfefa | 620 | &Header::closepage(); |
c010871a | 621 |