mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
fix: 修复更新后导致节点后端交互api不可用的问题
This commit is contained in:
parent
7eb8d76c87
commit
c2b08c2627
@ -16,7 +16,7 @@ class Server
|
|||||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next, $node_type = null)
|
||||||
{
|
{
|
||||||
// alias
|
// alias
|
||||||
$aliasTypes = [
|
$aliasTypes = [
|
||||||
@ -27,6 +27,7 @@ class Server
|
|||||||
'token' => ['required', 'string', 'in:' . admin_setting('server_token')],
|
'token' => ['required', 'string', 'in:' . admin_setting('server_token')],
|
||||||
'node_id' => 'required',
|
'node_id' => 'required',
|
||||||
'node_type' => [
|
'node_type' => [
|
||||||
|
'nullable',
|
||||||
'regex:/^(?i)(hysteria|hysteria2|vless|trojan|vmess|v2ray|tuic|shadowsocks|shadowsocks-plugin)$/',
|
'regex:/^(?i)(hysteria|hysteria2|vless|trojan|vmess|v2ray|tuic|shadowsocks|shadowsocks-plugin)$/',
|
||||||
function ($attribute, $value, $fail) use ($aliasTypes, $request) {
|
function ($attribute, $value, $fail) use ($aliasTypes, $request) {
|
||||||
$request->merge([$attribute => strtolower(isset ($aliasTypes[$value]) ? $aliasTypes[$value] : $value)]);
|
$request->merge([$attribute => strtolower(isset ($aliasTypes[$value]) ? $aliasTypes[$value] : $value)]);
|
||||||
@ -36,7 +37,7 @@ class Server
|
|||||||
'token.in' => 'Token is error!',
|
'token.in' => 'Token is error!',
|
||||||
'node_type.regex' => 'node_type is error!'
|
'node_type.regex' => 'node_type is error!'
|
||||||
]);
|
]);
|
||||||
$nodeInfo = ServerService::getServer($request->input('node_id'), $request->input('node_type'));
|
$nodeInfo = ServerService::getServer($request->input('node_id'), $request->input('node_type') ?? $node_type);
|
||||||
if (!$nodeInfo)
|
if (!$nodeInfo)
|
||||||
throw new ApiException('server is not exist!');
|
throw new ApiException('server is not exist!');
|
||||||
$request->merge(['node_info' => $nodeInfo]);
|
$request->merge(['node_info' => $nodeInfo]);
|
||||||
|
@ -13,24 +13,35 @@ class ServerRoute
|
|||||||
{
|
{
|
||||||
$router->group([
|
$router->group([
|
||||||
'prefix' => 'server',
|
'prefix' => 'server',
|
||||||
'middleware' => 'server'
|
|
||||||
], function ($router) {
|
], function ($router) {
|
||||||
$router->prefix('UniProxy')->group(function ($route) {
|
$router->group([
|
||||||
|
'prefix' => 'UniProxy',
|
||||||
|
'middleware' => 'server'
|
||||||
|
] ,function ($route) {
|
||||||
$route->get('config', [UniProxyController::class, 'config']);
|
$route->get('config', [UniProxyController::class, 'config']);
|
||||||
$route->get('user', [UniProxyController::class, 'user']);
|
$route->get('user', [UniProxyController::class, 'user']);
|
||||||
$route->post('push', [UniProxyController::class, 'push']);
|
$route->post('push', [UniProxyController::class, 'push']);
|
||||||
$route->post('alive', [UniProxyController::class, 'alive']);
|
$route->post('alive', [UniProxyController::class, 'alive']);
|
||||||
});
|
});
|
||||||
$router->prefix('Deepbwork')->group(function ($route) {
|
$router->group([
|
||||||
|
'prefix' => 'Deepbwork',
|
||||||
|
'middleware' => 'server:vmess'
|
||||||
|
], function ($route) {
|
||||||
$route->get('config', [DeepbworkController::class, 'config']);
|
$route->get('config', [DeepbworkController::class, 'config']);
|
||||||
$route->get('user', [DeepbworkController::class, 'user']);
|
$route->get('user', [DeepbworkController::class, 'user']);
|
||||||
$route->post('submit', [DeepbworkController::class, 'submit']);
|
$route->post('submit', [DeepbworkController::class, 'submit']);
|
||||||
});
|
});
|
||||||
$router->prefix('ShadowsocksTidalab')->group(function ($route) {
|
$router->group([
|
||||||
|
'prefix' => 'ShadowsocksTidalab',
|
||||||
|
'middleware' => 'server:shadowsocks'
|
||||||
|
], function ($route) {
|
||||||
$route->get('user', [ShadowsocksTidalabController::class, 'user']);
|
$route->get('user', [ShadowsocksTidalabController::class, 'user']);
|
||||||
$route->post('submit', [ShadowsocksTidalabController::class, 'submit']);
|
$route->post('submit', [ShadowsocksTidalabController::class, 'submit']);
|
||||||
});
|
});
|
||||||
$router->prefix('TrojanTidalab')->group(function ($route) {
|
$router->group([
|
||||||
|
'prefix' => 'TrojanTidalab',
|
||||||
|
'middleware' => 'server:trojan'
|
||||||
|
], function ($route) {
|
||||||
$route->get('config', [TrojanTidalabController::class, 'config']);
|
$route->get('config', [TrojanTidalabController::class, 'config']);
|
||||||
$route->get('user', [TrojanTidalabController::class, 'user']);
|
$route->get('user', [TrojanTidalabController::class, 'user']);
|
||||||
$route->post('submit', [TrojanTidalabController::class, 'submit']);
|
$route->post('submit', [TrojanTidalabController::class, 'submit']);
|
||||||
|
Loading…
Reference in New Issue
Block a user