diff --git a/composer.json b/composer.json index 94c880b97..dc83f10ee 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,6 @@ "ext-zip": "*", "anankke/omnipay-alipay": "^3.1.3", "aws/aws-sdk-php": "^3.283.14", - "cloudflare/sdk": "^1.3", "geoip2/geoip2": "^2.13", "guzzlehttp/guzzle": "^7.8", "guzzlehttp/psr7": "^2.6.1", diff --git a/composer.lock b/composer.lock index 53520bebe..da6e79c8b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "58dc2315c9baefadd2dcc29e3d794ac5", + "content-hash": "f8b1e684f7b38581333490d04454a37f", "packages": [ { "name": "anankke/omnipay-alipay", @@ -123,16 +123,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.285.3", + "version": "3.285.4", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "afa1e722f1b2c95644f375dc1a19072e4daf67be" + "reference": "c462af819d81cba49939949032b20799f5ef0fff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/afa1e722f1b2c95644f375dc1a19072e4daf67be", - "reference": "afa1e722f1b2c95644f375dc1a19072e4daf67be", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/c462af819d81cba49939949032b20799f5ef0fff", + "reference": "c462af819d81cba49939949032b20799f5ef0fff", "shasum": "" }, "require": { @@ -212,9 +212,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.285.3" + "source": "https://github.com/aws/aws-sdk-php/tree/3.285.4" }, - "time": "2023-11-09T19:07:19+00:00" + "time": "2023-11-10T19:25:49+00:00" }, { "name": "bacon/bacon-qr-code", @@ -392,54 +392,6 @@ ], "time": "2023-01-15T23:15:59+00:00" }, - { - "name": "cloudflare/sdk", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/cloudflare/cloudflare-php.git", - "reference": "fdfc656aa8b78016f4722acec30b54136c027d8e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/cloudflare/cloudflare-php/zipball/fdfc656aa8b78016f4722acec30b54136c027d8e", - "reference": "fdfc656aa8b78016f4722acec30b54136c027d8e", - "shasum": "" - }, - "require": { - "ext-json": "*", - "guzzlehttp/guzzle": "^7.0.1", - "php": ">=7.2.5", - "psr/http-message": "~1.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.6", - "phpmd/phpmd": "@stable", - "phpunit/phpunit": "^5.7" - }, - "type": "library", - "autoload": { - "psr-4": { - "Cloudflare\\API\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Junade Ali", - "email": "junade@cloudflare.com" - } - ], - "description": "PHP binding for v4 of the Cloudflare Client API.", - "support": { - "issues": "https://github.com/cloudflare/cloudflare-php/issues", - "source": "https://github.com/cloudflare/cloudflare-php/tree/1.3.0" - }, - "time": "2021-10-13T03:40:33+00:00" - }, { "name": "clue/stream-filter", "version": "v1.6.0", @@ -4961,16 +4913,16 @@ }, { "name": "symfony/http-client", - "version": "v6.3.7", + "version": "v6.3.8", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "cd67fcaf4524ec6ae5d9b2d9497682d7ad3ce57d" + "reference": "0314e2d49939a9831929d6fc81c01c6df137fd0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/cd67fcaf4524ec6ae5d9b2d9497682d7ad3ce57d", - "reference": "cd67fcaf4524ec6ae5d9b2d9497682d7ad3ce57d", + "url": "https://api.github.com/repos/symfony/http-client/zipball/0314e2d49939a9831929d6fc81c01c6df137fd0a", + "reference": "0314e2d49939a9831929d6fc81c01c6df137fd0a", "shasum": "" }, "require": { @@ -5033,7 +4985,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v6.3.7" + "source": "https://github.com/symfony/http-client/tree/v6.3.8" }, "funding": [ { @@ -5049,7 +5001,7 @@ "type": "tidelift" } ], - "time": "2023-10-29T12:41:36+00:00" + "time": "2023-11-06T18:31:59+00:00" }, { "name": "symfony/http-client-contracts", @@ -5131,16 +5083,16 @@ }, { "name": "symfony/http-foundation", - "version": "v6.3.7", + "version": "v6.3.8", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "59d1837d5d992d16c2628cd0d6b76acf8d69b33e" + "reference": "ce332676de1912c4389222987193c3ef38033df6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/59d1837d5d992d16c2628cd0d6b76acf8d69b33e", - "reference": "59d1837d5d992d16c2628cd0d6b76acf8d69b33e", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/ce332676de1912c4389222987193c3ef38033df6", + "reference": "ce332676de1912c4389222987193c3ef38033df6", "shasum": "" }, "require": { @@ -5188,7 +5140,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v6.3.7" + "source": "https://github.com/symfony/http-foundation/tree/v6.3.8" }, "funding": [ { @@ -5204,7 +5156,7 @@ "type": "tidelift" } ], - "time": "2023-10-28T23:55:27+00:00" + "time": "2023-11-07T10:17:15+00:00" }, { "name": "symfony/options-resolver", @@ -7251,16 +7203,16 @@ }, { "name": "nunomaduro/phpinsights", - "version": "v2.9.0", + "version": "v2.10.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/phpinsights.git", - "reference": "52d69d895239b1e9a90d7212dffc6c7e73ec822e" + "reference": "e0988110b32f79a33cfcab5968a4bd426924b191" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/phpinsights/zipball/52d69d895239b1e9a90d7212dffc6c7e73ec822e", - "reference": "52d69d895239b1e9a90d7212dffc6c7e73ec822e", + "url": "https://api.github.com/repos/nunomaduro/phpinsights/zipball/e0988110b32f79a33cfcab5968a4bd426924b191", + "reference": "e0988110b32f79a33cfcab5968a4bd426924b191", "shasum": "" }, "require": { @@ -7337,7 +7289,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/phpinsights/issues", - "source": "https://github.com/nunomaduro/phpinsights/tree/v2.9.0" + "source": "https://github.com/nunomaduro/phpinsights/tree/v2.10.0" }, "funding": [ { @@ -7353,7 +7305,7 @@ "type": "github" } ], - "time": "2023-10-20T15:58:50+00:00" + "time": "2023-11-10T03:23:41+00:00" }, { "name": "phar-io/manifest", @@ -9080,16 +9032,16 @@ }, { "name": "symfony/cache", - "version": "v6.3.6", + "version": "v6.3.8", "source": { "type": "git", "url": "https://github.com/symfony/cache.git", - "reference": "84aff8d948d6292d2b5a01ac622760be44dddc72" + "reference": "ba33517043c22c94c7ab04b056476f6f86816cf8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache/zipball/84aff8d948d6292d2b5a01ac622760be44dddc72", - "reference": "84aff8d948d6292d2b5a01ac622760be44dddc72", + "url": "https://api.github.com/repos/symfony/cache/zipball/ba33517043c22c94c7ab04b056476f6f86816cf8", + "reference": "ba33517043c22c94c7ab04b056476f6f86816cf8", "shasum": "" }, "require": { @@ -9156,7 +9108,7 @@ "psr6" ], "support": { - "source": "https://github.com/symfony/cache/tree/v6.3.6" + "source": "https://github.com/symfony/cache/tree/v6.3.8" }, "funding": [ { @@ -9172,7 +9124,7 @@ "type": "tidelift" } ], - "time": "2023-10-17T14:44:58+00:00" + "time": "2023-11-07T10:17:15+00:00" }, { "name": "symfony/cache-contracts", @@ -9252,16 +9204,16 @@ }, { "name": "symfony/console", - "version": "v6.3.4", + "version": "v6.3.8", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6" + "reference": "0d14a9f6d04d4ac38a8cea1171f4554e325dae92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/eca495f2ee845130855ddf1cf18460c38966c8b6", - "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6", + "url": "https://api.github.com/repos/symfony/console/zipball/0d14a9f6d04d4ac38a8cea1171f4554e325dae92", + "reference": "0d14a9f6d04d4ac38a8cea1171f4554e325dae92", "shasum": "" }, "require": { @@ -9322,7 +9274,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.3.4" + "source": "https://github.com/symfony/console/tree/v6.3.8" }, "funding": [ { @@ -9338,7 +9290,7 @@ "type": "tidelift" } ], - "time": "2023-08-16T10:10:12+00:00" + "time": "2023-10-31T08:09:35+00:00" }, { "name": "symfony/event-dispatcher", @@ -9909,16 +9861,16 @@ }, { "name": "symfony/string", - "version": "v6.3.5", + "version": "v6.3.8", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339" + "reference": "13880a87790c76ef994c91e87efb96134522577a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/13d76d0fb049051ed12a04bef4f9de8715bea339", - "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339", + "url": "https://api.github.com/repos/symfony/string/zipball/13880a87790c76ef994c91e87efb96134522577a", + "reference": "13880a87790c76ef994c91e87efb96134522577a", "shasum": "" }, "require": { @@ -9975,7 +9927,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.3.5" + "source": "https://github.com/symfony/string/tree/v6.3.8" }, "funding": [ { @@ -9991,7 +9943,7 @@ "type": "tidelift" } ], - "time": "2023-09-18T10:38:32+00:00" + "time": "2023-11-09T08:28:21+00:00" }, { "name": "symfony/var-exporter", diff --git a/config/.config.example.php b/config/.config.example.php index 7a1b8c4a3..4916a4e2c 100644 --- a/config/.config.example.php +++ b/config/.config.example.php @@ -120,12 +120,6 @@ // ClientDownload 命令解决 API 访问频率高而被限制使用的 Github access token $_ENV['github_access_token'] = ''; -#Cloudflare -$_ENV['cloudflare_enable'] = false; //是否开启 Cloudflare 解析 -$_ENV['cloudflare_email'] = ''; //Cloudflare 邮箱地址 -$_ENV['cloudflare_key'] = ''; //Cloudflare API Key -$_ENV['cloudflare_name'] = ''; //域名 - // use Cloudflare R2 for clients download $_ENV['enable_r2_client_download'] = false; $_ENV['r2_bucket_name'] = ''; diff --git a/src/Controllers/Admin/NodeController.php b/src/Controllers/Admin/NodeController.php index 5c711ac62..390714aab 100644 --- a/src/Controllers/Admin/NodeController.php +++ b/src/Controllers/Admin/NodeController.php @@ -7,15 +7,12 @@ use App\Controllers\BaseController; use App\Models\Config; use App\Models\Node; -use App\Services\Cloudflare; use App\Services\IM\Telegram; use App\Utils\Tools; -use Cloudflare\API\Endpoints\EndpointException; use Exception; use Psr\Http\Message\ResponseInterface; use Slim\Http\Response; use Slim\Http\ServerRequest; -use function explode; use function json_decode; use function json_encode; use function round; @@ -145,11 +142,6 @@ public function add(ServerRequest $request, Response $response, array $args): Re ]); } - if ($_ENV['cloudflare_enable']) { - $domain_name = explode('.' . $_ENV['cloudflare_name'], $node->server); - Cloudflare::updateRecord($domain_name[0], $node->node_ip); - } - if (Config::obtain('telegram_add_node')) { try { (new Telegram())->send( @@ -178,8 +170,6 @@ public function add(ServerRequest $request, Response $response, array $args): Re /** * 后台编辑指定节点页面 - * - * @throws Exception */ public function edit(ServerRequest $request, Response $response, array $args): ResponseInterface { @@ -205,8 +195,6 @@ public function edit(ServerRequest $request, Response $response, array $args): R /** * 后台更新指定节点内容 - * - * @throws EndpointException */ public function update(ServerRequest $request, Response $response, array $args): ResponseInterface { @@ -258,11 +246,6 @@ public function update(ServerRequest $request, Response $response, array $args): ]); } - if ($_ENV['cloudflare_enable']) { - $domain_name = explode('.' . $_ENV['cloudflare_name'], $node->server); - Cloudflare::updateRecord($domain_name[0], $node->node_ip); - } - if (Config::obtain('telegram_update_node')) { try { (new Telegram())->send( diff --git a/src/Services/Cloudflare.php b/src/Services/Cloudflare.php index 8c3b45498..1671c27c6 100644 --- a/src/Services/Cloudflare.php +++ b/src/Services/Cloudflare.php @@ -6,41 +6,10 @@ use Aws\Credentials\Credentials; use Aws\S3\S3Client; -use Cloudflare\API\Adapter\Guzzle; -use Cloudflare\API\Auth\APIKey; -use Cloudflare\API\Endpoints\DNS; -use Cloudflare\API\Endpoints\EndpointException; -use Cloudflare\API\Endpoints\Zones; use Exception; final class Cloudflare { - /** - * @throws EndpointException - */ - public static function updateRecord($name, $content, $proxied = false): void - { - $key = new APIKey($_ENV['cloudflare_email'], $_ENV['cloudflare_key']); - $adapter = new Guzzle($key); - $zones = new Zones($adapter); - $dns = new DNS($adapter); - - $zoneID = $zones->getZoneID($_ENV['cloudflare_name']); - $r = $dns->listRecords($zoneID, '', $name); - $recordCount = $r->result_info->count; - $records = $r->result; - - if ($recordCount === 0) { - $dns->addRecord($zoneID, $type, $name, $content, $ttl, $proxied); - } elseif ($recordCount >= 1) { - foreach ($records as $record) { - $recordID = $record->id; - $details = ['type' => 'A', 'name' => $name, 'content' => $content, 'proxied' => $proxied]; - $dns->updateRecordDetails($zoneID, $recordID, $details); - } - } - } - public static function initR2(): S3Client { $credentials = new Credentials($_ENV['r2_access_key_id'], $_ENV['r2_access_key_secret']);