| @@ 67-81 (lines=15) @@ | ||
| 64 | * |
|
| 65 | * @return string the OpenVPN version string |
|
| 66 | */ |
|
| 67 | public function version() |
|
| 68 | { |
|
| 69 | try { |
|
| 70 | $this->serverSocket->open(); |
|
| 71 | $response = $this->serverSocket->command('version'); |
|
| 72 | $this->serverSocket->close(); |
|
| 73 | ||
| 74 | return $this->ok( |
|
| 75 | 'version', |
|
| 76 | substr($response[0], strlen('OpenVPN Version: ')) |
|
| 77 | ); |
|
| 78 | } catch (ServerSocketException $e) { |
|
| 79 | return $this->error(); |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Obtain the current load statistics from OpenVPN. |
|
| @@ 121-132 (lines=12) @@ | ||
| 118 | * |
|
| 119 | * @param string $commonName the common name of the connection to kill |
|
| 120 | */ |
|
| 121 | public function kill($commonName) |
|
| 122 | { |
|
| 123 | try { |
|
| 124 | $this->serverSocket->open(); |
|
| 125 | $response = $this->serverSocket->command(sprintf('kill %s', $commonName)); |
|
| 126 | $this->serverSocket->close(); |
|
| 127 | ||
| 128 | return $this->ok('kill', 0 === strpos($response[0], 'SUCCESS: ')); |
|
| 129 | } catch (ServerSocketException $e) { |
|
| 130 | return $this->error(); |
|
| 131 | } |
|
| 132 | } |
|
| 133 | ||
| 134 | private function ok($command, $response) |
|
| 135 | { |
|