]> git.ipfire.org Git - ipfire-2.x.git/blame - html/cgi-bin/netovpnsrv.cgi
hostapd: make client isolation configurable via WebUI
[ipfire-2.x.git] / html / cgi-bin / netovpnsrv.cgi
CommitLineData
5795fc1b
AM
1#!/usr/bin/perl
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2014 Alexnder Marx #
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;
23
24# enable only the following on debugging purpose
25#use warnings;
26#use CGI::Carp 'fatalsToBrowser';
27
28require '/var/ipfire/general-functions.pl';
29require "${General::swroot}/lang.pl";
30require "${General::swroot}/header.pl";
31require "${General::swroot}/graphs.pl";
32
33my %color = ();
34my %mainsettings = ();
35&General::readhash("${General::swroot}/main/settings", \%mainsettings);
36&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
37
1e2b2577
MT
38my %vpnsettings = ();
39&General::readhasharray("${General::swroot}/vpn/config", \%vpnsettings);
40
5795fc1b
AM
41my @vpns=();
42
1e2b2577
MT
43# Make list of all IPsec graphs
44my %ipsecgraphs = ();
45foreach my $key (sort {$vpnsettings{$a}[1] <=> $vpnsettings{$b}[1]} keys %vpnsettings) {
46 my $interface_mode = $vpnsettings{$key}[36];
47 next unless ($interface_mode);
48
49 $ipsecgraphs{$vpnsettings{$key}[1]} = "${interface_mode}${key}";
50}
51
5795fc1b
AM
52my @querry = split(/\?/,$ENV{'QUERY_STRING'});
53$querry[0] = '' unless defined $querry[0];
54$querry[1] = 'week' unless defined $querry[1];
55
56if ( $querry[0] ne ""){
57 print "Content-type: image/png\n\n";
58 binmode(STDOUT);
1e2b2577
MT
59 if (grep { $_ eq $querry[0] } values %ipsecgraphs) {
60 &Graphs::updateifgraph($querry[0],$querry[1]);
61 } else {
62 &Graphs::updatevpnn2ngraph($querry[0],$querry[1]);
63 }
5795fc1b
AM
64}else{
65 &Header::showhttpheaders();
679ac9f1 66 &Header::openpage($Lang::tr{'vpn statistic n2n'}, 1, '');
5795fc1b
AM
67 &Header::openbigbox('100%', 'left');
68
679ac9f1 69 my @vpngraphs = `find /var/log/rrd/collectd/localhost/openvpn-*-n2n/ -not -path *openvpn-UNDEF* -name *traffic.rrd 2>/dev/null|sort`;
5795fc1b 70 foreach (@vpngraphs){
c9ac8b80
AM
71 if($_ =~ /(.*)\/openvpn-(.*)\/if_octets_derive-traffic.rrd/){
72 push(@vpns,$2);
73 }
5795fc1b 74 }
1e2b2577
MT
75 if (@vpns || %ipsecgraphs) {
76 foreach my $name (sort keys %ipsecgraphs) {
77 &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name");
78 &Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day");
79 &Header::closebox();
80 }
81
c9ac8b80
AM
82 foreach (@vpns) {
83 &Header::openbox('100%', 'center', "$_ $Lang::tr{'graph'}");
a249ccd2 84 &Graphs::makegraphbox("netovpnsrv.cgi",$_, "day");
c9ac8b80
AM
85 &Header::closebox();
86 }
87 }else{
88 print "<center>".$Lang::tr{'no data'}."</center>";
5795fc1b 89 }
5795fc1b
AM
90 my $output = '';
91
92 &Header::closebigbox();
93 &Header::closepage();
94}