@@ -108,6 +108,9 @@ |
||
| 108 | 108 | return @file_get_contents($filePath); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | + /** |
|
| 112 | + * @param string $filePath |
|
| 113 | + */ |
|
| 111 | 114 | private static function writeFile($filePath, $fileContent, $appendFile = true) |
| 112 | 115 | { |
| 113 | 116 | $opt = $appendFile ? FILE_APPEND : 0; |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | - * |
|
| 5 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | - * you may not use this file except in compliance with the License. |
|
| 7 | - * You may obtain a copy of the License at |
|
| 8 | - * |
|
| 9 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | - * |
|
| 11 | - * Unless required by applicable law or agreed to in writing, software |
|
| 12 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | - * See the License for the specific language governing permissions and |
|
| 15 | - * limitations under the License. |
|
| 16 | - */ |
|
| 3 | + * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | + * |
|
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | + * you may not use this file except in compliance with the License. |
|
| 7 | + * You may obtain a copy of the License at |
|
| 8 | + * |
|
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | + * |
|
| 11 | + * Unless required by applicable law or agreed to in writing, software |
|
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | + * See the License for the specific language governing permissions and |
|
| 15 | + * limitations under the License. |
|
| 16 | + */ |
|
| 17 | 17 | namespace fkooman\VPN\Server; |
| 18 | 18 | |
| 19 | 19 | use RuntimeException; |
@@ -56,6 +56,9 @@ |
||
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | + /** |
|
| 60 | + * @param string $data |
|
| 61 | + */ |
|
| 59 | 62 | private function write($data) |
| 60 | 63 | { |
| 61 | 64 | if (false === @fwrite($this->socket, $data)) { |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | - * |
|
| 5 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | - * you may not use this file except in compliance with the License. |
|
| 7 | - * You may obtain a copy of the License at |
|
| 8 | - * |
|
| 9 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | - * |
|
| 11 | - * Unless required by applicable law or agreed to in writing, software |
|
| 12 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | - * See the License for the specific language governing permissions and |
|
| 15 | - * limitations under the License. |
|
| 16 | - */ |
|
| 3 | + * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | + * |
|
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | + * you may not use this file except in compliance with the License. |
|
| 7 | + * You may obtain a copy of the License at |
|
| 8 | + * |
|
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | + * |
|
| 11 | + * Unless required by applicable law or agreed to in writing, software |
|
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | + * See the License for the specific language governing permissions and |
|
| 15 | + * limitations under the License. |
|
| 16 | + */ |
|
| 17 | 17 | namespace fkooman\VPN\Server; |
| 18 | 18 | |
| 19 | 19 | use RuntimeException; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $service = new Service(); |
| 53 | 53 | $service->get( |
| 54 | 54 | '/connections', |
| 55 | - function (Request $request) use ($manage) { |
|
| 55 | + function(Request $request) use ($manage) { |
|
| 56 | 56 | $clientConnections = $manage->getConnections(); |
| 57 | 57 | $response = new JsonResponse(); |
| 58 | 58 | $response->setBody($clientConnections); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $service->get( |
| 65 | 65 | '/servers', |
| 66 | - function (Request $request) use ($manage) { |
|
| 66 | + function(Request $request) use ($manage) { |
|
| 67 | 67 | $serverInfo = $manage->getServerInfo(); |
| 68 | 68 | $response = new JsonResponse(); |
| 69 | 69 | $response->setBody($serverInfo); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $service->post( |
| 76 | 76 | '/kill', |
| 77 | - function (Request $request) use ($manage) { |
|
| 77 | + function(Request $request) use ($manage) { |
|
| 78 | 78 | // XXX: should we disconnect the user from all servers? |
| 79 | 79 | $id = $request->getPostParameter('id'); |
| 80 | 80 | Utils::validateServerId($id); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | $service->post( |
| 97 | 97 | '/disableCommonName', |
| 98 | - function (Request $request) use ($ccdHandler) { |
|
| 98 | + function(Request $request) use ($ccdHandler) { |
|
| 99 | 99 | $commonName = $request->getPostParameter('common_name'); |
| 100 | 100 | Utils::validateCommonName($commonName); |
| 101 | 101 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | $service->post( |
| 114 | 114 | '/enableCommonName', |
| 115 | - function (Request $request) use ($ccdHandler) { |
|
| 115 | + function(Request $request) use ($ccdHandler) { |
|
| 116 | 116 | $commonName = $request->getPostParameter('common_name'); |
| 117 | 117 | Utils::validateCommonName($commonName); |
| 118 | 118 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $service->get( |
| 131 | 131 | '/disabledCommonNames', |
| 132 | - function (Request $request) use ($ccdHandler) { |
|
| 132 | + function(Request $request) use ($ccdHandler) { |
|
| 133 | 133 | $userId = $request->getUrl()->getQueryParameter('filterByUser'); |
| 134 | 134 | if (!is_null($userId)) { |
| 135 | 135 | Utils::validateUserId($userId); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $service->post( |
| 150 | 150 | '/refreshCrl', |
| 151 | - function (Request $request) use ($crlFetcher) { |
|
| 151 | + function(Request $request) use ($crlFetcher) { |
|
| 152 | 152 | $response = new JsonResponse(); |
| 153 | 153 | $response->setBody( |
| 154 | 154 | array( |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | 166 | $auth = new BasicAuthentication( |
| 167 | - function ($userId) use ($reader) { |
|
| 167 | + function($userId) use ($reader) { |
|
| 168 | 168 | $userList = $reader->v('Users'); |
| 169 | 169 | if (!array_key_exists($userId, $userList)) { |
| 170 | 170 | return false; |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | - * |
|
| 5 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | - * you may not use this file except in compliance with the License. |
|
| 7 | - * You may obtain a copy of the License at |
|
| 8 | - * |
|
| 9 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | - * |
|
| 11 | - * Unless required by applicable law or agreed to in writing, software |
|
| 12 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | - * See the License for the specific language governing permissions and |
|
| 15 | - * limitations under the License. |
|
| 16 | - */ |
|
| 3 | + * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | + * |
|
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | + * you may not use this file except in compliance with the License. |
|
| 7 | + * You may obtain a copy of the License at |
|
| 8 | + * |
|
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | + * |
|
| 11 | + * Unless required by applicable law or agreed to in writing, software |
|
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | + * See the License for the specific language governing permissions and |
|
| 15 | + * limitations under the License. |
|
| 16 | + */ |
|
| 17 | 17 | namespace fkooman\VPN\Server; |
| 18 | 18 | |
| 19 | 19 | use InvalidArgumentException; |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | - * |
|
| 5 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | - * you may not use this file except in compliance with the License. |
|
| 7 | - * You may obtain a copy of the License at |
|
| 8 | - * |
|
| 9 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | - * |
|
| 11 | - * Unless required by applicable law or agreed to in writing, software |
|
| 12 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | - * See the License for the specific language governing permissions and |
|
| 15 | - * limitations under the License. |
|
| 16 | - */ |
|
| 3 | + * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | + * |
|
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | + * you may not use this file except in compliance with the License. |
|
| 7 | + * You may obtain a copy of the License at |
|
| 8 | + * |
|
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | + * |
|
| 11 | + * Unless required by applicable law or agreed to in writing, software |
|
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | + * See the License for the specific language governing permissions and |
|
| 15 | + * limitations under the License. |
|
| 16 | + */ |
|
| 17 | 17 | namespace fkooman\VPN\Server; |
| 18 | 18 | |
| 19 | 19 | use RuntimeException; |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | - * |
|
| 5 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | - * you may not use this file except in compliance with the License. |
|
| 7 | - * You may obtain a copy of the License at |
|
| 8 | - * |
|
| 9 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | - * |
|
| 11 | - * Unless required by applicable law or agreed to in writing, software |
|
| 12 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | - * See the License for the specific language governing permissions and |
|
| 15 | - * limitations under the License. |
|
| 16 | - */ |
|
| 3 | + * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | + * |
|
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | + * you may not use this file except in compliance with the License. |
|
| 7 | + * You may obtain a copy of the License at |
|
| 8 | + * |
|
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | + * |
|
| 11 | + * Unless required by applicable law or agreed to in writing, software |
|
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | + * See the License for the specific language governing permissions and |
|
| 15 | + * limitations under the License. |
|
| 16 | + */ |
|
| 17 | 17 | namespace fkooman\VPN\Server; |
| 18 | 18 | |
| 19 | 19 | use GuzzleHttp\Client; |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | - * |
|
| 5 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | - * you may not use this file except in compliance with the License. |
|
| 7 | - * You may obtain a copy of the License at |
|
| 8 | - * |
|
| 9 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | - * |
|
| 11 | - * Unless required by applicable law or agreed to in writing, software |
|
| 12 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | - * See the License for the specific language governing permissions and |
|
| 15 | - * limitations under the License. |
|
| 16 | - */ |
|
| 3 | + * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | + * |
|
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | + * you may not use this file except in compliance with the License. |
|
| 7 | + * You may obtain a copy of the License at |
|
| 8 | + * |
|
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | + * |
|
| 11 | + * Unless required by applicable law or agreed to in writing, software |
|
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | + * See the License for the specific language governing permissions and |
|
| 15 | + * limitations under the License. |
|
| 16 | + */ |
|
| 17 | 17 | namespace fkooman\VPN\Server; |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | - * |
|
| 5 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | - * you may not use this file except in compliance with the License. |
|
| 7 | - * You may obtain a copy of the License at |
|
| 8 | - * |
|
| 9 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | - * |
|
| 11 | - * Unless required by applicable law or agreed to in writing, software |
|
| 12 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | - * See the License for the specific language governing permissions and |
|
| 15 | - * limitations under the License. |
|
| 16 | - */ |
|
| 3 | + * Copyright 2015 François Kooman <[email protected]>. |
|
| 4 | + * |
|
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 6 | + * you may not use this file except in compliance with the License. |
|
| 7 | + * You may obtain a copy of the License at |
|
| 8 | + * |
|
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 10 | + * |
|
| 11 | + * Unless required by applicable law or agreed to in writing, software |
|
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 14 | + * See the License for the specific language governing permissions and |
|
| 15 | + * limitations under the License. |
|
| 16 | + */ |
|
| 17 | 17 | namespace fkooman\VPN\Server; |
| 18 | 18 | |
| 19 | 19 | class Api |