|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* MikoPBX - free phone system for small business |
|
4
|
|
|
* Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov |
|
5
|
|
|
* |
|
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU General Public License as published by |
|
8
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
9
|
|
|
* (at your option) any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU General Public License for more details. |
|
15
|
|
|
* |
|
16
|
|
|
* You should have received a copy of the GNU General Public License along with this program. |
|
17
|
|
|
* If not, see <https://www.gnu.org/licenses/>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace MikoPBX\Core\System\Upgrade\Releases; |
|
21
|
|
|
|
|
22
|
|
|
use MikoPBX\Common\Models\FirewallRules; |
|
23
|
|
|
use MikoPBX\Common\Models\NetworkFilters; |
|
24
|
|
|
use MikoPBX\Common\Models\PbxSettings; |
|
25
|
|
|
use MikoPBX\Common\Models\PbxSettingsConstants; |
|
26
|
|
|
use MikoPBX\Core\System\Upgrade\UpgradeSystemConfigInterface; |
|
27
|
|
|
use Phalcon\Di\Injectable; |
|
28
|
|
|
|
|
29
|
|
|
class UpdateConfigsUpToVer2024v2v10 extends Injectable implements UpgradeSystemConfigInterface |
|
30
|
|
|
{ |
|
31
|
|
|
public const PBX_VERSION = '2024.2.10'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Class constructor. |
|
35
|
|
|
*/ |
|
36
|
|
|
public function __construct() |
|
37
|
|
|
{ |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* https://github.com/mikopbx/Core/issues/782 |
|
42
|
|
|
*/ |
|
43
|
|
|
public function processUpdate(): void |
|
44
|
|
|
{ |
|
45
|
|
|
$colName = PbxSettingsConstants::IAX_PORT; |
|
46
|
|
|
$iax_port = PbxSettings::getValueByKey(PbxSettingsConstants::IAX_PORT); |
|
47
|
|
|
$nets = NetworkFilters::find(['columns' => 'id']); |
|
48
|
|
|
foreach ($nets as $net){ |
|
49
|
|
|
$filter = [ |
|
50
|
|
|
"portFromKey='$colName' AND networkfilterid='$net->id'", |
|
51
|
|
|
'columns' => 'id' |
|
52
|
|
|
]; |
|
53
|
|
|
$rule = FirewallRules::findFirst($filter); |
|
54
|
|
|
if($rule){ |
|
55
|
|
|
continue; |
|
56
|
|
|
} |
|
57
|
|
|
$rule = new FirewallRules(); |
|
58
|
|
|
foreach ($rule->toArray() as $key => $value){ |
|
59
|
|
|
$rule->$key = $value; |
|
60
|
|
|
} |
|
61
|
|
|
$rule->networkfilterid = $net->id; |
|
62
|
|
|
$rule->action = 'block'; |
|
63
|
|
|
$rule->portfrom = $iax_port; |
|
64
|
|
|
$rule->portto = $iax_port; |
|
65
|
|
|
$rule->protocol = 'udp'; |
|
66
|
|
|
$rule->portFromKey = $colName; |
|
67
|
|
|
$rule->portToKey = $colName; |
|
68
|
|
|
$rule->category = 'IAX'; |
|
69
|
|
|
$rule->save(); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
} |