Merge branch 'cedar2025:master' into master

This commit is contained in:
socksprox 2025-02-07 09:09:27 +01:00 committed by GitHub
commit d41909d564
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 31 additions and 20 deletions

View File

@ -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 /

View File

@ -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' => '插件禁用成功'
]);
}
/**

View File

@ -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);
}
/**

View File

@ -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) {

View File

@ -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 {