diff options
author | Seth Mos <seth.mos@dds.nl> | 2011-02-01 15:28:55 +0100 |
---|---|---|
committer | Seth Mos <seth.mos@dds.nl> | 2011-02-01 15:28:55 +0100 |
commit | 7203754c2ef2e457bcebec7cc96012b774e04681 (patch) | |
tree | 4d3731e1c853b4ecaeb0214a8e05dd0783e2d575 /usr | |
parent | cebd086a856086529728d2d8592ebd9687451ca3 (diff) | |
parent | 20fef17c7398170e18c9d03bcc04ee794002e981 (diff) | |
download | pfsense-7203754c2ef2e457bcebec7cc96012b774e04681.zip pfsense-7203754c2ef2e457bcebec7cc96012b774e04681.tar.gz |
Merge remote branch 'upstream/master'
Diffstat (limited to 'usr')
-rw-r--r-- | usr/local/bin/captiveportal_gather_stats.php | 106 | ||||
-rw-r--r-- | usr/local/www/diag_limiter_info.php | 2 | ||||
-rw-r--r-- | usr/local/www/diag_pf_info.php | 2 | ||||
-rw-r--r-- | usr/local/www/diag_system_activity.php | 2 | ||||
-rw-r--r-- | usr/local/www/diag_system_pftop.php | 2 | ||||
-rwxr-xr-x | usr/local/www/firewall_rules.php | 6 | ||||
-rwxr-xr-x | usr/local/www/status_rrd_graph.php | 16 | ||||
-rw-r--r-- | usr/local/www/status_rrd_graph_img.php | 39 | ||||
-rwxr-xr-x | usr/local/www/status_rrd_graph_settings.php | 10 | ||||
-rwxr-xr-x | usr/local/www/themes/code-red/rrdcolors.inc.php | 1 | ||||
-rw-r--r-- | usr/local/www/themes/metallic/rrdcolors.inc.php | 1 | ||||
-rw-r--r-- | usr/local/www/themes/pfsense-dropdown/rrdcolors.inc.php | 1 | ||||
-rw-r--r-- | usr/local/www/themes/pfsense/rrdcolors.inc.php | 1 | ||||
-rw-r--r-- | usr/local/www/themes/pfsense_ng/rrdcolors.inc.php | 1 | ||||
-rw-r--r-- | usr/local/www/themes/the_wall/rrdcolors.inc.php | 1 | ||||
-rw-r--r-- | usr/local/www/vpn_ipsec_phase1.php | 8 | ||||
-rw-r--r-- | usr/local/www/vpn_openvpn_client.php | 2 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/openvpn.widget.php | 25 |
18 files changed, 209 insertions, 17 deletions
diff --git a/usr/local/bin/captiveportal_gather_stats.php b/usr/local/bin/captiveportal_gather_stats.php new file mode 100644 index 0000000..5fe1c6b --- /dev/null +++ b/usr/local/bin/captiveportal_gather_stats.php @@ -0,0 +1,106 @@ +#!/usr/local/bin/php -q +<?php +/* $Id$ */ +/* + captiveportal_gather_stats.php + Copyright (C) 2011 Warren Baker + 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. +*/ + +require_once("functions.inc"); +require_once("captiveportal.inc"); +require_once("util.inc"); + +/* read in captive portal db */ +$cpdb = captiveportal_read_db(); + +/* determine number of logged in users */ +$no_users = count($cpdb); +$concurrent_users = $no_users; + +/* set initial user count to zero */ +$current_user_count = 0; + +/* tmp file to use to store old data (per interface)*/ +$tmpfile = "{$g['tmp_path']}/captiveportal_online_users"; + +$type = $argv[1]; + +if(empty($type)) + exit; + +/* echo the rrd required syntax */ +echo "N:"; + +if ($type == "loggedin") { + + /* Find out the previous user timestamp + * so we can determine the difference between the current + * and previous user count. If the file is empty return a 0. + */ + $fd = @fopen($tmpfile, "r"); + if ($fd) { + while (!feof($fd)) { + $line = trim(fgets($fd)); + if($line) + $previous_user_timestamp = $line; + else + $previous_user_timestamp = 0; + } + } else { + $previous_user_timestamp = 0; + } + @fclose($fd); + + + foreach($cpdb as $user) { + $user_ip = $user[2]; + // Record the timestamp + $timestamp = $user[0]; + if ($timestamp > $previous_user_timestamp) + $current_user_count = $current_user_count + 1; + } + + // Write out the latest timestamp + $fd = @fopen($tmpfile, "w"); + if ($fd) { + fwrite($fd, $timestamp); + } + @fclose($fd); + + /* If $timestamp is less than or equal to previous_user_timestamp return 0, + * as we only want the 'X' number of users logged in since last RRD poll. + */ + if($timestamp <= $previous_user_timestamp) + $result = 0; + else { + $result = $current_user_count; + } +} else + $result = $no_users; + + +echo "$result"; + +?>
\ No newline at end of file diff --git a/usr/local/www/diag_limiter_info.php b/usr/local/www/diag_limiter_info.php index 1d4ca28..6f525dc 100644 --- a/usr/local/www/diag_limiter_info.php +++ b/usr/local/www/diag_limiter_info.php @@ -71,7 +71,7 @@ include("head.inc"); }); } function activitycallback(transport) { - $('limiteractivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre>' + transport.responseText + '</pre></font>'; + $('limiteractivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre style="text-align:left;">' + transport.responseText + '</pre></font>'; setTimeout('getlimiteractivity()', 2000); } setTimeout('getlimiteractivity()', 5000); diff --git a/usr/local/www/diag_pf_info.php b/usr/local/www/diag_pf_info.php index 633cd1e..cba9727 100644 --- a/usr/local/www/diag_pf_info.php +++ b/usr/local/www/diag_pf_info.php @@ -75,7 +75,7 @@ include("head.inc"); }); } function activitycallback(transport) { - $('cpuactivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre>' + transport.responseText + '</pre></font>'; + $('cpuactivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre style="text-align:left;">' + transport.responseText + '</pre></font>'; setTimeout('getcpuactivity()', 2000); } setTimeout('getcpuactivity()', 5000); diff --git a/usr/local/www/diag_system_activity.php b/usr/local/www/diag_system_activity.php index b94dc92..e1e8003 100644 --- a/usr/local/www/diag_system_activity.php +++ b/usr/local/www/diag_system_activity.php @@ -70,7 +70,7 @@ include("head.inc"); }); } function activitycallback(transport) { - $('cpuactivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre>' + transport.responseText + '</pre></font>'; + $('cpuactivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre style="text-align:left;">' + transport.responseText + '</pre></font>'; setTimeout('getcpuactivity()', 2500); } setTimeout('getcpuactivity()', 1000); diff --git a/usr/local/www/diag_system_pftop.php b/usr/local/www/diag_system_pftop.php index a064f27..af0a581 100644 --- a/usr/local/www/diag_system_pftop.php +++ b/usr/local/www/diag_system_pftop.php @@ -77,7 +77,7 @@ else }); } function activitycallback(transport) { - $('cpuactivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre>' + transport.responseText + '</pre></font>'; + $('cpuactivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre style="text-align:left;">' + transport.responseText + '</pre></font>'; setTimeout('getcpuactivity()', 2500); } setTimeout('getcpuactivity()', 1000); diff --git a/usr/local/www/firewall_rules.php b/usr/local/www/firewall_rules.php index d09b39f..600348d 100755 --- a/usr/local/www/firewall_rules.php +++ b/usr/local/www/firewall_rules.php @@ -162,9 +162,9 @@ if ($config['pptpd']['mode'] == "server") if(have_ruleint_access("pptp")) $iflist['pptp'] = "PPTP VPN"; -if ($config['pppoe']['mode'] == "server") - if(have_ruleint_access("pppoe")) - $iflist['pppoe'] = "PPPoE VPN"; +foreach ($config['pppoes']['pppoe'] as $pppoes) + if (($pppoes['mode'] == 'server') && have_ruleint_access("pppoe")) + $iflist['pppoe'] = "PPPoE Server"; /* add ipsec interfaces */ if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable'])) diff --git a/usr/local/www/status_rrd_graph.php b/usr/local/www/status_rrd_graph.php index 28b1b4c..4505a02 100755 --- a/usr/local/www/status_rrd_graph.php +++ b/usr/local/www/status_rrd_graph.php @@ -122,6 +122,9 @@ if ($_GET['option']) { continue 2; } } + case "captiveportal": + $curoption = "allgraphs"; + break; default: $curoption = "wan"; break; @@ -173,6 +176,7 @@ $dbheader = array("allgraphs-traffic.rrd", "allgraphs-wireless.rrd", "allgraphs-cellular.rrd", "allgraphs-vpnusers.rrd", + "captiveportal-allgraphs.rrd", "allgraphs-packets.rrd", "system-allgraphs.rrd", "system-throughput.rrd", @@ -196,6 +200,9 @@ foreach($databases as $database) { if(stristr($database, "-vpnusers")) { $vpnusers = true; } + if(stristr($database, "captiveportal-") && isset($config['captiveportal']['enable'])) { + $captiveportal = true; + } } /* append the existing array to the header */ $ui_databases = array_merge($dbheader, $databases); @@ -344,6 +351,10 @@ function get_dates($curperiod, $graph) { if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; } $tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers"); } + if($captiveportal) { + if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; } + $tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal"); + } if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; } $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom"); if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; } @@ -387,6 +398,11 @@ function get_dates($curperiod, $graph) { $replace = array(" :: ", "", $friendly); switch($curcat) { + case "captiveportal": + $optionc = str_replace($search, $replace, $optionc[1]); + echo "<option value=\"$optionc\""; + $prettyprint = ucwords(str_replace($search, $replace, $optionc)); + break; case "system": $optionc = str_replace($search, $replace, $optionc[1]); echo "<option value=\"$optionc\""; diff --git a/usr/local/www/status_rrd_graph_img.php b/usr/local/www/status_rrd_graph_img.php index 3943b51..18c938f 100644 --- a/usr/local/www/status_rrd_graph_img.php +++ b/usr/local/www/status_rrd_graph_img.php @@ -209,6 +209,7 @@ if(file_exists($rrdcolors)) { $colorspamdtime = array('DDDDFF', 'AAAAFF', 'DDDDFF', '000066'); $colorspamdconn = array('00AA00BB', 'FFFFFFFF', '00660088', 'FFFFFF88', '006600'); $colorvpnusers = array('990000'); + $colorcaptiveportalusers = array('990000'); } switch ($curstyle) { @@ -1034,6 +1035,44 @@ elseif((strstr($curdatabase, "-cellular.rrd")) && (file_exists("$rrddbpath$curda $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\" "; } +elseif((strstr($curdatabase, "-loggedin.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { + /* define graphcmd for online Captive Portal users stats */ + $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; + $graphcmd .= "--start $start --end $end "; + $graphcmd .= "--vertical-label \"Captive Portal Users\" "; + $graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee "; + $graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" "; + $graphcmd .= "--height 200 --width 620 "; + $graphcmd .= "DEF:\"$curif-loggedinusers=$rrddbpath$curdatabase:loggedinusers:AVERAGE\" "; + $graphcmd .= "LINE2:\"$curif-loggedinusers#{$colorcaptiveportalusers[0]}:$curif-loggedinusers\" "; + $graphcmd .= "COMMENT:\"\\n\" "; + $graphcmd .= "COMMENT:\"\t\t\t current\t\t average\t maximum\\n\" "; + $graphcmd .= "COMMENT:\"Users Online\t\" "; + $graphcmd .= "GPRINT:\"$curif-loggedinusers:LAST:%7.2lf \" "; + $graphcmd .= "GPRINT:\"$curif-loggedinusers:AVERAGE:%7.2lf \" "; + $graphcmd .= "GPRINT:\"$curif-loggedinusers:MAX:%7.2lf \" "; + $graphcmd .= "COMMENT:\"\\n\" "; + $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\" "; +} +elseif((strstr($curdatabase, "-concurrent.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { + /* define graphcmd for online Captive Portal users stats */ + $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; + $graphcmd .= "--start $start --end $end "; + $graphcmd .= "--vertical-label \"Captive Portal Users\" "; + $graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee "; + $graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" "; + $graphcmd .= "--height 200 --width 620 "; + $graphcmd .= "DEF:\"$curif-concurrentusers=$rrddbpath$curdatabase:concurrentusers:AVERAGE\" "; + $graphcmd .= "LINE2:\"$curif-concurrentusers#{$colorcaptiveportalusers[0]}:$curif-concurrentusers\" "; + $graphcmd .= "COMMENT:\"\\n\" "; + $graphcmd .= "COMMENT:\"\t\t\t current\t\t average\t maximum\\n\" "; + $graphcmd .= "COMMENT:\"Users Online\t\" "; + $graphcmd .= "GPRINT:\"$curif-concurrentusers:LAST:%7.2lf \" "; + $graphcmd .= "GPRINT:\"$curif-concurrentusers:AVERAGE:%7.2lf \" "; + $graphcmd .= "GPRINT:\"$curif-concurrentusers:MAX:%7.2lf \" "; + $graphcmd .= "COMMENT:\"\\n\" "; + $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\" "; +} else { $data = false; log_error(sprintf(gettext("Sorry we do not have data to graph for %s"),$curdatabase)); diff --git a/usr/local/www/status_rrd_graph_settings.php b/usr/local/www/status_rrd_graph_settings.php index 7accd25..a4b562e 100755 --- a/usr/local/www/status_rrd_graph_settings.php +++ b/usr/local/www/status_rrd_graph_settings.php @@ -54,7 +54,8 @@ $categories = array('system' => gettext("System"), 'traffic' => gettext("Traffic"), 'packets' => gettext("Packets"), 'quality' => gettext("Quality"), - 'queues' => gettext("Queues")); + 'queues' => gettext("Queues"), + 'captiveportal' => gettext("Captive Portal")); $styles = array('inverse' => gettext("Inverse"), 'absolute' => gettext("Absolute")); $periods = array("absolute" => gettext("Absolute Timespans"), @@ -101,6 +102,9 @@ foreach($databases as $database) { if(stristr($database, "-vpnusers")) { $vpnusers = true; } + if(stristr($database, "captiveportal-") && isset($config['captiveportal']['enable'])) { + $captiveportal = true; + } } $pgtitle = array(gettext("Status"),gettext("RRD Graphs")); @@ -143,6 +147,10 @@ include("head.inc"); if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; } $tab_array[] = array(gettext("VPN"), $tabactive, "status_rrd_graph.php?cat=vpnusers"); } + if($captiveportal) { + if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; } + $tab_array[] = array(gettext("Captive Portal"), $tabactive, "status_rrd_graph.php?cat=captiveportal"); + } if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; } $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom"); if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; } diff --git a/usr/local/www/themes/code-red/rrdcolors.inc.php b/usr/local/www/themes/code-red/rrdcolors.inc.php index cdaff68..7da2805 100755 --- a/usr/local/www/themes/code-red/rrdcolors.inc.php +++ b/usr/local/www/themes/code-red/rrdcolors.inc.php @@ -47,5 +47,6 @@ $colorwireless = array('990000','a83c3c','b36666'); $colorspamdtime = array('DDDDFF', 'AAAAFF', 'DDDDFF', '000066'); $colorspamdconn = array('00AA00BB', 'FFFFFFFF', '00660088', 'FFFFFF88', '006600'); $colorvpnusers = array('990000'); +$colorcaptiveportalusers = array('990000'); ?> diff --git a/usr/local/www/themes/metallic/rrdcolors.inc.php b/usr/local/www/themes/metallic/rrdcolors.inc.php index 8e74545..c2bc613 100644 --- a/usr/local/www/themes/metallic/rrdcolors.inc.php +++ b/usr/local/www/themes/metallic/rrdcolors.inc.php @@ -47,5 +47,6 @@ $colorwireless = array('333333','a83c3c','999999'); $colorspamdtime = array('DDDDFF', 'AAAAFF', 'DDDDFF', '000066'); $colorspamdconn = array('00AA00BB', 'FFFFFFFF', '00660088', 'FFFFFF88', '006600'); $colorvpnusers = array('990000'); +$colorcaptiveportalusers = array('990000'); ?> diff --git a/usr/local/www/themes/pfsense-dropdown/rrdcolors.inc.php b/usr/local/www/themes/pfsense-dropdown/rrdcolors.inc.php index 8e74545..c2bc613 100644 --- a/usr/local/www/themes/pfsense-dropdown/rrdcolors.inc.php +++ b/usr/local/www/themes/pfsense-dropdown/rrdcolors.inc.php @@ -47,5 +47,6 @@ $colorwireless = array('333333','a83c3c','999999'); $colorspamdtime = array('DDDDFF', 'AAAAFF', 'DDDDFF', '000066'); $colorspamdconn = array('00AA00BB', 'FFFFFFFF', '00660088', 'FFFFFF88', '006600'); $colorvpnusers = array('990000'); +$colorcaptiveportalusers = array('990000'); ?> diff --git a/usr/local/www/themes/pfsense/rrdcolors.inc.php b/usr/local/www/themes/pfsense/rrdcolors.inc.php index 8e74545..c2bc613 100644 --- a/usr/local/www/themes/pfsense/rrdcolors.inc.php +++ b/usr/local/www/themes/pfsense/rrdcolors.inc.php @@ -47,5 +47,6 @@ $colorwireless = array('333333','a83c3c','999999'); $colorspamdtime = array('DDDDFF', 'AAAAFF', 'DDDDFF', '000066'); $colorspamdconn = array('00AA00BB', 'FFFFFFFF', '00660088', 'FFFFFF88', '006600'); $colorvpnusers = array('990000'); +$colorcaptiveportalusers = array('990000'); ?> diff --git a/usr/local/www/themes/pfsense_ng/rrdcolors.inc.php b/usr/local/www/themes/pfsense_ng/rrdcolors.inc.php index 246b717..fc66253 100644 --- a/usr/local/www/themes/pfsense_ng/rrdcolors.inc.php +++ b/usr/local/www/themes/pfsense_ng/rrdcolors.inc.php @@ -47,5 +47,6 @@ $colorwireless = array('333333','a83c3c','999999'); $colorspamdtime = array('DDDDFF', 'AAAAFF', 'DDDDFF', '000066'); $colorspamdconn = array('00AA00BB', 'FFFFFFFF', '00660088', 'FFFFFF88', '006600'); $colorvpnusers = array('990000'); +$colorcaptiveportalusers = array('990000'); ?> diff --git a/usr/local/www/themes/the_wall/rrdcolors.inc.php b/usr/local/www/themes/the_wall/rrdcolors.inc.php index 246b717..fc66253 100644 --- a/usr/local/www/themes/the_wall/rrdcolors.inc.php +++ b/usr/local/www/themes/the_wall/rrdcolors.inc.php @@ -47,5 +47,6 @@ $colorwireless = array('333333','a83c3c','999999'); $colorspamdtime = array('DDDDFF', 'AAAAFF', 'DDDDFF', '000066'); $colorspamdconn = array('00AA00BB', 'FFFFFFFF', '00660088', 'FFFFFF88', '006600'); $colorvpnusers = array('990000'); +$colorcaptiveportalusers = array('990000'); ?> diff --git a/usr/local/www/vpn_ipsec_phase1.php b/usr/local/www/vpn_ipsec_phase1.php index 6240a63..3a14f3b 100644 --- a/usr/local/www/vpn_ipsec_phase1.php +++ b/usr/local/www/vpn_ipsec_phase1.php @@ -389,6 +389,8 @@ function methodsel_change() { document.getElementById('opt_peerid').style.display = ''; document.getElementById('opt_cert').style.display = ''; document.getElementById('opt_ca').style.display = ''; + document.getElementById('opt_cert').disabled = false; + document.getElementById('opt_ca').disabled = false; break; case 'xauth_rsa_server': case 'rsasig': @@ -396,6 +398,8 @@ function methodsel_change() { document.getElementById('opt_peerid').style.display = ''; document.getElementById('opt_cert').style.display = ''; document.getElementById('opt_ca').style.display = ''; + document.getElementById('opt_cert').disabled = false; + document.getElementById('opt_ca').disabled = false; break; <?php if ($pconfig['mobile']) { ?> case 'pre_shared_key': @@ -403,6 +407,8 @@ function methodsel_change() { document.getElementById('opt_peerid').style.display = 'none'; document.getElementById('opt_cert').style.display = 'none'; document.getElementById('opt_ca').style.display = 'none'; + document.getElementById('opt_cert').disabled = true; + document.getElementById('opt_ca').disabled = true; break; <?php } ?> default: /* psk modes*/ @@ -410,6 +416,8 @@ function methodsel_change() { document.getElementById('opt_peerid').style.display = ''; document.getElementById('opt_cert').style.display = 'none'; document.getElementById('opt_ca').style.display = 'none'; + document.getElementById('opt_cert').disabled = true; + document.getElementById('opt_ca').disabled = true; break; } } diff --git a/usr/local/www/vpn_openvpn_client.php b/usr/local/www/vpn_openvpn_client.php index d2374b2..d28315d 100644 --- a/usr/local/www/vpn_openvpn_client.php +++ b/usr/local/www/vpn_openvpn_client.php @@ -125,7 +125,7 @@ if($_GET['act']=="edit"){ } else $pconfig['shared_key'] = base64_decode($a_client[$id]['shared_key']); $pconfig['crypto'] = $a_client[$id]['crypto']; - $pconfig['engine'] = $a_server[$id]['engine']; + $pconfig['engine'] = $a_client[$id]['engine']; $pconfig['tunnel_network'] = $a_client[$id]['tunnel_network']; $pconfig['remote_network'] = $a_client[$id]['remote_network']; diff --git a/usr/local/www/widgets/widgets/openvpn.widget.php b/usr/local/www/widgets/widgets/openvpn.widget.php index fdf2e3c..c93c708 100644 --- a/usr/local/www/widgets/widgets/openvpn.widget.php +++ b/usr/local/www/widgets/widgets/openvpn.widget.php @@ -13,7 +13,7 @@ if($_GET['action']) { $retval = kill_client($port, $remipp); echo htmlentities("|{$port}|{$remipp}|{$retval}|"); } else { - echo "invalid input"; + echo gettext("invalid input"); } exit; } @@ -21,7 +21,10 @@ if($_GET['action']) { function kill_client($port, $remipp) { - $tcpsrv = "tcp://127.0.0.1:{$port}"; + global $g; + + //$tcpsrv = "tcp://127.0.0.1:{$port}"; + $tcpsrv = "unix://{$g['varetc_path']}/openvpn/{$port}.sock"; $errval; $errstr; @@ -29,13 +32,19 @@ function kill_client($port, $remipp) { $fp = @stream_socket_client($tcpsrv, $errval, $errstr, 1); $killed = -1; if ($fp) { + stream_set_timeout($fp, 1); fputs($fp, "kill {$remipp}\n"); while (!feof($fp)) { $line = fgets($fp, 1024); + + $info = stream_get_meta_data($fp); + if ($info['timed_out']) + break; + /* parse header list line */ - if (strpos($line, "INFO:")) + if (strpos($line, "INFO:") !== false) continue; - if (strpos($line, "UCCESS")) { + if (strpos($line, "SUCCESS") !== false) { $killed = 0; } break; @@ -97,7 +106,7 @@ $clients = openvpn_get_active_clients(); <td class="listhdrr">Real/Virtual IP</td> </tr> <?php foreach ($server['conns'] as $conn): ?> - <tr name='<?php echo "r:{$server['port']}:{$conn['remote_host']}"; ?>'> + <tr name='<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>'> <td class="listlr"> <?=$conn['common_name'];?> </td> @@ -106,12 +115,12 @@ $clients = openvpn_get_active_clients(); </td> <td class='list' rowspan="2"> <img src='/themes/<?php echo $g['theme']; ?>/images/icons/icon_x.gif' height='17' width='17' border='0' - onclick="killClient('<?php echo $server['port']; ?>', '<?php echo $conn['remote_host']; ?>');" style='cursor:pointer;' - name='<?php echo "i:{$server['port']}:{$conn['remote_host']}"; ?>' + onclick="killClient('<?php echo $server['mgmt']; ?>', '<?php echo $conn['remote_host']; ?>');" style='cursor:pointer;' + name='<?php echo "i:{$server['mgmt']}:{$conn['remote_host']}"; ?>' title='Kill client connection from <?php echo $conn['remote_host']; ?>' alt='' /> </td> </tr> - <tr name='<?php echo "r:{$server['port']}:{$conn['remote_host']}"; ?>'> + <tr name='<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>'> <td class="listlr"> <?=$conn['connect_time'];?> </td> |