mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-28 06:47:24 +08:00
feat: add traffic.before_process hook
This commit is contained in:
@@ -134,16 +134,11 @@ class PluginController extends Controller
|
|||||||
'code' => 'required|string'
|
'code' => 'required|string'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
try {
|
$this->pluginManager->disable($request->input('code'));
|
||||||
$this->pluginManager->disable($request->input('code'));
|
return response()->json([
|
||||||
return response()->json([
|
'message' => '插件禁用成功'
|
||||||
'message' => '插件禁用成功'
|
]);
|
||||||
]);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return response()->json([
|
|
||||||
'message' => '插件禁用失败:' . $e->getMessage()
|
|
||||||
], 400);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Jobs\TrafficFetchJob;
|
|||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use App\Models\Plan;
|
use App\Models\Plan;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Services\Plugin\HookManager;
|
||||||
|
|
||||||
class UserService
|
class UserService
|
||||||
{
|
{
|
||||||
@@ -172,6 +173,11 @@ class UserService
|
|||||||
|
|
||||||
public function trafficFetch(array $server, string $protocol, array $data)
|
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'));
|
$timestamp = strtotime(date('Y-m-d'));
|
||||||
collect($data)->chunk(1000)->each(function ($chunk) use ($timestamp, $server, $protocol) {
|
collect($data)->chunk(1000)->each(function ($chunk) use ($timestamp, $server, $protocol) {
|
||||||
|
|||||||
Reference in New Issue
Block a user