From 03dfcbc7a147bfaa0d4bd2477cee118791d8dc7b Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sun, 17 Feb 2008 00:15:21 +0000 Subject: Importing OpenVPN status page form m0n0wall. --- usr/local/www/status_ovpn.php | 122 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 usr/local/www/status_ovpn.php (limited to 'usr/local/www/status_ovpn.php') diff --git a/usr/local/www/status_ovpn.php b/usr/local/www/status_ovpn.php new file mode 100644 index 0000000..1aee1a6 --- /dev/null +++ b/usr/local/www/status_ovpn.php @@ -0,0 +1,122 @@ +#!/usr/local/bin/php +. + Copyright (C) 2005-2006 Peter Allgeyer . + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +$pgtitle = array("Status", "OpenVPN"); +require("guiconfig.inc"); + +$client_list = array(); +$virtip_list = array(); + +function dump_log($type) { + global $g, $config; + + unset($client_list); + $client_list = array(); + + unset($virtip_list); + $virtip_list = array(); + + $max = ($type == 'tun') ? 17 : 4; + for ($i = 0; $i < $max; $i++) { + if (file_exists("/var/log/openvpn_{$type}{$i}.log")) { + + unset($string); + unset($logarr); + + exec("/bin/cat /var/log/openvpn_{$type}{$i}.log", $logarr); + + foreach ($logarr as $logent) { + $logent = preg_split("/,/", $logent, 5); + $string = preg_split("/:/", $logent[1]); + + /* search for ip address in second column */ + if (isset($string[0]) && is_ipaddr($string[0])) + array_push($client_list, $logent); + + /* search for ip address in first column */ + else if (is_ipaddr($logent[0])) + array_push($virtip_list, $logent); + } + } + } + + if (count($client_list > 1)) { + foreach ($client_list as $cent) { + echo "\n"; + echo "" . htmlspecialchars($cent[0]) . "\n"; + echo "" . htmlspecialchars($cent[1]) . "\n"; + + unset($found); + if (isset($virtip_list)) { + foreach ($virtip_list as $vent) { + if ($cent[1] == $vent[2]) { + $found = 1; + echo "" . htmlspecialchars($vent[0]) . " \n"; + } + } + } + if (!isset($found)) + echo "--\n"; + + $date = preg_split("/\s+/", $cent[4]); + echo "" . htmlspecialchars($date[1]) . " " . htmlspecialchars($date[2]) . " " . htmlspecialchars($date[3]) . "\n"; + echo "" . htmlspecialchars($cent[2]) . "\n"; + echo "" . htmlspecialchars($cent[3]) . "\n"; + echo "\n"; + } + } +} + +?> + + + + + + + + + + + + + + +
+ OpenVPN server status entries
Common NameReal AddressVirtual AddressConnected SinceBytes ReceivedBytes Sent
+
+Note:
+
Please note that status entries are updated once every minute only. +So don't bother about entries on this page being possibly too old! + + -- cgit v1.1