mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-02-02 07:28:13 -05:00
fix: correct know file issues
This commit is contained in:
parent
3efdeaa9c9
commit
652c6eb125
@ -1,15 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Support\Setting;
|
use App\Support\Setting;
|
||||||
|
|
||||||
|
|
||||||
if (! function_exists("get_request_content")){
|
|
||||||
function get_request_content(){
|
|
||||||
|
|
||||||
return request()->getContent() ?: json_encode($_POST);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! function_exists('admin_setting')) {
|
if (! function_exists('admin_setting')) {
|
||||||
/**
|
/**
|
||||||
* 获取或保存配置参数.
|
* 获取或保存配置参数.
|
||||||
|
@ -23,7 +23,7 @@ class TelegramController extends Controller
|
|||||||
if ($request->input('access_token') !== md5(admin_setting('telegram_bot_token'))) {
|
if ($request->input('access_token') !== md5(admin_setting('telegram_bot_token'))) {
|
||||||
throw new ApiException('access_token is error', 401);
|
throw new ApiException('access_token is error', 401);
|
||||||
}
|
}
|
||||||
$data = json_decode(get_request_content(),true);
|
$data = json_decode(request()->getContent(),true);
|
||||||
$this->formatMessage($data);
|
$this->formatMessage($data);
|
||||||
$this->formatChatJoinRequest($data);
|
$this->formatChatJoinRequest($data);
|
||||||
$this->handle();
|
$this->handle();
|
||||||
|
@ -36,15 +36,34 @@ class UniProxyController extends Controller
|
|||||||
// 后端提交数据
|
// 后端提交数据
|
||||||
public function push(Request $request)
|
public function push(Request $request)
|
||||||
{
|
{
|
||||||
$res = json_decode(get_request_content(), true);
|
$res = json_decode(request()->getContent(), true);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
return $this->fail([422, 'Invalid data format']);
|
||||||
|
}
|
||||||
$data = array_filter($res, function ($item) {
|
$data = array_filter($res, function ($item) {
|
||||||
return is_array($item) && count($item) === 2 && is_numeric($item[0]) && is_numeric($item[1]);
|
return is_array($item)
|
||||||
|
&& count($item) === 2
|
||||||
|
&& is_numeric($item[0])
|
||||||
|
&& is_numeric($item[1]);
|
||||||
});
|
});
|
||||||
|
if (empty($data)) {
|
||||||
|
return $this->success(true);
|
||||||
|
}
|
||||||
$node = $request->input('node_info');
|
$node = $request->input('node_info');
|
||||||
$nodeType = $node->type;
|
$nodeType = $node->type;
|
||||||
$nodeId = $node->id;
|
$nodeId = $node->id;
|
||||||
Cache::put(CacheKey::get('SERVER_' . strtoupper($nodeType) . '_ONLINE_USER', $nodeId), count($data), 3600);
|
|
||||||
Cache::put(CacheKey::get('SERVER_' . strtoupper($nodeType) . '_LAST_PUSH_AT', $nodeId), time(), 3600);
|
Cache::put(
|
||||||
|
CacheKey::get('SERVER_' . strtoupper($nodeType) . '_ONLINE_USER', $nodeId),
|
||||||
|
count($data),
|
||||||
|
3600
|
||||||
|
);
|
||||||
|
Cache::put(
|
||||||
|
CacheKey::get('SERVER_' . strtoupper($nodeType) . '_LAST_PUSH_AT', $nodeId),
|
||||||
|
time(),
|
||||||
|
3600
|
||||||
|
);
|
||||||
|
|
||||||
$userService = new UserService();
|
$userService = new UserService();
|
||||||
$userService->trafficFetch($node->toArray(), $nodeType, $data);
|
$userService->trafficFetch($node->toArray(), $nodeType, $data);
|
||||||
return $this->success(true);
|
return $this->success(true);
|
||||||
@ -55,48 +74,50 @@ class UniProxyController extends Controller
|
|||||||
{
|
{
|
||||||
$node = $request->input('node_info');
|
$node = $request->input('node_info');
|
||||||
$nodeType = $node->type;
|
$nodeType = $node->type;
|
||||||
|
|
||||||
$protocolSettings = $node->protocol_settings;
|
$protocolSettings = $node->protocol_settings;
|
||||||
|
|
||||||
|
$serverPort = $node->server_port;
|
||||||
|
$host = $node->host;
|
||||||
|
|
||||||
|
$baseConfig = [
|
||||||
|
'server_port' => $serverPort,
|
||||||
|
'network' => $protocolSettings['network'] ?? null,
|
||||||
|
'network_settings' => $protocolSettings['network_settings'] ?? null,
|
||||||
|
];
|
||||||
|
|
||||||
$response = match ($nodeType) {
|
$response = match ($nodeType) {
|
||||||
'shadowsocks' => [
|
'shadowsocks' => [
|
||||||
'server_port' => $node->server_port,
|
...$baseConfig,
|
||||||
'cipher' => $protocolSettings['cipher'],
|
'cipher' => $protocolSettings['cipher'],
|
||||||
'obfs' => $protocolSettings['obfs'],
|
'obfs' => $protocolSettings['obfs'],
|
||||||
'obfs_settings' => $protocolSettings['obfs_settings'],
|
'obfs_settings' => $protocolSettings['obfs_settings'],
|
||||||
'server_key' => $protocolSettings['cipher'] === '2022-blake3-aes-128-gcm'
|
'server_key' => match ($protocolSettings['cipher']) {
|
||||||
? Helper::getServerKey($node->created_at, 16)
|
'2022-blake3-aes-128-gcm' => Helper::getServerKey($node->created_at, 16),
|
||||||
: ($protocolSettings['cipher'] === '2022-blake3-aes-256-gcm'
|
'2022-blake3-aes-256-gcm' => Helper::getServerKey($node->created_at, 32),
|
||||||
? Helper::getServerKey($node->created_at, 32)
|
default => null
|
||||||
: null)
|
}
|
||||||
],
|
],
|
||||||
'vmess' => [
|
'vmess' => [
|
||||||
'server_port' => $node->server_port,
|
...$baseConfig,
|
||||||
'network' => $protocolSettings['network'],
|
|
||||||
'networkSettings' => $protocolSettings['network_settings'],
|
|
||||||
'tls' => $protocolSettings['tls']
|
'tls' => $protocolSettings['tls']
|
||||||
],
|
],
|
||||||
'trojan' => [
|
'trojan' => [
|
||||||
'host' => $node->host,
|
...$baseConfig,
|
||||||
'server_port' => $node->server_port,
|
'host' => $host,
|
||||||
'server_name' => $protocolSettings['server_name'],
|
'server_name' => $protocolSettings['server_name'],
|
||||||
'network' => $protocolSettings['network'],
|
|
||||||
'networkSettings' => $protocolSettings['network_settings'],
|
|
||||||
],
|
],
|
||||||
'vless' => [
|
'vless' => [
|
||||||
'server_port' => $node->server_port,
|
...$baseConfig,
|
||||||
'network' => $protocolSettings['network'],
|
|
||||||
'network_settings' => $protocolSettings['network_settings'],
|
|
||||||
'tls' => $protocolSettings['tls'],
|
'tls' => $protocolSettings['tls'],
|
||||||
'flow' => $protocolSettings['flow'],
|
'flow' => $protocolSettings['flow'],
|
||||||
'tls_settings' => match ((int) $protocolSettings['tls']) {
|
'tls_settings' => (int) $protocolSettings['tls'] === 1
|
||||||
1 => $protocolSettings['tls_settings'],
|
? $protocolSettings['tls_settings']
|
||||||
2 => $protocolSettings['reality_settings']
|
: $protocolSettings['reality_settings']
|
||||||
}
|
|
||||||
],
|
],
|
||||||
'hysteria' => [
|
'hysteria' => [
|
||||||
'version' => $protocolSettings['version'],
|
'version' => $protocolSettings['version'],
|
||||||
'host' => $node->host,
|
'host' => $host,
|
||||||
'server_port' => $node->server_port,
|
'server_port' => $serverPort,
|
||||||
'server_name' => $protocolSettings['tls']['server_name'],
|
'server_name' => $protocolSettings['tls']['server_name'],
|
||||||
'up_mbps' => $protocolSettings['bandwidth']['up'],
|
'up_mbps' => $protocolSettings['bandwidth']['up'],
|
||||||
'down_mbps' => $protocolSettings['bandwidth']['down'],
|
'down_mbps' => $protocolSettings['bandwidth']['down'],
|
||||||
@ -104,18 +125,20 @@ class UniProxyController extends Controller
|
|||||||
],
|
],
|
||||||
default => []
|
default => []
|
||||||
};
|
};
|
||||||
|
|
||||||
$response['base_config'] = [
|
$response['base_config'] = [
|
||||||
'push_interval' => (int) admin_setting('server_push_interval', 60),
|
'push_interval' => (int) admin_setting('server_push_interval', 60),
|
||||||
'pull_interval' => (int) admin_setting('server_pull_interval', 60)
|
'pull_interval' => (int) admin_setting('server_pull_interval', 60)
|
||||||
];
|
];
|
||||||
if ($node['route_id']) {
|
|
||||||
$response['routes'] = ServerService::getRoutes($node['route_id']);
|
if (!empty($node['route_ids'])) {
|
||||||
}
|
$response['routes'] = ServerService::getRoutes($node['route_ids']);
|
||||||
$eTag = sha1(json_encode($response));
|
|
||||||
if (strpos($request->header('If-None-Match'), $eTag) !== false) {
|
|
||||||
return response(null, 304);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$eTag = sha1(json_encode($response));
|
||||||
|
if (strpos($request->header('If-None-Match') ?? '', $eTag) !== false) {
|
||||||
|
return response(null, 304);
|
||||||
|
}
|
||||||
return response($response)->header('ETag', "\"{$eTag}\"");
|
return response($response)->header('ETag', "\"{$eTag}\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +93,9 @@ class ServerSave extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name.required' => '节点名称不能为空',
|
'name.required' => '节点名称不能为空',
|
||||||
'group_id.required' => '权限组不能为空',
|
'group_ids.required' => '权限组不能为空',
|
||||||
'group_id.array' => '权限组格式不正确',
|
'group_ids.array' => '权限组格式不正确',
|
||||||
'route_id.array' => '路由组格式不正确',
|
'route_ids.array' => '路由组格式不正确',
|
||||||
'parent_id.integer' => '父ID格式不正确',
|
'parent_id.integer' => '父ID格式不正确',
|
||||||
'host.required' => '节点地址不能为空',
|
'host.required' => '节点地址不能为空',
|
||||||
'port.required' => '连接端口不能为空',
|
'port.required' => '连接端口不能为空',
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Requests\Admin;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
|
|
||||||
class ServerShadowsocksSave extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'show' => '',
|
|
||||||
'name' => 'required',
|
|
||||||
'group_id' => 'required|array',
|
|
||||||
'parent_id' => 'nullable|integer',
|
|
||||||
'route_id' => 'nullable|array',
|
|
||||||
'host' => 'required',
|
|
||||||
'port' => 'required',
|
|
||||||
'server_port' => 'required',
|
|
||||||
'cipher' => 'required|in:aes-128-gcm,aes-192-gcm,aes-256-gcm,chacha20-ietf-poly1305,2022-blake3-aes-128-gcm,2022-blake3-aes-256-gcm',
|
|
||||||
'obfs' => 'nullable|in:http',
|
|
||||||
'obfs_settings' => 'nullable|array',
|
|
||||||
'tags' => 'nullable|array',
|
|
||||||
'excludes' => 'nullable|array',
|
|
||||||
'ips' => 'nullable|array',
|
|
||||||
'rate' => 'required|numeric'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function messages()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'name.required' => '节点名称不能为空',
|
|
||||||
'group_id.required' => '权限组不能为空',
|
|
||||||
'group_id.array' => '权限组格式不正确',
|
|
||||||
'route_id.array' => '路由组格式不正确',
|
|
||||||
'parent_id.integer' => '父节点格式不正确',
|
|
||||||
'host.required' => '节点地址不能为空',
|
|
||||||
'port.required' => '连接端口不能为空',
|
|
||||||
'server_port.required' => '后端服务端口不能为空',
|
|
||||||
'cipher.required' => '加密方式不能为空',
|
|
||||||
'tags.array' => '标签格式不正确',
|
|
||||||
'rate.required' => '倍率不能为空',
|
|
||||||
'rate.numeric' => '倍率格式不正确',
|
|
||||||
'obfs.in' => '混淆格式不正确',
|
|
||||||
'obfs_settings.array' => '混淆设置格式不正确'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Requests\Admin;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
|
|
||||||
class ServerShadowsocksUpdate extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'show' => 'in:0,1'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function messages()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'show.in' => '显示状态格式不正确'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Requests\Admin;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
|
|
||||||
class ServerTrojanSave extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'show' => '',
|
|
||||||
'name' => 'required',
|
|
||||||
'network' => 'required',
|
|
||||||
'networkSettings' => 'nullable',
|
|
||||||
'group_id' => 'required|array',
|
|
||||||
'route_id' => 'nullable|array',
|
|
||||||
'parent_id' => 'nullable|integer',
|
|
||||||
'host' => 'required',
|
|
||||||
'port' => 'required',
|
|
||||||
'server_port' => 'required',
|
|
||||||
'allow_insecure' => 'nullable|in:0,1',
|
|
||||||
'server_name' => 'nullable',
|
|
||||||
'tags' => 'nullable|array',
|
|
||||||
'excludes' => 'nullable|array',
|
|
||||||
'ips' => 'nullable|array',
|
|
||||||
'rate' => 'required|numeric'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function messages()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'name.required' => '节点名称不能为空',
|
|
||||||
'network.required' => '传输协议不能为空',
|
|
||||||
'group_id.required' => '权限组不能为空',
|
|
||||||
'group_id.array' => '权限组格式不正确',
|
|
||||||
'route_id.array' => '路由组格式不正确',
|
|
||||||
'parent_id.integer' => '父节点格式不正确',
|
|
||||||
'host.required' => '节点地址不能为空',
|
|
||||||
'port.required' => '连接端口不能为空',
|
|
||||||
'server_port.required' => '后端服务端口不能为空',
|
|
||||||
'allow_insecure.in' => '允许不安全格式不正确',
|
|
||||||
'tags.array' => '标签格式不正确',
|
|
||||||
'rate.required' => '倍率不能为空',
|
|
||||||
'rate.numeric' => '倍率格式不正确'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Requests\Admin;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
|
|
||||||
class ServerTrojanUpdate extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'show' => 'in:0,1'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function messages()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'show.in' => '显示状态格式不正确'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Requests\Admin;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
|
|
||||||
class ServerVmessSave extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'show' => '',
|
|
||||||
'name' => 'required',
|
|
||||||
'group_id' => 'required|array',
|
|
||||||
'route_id' => 'nullable|array',
|
|
||||||
'parent_id' => 'nullable|integer',
|
|
||||||
'host' => 'required',
|
|
||||||
'port' => 'required',
|
|
||||||
'server_port' => 'required',
|
|
||||||
'tls' => 'required',
|
|
||||||
'tags' => 'nullable|array',
|
|
||||||
'excludes' => 'nullable|array',
|
|
||||||
'ips' => 'nullable|array',
|
|
||||||
'rate' => 'required|numeric',
|
|
||||||
'network' => 'required|in:tcp,kcp,ws,http,domainsocket,quic,grpc',
|
|
||||||
'networkSettings' => 'nullable|array',
|
|
||||||
'ruleSettings' => 'nullable|array',
|
|
||||||
'tlsSettings' => 'nullable|array',
|
|
||||||
'dnsSettings' => 'nullable|array'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function messages()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'name.required' => '节点名称不能为空',
|
|
||||||
'group_id.required' => '权限组不能为空',
|
|
||||||
'group_id.array' => '权限组格式不正确',
|
|
||||||
'route_id.array' => '路由组格式不正确',
|
|
||||||
'parent_id.integer' => '父ID格式不正确',
|
|
||||||
'host.required' => '节点地址不能为空',
|
|
||||||
'port.required' => '连接端口不能为空',
|
|
||||||
'server_port.required' => '后端服务端口不能为空',
|
|
||||||
'tls.required' => 'TLS不能为空',
|
|
||||||
'tags.array' => '标签格式不正确',
|
|
||||||
'rate.required' => '倍率不能为空',
|
|
||||||
'rate.numeric' => '倍率格式不正确',
|
|
||||||
'network.required' => '传输协议不能为空',
|
|
||||||
'network.in' => '传输协议格式不正确',
|
|
||||||
'networkSettings.array' => '传输协议配置有误',
|
|
||||||
'ruleSettings.array' => '规则配置有误',
|
|
||||||
'tlsSettings.array' => 'tls配置有误',
|
|
||||||
'dnsSettings.array' => 'dns配置有误'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Requests\Admin;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
|
|
||||||
class ServerVmessUpdate extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'show' => 'in:0,1'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function messages()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'show.in' => '显示状态格式不正确'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
||||||
|
|
||||||
class ServerShadowsocks extends Model
|
|
||||||
{
|
|
||||||
protected $table = 'v2_server_shadowsocks';
|
|
||||||
protected $dateFormat = 'U';
|
|
||||||
protected $guarded = ['id'];
|
|
||||||
protected $casts = [
|
|
||||||
'created_at' => 'timestamp',
|
|
||||||
'updated_at' => 'timestamp',
|
|
||||||
'group_id' => 'array',
|
|
||||||
'route_id' => 'array',
|
|
||||||
'tags' => 'array',
|
|
||||||
'excludes' => 'array',
|
|
||||||
'obfs_settings' => 'array',
|
|
||||||
'ips' => 'array'
|
|
||||||
];
|
|
||||||
|
|
||||||
public function parent(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(self::class, 'parent_id', 'id');
|
|
||||||
}
|
|
||||||
}
|
|
@ -68,7 +68,7 @@ class BTCPay implements PaymentInterface
|
|||||||
|
|
||||||
public function notify($params): array|bool
|
public function notify($params): array|bool
|
||||||
{
|
{
|
||||||
$payload = trim(get_request_content());
|
$payload = trim(request()->getContent());
|
||||||
|
|
||||||
$headers = getallheaders();
|
$headers = getallheaders();
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class Coinbase implements PaymentInterface
|
|||||||
public function notify($params): array
|
public function notify($params): array
|
||||||
{
|
{
|
||||||
|
|
||||||
$payload = trim(get_request_content());
|
$payload = trim(request()->getContent());
|
||||||
$json_param = json_decode($payload, true);
|
$json_param = json_decode($payload, true);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user