Add routed IPsec connections to traffic graphs section

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2019-01-22 13:15:48 +00:00
parent 7ba652af8c
commit 1e2b257789
11 changed files with 58 additions and 5 deletions

View File

@@ -35,8 +35,20 @@ my %mainsettings = ();
&General::readhash("${General::swroot}/main/settings", \%mainsettings);
&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
my %vpnsettings = ();
&General::readhasharray("${General::swroot}/vpn/config", \%vpnsettings);
my @vpns=();
# Make list of all IPsec graphs
my %ipsecgraphs = ();
foreach my $key (sort {$vpnsettings{$a}[1] <=> $vpnsettings{$b}[1]} keys %vpnsettings) {
my $interface_mode = $vpnsettings{$key}[36];
next unless ($interface_mode);
$ipsecgraphs{$vpnsettings{$key}[1]} = "${interface_mode}${key}";
}
my @querry = split(/\?/,$ENV{'QUERY_STRING'});
$querry[0] = '' unless defined $querry[0];
$querry[1] = 'week' unless defined $querry[1];
@@ -44,7 +56,11 @@ $querry[1] = 'week' unless defined $querry[1];
if ( $querry[0] ne ""){
print "Content-type: image/png\n\n";
binmode(STDOUT);
&Graphs::updatevpnn2ngraph($querry[0],$querry[1]);
if (grep { $_ eq $querry[0] } values %ipsecgraphs) {
&Graphs::updateifgraph($querry[0],$querry[1]);
} else {
&Graphs::updatevpnn2ngraph($querry[0],$querry[1]);
}
}else{
&Header::showhttpheaders();
&Header::openpage($Lang::tr{'vpn statistic n2n'}, 1, '');
@@ -56,7 +72,13 @@ if ( $querry[0] ne ""){
push(@vpns,$2);
}
}
if (@vpns){
if (@vpns || %ipsecgraphs) {
foreach my $name (sort keys %ipsecgraphs) {
&Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name");
&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day");
&Header::closebox();
}
foreach (@vpns) {
&Header::openbox('100%', 'center', "$_ $Lang::tr{'graph'}");
&Graphs::makegraphbox("netovpnsrv.cgi",$_, "day");