From 09f70ade859e01efd9eca2c8539000784b1a982d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Sun, 27 Oct 2024 21:13:12 +0900 Subject: [PATCH] cfmgrv4 init...4 --- app/Language/en/Cloudflare/Record.php | 60 +++++++++--------- app/Language/en/Cloudflare/Zone.php | 76 +++++++++++------------ app/Services/Cloudflare/RecordService.php | 2 +- app/Services/Cloudflare/ZoneService.php | 23 ++++--- 4 files changed, 83 insertions(+), 78 deletions(-) diff --git a/app/Language/en/Cloudflare/Record.php b/app/Language/en/Cloudflare/Record.php index 3d77653..23cf516 100644 --- a/app/Language/en/Cloudflare/Record.php +++ b/app/Language/en/Cloudflare/Record.php @@ -1,47 +1,47 @@ "Record정보", - 'label' => [ - 'uid' => "번호", - 'zone_uid' => "도메인", - 'type' => "Type", - 'host' => "호스트명", - 'content' => "IP정보", - 'ttl' => "TTL", - 'proxiable' => "proxiable", - 'fixed' => "CDN잠금", - 'proxied' => "CDN사용여부", - 'locked' => "서비스", + 'title' => "Record정보", + 'label' => [ + 'uid' => "번호", + 'zone_uid' => "도메인", + 'type' => "Type", + 'host' => "호스트명", + 'content' => "IP정보", + 'ttl' => "TTL", + 'proxiable' => "proxiable", + 'fixed' => "CDN잠금", + 'proxied' => "CDN사용여부", + 'locked' => "서비스", 'updated_at' => "수정일", 'created_at' => "작성일", - 'hosts' => "호스트명", + 'hosts' => "호스트명", ], - "ZONE_UID" => [], - "TYPE" => [ - 'A' => 'A', + "ZONE_UID" => [], + "TYPE" => [ + 'A' => 'A', 'CNAME' => 'CNAME', - 'NS' => 'NS', - 'MX' => 'MX', - 'PTR' => 'PTR', - 'SPF' => 'SPF', - 'TXT' => 'TXT', - 'SRV' => 'SRV', - 'INFO' => 'INFO', + 'NS' => 'NS', + 'MX' => 'MX', + 'PTR' => 'PTR', + 'SPF' => 'SPF', + 'TXT' => 'TXT', + 'SRV' => 'SRV', + 'INFO' => 'INFO', ], - "FIXED" => [ - "on" => "고정", + "FIXED" => [ + "on" => "고정", "off" => "비고정", ], "PROXIABLE" => [ - "on" => "사용", + "on" => "사용", "off" => "사용 않함", ], - "PROXIED" => [ - "on" => "CDN 사용", + "PROXIED" => [ + "on" => "CDN 사용", "off" => "CDN 미사용", ], - "LOCKED" => [ - "on" => "운영중", + "LOCKED" => [ + "on" => "운영중", "off" => "잠김", ], ]; diff --git a/app/Language/en/Cloudflare/Zone.php b/app/Language/en/Cloudflare/Zone.php index 8df5a65..bb3676f 100644 --- a/app/Language/en/Cloudflare/Zone.php +++ b/app/Language/en/Cloudflare/Zone.php @@ -1,62 +1,62 @@ "Zone정보", - 'label' => [ - 'uid' => "번호", - 'account_uid' => "계정", - 'domain' => "도메인", - 'name_servers' => "네임서버", + 'title' => "Zone정보", + 'label' => [ + 'uid' => "번호", + 'account_uid' => "계정", + 'domain' => "도메인", + 'name_servers' => "네임서버", 'original_name_servers' => "이전네임서버", - 'plan' => "plan", - 'development_mode' => "개발모드", - 'ipv6' => "ipv6", - 'security_level' => "공격방어", - 'ssl_mode' => "SSL모드", - 'always_use_https' => "https사용", - 'status' => "서비스", - 'updated_at' => "수정일", - 'created_at' => "작성일", - 'domains' => "도메인명", - 'hosts' => "호스트명", - 'type' => "TYPE", - 'content' => "IP정보", - 'proxied' => "CDN기능", + 'plan' => "plan", + 'development_mode' => "개발모드", + 'ipv6' => "ipv6", + 'security_level' => "공격방어", + 'ssl_mode' => "SSL모드", + 'always_use_https' => "https사용", + 'status' => "서비스", + 'updated_at' => "수정일", + 'created_at' => "작성일", + 'domains' => "도메인명", + 'hosts' => "호스트명", + 'type' => "TYPE", + 'content' => "IP정보", + 'proxied' => "CDN기능", ], - "ACCOUNT_UID" => [], + "ACCOUNT_UID" => [], "DEVELOPMENT_MODE" => [ - "on" => "사용", + "on" => "사용", "off" => "사용않함", ], - "PLAN" => [ - "Free Website" => "Free", + "PLAN" => [ + "Free Website" => "Free", "Pro Website" => "Pro", "Business Website" => "Business", ], - "IPV6" => [ - "on" => "사용", + "IPV6" => [ + "on" => "사용", "off" => "사용않함", ], - "SECURITY_LEVEL" => [ - "under_attack" => "under_attack", - "medium" => "medium", - "low" => "low", + "SECURITY_LEVEL" => [ + "under_attack" => "under_attack", + "medium" => "medium", + "low" => "low", "essentially_off" => "essentially_off", ], - "ALWAYS_USE_HTTPS" => [ - "on" => "사용", + "ALWAYS_USE_HTTPS" => [ + "on" => "사용", "off" => "사용않함", ], - "SSL_MODE" => [ - "off" => "off", - "flexible" => "flexible", - "full" => "full", + "SSL_MODE" => [ + "off" => "off", + "flexible" => "flexible", + "full" => "full", "strict" => "strict", "origin_pull" => "origin_pull" ], - "STATUS" => [ + "STATUS" => [ "initializing" => "initializing", "pending" => "pending", - "active" => "active", + "active" => "active", "moved" => "moved" ], ]; diff --git a/app/Services/Cloudflare/RecordService.php b/app/Services/Cloudflare/RecordService.php index 0e1ee84..826e305 100644 --- a/app/Services/Cloudflare/RecordService.php +++ b/app/Services/Cloudflare/RecordService.php @@ -168,7 +168,7 @@ class RecordService extends CloudflareService $entitys = []; try { $results = $this->reload_procedure("zones/{$this->getParentEntity()->getPK()}/dns_records"); - $total = count($results); + $total = count($results); if ($total > 0) { $cnt = 1; foreach ($results as $result) { diff --git a/app/Services/Cloudflare/ZoneService.php b/app/Services/Cloudflare/ZoneService.php index 7cc0054..cef6620 100644 --- a/app/Services/Cloudflare/ZoneService.php +++ b/app/Services/Cloudflare/ZoneService.php @@ -170,19 +170,24 @@ class ZoneService extends CloudflareService $entitys = []; try { $results = $this->reload_procedure("zones"); - $cnt = 1; - $total = count($results); + $cnt = 1; + $total = count($results); if ($total > 0) { foreach ($results as $result) { if (!is_object($result) || get_class($result) !== 'stdClass') { - throw new \Exception("Zone: result is not a stdClass:\n" . var_export($result, true) . "\n"); + log_message("error", "Zone: result is not a stdClass:\n" . var_export($result, true) . "\n"); + continue; + } + if (isset($result->status) && $result->status === 'active') { + $formDatas = $this->getArrayByResult($result); + $formDatas = $this->getCFSetting($formDatas[ZoneModel::PK], $formDatas); + $entity = $this->getModel()->modify(new ZoneEntity(), $formDatas); + log_message("debug", "{$cnt}/{$total} => {$entity->getTitle()} Zone 처리,[{$this->getMySocket()::$_request}]"); + $entitys[$entity->getPK()] = $entity; + $cnt++; + } else { + log_message("error", "Zone is abnomral status:\n" . var_export($result, true) . "\n"); } - $formDatas = $this->getArrayByResult($result); - $formDatas = $this->getCFSetting($formDatas[ZoneModel::PK], $formDatas); - $entity = $this->getModel()->modify(new ZoneEntity(), $formDatas); - log_message("debug", "{$cnt}/{$total} => {$entity->getTitle()} Zone 처리,[{$this->getMySocket()::$_request}]"); - $entitys[$entity->getPK()] = $entity; - $cnt++; } //부모키를 기준으로 CF에 존재하지 않는 데이터 삭제용 $this->getModel()->where(ZoneModel::PARENT, value: $this->getParentEntity()->getPK());