]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/netexternal.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2005-2010 IPFire Team #
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. #
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. #
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/>. #
20 ###############################################################################
23 use experimental
'smartmatch';
25 # enable only the following on debugging purpose
27 #use CGI::Carp 'fatalsToBrowser';
31 require '/var/ipfire/general-functions.pl';
32 require "${General::swroot}/lang.pl";
33 require "${General::swroot}/header.pl";
34 require "${General::swroot}/geoip-functions.pl";
35 require "${General::swroot}/graphs.pl";
38 my %mainsettings = ();
40 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
41 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
42 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
47 my @querry = split(/\?/,$ENV{'QUERY_STRING'});
48 $querry[0] = '' unless defined $querry[0];
49 $querry[1] = 'hour' unless defined $querry[1];
51 if ( $querry[0] ne~ ""){
52 print "Content-type: image/png\n\n";
54 &Graphs
::updateifgraph
($querry[0],$querry[1]);
57 &Header
::showhttpheaders
();
58 &Header
::openpage
($Lang::tr
{'network traffic graphs external'}, 1, '');
59 &Header
::openbigbox
('100%', 'left');
61 if ($netsettings{'RED_TYPE'} ne 'PPPOE'){
62 if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}){
63 push (@graphs, ($netsettings{'RED_DEV'}));
66 push (@graphs, "ppp0");
69 if (-e
"/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd"){
70 push (@graphs, ("ipsec0"));
73 if (-e
"/var/log/rrd/collectd/localhost/interface/if_octets-tun0.rrd"){
74 push (@graphs, ("tun0"));
78 &Header
::openbox
('100%', 'center', "$_ $Lang::tr{'graph'}");
79 &Graphs
::makegraphbox
("netexternal.cgi",$_,"day");
85 foreach my $f ("${General::swroot}/red/dns1", "${General::swroot}/red/dns2") {
87 my $nameserver = <DNS
>;
92 push(@nameservers, $nameserver);
96 &Header
::openbox
('100%', 'center', $Lang::tr
{'dnssec information'});
99 <table class="tbl" width='66%'>
103 <strong>$Lang::tr{'nameserver'}</strong>
106 <strong>$Lang::tr{'country'}</strong>
109 <strong>$Lang::tr{'rdns'}</strong>
112 <strong>$Lang::tr{'status'}</strong>
120 for my $nameserver (@nameservers) {
121 my $status = &check_dnssec
($nameserver, "ping.ipfire.org");
127 # DNSSEC Not supported
129 $message = $Lang::tr
{'dnssec not supported'};
131 $bgcolour = ${Header
::colourred
};
134 } elsif ($status == 1) {
135 $message = $Lang::tr
{'dnssec aware'};
137 $bgcolour = ${Header
::colouryellow
};
140 } elsif ($status == 2) {
141 $message = $Lang::tr
{'dnssec validating'};
143 $bgcolour = ${Header
::colourgreen
};
147 $colour = ${Header
::colourred
};
150 my $table_colour = ($id++ % 2) ?
$color{'color22'} : $color{'color20'};
152 # collect more information about name server (rDNS, GeoIP country code)
153 my $ccode = &GeoIP
::lookup
($nameserver);
154 my $flag_icon = &GeoIP
::get_flag_icon
($ccode);
156 my $iaddr = inet_aton
($nameserver);
157 my $rdns = gethostbyaddr($iaddr, AF_INET
);
158 if (!$rdns) { $rdns = $Lang::tr
{'lookup failed'}; }
161 <tr bgcolor="$table_colour">
166 <a href='country.cgi#$ccode'><img src="$flag_icon" border="0" alt="$ccode" title="$ccode" /></a>
171 <td bgcolor="$bgcolour" align="center">
172 <font color="$colour"><strong>$message</strong></font>
185 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP"){
187 &Header
::openbox
('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
188 if (-s
"${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
190 &General
::readhash
("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \
%dhcpinfo);
192 my $DNS1=`echo $dhcpinfo{'domain_name_servers'} | cut -f 1 -d " "`;
193 my $DNS2=`echo $dhcpinfo{'domain_name_servers'} | cut -f 2 -d " "`;
197 if ($dhcpinfo{'dhcp_lease_time'} ne "") {
198 $lsetme=$dhcpinfo{'dhcp_lease_time'};
199 $lsetme=($lsetme/60);
202 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
204 $leasetime=$lsetme." Minute";
208 $leasetime=$leasetime."s";
215 if ($dhcpinfo{'dhcp_renewal_time'} ne "") {
216 $rentme=$dhcpinfo{'dhcp_renewal_time'};
217 $rentme=($rentme/60);
220 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
222 $rnwltime=$rentme." Minute";
226 $rnwltime=$rnwltime."s";
233 if ($dhcpinfo{'dhcp_rebinding_time'} ne "") {
234 $maxtme=$dhcpinfo{'dhcp_rebinding_time'};
235 $maxtme=($maxtme/60);
238 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
240 $maxtime=$maxtme." Minute";
244 $maxtime=$maxtime."s";
251 <tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'domain_name'}</td></tr>
252 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'routers'}</td></tr>
253 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
254 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
255 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'dhcp_server_identifier'}</td></tr>
256 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
257 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
258 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
263 print "$Lang::tr{'no dhcp lease'}";
268 &Header
::closebigbox
();
269 &Header
::closepage
();
272 sub check_dnssec
($$) {
273 my $nameserver = shift;
276 my @command = ("dig", "+dnssec", $record, "\@$nameserver");
278 my @output = qx(@command);
279 my $output = join("", @output);
282 if ($output =~ m/status: (\w+)/) {
283 $status = ($1 eq "NOERROR");
291 if ($output =~ m/flags: (.*);/) {
292 @flags = split(/ /, $1);
295 my $aware = ($output =~ m/RRSIG/);
296 my $validating = ("ad" ~~ @flags);
298 return $aware + $validating;