]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/netexternal.cgi
suricata: Change midstream policy to "pass-flow"
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / netexternal.cgi
CommitLineData
4e481c3a
CS
1#!/usr/bin/perl
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
0d08de33 5# Copyright (C) 2005-2010 IPFire Team #
4e481c3a
CS
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
22use strict;
5653e551 23use experimental 'smartmatch';
4e481c3a
CS
24
25# enable only the following on debugging purpose
26#use warnings;
27#use CGI::Carp 'fatalsToBrowser';
28
297110d4
PM
29use IO::Socket;
30
4e481c3a
CS
31require '/var/ipfire/general-functions.pl';
32require "${General::swroot}/lang.pl";
33require "${General::swroot}/header.pl";
34require "${General::swroot}/graphs.pl";
35
36my %color = ();
37my %mainsettings = ();
38my %netsettings=();
39&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
40&General::readhash("${General::swroot}/main/settings", \%mainsettings);
8186b372 41&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
4e481c3a
CS
42
43my @graphs=();
44my %dhcpinfo=();
45
4190b2a6
LAH
46&Header::showhttpheaders();
47&Header::openpage($Lang::tr{'network traffic graphs external'}, 1, '');
48&Header::openbigbox('100%', 'left');
4e481c3a 49
4190b2a6
LAH
50if ($netsettings{'RED_TYPE'} ne 'PPPOE'){
51 if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}){
52 push (@graphs, ($netsettings{'RED_DEV'}));
4e481c3a 53 }
4190b2a6
LAH
54}else{
55 push (@graphs, "ppp0");
56}
57
58if (-e "/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd"){
59 push (@graphs, ("ipsec0"));
60}
61
62if (-e "/var/log/rrd/collectd/localhost/interface/if_octets-tun0.rrd"){
63 push (@graphs, ("tun0"));
64}
65
66foreach (@graphs) {
67 &Header::openbox('100%', 'center', "$_ $Lang::tr{'graph'}");
68 &Graphs::makegraphbox("netexternal.cgi",$_,"day");
69 &Header::closebox();
70}
71
72if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP"){
73
74 &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
75 if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
76
77 &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
78
79 my ($DNS1, $DNS2) = split(/ /, $dhcpinfo{'domain_name_servers'});
80
81 my $lsetme=0;
82 my $leasetime="";
83 if ($dhcpinfo{'dhcp_lease_time'} ne "") {
84 $lsetme=$dhcpinfo{'dhcp_lease_time'};
85 $lsetme=($lsetme/60);
66c36198 86
4190b2a6
LAH
87 if ($lsetme > 59) {
88 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
89 }else{
90 $leasetime=$lsetme." Minute";
4e481c3a 91 }
66c36198 92
4190b2a6
LAH
93 if ($lsetme > 1) {
94 $leasetime=$leasetime."s";
95 }
96 }
4e481c3a 97
4190b2a6
LAH
98 my $rentme=0;
99 my $rnwltime="";
100
101 if ($dhcpinfo{'dhcp_renewal_time'} ne "") {
102 $rentme=$dhcpinfo{'dhcp_renewal_time'};
103 $rentme=($rentme/60);
66c36198 104
4190b2a6
LAH
105 if ($rentme > 59){
106 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
107 }else{
108 $rnwltime=$rentme." Minute";
4e481c3a 109 }
66c36198 110
4190b2a6
LAH
111 if ($rentme > 1){
112 $rnwltime=$rnwltime."s";
113 }
114 }
4e481c3a 115
4190b2a6
LAH
116 my $maxtme=0;
117 my $maxtime="";
4e481c3a 118
4190b2a6
LAH
119 if ($dhcpinfo{'dhcp_rebinding_time'} ne "") {
120 $maxtme=$dhcpinfo{'dhcp_rebinding_time'};
121 $maxtme=($maxtme/60);
4e481c3a 122
4190b2a6
LAH
123 if ($maxtme > 59){
124 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
125 } else {
126 $maxtime=$maxtme." Minute";
127 }
4e481c3a 128
4190b2a6
LAH
129 if ($maxtme > 1) {
130 $maxtime=$maxtime."s";
4e481c3a 131 }
4190b2a6 132 }
4e481c3a 133
4e481c3a 134
4190b2a6 135 print <<END
21d1c72e 136<table width='100%'>
4190b2a6
LAH
137 <tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'domain_name'}</td></tr>
138 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'routers'}</td></tr>
139 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
140 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
141 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'dhcp_server_identifier'}</td></tr>
142 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
143 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
144 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
4e481c3a
CS
145</table>
146END
147;
4190b2a6
LAH
148 }else{
149 print "$Lang::tr{'no dhcp lease'}";
4e481c3a 150 }
4190b2a6
LAH
151 &Header::closebox();
152}
4e481c3a 153
4190b2a6
LAH
154&Header::closebigbox();
155&Header::closepage();