summaryrefslogtreecommitdiffstats
path: root/src/etc
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-12-17 10:14:17 +0545
committerPhil Davis <phil.davis@inf.org>2015-12-17 10:14:17 +0545
commit61fce4a6f6f61f25356708df4175d28892a04b4c (patch)
tree119d4905f375a331ee76a5f87e3c27867df4d8f5 /src/etc
parent9851ce32c1c40281fd76ac1ff140acaccbcc1d30 (diff)
downloadpfsense-61fce4a6f6f61f25356708df4175d28892a04b4c.zip
pfsense-61fce4a6f6f61f25356708df4175d28892a04b4c.tar.gz
Consolidate OpenVPN kill_client routine
After a gitsync just now I started getting "cannot redeclare kill_client" error messages. Whatever it was that caused this to start happening, the kill_client() function in these 2 places is identical. Might as well put it in openvpn.inc
Diffstat (limited to 'src/etc')
-rw-r--r--src/etc/inc/openvpn.inc36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/etc/inc/openvpn.inc b/src/etc/inc/openvpn.inc
index da666e3..9dc83c5 100644
--- a/src/etc/inc/openvpn.inc
+++ b/src/etc/inc/openvpn.inc
@@ -1611,6 +1611,42 @@ function openvpn_get_client_status($client, $socket) {
return $client;
}
+function openvpn_kill_client($port, $remipp) {
+ global $g;
+
+ //$tcpsrv = "tcp://127.0.0.1:{$port}";
+ $tcpsrv = "unix://{$g['varetc_path']}/openvpn/{$port}.sock";
+ $errval = null;
+ $errstr = null;
+
+ /* open a tcp connection to the management port of each server */
+ $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:") !== false) {
+ continue;
+ }
+ if (strpos($line, "SUCCESS") !== false) {
+ $killed = 0;
+ }
+ break;
+ }
+ fclose($fp);
+ }
+ return $killed;
+}
+
function openvpn_refresh_crls() {
global $g, $config;
OpenPOWER on IntegriCloud