Compare commits
No commits in common. "7c82052b64849b510f0c1e527ec964e05532c7db" and "40700434caeacf9c1a214a01d81da3a80bee65e8" have entirely different histories.
7c82052b64
...
40700434ca
@ -41,7 +41,7 @@ class Kint
|
|||||||
*/
|
*/
|
||||||
public string $richTheme = 'aante-light.css';
|
public string $richTheme = 'aante-light.css';
|
||||||
public bool $richFolder = false;
|
public bool $richFolder = false;
|
||||||
#public int $richSort = AbstractRenderer::SORT_FULL;
|
public int $richSort = AbstractRenderer::SORT_FULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array<string, class-string<ValuePluginInterface>>|null
|
* @var array<string, class-string<ValuePluginInterface>>|null
|
||||||
|
|||||||
@ -17,8 +17,8 @@ $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes)
|
|||||||
$routes->cli('reload/(:num)', 'Cloudflare::reload/$1');
|
$routes->cli('reload/(:num)', 'Cloudflare::reload/$1');
|
||||||
$routes->cli('auditlog', 'Cloudflare::auditlog');
|
$routes->cli('auditlog', 'Cloudflare::auditlog');
|
||||||
$routes->cli('auditlog/(:num)', 'Cloudflare::auditlog/$1');
|
$routes->cli('auditlog/(:num)', 'Cloudflare::auditlog/$1');
|
||||||
$routes->cli('expire', 'Cloudflare::expire');
|
|
||||||
$routes->cli('expire/(:any)', 'Cloudflare::expire/$1');
|
$routes->cli('expire/(:any)', 'Cloudflare::expire/$1');
|
||||||
|
$routes->cli('hosts/(:any)', 'Cloudflare::hosts/$1');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$routes->get('/', 'Home::index');
|
$routes->get('/', 'Home::index');
|
||||||
|
|||||||
@ -81,7 +81,7 @@ class AccountController extends CloudflareController
|
|||||||
{
|
{
|
||||||
//부모데이터정의
|
//부모데이터정의
|
||||||
$this->auth_entity = $this->getAuthModel()->getEntityByPK($uid);
|
$this->auth_entity = $this->getAuthModel()->getEntityByPK($uid);
|
||||||
if ($this->auth_entity === null) {
|
if ($this->_zone_entity === null) {
|
||||||
throw new \Exception("Auth: [{$uid}] 정보를 찾을수 없습니다.");
|
throw new \Exception("Auth: [{$uid}] 정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
$this->getService()->reload($this->auth_entity);
|
$this->getService()->reload($this->auth_entity);
|
||||||
|
|||||||
@ -3,8 +3,11 @@
|
|||||||
namespace App\Controllers\CLI;
|
namespace App\Controllers\CLI;
|
||||||
|
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Models\Cloudflare\AccountModel;
|
use App\Entities\Cloudflare\AccountEntity;
|
||||||
|
use App\Entities\Cloudflare\AuthEntity;
|
||||||
|
use App\Entities\Cloudflare\ZoneEntity;
|
||||||
use App\Models\Cloudflare\AuthModel;
|
use App\Models\Cloudflare\AuthModel;
|
||||||
|
use App\Models\Cloudflare\RecordModel;
|
||||||
use App\Models\Cloudflare\ZoneModel;
|
use App\Models\Cloudflare\ZoneModel;
|
||||||
use App\Services\Cloudflare\AccountService;
|
use App\Services\Cloudflare\AccountService;
|
||||||
use App\Services\Cloudflare\AuditLogService;
|
use App\Services\Cloudflare\AuditLogService;
|
||||||
@ -102,24 +105,42 @@ class Cloudflare extends BaseController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function expire(string $domain = ""): void
|
public function expire(string $domain): void
|
||||||
{
|
{
|
||||||
//Transaction Start
|
//Transaction Start
|
||||||
// $this->_db->transStart();
|
// $this->_db->transStart();
|
||||||
try {
|
try {
|
||||||
$zone_model = model(ZoneModel::class);
|
$zone_model = model(ZoneModel::class);
|
||||||
if ($domain !== "") {
|
|
||||||
$zone_model->where(['domain' => $domain]);
|
$zone_model->where(['domain' => $domain]);
|
||||||
}
|
$zone_entity = $zone_model->getEntity();
|
||||||
$account_entitys = [];
|
|
||||||
$account_model = model(AccountModel::class);
|
|
||||||
$zone = new ZoneService();
|
$zone = new ZoneService();
|
||||||
foreach ($zone_model->getEntitys() as $entity) {
|
$zone->expire($zone_entity);
|
||||||
if (!array_key_exists($entity->getParent(), $account_entitys)) {
|
log_message("notice", "Expire 작업을 완료하였습니다.");
|
||||||
$account_entitys[$entity->getParent()] = $account_model->getEntity($entity->getParent());
|
// $this->_db->transCommit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
//Transaction Rollback
|
||||||
|
// $this->_db->transRollback();
|
||||||
|
log_message(
|
||||||
|
"error",
|
||||||
|
"Expire 작업을 실패하였습니다.\n--------------\n" .
|
||||||
|
$e->getMessage() .
|
||||||
|
"\n--------------\n"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$zone->expire($account_entitys[$entity->getParent()], $entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hosts(string $ip): void
|
||||||
|
{
|
||||||
|
//Transaction Start
|
||||||
|
// $this->_db->transStart();
|
||||||
|
try {
|
||||||
|
$record_model = model(RecordModel::class);
|
||||||
|
$record_model->where(['content' => $ip]);
|
||||||
|
$hosts = [];
|
||||||
|
foreach ($record_model->getEntitys() as $entity) {
|
||||||
|
$hosts[] = $entity->host;
|
||||||
|
}
|
||||||
|
echo implode("\n", $hosts);
|
||||||
log_message("notice", "Expire 작업을 완료하였습니다.");
|
log_message("notice", "Expire 작업을 완료하였습니다.");
|
||||||
// $this->_db->transCommit();
|
// $this->_db->transCommit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|||||||
@ -46,7 +46,7 @@ class CloudflareSocket extends MySocket
|
|||||||
log_message('warning', sprintf("--Cloudflare API Call %s초 대기 종료--", self::$_request_timewait));
|
log_message('warning', sprintf("--Cloudflare API Call %s초 대기 종료--", self::$_request_timewait));
|
||||||
}
|
}
|
||||||
self::$_request++;
|
self::$_request++;
|
||||||
log_message("debug", "현재 [" . self::$_request . "]:{$uri}");
|
// log_message("debug", "현재 [" . self::$_request . "]:{$uri}");
|
||||||
return parent::request($method, $uri, $options, $headers);
|
return parent::request($method, $uri, $options, $headers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class FirewallService extends CloudflareService
|
|||||||
}
|
}
|
||||||
return $this->_parent_entity;
|
return $this->_parent_entity;
|
||||||
}
|
}
|
||||||
private function setParentEntity(ZoneEntity $parent_entity): void
|
private function setParentEntity(mixed $parent_entity): void
|
||||||
{
|
{
|
||||||
$this->_parent_entity = $parent_entity;
|
$this->_parent_entity = $parent_entity;
|
||||||
$account_entity = $this->getAccountModel()->getEntityByPK($this->getParentEntity()->getParent());
|
$account_entity = $this->getAccountModel()->getEntityByPK($this->getParentEntity()->getParent());
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class RecordService extends CloudflareService
|
|||||||
}
|
}
|
||||||
return $this->_parent_entity;
|
return $this->_parent_entity;
|
||||||
}
|
}
|
||||||
private function setParentEntity(ZoneEntity $parent_entity): void
|
private function setParentEntity(mixed $parent_entity): void
|
||||||
{
|
{
|
||||||
$this->_parent_entity = $parent_entity;
|
$this->_parent_entity = $parent_entity;
|
||||||
$account_entity = $this->getAccountModel()->getEntityByPK($this->getParentEntity()->getParent());
|
$account_entity = $this->getAccountModel()->getEntityByPK($this->getParentEntity()->getParent());
|
||||||
|
|||||||
@ -5,6 +5,7 @@ namespace App\Services\Cloudflare;
|
|||||||
use App\Entities\Cloudflare\AccountEntity;
|
use App\Entities\Cloudflare\AccountEntity;
|
||||||
use App\Entities\Cloudflare\ZoneEntity;
|
use App\Entities\Cloudflare\ZoneEntity;
|
||||||
use App\Models\Cloudflare\ZoneModel;
|
use App\Models\Cloudflare\ZoneModel;
|
||||||
|
use Iodev\Whois\Factory;
|
||||||
|
|
||||||
class ZoneService extends CloudflareService
|
class ZoneService extends CloudflareService
|
||||||
{
|
{
|
||||||
@ -30,10 +31,10 @@ class ZoneService extends CloudflareService
|
|||||||
}
|
}
|
||||||
return $this->_parent_entity;
|
return $this->_parent_entity;
|
||||||
}
|
}
|
||||||
private function setParentEntity(AccountEntity $parent_entity): void
|
private function setParentEntity(mixed $parent_entity): void
|
||||||
{
|
{
|
||||||
$this->_parent_entity = $parent_entity;
|
$this->_parent_entity = $parent_entity;
|
||||||
$auth_entity = $this->getAuthModel()->getEntityByPK($this->getParentEntity()->getParent());
|
$auth_entity = $this->getAuthModel()->getEntityByPK(uid: $this->getParentEntity()->getParent());
|
||||||
if ($auth_entity === null) {
|
if ($auth_entity === null) {
|
||||||
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
|
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
@ -158,16 +159,15 @@ class ZoneService extends CloudflareService
|
|||||||
// log_message("debug", $this->getModel()->getLastQuery());
|
// log_message("debug", $this->getModel()->getLastQuery());
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
public function expire(AccountEntity $parent_entity, ZoneEntity $entity): ZoneEntity
|
public function expire(ZoneEntity $entity)
|
||||||
{
|
{
|
||||||
$this->setParentEntity($parent_entity);
|
$whois = Factory::get()->createWhois();
|
||||||
$response = $this->getMySocket()->get("accounts/{$entity->getParent()}/registrar/domains/{$entity->getTitle()}");
|
$info = $whois->loadDomainInfo($entity->getTitle());
|
||||||
$body = json_decode($response->getBody());
|
print_r([
|
||||||
$formDatas = ['expire_date', $body->result->expires_at];
|
'Domain created' => date("Y-m-d", $info->creationDate),
|
||||||
// log_message("debug", var_export($formDatas, true));
|
'Domain expires' => date("Y-m-d", $info->expirationDate),
|
||||||
$entity = $this->getModel()->modify($entity, $formDatas);
|
'Domain owner' => $info->owner,
|
||||||
// log_message("debug", $this->getModel()->getLastQuery());
|
]);
|
||||||
return $entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reload
|
//Reload
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"codeigniter4/framework": "^4.5",
|
"codeigniter4/framework": "^4.5",
|
||||||
"google/apiclient": "^2.15.0",
|
"google/apiclient": "^2.15.0",
|
||||||
"guzzlehttp/guzzle": "^7.9",
|
"guzzlehttp/guzzle": "^7.9",
|
||||||
"io-developer/php-whois": "^4.1",
|
"io-developer/php-whois": "4.0",
|
||||||
"phpoffice/phpspreadsheet": "^1.27",
|
"phpoffice/phpspreadsheet": "^1.27",
|
||||||
"symfony/css-selector": "^7.1",
|
"symfony/css-selector": "^7.1",
|
||||||
"symfony/dom-crawler": "^7.1",
|
"symfony/dom-crawler": "^7.1",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user