]>
git.ipfire.org Git - 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 ###############################################################################
24 # enable only the following on debugging purpose
26 #use CGI::Carp 'fatalsToBrowser';
30 require '/var/ipfire/general-functions.pl';
31 require "${General::swroot}/lang.pl";
32 require "${General::swroot}/header.pl";
33 require "${General::swroot}/geoip-functions.pl";
34 require "${General::swroot}/graphs.pl";
37 my %mainsettings = ();
39 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
40 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
41 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
46 my @querry = split(/\?/,$ENV{'QUERY_STRING'});
47 $querry[0] = '' unless defined $querry[0];
48 $querry[1] = 'hour' unless defined $querry[1];
50 if ( $querry[0] ne~ ""){
51 print "Content-type: image/png\n\n";
53 &Graphs
::updateifgraph
($querry[0],$querry[1]);
56 &Header
::showhttpheaders
();
57 &Header
::openpage
($Lang::tr
{'network traffic graphs external'}, 1, '');
58 &Header
::openbigbox
('100%', 'left');
60 if ($netsettings{'RED_TYPE'} ne 'PPPOE'){
61 if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}){
62 push (@graphs, ($netsettings{'RED_DEV'}));
65 push (@graphs, "ppp0");
68 if (-e
"/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd"){
69 push (@graphs, ("ipsec0"));
72 if (-e
"/var/log/rrd/collectd/localhost/interface/if_octets-tun0.rrd"){
73 push (@graphs, ("tun0"));
77 &Header
::openbox
('100%', 'center', "$_ $Lang::tr{'graph'}");
78 &Graphs
::makegraphbox
("netexternal.cgi",$_,"day");
84 foreach my $f ("${General::swroot}/red/dns1", "${General::swroot}/red/dns2") {
86 my $nameserver = <DNS
>;
91 push(@nameservers, $nameserver);
95 &Header
::openbox
('100%', 'center', $Lang::tr
{'dnssec information'});
98 <table class="tbl" width='66%'>
102 <strong>$Lang::tr{'nameserver'}</strong>
105 <strong>$Lang::tr{'country'}</strong>
108 <strong>$Lang::tr{'rdns'}</strong>
111 <strong>$Lang::tr{'status'}</strong>
119 for my $nameserver (@nameservers) {
120 my $status = &check_dnssec
($nameserver, "ping.ipfire.org");
126 # DNSSEC Not supported
128 $message = $Lang::tr
{'dnssec not supported'};
130 $bgcolour = ${Header
::colourred
};
133 } elsif ($status == 1) {
134 $message = $Lang::tr
{'dnssec aware'};
136 $bgcolour = ${Header
::colouryellow
};
139 } elsif ($status == 2) {
140 $message = $Lang::tr
{'dnssec validating'};
142 $bgcolour = ${Header
::colourgreen
};
146 $colour = ${Header
::colourred
};
149 my $table_colour = ($id++ % 2) ?
$color{'color22'} : $color{'color20'};
151 # collect more information about name server (rDNS, GeoIP country code)
152 my $ccode = &GeoIP
::lookup
($nameserver);
153 my $flag_icon = &GeoIP
::get_flag_icon
($ccode);
155 my $iaddr = inet_aton
($nameserver);
156 my $rdns = gethostbyaddr($iaddr, AF_INET
);
157 if (!$rdns) { $rdns = $Lang::tr
{'lookup failed'}; }
160 <tr bgcolor="$table_colour">
165 <a href='country.cgi#$ccode'><img src="$flag_icon" border="0" alt="$ccode" title="$ccode" /></a>
170 <td bgcolor="$bgcolour" align="center">
171 <font color="$colour"><strong>$message</strong></font>
184 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP"){
186 &Header
::openbox
('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
187 if (-s
"${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
189 &General
::readhash
("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \
%dhcpinfo);
191 my $DNS1=`echo $dhcpinfo{'domain_name_servers'} | cut -f 1 -d " "`;
192 my $DNS2=`echo $dhcpinfo{'domain_name_servers'} | cut -f 2 -d " "`;
196 if ($dhcpinfo{'dhcp_lease_time'} ne "") {
197 $lsetme=$dhcpinfo{'dhcp_lease_time'};
198 $lsetme=($lsetme/60);
201 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
203 $leasetime=$lsetme." Minute";
207 $leasetime=$leasetime."s";
214 if ($dhcpinfo{'dhcp_renewal_time'} ne "") {
215 $rentme=$dhcpinfo{'dhcp_renewal_time'};
216 $rentme=($rentme/60);
219 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
221 $rnwltime=$rentme." Minute";
225 $rnwltime=$rnwltime."s";
232 if ($dhcpinfo{'dhcp_rebinding_time'} ne "") {
233 $maxtme=$dhcpinfo{'dhcp_rebinding_time'};
234 $maxtme=($maxtme/60);
237 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
239 $maxtime=$maxtme." Minute";
243 $maxtime=$maxtime."s";
250 <tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'domain_name'}</td></tr>
251 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'routers'}</td></tr>
252 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
253 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
254 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'dhcp_server_identifier'}</td></tr>
255 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
256 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
257 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
262 print "$Lang::tr{'no dhcp lease'}";
267 &Header
::closebigbox
();
268 &Header
::closepage
();
271 sub check_dnssec
($$) {
272 my $nameserver = shift;
275 my @command = ("dig", "+dnssec", $record, "\@$nameserver");
277 my @output = qx(@command);
278 my $output = join("", @output);
281 if ($output =~ m/status: (\w+)/) {
282 $status = ($1 eq "NOERROR");
290 if ($output =~ m/flags: (.*);/) {
291 @flags = split(/ /, $1);
294 my $aware = ($output =~ m/RRSIG/);
295 my $validating = ("ad" ~~ @flags);
297 return $aware + $validating;