]> git.ipfire.org Git - ipfire-2.x.git/blame - html/cgi-bin/index.cgi
suricata: Fix ownership and file permissions of files inside /var/lib/suricata.
[ipfire-2.x.git] / html / cgi-bin / index.cgi
CommitLineData
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
22use strict;
54fd0535 23use Net::Telnet;
9d386698 24use 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 30require '/var/ipfire/general-functions.pl';
ac1cfefa
MT
31require "${General::swroot}/lang.pl";
32require "${General::swroot}/header.pl";
2b38ab5c 33require "/opt/pakfire/lib/functions.pl";
ac1cfefa
MT
34
35my %cgiparams=();
36my %pppsettings=();
37my %modemsettings=();
38my %netsettings=();
39my %ddnssettings=();
9d386698
AM
40my %proxysettings=();
41my %vpnsettings=();
42my %vpnconfig=();
43my %ovpnconfig=();
ac1cfefa 44my $warnmessage = '';
c85ec3b4 45my $refresh = "";
e383179b 46my $ipaddr='';
9d386698
AM
47my $showbox=0;
48my $showipsec=0;
49my $showovpn=0;
50
51if ( ! -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
70my %color = ();
71my %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 75my $connstate = &Header::connectionstatus();
56b7a3e2 76
9d386698
AM
77if ( -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
85if ($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
120if ($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
128my $c;
129my $maxprofiles = 5;
130my @profilenames = ();
131
132for ($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}
139my %selected;
140for ($c = 1; $c <= $maxprofiles; $c++) {
141 $selected{'PROFILE'}{$c} = '';
142}
143$selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'";
144my $dialButtonDisabled = "disabled='disabled'";
145
ac1cfefa
MT
146&Header::openpage($Lang::tr{'main page'}, 1, $refresh);
147&Header::openbigbox('', 'center');
9d386698
AM
148if (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 155if ( ( $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 172print <<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 185END
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
190END
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
200END
201 }
317638e7 202
e24d6112
AF
203 my $dns_servers;
204 if ( -e "${General::swroot}/red/dns" ) {
205 open (TMP, "<${General::swroot}/red/dns");
206 $dns_servers = <TMP>;
207 chomp($dns_servers);
208 close TMP;
317638e7 209 }
125b6fcd
MT
210 print <<END;
211 <tr>
212 <td>
e15d5f25 213 <b><a href="netexternal.cgi">$Lang::tr{'dns servers'}</a>:</b>
125b6fcd 214 </td>
c010871a 215 <td style='text-align:center;'>
e24d6112 216 $dns_servers
125b6fcd 217 </td>
c010871a 218 <td></td>
125b6fcd 219 </tr>
c335b0cd
MT
220END
221
222 if (&General::RedIsWireless()) {
223 my $iface = $netsettings{"RED_DEV"} || "red0";
224
225 my $essid = &Network::wifi_get_essid($iface);
226 my $frequency = &Network::wifi_get_frequency($iface);
227 my $access_point = &Network::wifi_get_access_point($iface);
228 my $bit_rate = &Network::wifi_get_bit_rate($iface);
229 my $link_quality = &Network::wifi_get_link_quality($iface);
230 my $signal_level = &Network::wifi_get_signal_level($iface);
231
232 print <<END;
233 <tr>
234 <td>
235 <strong>$Lang::tr{'wireless network'}:</strong>
236 </td>
237 <td style="text-align: center">
238 $essid
239 </td>
240 <td style="text-align: center">
241 $access_point @ $frequency
242 </td>
243 </tr>
244 <tr>
245 <td>
246 <strong>
247 $Lang::tr{'uplink bit rate'}:
248 </strong>
249 </td>
250 <td style="text-align: center">
251 $bit_rate
252 </td>
253 <td style="text-align: center">
254 $link_quality% @ $signal_level
255 </td>
256 </tr>
257END
258 }
259
260 print <<END;
261 </table>
043cfbc0 262END
043cfbc0
AM
263
264#Dial profiles
c85ec3b4 265if ( $netsettings{'RED_TYPE'} ne "STATIC" && $netsettings{'RED_TYPE'} ne "DHCP" ){
c010871a
AH
266 if ( ( $pppsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) {
267 print <<END;
268 <br/>
269 <table style='width:80%;'>
043cfbc0 270 <tr><td>
957363eb 271 <form method='post' action='$ENV{'SCRIPT_NAME'}'>$Lang::tr{'profile'}:
e383179b
MT
272 <select name='PROFILE'>
273END
c010871a
AH
274 for ($c = 1; $c <= $maxprofiles; $c++)
275 {
276 if ($profilenames[$c] ne '') {
277 $dialButtonDisabled = "";
278 print "<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>";
279 }
e383179b 280 }
c010871a 281 $dialButtonDisabled = "disabled='disabled'" if (-e '/var/run/ppp-ipfire.pid' || -e "${General::swroot}/red/active");
e383179b 282 print <<END;
c010871a
AH
283 </select>
284 <input type='submit' name='ACTION' value='$Lang::tr{'dial profile'}' $dialButtonDisabled />
285 </form>
286 </td>
287 <td style='text-align:center;'>
288 <table style='width:100%;'>
289 <tr>
290 <td style='width=50%; text-align:right;'>
291 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
292 <input type='submit' name='ACTION' value='$Lang::tr{'dial'}'>
293 </form>
294 </td>
295 <td style='width=50%; text-align:left;'>
296 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
297 <input type='submit' name='ACTION' value='$Lang::tr{'hangup'}'>
298 </form>
299 </td>
300 </tr>
301 </table>
302 </td>
303 </tr>
304 </table>
e383179b
MT
305END
306 } else {
c010871a 307 print "<br/><span style='color:red;'>$Lang::tr{'profile has errors'}</span><br/>";
e383179b 308 }
c85ec3b4 309}
c010871a
AH
310
311
312print <<END;
313<br/>
314<table class='tbl' style='width:80%;'>
315<tr>
316 <th>$Lang::tr{'network'}</th>
317 <th>$Lang::tr{'ip address'}</th>
318 <th>$Lang::tr{'status'}</th>
319</tr>
320END
321
322if ( $netsettings{'GREEN_DEV'} ) {
043cfbc0 323 my $sub=&General::iporsubtocidr($netsettings{'GREEN_NETMASK'});
786f2c8a 324 print <<END;
043cfbc0 325 <tr>
c010871a
AH
326 <td style='width:25%; text-align:center; background-color:$Header::colourgreen;'>
327 <a href='/cgi-bin/dhcp.cgi' style='color:white'><b>$Lang::tr{'lan'}</b></a>
328 </td>
329 <td style='width:30%; text-align:center;'>$netsettings{'GREEN_ADDRESS'}/$sub</td>
330 <td style='width:45%; text-align:center;'>
e383179b 331END
9d386698
AM
332 if ( $proxysettings{'ENABLE'} eq 'on' ) {
333 print $Lang::tr{'advproxy on'};
334 if ( $proxysettings{'TRANSPARENT'} eq 'on' ) { print " (transparent)"; }
ef482d53 335 } else { print $Lang::tr{'advproxy off'}; }
c010871a
AH
336 print '</td>';
337 print '</tr>';
072cd997 338 }
db1078ff 339if (&Header::blue_used()) {
043cfbc0
AM
340 my $sub=&General::iporsubtocidr($netsettings{'BLUE_NETMASK'});
341 print <<END;
c010871a
AH
342 <tr>
343 <td style='width:25%; text-align:center; background-color:$Header::colourblue;'>
344 <a href='/cgi-bin/wireless.cgi' style='color:white'><b>$Lang::tr{'wireless'}</b></a>
345 </td>
346 <td style='width:30%; text-align:center;'>$netsettings{'BLUE_ADDRESS'}/$sub
347 <td style='width:45%; text-align:center;'>
e383179b 348END
9d386698
AM
349 if ( $proxysettings{'ENABLE_BLUE'} eq 'on' ) {
350 print $Lang::tr{'advproxy on'};
351 if ( $proxysettings{'TRANSPARENT_BLUE'} eq 'on' ) { print " (transparent)"; }
ef482d53 352 } else { print $Lang::tr{'advproxy off'}; }
c010871a
AH
353 print '</td>';
354 print '</tr>';
072cd997 355 }
db1078ff 356if (&Header::orange_used()) {
043cfbc0
AM
357 my $sub=&General::iporsubtocidr($netsettings{'ORANGE_NETMASK'});
358 print <<END;
c010871a
AH
359 <tr>
360 <td style='width:25%; text-align:center; background-color:$Header::colourorange;'>
361 <a href='/cgi-bin/firewall.cgi' style='color:white'><b>$Lang::tr{'dmz'}</b></a>
362 </td>
363 <td style='width:30%; text-align:center;'>$netsettings{'ORANGE_ADDRESS'}/$sub</td>
364 <td style='width:45%; text-align:center; color:$Header::colourgreen;'>Online</td>
365 </tr>
043cfbc0
AM
366END
367 }
368#check if IPSEC is running
9d386698 369if ( $vpnsettings{'ENABLED'} eq 'on' || $vpnsettings{'ENABLED_BLUE'} eq 'on' ) {
043cfbc0 370print<<END;
c010871a
AH
371 <tr>
372 <td style='width:25%; text-align:center; background-color:$Header::colourvpn;'>
373 <a href='/cgi-bin/vpnmain.cgi' style='color:white'><b>$Lang::tr{'ipsec'}</b></a>
374 </td>
517683ee 375 <td style='width:30%; text-align:center;'></td>
c010871a
AH
376 <td style='width:45%; text-align:center; color:$Header::colourgreen;'>Online</td>
377 </tr>
043cfbc0
AM
378END
379}
380
381#check if OpenVPN is running
382my %confighash=();
383&General::readhash("${General::swroot}/ovpn/settings", \%confighash);
384
385if (($confighash{'ENABLED'} eq "on") ||
386 ($confighash{'ENABLED_BLUE'} eq "on") ||
387 ($confighash{'ENABLED_ORANGE'} eq "on")) {
388 my ($ovpnip,$sub) = split("/",$confighash{'DOVPN_SUBNET'});
389 $sub=&General::iporsubtocidr($sub);
390 $ovpnip="$ovpnip/$sub";
043cfbc0
AM
391print <<END;
392 <tr>
5ef260ae 393 <td style='width:25%; text-align:center; background-color:$Header::colourovpn;'>
c010871a 394 <a href='/cgi-bin/ovpnmain.cgi' style='color:white'><b>OpenVPN</b></a>
043cfbc0 395 </td>
c010871a
AH
396 <td style='width:30%; text-align:center;'>$ovpnip</td>
397 <td style='width:45%; text-align:center; color:$Header::colourgreen;'>Online</td>
398 </tr>
e383179b 399END
072cd997 400 }
c010871a 401print"</table>";
043cfbc0
AM
402&Header::closebox();
403
9d386698
AM
404#Check if there are any vpns configured (ipsec and openvpn)
405&General::readhasharray("${General::swroot}/vpn/config", \%vpnconfig);
406foreach my $key (sort { ncmp($vpnconfig{$a}[1],$vpnconfig{$b}[1]) } keys %vpnconfig) {
5ef260ae 407 if ($vpnconfig{$key}[0] eq 'on' && $vpnconfig{$key}[3] ne 'host'){
9d386698
AM
408 $showipsec=1;
409 $showbox=1;
410 last;
411 }
412}
413&General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%ovpnconfig);
414foreach my $dkey (sort { ncmp($ovpnconfig{$a}[1],$ovpnconfig{$b}[1])} keys %ovpnconfig) {
415 if (($ovpnconfig{$dkey}[3] eq 'net') && (-e "/var/run/$ovpnconfig{$dkey}[1]n2n.pid")){
416 $showbox=1;
417 $showovpn=1;
418 last;
419 }
420}
043cfbc0 421
9d386698
AM
422if ($showbox){
423# Start of Box wich contains all vpn connections
424 &Header::openbox('100%', 'center', $Lang::tr{'vpn'});
c010871a
AH
425
426 #show ipsec connectiontable
9d386698
AM
427 if ( $showipsec ) {
428 my $ipsecip = $vpnsettings{'VPN_IP'};
db073a10 429 my @status = `/usr/local/bin/ipsecctrl I`;
e455cafe 430 my %confighash = ();
9d386698
AM
431 my $id = 0;
432 my $gif;
433 my $col="";
434 my $count=0;
072cd997 435 print <<END;
c010871a 436 <table class='tbl' style='width:80%;'>
043cfbc0 437 <tr>
c010871a
AH
438 <th style='width:40%;'>$Lang::tr{'ipsec network'}</th>
439 <th style='width:30%;'>$Lang::tr{'ip address'}</th>
440 <th style='width:30%;'>$Lang::tr{'status'}</th>
043cfbc0 441 </tr>
e383179b 442END
9d386698 443 foreach my $key (sort { uc($vpnconfig{$a}[1]) cmp uc($vpnconfig{$b}[1]) } keys %vpnconfig) {
5ef260ae 444 if ($vpnconfig{$key}[0] eq 'on' && $vpnconfig{$key}[3] ne 'host') {
9d386698 445 $count++;
cb18f193
MT
446
447 my @n = ();
448
449 my @networks = split(/\|/, $vpnconfig{$key}[11]);
450 foreach my $network (@networks) {
451 my ($vpnip, $vpnsub) = split("/", $network);
452 $vpnsub = &Network::convert_netmask2prefix($vpnsub) || $vpnsub;
453 push(@n, "$vpnip/$vpnsub");
454 }
455
9d386698 456 if ($count % 2){
c010871a 457 $col = $color{'color22'};
9d386698 458 }else{
c010871a 459 $col = $color{'color20'};
9d386698 460 }
c010871a 461 print "<tr>";
5ef260ae 462 print "<td style='text-align:left; color:white; background-color:$Header::colourvpn;'>$vpnconfig{$key}[1]</td>";
cb18f193 463 print "<td style='text-align:center; background-color:$col'>" . join("<br>", @n) . "</td>";
c010871a
AH
464
465 my $activecolor = $Header::colourred;
466 my $activestatus = $Lang::tr{'capsclosed'};
aec1925b
MT
467 if ($vpnconfig{$key}[33] eq "add") {
468 $activecolor = ${Header::colourorange};
469 $activestatus = $Lang::tr{'vpn wait'};
470 }
9d386698 471 if ($vpnconfig{$key}[0] eq 'off') {
c010871a
AH
472 $activecolor = $Header::colourblue;
473 $activestatus = $Lang::tr{'capsclosed'};
9d386698
AM
474 } else {
475 foreach my $line (@status) {
476 if (($line =~ /\"$vpnconfig{$key}[1]\".*IPsec SA established/) || ($line =~/$vpnconfig{$key}[1]\{.*INSTALLED/ )){
c010871a
AH
477 $activecolor = $Header::colourgreen;
478 $activestatus = $Lang::tr{'capsopen'};
1fab4edf
MT
479 } elsif ($line =~ /$vpnconfig{$key}[1]\[.*CONNECTING/) {
480 $activecolor = $Header::colourorange;
481 $activestatus = $Lang::tr{'vpn connecting'};
8057ab15
MT
482 } elsif ($line =~ /$vpnconfig{$key}[1]\{.*ROUTED/) {
483 $activecolor = $Header::colourorange;
484 $activestatus = $Lang::tr{'vpn on-demand'};
9d386698
AM
485 }
486 }
e455cafe 487 }
c010871a
AH
488 print "<td style='text-align:center; color:white; background-color:$activecolor;'><b>$activestatus</b></td>";
489 print "</tr>";
e455cafe 490 }
e455cafe 491 }
c010871a 492 print "</table>";
072cd997 493 }
4715ddb3 494
c010871a 495 # Check if there is any OpenVPN connection configured.
9d386698
AM
496 if ( $showovpn ){
497 print <<END;
c010871a
AH
498 <br/>
499 <table class='tbl' style='width:80%;'>
9d386698 500 <tr>
c010871a
AH
501 <th style='width:40%;'>$Lang::tr{'openvpn network'}</th>
502 <th style='width:30%;'>$Lang::tr{'ip address'}</th>
503 <th style='width:30%;'>$Lang::tr{'status'}</th>
4715ddb3 504END
4715ddb3 505
9d386698
AM
506 # Check if the OpenVPN server for Road Warrior Connections is running and display status information.
507 my $active;
508 my $count=0;
509 # Print the OpenVPN N2N connection status.
510 if ( -d "${General::swroot}/ovpn/n2nconf") {
511 my $col="";
512 foreach my $dkey (sort { ncmp ($ovpnconfig{$a}[1],$ovpnconfig{$b}[1])} keys %ovpnconfig) {
513 if (($ovpnconfig{$dkey}[3] eq 'net') && (-e "/var/run/$ovpnconfig{$dkey}[1]n2n.pid")){
514 $count++;
515 my $tport = $ovpnconfig{$dkey}[22];
516 next if ($tport eq '');
517 my $tnet = new Net::Telnet ( Timeout=>5, Errmode=>'return', Port=>$tport);
518 $tnet->open('127.0.0.1');
519 my @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/');
520 my @tustate = split(/\,/, $output[1]);
521 my $display;
522 my $display_colour = $Header::colourred;
523 if ( $tustate[1] eq 'CONNECTED' || ($tustate[1] eq 'WAIT')) {
524 $display_colour = $Header::colourgreen;
525 $display = $Lang::tr{'capsopen'};
526 } else {
527 $display = $tustate[1];
528 }
529 if ($count %2){
c010871a 530 $col = $color{'color22'};
9d386698 531 }else{
c010871a 532 $col = $color{'color20'};
9d386698
AM
533 }
534 $active='off';
535 #make cidr from ip
536 my ($vpnip,$vpnsub) = split("/",$ovpnconfig{$dkey}[11]);
537 my $vpnsub=&General::iporsubtocidr($vpnsub);
538 my $vpnip="$vpnip/$vpnsub";
539 print <<END;
540 <tr>
c010871a
AH
541 <td style='text-align:left; color:white; background-color:$Header::colourovpn;'>$ovpnconfig{$dkey}[1]</td>
542 <td style='text-align:center; background-color:$col'>$vpnip</td>
543 <td style='text-align:center; color:white; background-color:$display_colour' ><b>$display</b></td>
9d386698 544 </tr>
54fd0535 545END
9d386698 546 }
4715ddb3 547 }
acb305f5 548 }
9d386698 549 if ($active ne 'off'){
c010871a 550 print "<tr><td colspan='3' style='text-align:center;'>$Lang::tr{'ovpn no connections'}</td></tr>";
9d386698
AM
551 }
552 print"</table>";
acb305f5 553 }
043cfbc0 554&Header::closebox();
9d386698
AM
555}
556
183b23b5
MT
557my $dnssec_status = &General::dnssec_status();
558if ($dnssec_status eq "off") {
559 $warnmessage .= "<li>$Lang::tr{'dnssec disabled warning'}</li>";
560}
561
579a39d0
MT
562# Fireinfo
563if ( ! -e "/var/ipfire/main/send_profile") {
564 $warnmessage .= "<li><a style='color: white;' href='fireinfo.cgi'>$Lang::tr{'fireinfo please enable'}</a></li>";
565}
566
ac1cfefa
MT
567# Memory usage warning
568my @free = `/usr/bin/free`;
569$free[1] =~ m/(\d+)/;
570my $mem = $1;
571$free[2] =~ m/(\d+)/;
572my $used = $1;
573my $pct = int 100 * ($mem - $used) / $mem;
574if ($used / $mem > 90) {
c010871a 575 $warnmessage .= "<li>$Lang::tr{'high memory usage'}: $pct% !</li>";
ac1cfefa
MT
576}
577
578# Diskspace usage warning
579my @temp=();
580my $temp2=();
8955b5a7 581my @df = `/bin/df -B M -P -x rootfs`;
ac1cfefa
MT
582foreach my $line (@df) {
583 next if $line =~ m/^Filesystem/;
584 if ($line =~ m/root/ ) {
585 $line =~ m/^.* (\d+)M.*$/;
586 @temp = split(/ +/,$line);
587 if ($1<5) {
588 # available:plain value in MB, and not %used as 10% is too much to waste on small disk
589 # and root size should not vary during time
c010871a 590 $warnmessage .= "<li>$Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$1M</b> !</li>";
ac1cfefa
MT
591 }
592
593 } else {
594 # $line =~ m/^.* (\d+)m.*$/;
595 $line =~ m/^.* (\d+)\%.*$/;
596 if ($1>90) {
597 @temp = split(/ /,$line);
598 $temp2=int(100-$1);
c010871a 599 $warnmessage .= "<li>$Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$temp2%</b> !</li>";
ac1cfefa
MT
600 }
601 }
602}
603
c1712013 604# S.M.A.R.T. health warning
73c7eff8 605my @files = `/bin/ls /var/run/smartctl_out_hddtemp-* 2>/dev/null`;
c1712013
AF
606foreach my $file (@files) {
607 chomp ($file);
608 my $disk=`echo $file | cut -d"-" -f2`;
609 chomp ($disk);
610 if (`/bin/grep "SAVE ALL DATA" $file`) {
c010871a 611 $warnmessage .= "<li>$Lang::tr{'smartwarn1'} /dev/$disk $Lang::tr{'smartwarn2'} !</li>";
c1712013
AF
612 }
613}
614
b81b96d2
AF
615# Reiser4 warning
616my @files = `mount | grep " reiser4 (" 2>/dev/null`;
617foreach my $disk (@files) {
618 chomp ($disk);
c010871a 619 $warnmessage .= "<li>$disk - $Lang::tr{'deprecated fs warn'}</li>";
b81b96d2
AF
620}
621
ac1cfefa 622if ($warnmessage) {
9d386698 623 &Header::openbox('100%','center', );
c010871a 624 print "<table class='tbl' style='width:80%;'>";
9d386698 625 print "<tr><th>$Lang::tr{'fwhost hint'}</th></tr>";
c010871a
AH
626 print "<tr><td style='color:white; background-color:$Header::colourred;'>$warnmessage</td></tr>";
627 print "</table>";
9d386698 628 &Header::closebox();
ac1cfefa 629}
9d386698 630
2b38ab5c 631&Pakfire::dblist("upgrade", "notice");
f341a168 632if ( -e "/var/run/need_reboot" ) {
c010871a
AH
633 print "<div style='text-align:center; color:red;'>";
634 print "<br/><br/>$Lang::tr{'needreboot'}!";
635 print "</div>";
337305ef 636}
7fa7c7dd 637
ac1cfefa 638&Header::closebigbox();
ac1cfefa 639&Header::closepage();
c010871a 640