From 6dc4dffd3769d02e0a187969c3554b5ad131ffaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Tue, 22 Oct 2024 16:16:19 +0900 Subject: [PATCH] cfmgrv4 init...3 --- app/Controllers/CLI/Cloudflare.php | 20 +++++++++++--------- app/Services/Cloudflare/Account.php | 2 +- app/Services/Cloudflare/Firewall.php | 8 +++++--- app/Services/Cloudflare/Record.php | 2 +- app/Services/Cloudflare/Zone.php | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/Controllers/CLI/Cloudflare.php b/app/Controllers/CLI/Cloudflare.php index 2d2e5ce..4de4884 100644 --- a/app/Controllers/CLI/Cloudflare.php +++ b/app/Controllers/CLI/Cloudflare.php @@ -61,20 +61,22 @@ class Cloudflare extends BaseController // $this->_db->transStart(); try { $auths = $this->auth_process($uid); - $accounts = []; foreach ($auths as $auth) { - $accounts += $this->account_process($auth); - } - $zones = []; - foreach ($accounts as $key => $account) { - $zones += $this->zone_process($account); + $accounts = $this->account_process($auth); + foreach (array_values($accounts) as $account) { + $zones = $this->zone_process($account); + foreach (array_values($zones) as $zone) { + $records = $this->record_process($zone); + $firewalls = $this->firewall_process($zone); + } + } } foreach ($zones as $key => $zone) { $this->record_process($zone); } - foreach ($zones as $key => $zone) { - $this->firewall_process($zone); - } + // foreach ($zones as $key => $zone) { + // $this->firewall_process($zone); + // } log_message("notice", "Reload 작업을 완료하였습니다."); // $this->_db->transCommit(); } catch (\Exception $e) { diff --git a/app/Services/Cloudflare/Account.php b/app/Services/Cloudflare/Account.php index 0010f09..f0f1122 100644 --- a/app/Services/Cloudflare/Account.php +++ b/app/Services/Cloudflare/Account.php @@ -71,7 +71,7 @@ class Account extends Cloudflare } $formDatas = $this->getArrayByResult($result); $entity = $this->getModel()->modify(new AccountEntity(), $formDatas); - log_message("debug", "[{$this->getMySocket()::$_request}] :{$cnt}/{$total} => {$entity->getTitle()} Account 처리"); + log_message("debug", "{$cnt}/{$total} => {$entity->getTitle()} Account 처리,[{$this->getMySocket()::$_request}]"); $entitys[$entity->getPK()] = $entity; $cnt++; } diff --git a/app/Services/Cloudflare/Firewall.php b/app/Services/Cloudflare/Firewall.php index c4235dd..6c9f4ad 100644 --- a/app/Services/Cloudflare/Firewall.php +++ b/app/Services/Cloudflare/Firewall.php @@ -94,9 +94,11 @@ class Firewall extends Cloudflare if (!is_object(value: $rule) || get_class($rule) !== 'stdClass') { log_message("error", "Firewall: rule is not a stdClass:\n" . var_export($rule, true) . "\n"); } else { - $formDatas = ['rulesetid' => $body->result->id]; - $formDatas = $this->getArrayByResult($rule, $formDatas); - $entitys[$formDatas[FirewallModel::PK]] = $this->getModel()->modify(new FirewallEntity(), $formDatas); + $formDatas = ['rulesetid' => $body->result->id]; + $formDatas = $this->getArrayByResult($rule, $formDatas); + $entity = $this->getModel()->modify(new FirewallEntity(), $formDatas); + log_message("debug", "{$entity->getTitle()} Firewall 처리,[{$this->getMySocket()::$_request}]"); + $entitys[$entity->getPK()] = $entity; } } } catch (\Exception $e) { diff --git a/app/Services/Cloudflare/Record.php b/app/Services/Cloudflare/Record.php index da03b75..6c767dd 100644 --- a/app/Services/Cloudflare/Record.php +++ b/app/Services/Cloudflare/Record.php @@ -153,7 +153,7 @@ class Record extends Cloudflare } $formDatas = $this->getArrayByResult($result); $entity = $this->getModel()->modify(new RecordEntity(), $formDatas); - log_message("debug", "[{$this->getMySocket()::$_request}] :{$cnt}/{$total} => {$entity->getTitle()} Record 처리"); + log_message("debug", "{$cnt}/{$total} => {$entity->getTitle()} Record 처리,[{$this->getMySocket()::$_request}]"); $entitys[$entity->getPK()] = $entity; $cnt++; } diff --git a/app/Services/Cloudflare/Zone.php b/app/Services/Cloudflare/Zone.php index 7c9b253..a421187 100644 --- a/app/Services/Cloudflare/Zone.php +++ b/app/Services/Cloudflare/Zone.php @@ -160,7 +160,7 @@ class Zone extends Cloudflare $formDatas = $this->getArrayByResult($result); $formDatas = $this->getCFSetting($formDatas[ZoneModel::PK], $formDatas); $entity = $this->getModel()->modify(new ZoneEntity(), $formDatas); - log_message("debug", "[{$this->getMySocket()::$_request}] :{$cnt}/{$total} => {$entity->getTitle()} Zone 처리"); + log_message("debug", "{$cnt}/{$total} => {$entity->getTitle()} Zone 처리,[{$this->getMySocket()::$_request}]"); $entitys[$entity->getPK()] = $entity; $cnt++; }