Skip to content

Commit

Permalink
Исправил ошибку генерации acl
Browse files Browse the repository at this point in the history
  • Loading branch information
boffart committed Nov 13, 2024
1 parent eae7a01 commit 055203f
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/Core/Asterisk/Configs/AclConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AclConf extends AsteriskConfigClass
public int $priority = 1000;

protected string $description = 'acl.conf';
protected array $data_peers;
protected array $dataPeers;

/**
* Returns the models that this class depends on.
Expand All @@ -55,7 +55,7 @@ public function getDependenceModels(): array
public function getSettings(): void
{
// Settings for the current class.
$this->data_peers = $this->getPeers();
$this->dataPeers = $this->getPeers();
}

/**
Expand All @@ -66,7 +66,7 @@ public function getSettings(): void
private function getPeers(): array
{
$data = [];
$db_data = Sip::find(["type = 'peer' AND ( disabled <> '1')", 'columns' => 'networkfilterid']);
$db_data = Sip::find(["type = 'peer' AND ( disabled <> '1')", 'columns' => 'networkfilterid,manualattributes,extension']);
foreach ($db_data as $sip_peer) {
$arr_data = $sip_peer->toArray();
$network_filter = null;
Expand All @@ -78,7 +78,6 @@ private function getPeers(): array

$data[] = $arr_data;
}

return $data;
}

Expand All @@ -88,20 +87,17 @@ private function getPeers(): array
protected function generateConfigProtected(): void
{
$conf_acl = '';
foreach ($this->data_peers as $peer) {
foreach ($this->dataPeers as $peer) {
$manual_attributes = Util::parseIniSettings($peer['manualattributes'] ?? '');

$deny = (trim($peer['deny']) === '') ? '0.0.0.0/0.0.0.0' : $peer['deny'];
$permit = (trim($peer['permit']) === '') ? '0.0.0.0/0.0.0.0' : $peer['permit'];

$options = [
'deny' => $deny,
'permit' => $permit,
];
$conf_acl .= "[acl_{$peer['extension']}] \n";
$conf_acl .= "[acl_$peer[extension]]".PHP_EOL;
$conf_acl .= Util::overrideConfigurationArray($options, $manual_attributes, 'acl');
}

Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/acl.conf', $conf_acl);
}
}
}

0 comments on commit 055203f

Please sign in to comment.