diff --git a/Dockerfile b/Dockerfile index e1e4bf6..443b45f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,16 @@ FROM phpswoole/swoole:php8.2-alpine COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ -RUN install-php-extensions pcntl bcmath zip redis \ - && apk --no-cache add shadow sqlite mysql-client mysql-client mysql-dev mariadb-connector-c git patch supervisor redis \ - && addgroup -S -g 1000 www && adduser -S -G www -u 1000 www \ - && (getent group redis || addgroup -S redis) \ - && (getent passwd redis || adduser -S -G redis -H -h /data redis) + +# Install PHP extensions one by one with lower optimization level for ARM64 compatibility +RUN CFLAGS="-O1" install-php-extensions pcntl && \ + CFLAGS="-O1" install-php-extensions bcmath && \ + install-php-extensions zip && \ + install-php-extensions redis && \ + apk --no-cache add shadow sqlite mysql-client mysql-dev mariadb-connector-c git patch supervisor redis && \ + addgroup -S -g 1000 www && adduser -S -G www -u 1000 www && \ + (getent group redis || addgroup -S redis) && \ + (getent passwd redis || adduser -S -G redis -H -h /data redis) WORKDIR /www COPY .docker / diff --git a/app/Http/Controllers/V2/Admin/PluginController.php b/app/Http/Controllers/V2/Admin/PluginController.php index 4be814e..8fcc6f8 100644 --- a/app/Http/Controllers/V2/Admin/PluginController.php +++ b/app/Http/Controllers/V2/Admin/PluginController.php @@ -134,16 +134,11 @@ class PluginController extends Controller 'code' => 'required|string' ]); - try { - $this->pluginManager->disable($request->input('code')); - return response()->json([ - 'message' => '插件禁用成功' - ]); - } catch (\Exception $e) { - return response()->json([ - 'message' => '插件禁用失败:' . $e->getMessage() - ], 400); - } + $this->pluginManager->disable($request->input('code')); + return response()->json([ + 'message' => '插件禁用成功' + ]); + } /** diff --git a/app/Services/Plugin/HookManager.php b/app/Services/Plugin/HookManager.php index decad6e..4147962 100644 --- a/app/Services/Plugin/HookManager.php +++ b/app/Services/Plugin/HookManager.php @@ -45,9 +45,9 @@ class HookManager * @param mixed ...$args 其他参数 * @return mixed */ - public static function filter(string $hook, mixed $value, mixed ...$args): mixed + public static function filter(string $hook, mixed $value): mixed { - return Eventy::filter($hook, $value, ...$args); + return Eventy::filter($hook, $value); } /** diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 5cb45c5..a733bfc 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -8,6 +8,7 @@ use App\Jobs\TrafficFetchJob; use App\Models\Order; use App\Models\Plan; use App\Models\User; +use App\Services\Plugin\HookManager; class UserService { @@ -172,6 +173,11 @@ class UserService public function trafficFetch(array $server, string $protocol, array $data) { + list($server, $protocol, $data) = HookManager::filter('traffic.before_process', [ + $server, + $protocol, + $data + ]); $timestamp = strtotime(date('Y-m-d')); collect($data)->chunk(1000)->each(function ($chunk) use ($timestamp, $server, $protocol) { diff --git a/app/Utils/Helper.php b/app/Utils/Helper.php index befc068..7e187e6 100644 --- a/app/Utils/Helper.php +++ b/app/Utils/Helper.php @@ -2,6 +2,9 @@ namespace App\Utils; +use App\Services\Plugin\HookManager; +use Illuminate\Support\Arr; + class Helper { public static function uuidToBase64($uuid, $length) @@ -111,12 +114,14 @@ class Helper public static function getSubscribeUrl(string $token, $subscribeUrl = null) { $path = route('client.subscribe', ['token' => $token], false); - if(!$subscribeUrl){ + if (!$subscribeUrl) { $subscribeUrls = explode(',', admin_setting('subscribe_url')); - $subscribeUrl = \Arr::random($subscribeUrls); + $subscribeUrl = Arr::random($subscribeUrls); $subscribeUrl = self::replaceByPattern($subscribeUrl); } - return $subscribeUrl ? rtrim($subscribeUrl, '/') . $path : url($path); + + $finalUrl = $subscribeUrl ? rtrim($subscribeUrl, '/') . $path : url($path); + return HookManager::filter('subscribe.url', $finalUrl); } public static function randomPort($range): int {